Skip to content

Commit

Permalink
Merge pull request #665 from plural/x-advancement
Browse files Browse the repository at this point in the history
Add support for proper display of X cost agendas.
  • Loading branch information
plural authored Jul 20, 2022
2 parents bfcc1a8 + c271798 commit bc1a021
Showing 1 changed file with 32 additions and 17 deletions.
49 changes: 32 additions & 17 deletions src/AppBundle/Service/CardsData.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ class CardsData
/** @var Packages $packages */
private $packages;

/** @var Illustrators $illustrators */
private $illustrators;
/** @var Illustrators $illustrators */
private $illustrators;

/** @var CardAliases $illustrators */
private $cardAliases;
private $cardAliases;

public function __construct(
EntityManagerInterface $entityManager,
Expand Down Expand Up @@ -490,21 +490,32 @@ public function get_search_rows(array $conditions, string $sortorder, string $lo
case 'g': // advancementcost
$or = [];
foreach ($condition as $arg) {
switch ($operator) {
case ':':
$or[] = "(c.advancementCost = ?$i)";
break;
case '!':
$or[] = "(c.advancementCost != ?$i)";
break;
case '<':
$or[] = "(c.advancementCost < ?$i)";
break;
case '>':
$or[] = "(c.advancementCost > ?$i)";
break;
if (($arg === 'x') or ($arg === 'X')) {
switch ($operator) {
case ':':
$or[] = "(c.advancementCost is null and (t.code = 'agenda'))";
break;
case '!':
$or[] = "(c.advancementCost is not null and (t.code = 'agenda'))";
break;
}
} else {
switch ($operator) {
case ':':
$or[] = "(c.advancementCost = ?$i)";
break;
case '!':
$or[] = "(c.advancementCost != ?$i)";
break;
case '<':
$or[] = "(c.advancementCost < ?$i)";
break;
case '>':
$or[] = "(c.advancementCost > ?$i)";
break;
}
$parameters[$i++] = $arg;
}
$parameters[$i++] = $arg;
}
$clauses[] = implode($operator == '!' ? " and " : " or ", $or);
break;
Expand Down Expand Up @@ -860,6 +871,10 @@ public function getCardInfo(Card $card, string $locale)
$cardinfo['cost'] = 'X';
}

if ($cardinfo['advancementcost'] === null && $cardinfo['type_code'] == 'agenda') {
$cardinfo['advancementcost'] = 'X';
}

// setting the card strength to X if the strength is null and the card is ICE or Program - Icebreaker
if ($cardinfo['strength'] === null &&
($cardinfo['type_code'] === 'ice' ||
Expand Down

0 comments on commit bc1a021

Please sign in to comment.