Skip to content

Commit

Permalink
Merge pull request #1455 from micahstairs/main-4
Browse files Browse the repository at this point in the history
Finish incorporating changes to ultimate cards and fix bugs
  • Loading branch information
micahstairs authored Aug 5, 2024
2 parents ffbdc0c + 681d6a9 commit 8777740
Show file tree
Hide file tree
Showing 64 changed files with 604 additions and 368 deletions.
22 changes: 12 additions & 10 deletions dbmodel.sql
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ CREATE TABLE IF NOT EXISTS `nested_card_execution` (
`nesting_index` SMALLINT UNSIGNED NOT NULL COMMENT 'The index of the nesting (0 is for the original card, 1 is for the next card, etc.)',
`card_id` SMALLINT COMMENT '-1 means no card',
`executing_as_if_on_card_id` SMALLINT COMMENT '-1 means no card',
`super_execute` BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'If true, the card is being super-executed',
`replace_may_with_must` BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'Whether effects that say "may" should be executed as if it said "must"',
`card_location` VARCHAR(12) DEFAULT NULL COMMENT 'The initial location of the card when its dogma was executed (usually board, display, or NULL)',
`launcher_id` INT(10) NOT NULL COMMENT 'ID of the player who initially launched this card',
Expand All @@ -74,6 +75,7 @@ CREATE TABLE IF NOT EXISTS `nested_card_execution` (
`step` TINYINT COMMENT 'The interaction that the card is on',
`step_max` TINYINT COMMENT 'The anticipated number of interactions that the card will have',
`post_execution_index` TINYINT DEFAULT 0 COMMENT '0 means the effect has not triggered another card, 1 means the effect already triggered another card and resumed executing this effect',
`performed_one_time_setup` BOOLEAN NOT NULL DEFAULT FALSE COMMENT 'Whether the oneTimeSetup function has been called yet for the execution of this card',
`auxiliary_value` INT DEFAULT -1 COMMENT 'An auxiliary value used by certain card implementations',
`auxiliary_value_2` INT DEFAULT -1 COMMENT 'A second auxiliary value used by certain card implementations',
PRIMARY KEY(`nesting_index`)
Expand Down Expand Up @@ -711,16 +713,16 @@ INSERT INTO `card` (`id`, `type`, `age`, `color`, `spot_1`, `spot_2`, `spot_3`,
(284, 2, 6, 4, 3, 1, 16, 1, 0, 14, 1, 'removed'),

/* Cities - Age 7 */
(285, 2, 7, 0, 3, 6, 14, 3, 0, 12, 3, 'removed'),
(286, 2, 7, 0, 107, 107, 3, 1, 0, 107, 1, 'removed'),
(287, 2, 7, 1, 1, 5, 12, 5, 0, 8, 5, 'removed'),
(288, 2, 7, 1, 5, 5, 14, 1, 0, 15, 5, 'removed'),
(289, 2, 7, 2, 5, 6, 16, 6, 0, 12, 6, 'removed'),
(290, 2, 7, 2, 107, 107, 6, 2, 0, 107, 6, 'removed'),
(291, 2, 7, 3, 2, 5, 12, 2, 0, 8, 2, 'removed'),
(292, 2, 7, 3, 107, 107, 2, 1, 0, 107, 1, 'removed'),
(293, 2, 7, 4, 5, 3, 12, 3, 0, 8, 3, 'removed'),
(294, 2, 7, 4, 1, 3, 109, 1, 0, 109, 1, 'removed'),
(285, 2, 7, 0, 3, 6, 14, 3, 0, 12, 3, 'removed'),
(286, 2, 7, 0, 107, 107, 3, 1, 0, 107, 1, 'removed'),
(287, 2, 7, 1, 1, 5, 12, 5, 0, 8, 5, 'removed'),
(288, 2, 7, 1, 5, 5, 14, 1, 0, 15, 5, 'removed'),
(289, 2, 7, 2, 5, 6, 16, 6, 0, 12, 6, 'removed'),
(290, 2, 7, 2, 107, 107, 6, 2, 0, 107, 6, 'removed'),
(291, 2, 7, 3, 2, 5, 12, 2, 0, 8, 2, 'removed'),
(292, 2, 7, 3, 107, 107, 2, 1, 0, 107, 1, 'removed'),
(293, 2, 7, 4, 5, 3, 12, 3, 0, 8, 3, 'removed'),
(294, 2, 7, 4, 1, 3, 109, 109, 0, 109, 1, 'removed'),

/* Cities - Age 8 */
(295, 2, 8, 0, 5, 5, 16, 3, 0, 14, 5, 'removed'),
Expand Down
303 changes: 112 additions & 191 deletions innovation.game.php

Large diffs are not rendered by default.

140 changes: 75 additions & 65 deletions material.inc.php

Large diffs are not rendered by default.

19 changes: 15 additions & 4 deletions modules/Innovation/Cards/AbstractCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ function __construct(\Innovation $game, ExecutionState $state)
public function oneTimeSetup()
{
// Subclasses are expected to override this method if the card need to do any one-time setup before any player executes anything.
// TODO(LATER): This method isn't actually called from the game logic yet. We need to wire it up if we want to use this method.
// Even if the card is endorsed, this method will still only be called once.
}

public abstract function initialExecution();
Expand Down Expand Up @@ -341,10 +341,10 @@ protected function selfExecute($card): bool
return $this->game->selfExecute($card);
}

protected function fullyExecute($card)
protected function superExecute($card)
{
if ($card) {
$this->game->fullyExecute($card);
$this->game->superExecute($card);
}
}

Expand Down Expand Up @@ -481,7 +481,7 @@ protected function transferToAchievements(?array $card, int $playerId = null)
return $this->game->transferCardFromTo($card, self::coercePlayerId($playerId), "achievements");
}

protected function return (?array $card): ?array
protected function return(?array $card): ?array
{
if (!$card) {
return null;
Expand Down Expand Up @@ -1347,6 +1347,17 @@ protected function countColorsWithIcon(int $icon, int $playerId = null): int
return $numColors;
}

protected function countSplayedColors(int $playerId = null): int
{
$numColors = 0;
foreach (Colors::ALL as $color) {
if (self::isSplayed($color, $playerId)) {
$numColors++;
}
}
return $numColors;
}

protected function getStandardIconCount(int $icon, int $playerId = null): int
{
return $this->game->getPlayerSingleRessourceCount(self::coercePlayerId($playerId), $icon);
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card114.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class Card114 extends AbstractCard
// value two higher. If the drawn card is purple, meld it and execute each of its non-demand
// dogma effects. Do not share them.
// - 4th edition:
// - Return a purple card from your hand. If you do, draw and reveal a card of any type of
// - Return a purple card from your hand. If you do, draw and reveal a card from any set of
// value two higher. If the drawn card is purple, meld it and self-execute it.

public function initialExecution()
Expand Down
6 changes: 3 additions & 3 deletions modules/Innovation/Cards/Artifacts/Card116.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class Card116 extends AbstractCard
// the top card's non-demand dogma effects. Do not share them.
// - Claim an achievement, if eligible.
// - 4th edition:
// - Score a card from your hand. If you have a top card matching its color, super-execute it
// if it is your turn, otherwise self-execute it.
// - Score a card from your hand. If you have a top card matching its color, super-execute
// that top card it is your turn, otherwise self-execute it.

public function initialExecution()
{
Expand All @@ -38,7 +38,7 @@ public function handleCardChoice(array $card)
{
$topCard = self::getTopCardOfColor($card['color']);
if (self::isFourthEdition() && self::isTheirTurn()) {
self::fullyExecute($topCard);
self::superExecute($topCard);
} else {
self::selfExecute($topCard);
}
Expand Down
4 changes: 2 additions & 2 deletions modules/Innovation/Cards/Artifacts/Card122.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ class Card122 extends AbstractCard
// those cards, ignoring eligibility.
// - 4th edition:
// - Choose a color. Each player reveals their hand. If you are the only player to reveal
// at least one card of that color, return them and claim all achievements of value matching
// those cards, ignoring eligibility.
// at least one card of that color, return them and claim all available achievements of value
// matching those cards, ignoring eligibility.

public function initialExecution()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card126.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Card126 extends AbstractCard
{

// Rosetta Stone
// - Choose a card type. Draw two [2] of that type. Meld one and transfer the other to an
// - Choose a set. Draw two [2] from that set. Meld one and transfer the other to an
// opponent's board.

public function initialExecution()
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card131.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Card131 extends AbstractCard
{

// Holy Grail
// - Return a card from your hand. Claim an achievement of matching value ignoring eligibility.
// - Return a card from your hand. Claim an available achievement of matching value ignoring eligibility.

public function initialExecution()
{
Expand Down
8 changes: 5 additions & 3 deletions modules/Innovation/Cards/Artifacts/Card133.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ class Card133 extends AbstractCard

// Dead Sea Scrolls
// - 3rd edition:
// - Draw an Artifact of value equal to the value of your highest top card.
// - 4th edition:
// - Draw an Artifact of value equal to the value of your highest top card. Junk the Artifact
// deck of that value.
// - 4th edition:
// - Draw an Artifact of value equal to the value of your highest top card.
// - Choose a player. Junk an available achievement of value equal to the highest top card on
// that player's board.

Expand All @@ -23,7 +23,9 @@ public function initialExecution()
if (self::isFirstNonDemand()) {
$value = self::getMaxValue(self::getTopCards());
self::drawType($value, CardTypes::ARTIFACTS);
self::junkDeck($value, CardTypes::ARTIFACTS);
if (self::isFourthEdition()) {
self::junkDeck($value, CardTypes::ARTIFACTS);
}
} else if (self::isSecondNonDemand()) {
self::setMaxSteps(2);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card144.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Card144 extends AbstractCard
// - 4th edition:
// - Return a card from your hand. If you do, return a top card of the same color from your
// board and a card of the same color from your score pile. If you do all three, claim an
// achievement ignoring eligibility.
// available achievement ignoring eligibility.


public function initialExecution()
Expand Down
3 changes: 1 addition & 2 deletions modules/Innovation/Cards/Artifacts/Card145_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@ class Card145_4E extends AbstractCard
{

// Petition of Right (4th edition):
// - I COMPEL you to transfer a card from your score pile to my score pile for each color with
// - I COMPEL you to transfer a card from your score pile to my score pile for every color with
// [AUTHORITY] on your board!
// - Junk an available achievement of value equal to the number of [AUTHORITY] on your board.


public function initialExecution()
{
self::setMaxSteps(1);
Expand Down
7 changes: 4 additions & 3 deletions modules/Innovation/Cards/Artifacts/Card149_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ public function getInteractionOptions(): array
];
} else {
return [
'location_from' => Locations::HAND,
'meld_keyword' => true,
'color' => [Colors::GREEN],
'location_from' => Locations::HAND,
'meld_keyword' => true,
'color' => [Colors::GREEN],
'reveal_if_unable' => true,
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card161.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public function getInteractionOptions(): array
}

public function handleCardChoice(array $card) {
self::fullyExecute($card);
self::superExecute($card);
}

}
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card162_3E.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function handleValueChoice(int $value)
public function handleCardChoice(array $card)
{
if (self::isThirdInteraction()) {
self::fullyExecute($card);
self::superExecute($card);
}
}

Expand Down
4 changes: 2 additions & 2 deletions modules/Innovation/Cards/Artifacts/Card163.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ class Card163 extends AbstractCard
// - 3rd edition:
// - Draw and reveal a [6]. If it is red, claim an achievement, ignoring eligibility.
// - 4th edition:
// - Draw and reveal a [6]. If it is red, claim an achievement, ignoring eligibility. Otherwise,
// junk an available standard achievement.
// - Draw and reveal a [6]. If it is red, claim an available standard achievement, ignoring
// eligibility. Otherwise, junk an available standard achievement.

public function initialExecution()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card164_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class Card164_4E extends AbstractCard
{
// Almira, Queen of Castile (4th edition):
// - Meld a card from your hand. If you do, claim an achievement of matching value, ignoring
// - Meld a card from your hand. If you do, claim an available achievement of matching value, ignoring
// eligibility. Otherwise, junk all cards in the deck of value equal to the lowest available
// achievement, if there is one.

Expand Down
7 changes: 6 additions & 1 deletion modules/Innovation/Cards/Artifacts/Card174.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,14 @@

class Card174 extends AbstractCard
{
// Marcha Real
// Marcha Real:
// - 3rd edition:
// - Reveal and return two cards from your hand. If they have the same value, draw a card of
// value one higher. If they have the same color, claim an achievement, ignoring eligibility.
// - 4th edition:
// - Reveal and return two cards from your hand. If they have the same value, draw a card of
// value one higher. If they have the same color, claim an available achievement, ignoring
// eligibility.

public function initialExecution()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card178_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class Card178_4E extends AbstractCard
{
// Jedlik's Electromagnetic Self-Rotor (4th edition):
// - Draw and score an [8].
// - Draw and meld an [8]. If it is an [8], choose a value, and junk all cards in the deck of that value.
// - Draw and meld an [8]. If you do, choose a value, and junk all cards in the deck of that value.

public function initialExecution()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card183.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function afterInteraction()
self::drawAndScore($value);
if (self::getNumChosen() > 0) {
if (self::isFirstOrThirdEdition()) {
self::fullyExecute(self::getLastSelectedCard());
self::superExecute(self::getLastSelectedCard());
} else {
self::selfExecute(self::getLastSelectedCard());
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card186_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Card186_4E extends AbstractCard
// Earhart's Lockheed Electra 10E (4th edition):
// - For each value below 9, junk a top card of that value from your board, in descending order.
// Then, if there is a junked card of each value below 9, you win.
// - Claim an achievement, ignoring eligibility.
// - Claim an available achievement, ignoring eligibility.

public function initialExecution()
{
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card193.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function handleCardChoice(array $card)
self::notifyOthers(clienttranslate('${player_name} melded a card with no effects.'));
self::win();
} else if (self::isFirstOrThirdEdition()) {
self::fullyExecute($card);
self::superExecute($card);
} else if (self::isFourthEdition()) {
self::selfExecute($card);
}
Expand Down
8 changes: 6 additions & 2 deletions modules/Innovation/Cards/Artifacts/Card194.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Card194 extends AbstractCard
// - 4th edition:
// - I COMPEL you to return one of your claimed standard achievements!
// - Draw and reveal an [8]. The single player with the highest top card of the drawn card's
// color achieves the drawn card, ignoring eligibility. If they do, repeat this effect.
// color achieves the top card, ignoring eligibility. If they do, repeat this effect.

public function initialExecution()
{
Expand All @@ -31,7 +31,11 @@ public function initialExecution()
$args = ['i18n' => ['color'], 'color' => Colors::render($color)];
self::notifyPlayer(clienttranslate('${You} have the highest top ${color} card.'), $args, $playerId);
self::notifyOthers(clienttranslate('${player_name} has the highest top ${color} card.'), $args, $playerId);
self::achieve($card, $playerId);
if (self::isFirstOrThirdEdition()) {
self::achieve($card, $playerId);
} else {
self::achieve(self::getTopCardOfColor($color), $playerId);
}
} else {
self::transferToHand($card);
return;
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card195.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function initialExecution()
}

if (self::isFirstOrThirdEdition()) {
self::fullyExecute($card);
self::superExecute($card);
} else {
self::selfExecute($card);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card205.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function initialExecution()
{
$card = self::drawAndMeldType(10, CardTypes::ARTIFACTS);
if (self::isFirstOrThirdEdition()) {
self::fullyExecute($card);
self::superExecute($card);
} else {
self::selfExecute($card);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card456.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function handleCardChoice(array $card)
$other_card_id = self::getAuxiliaryArray()[0];
$other_card = self::meld(self::getCard($other_card_id));
if (self::isTheirTurn()) {
self::fullyExecute($other_card);
self::superExecute($other_card);
} else {
self::selfExecute($other_card);
}
Expand Down
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Artifacts/Card458.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class Card458 extends AbstractCard

// Jumbo Kingdom
// - Choose a color on your board. Junk all cards of that color from all boards.
// - Choose a card in the junk. Score all cards of the chosen card's value in the junk. If you
// - Choose a valued card in the junk. Score all cards of the chosen card's value in the junk. If you
// do, and you score fewer than eleven points, repeat this effect.

public function initialExecution()
Expand Down
Loading

0 comments on commit 8777740

Please sign in to comment.