Skip to content

Commit

Permalink
Begin adding non-demand no-op checks to base set (#1456)
Browse files Browse the repository at this point in the history
  • Loading branch information
micahstairs committed Aug 18, 2024
1 parent f5428d9 commit cc0b91e
Show file tree
Hide file tree
Showing 10 changed files with 118 additions and 353 deletions.
337 changes: 20 additions & 317 deletions innovation.game.php

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions modules/Innovation/Cards/AbstractCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,18 @@ public function hasPostExecutionLogic(): bool
return false;
}

public function nonDemandsMightBeEffective(): bool
{
// Subclasses should override this method and return false if the card is guaranteed not to have an effect when the non-demands are executed.
return true;
}

public function echoMightBeEffective(): bool
{
// Subclasses should override this method and return false if the card is guaranteed not to have an effect when the echo effect is executed.
return true;
}

public function demandMightBeEffective(): bool
{
// Subclasses should override this method and return false if the card is guaranteed not to have an effect when "I demand" is executed.
Expand Down
5 changes: 3 additions & 2 deletions modules/Innovation/Cards/Base/Card0.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Innovation\Cards\Base;

use Innovation\Cards\AbstractCard;
use Innovation\Enums\Locations;

class Card0 extends AbstractCard
{
Expand All @@ -25,10 +26,10 @@ public function getInteractionOptions(): array
{
return [
'can_pass' => true,
'return_keyword' => true,
'n_min' => 1,
'n_max' => 3,
'location_from' => 'hand',
'return_keyword' => true,
'location_from' => Locations::HAND,
];
}

Expand Down
12 changes: 9 additions & 3 deletions modules/Innovation/Cards/Base/Card1.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Innovation\Cards\Base;

use Innovation\Cards\AbstractCard;
use Innovation\Enums\Locations;

class Card1 extends AbstractCard
{
Expand All @@ -21,16 +22,16 @@ public function getInteractionOptions(): array
if (self::isFirstNonDemand()) {
return [
'can_pass' => true,
'n' => 3,
'location_from' => 'hand',
'return_keyword' => true,
'n' => 3,
'location_from' => Locations::HAND,
];
} else {
return [
'can_pass' => true,
'location_from' => 'hand',
'return_keyword' => true,
'age' => 3,
'location_from' => Locations::HAND,
];
}
}
Expand All @@ -45,4 +46,9 @@ public function afterInteraction()
self::draw(1);
}
}

public function nonDemandsMightBeEffective(): bool
{
return self::hasCards(Locations::HAND);
}
}
5 changes: 5 additions & 0 deletions modules/Innovation/Cards/Base/Card11_3E.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,9 @@ public function afterInteraction() {
}
}

public function nonDemandsMightBeEffective(): bool
{
return count(self::filterByIcon(self::getCards(Locations::HAND), Icons::AUTHORITY)) > 0;
}

}
8 changes: 8 additions & 0 deletions modules/Innovation/Cards/Base/Card11_4E.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,12 @@ public function getInteractionOptions(): array
];
}

public function nonDemandsMightBeEffective(): bool
{
if (count(self::filterByIcon(self::getCards(Locations::HAND), Icons::AUTHORITY)) > 0) {
return true;
}
return self::countCardsKeyedByColor(Locations::BOARD)[Colors::RED] == 3;
}

}
14 changes: 11 additions & 3 deletions modules/Innovation/Cards/Base/Card3.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,33 @@ public function initialExecution()
{
if (self::isDemand()) {
self::draw(1);
self::setMaxSteps(1);
} else {
self::setMaxSteps(1);
}
self::setMaxSteps(1);
}

public function getInteractionOptions(): array
{
if (self::isDemand()) {
return [
'age' => ValueSelectors::HIGHEST,
'location' => Locations::HAND,
'owner_to' => self::getLauncherId(),
'age' => ValueSelectors::HIGHEST,
];
} else {
return [
'location_from' => Locations::AVAILABLE_ACHIEVEMENTS,
'junk_keyword' => true,
'location_from' => Locations::AVAILABLE_ACHIEVEMENTS,
'age_min' => 1,
'age_max' => 2,
];
}
}

public function nonDemandsMightBeEffective(): bool
{
return count(self::filterByValue(self::getAvailableStandardAchievements(), [1, 2])) > 0;
}

}
2 changes: 1 addition & 1 deletion modules/Innovation/Cards/Base/Card5.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

class Card5 extends AbstractCard
{
//
// Oars:
// - 3rd edition:
// - I DEMAND you transfer a card with a [PROSPERITY] from your hand to my score pile! If you
// do, draw a [1], and repeat this dogma effect!
Expand Down
69 changes: 43 additions & 26 deletions modules/Innovation/Cards/Base/Card6.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,10 @@ public function initialExecution()
if (self::isFirstNonDemand()) {
self::setMaxSteps(1);
} else if (self::isSecondNonDemand()) {
$numCardsToScore = 0;
$boards = $this->game->getBoards(self::getPlayerIds());
foreach (Colors::ALL as $color) { // Evaluate each color
if (!$boards[self::getPlayerId()][$color]) {
continue;
}
$presentOnOpposingBoard = false;
foreach (self::getOpponentIds() as $opponentId) {
if ($boards[$opponentId][$color]) {
$presentOnOpposingBoard = true;
break;
}
}
if (!$presentOnOpposingBoard) { // The opponents do not have this color => point
$numCardsToScore++;
}
}

$numCardsToScore = self::getNumberOfCardsToScore();
$args = ['i18n' => ['n'], 'n' => self::renderNumber($numCardsToScore)];
self::notifyPlayer(clienttranslate('${You} have ${n} color(s) present on your board not present on any opponent\'s board.'), $args);
self::notifyOthers(clienttranslate('${player_name} has ${n} color(s) present on his board not present on any of his opponents\' boards.'), $args);

for ($i = 0; $i < $numCardsToScore; $i++) {
self::drawAndScore(1);
}
Expand All @@ -51,18 +33,53 @@ public function initialExecution()

public function getInteractionOptions(): array
{
return [
'location_from' => Locations::HAND,
'meld_keyword' => true,
'color' => self::getColorsNotOnBoard(),
];
}

private function getColorsNotOnBoard(): array
{
$colorsNotOnBoard = [];
$stacks = self::getCardsKeyedByColor(Locations::BOARD);
$colors = [];
foreach (Colors::ALL as $color) {
if (!$stacks[$color]) {
$colors[] = $color;
$colorsNotOnBoard[] = $color;
}
}
return [
'location_from' => Locations::HAND,
'meld_keyword' => true,
'color' => $colors,
];
return $colorsNotOnBoard;
}

private function getNumberOfCardsToScore(): int
{
$numCardsToScore = 0;
$boards = $this->game->getBoards(self::getPlayerIds());
foreach (Colors::ALL as $color) { // Evaluate each color
if (!$boards[self::getPlayerId()][$color]) {
continue;
}
$presentOnOpposingBoard = false;
foreach (self::getOpponentIds() as $opponentId) {
if ($boards[$opponentId][$color]) {
$presentOnOpposingBoard = true;
break;
}
}
if (!$presentOnOpposingBoard) { // The opponents do not have this color
$numCardsToScore++;
}
}
return $numCardsToScore;
}

public function nonDemandsMightBeEffective(): bool
{
if (self::filterByColor(self::getCards(Locations::HAND), self::getColorsNotOnBoard())) {
return true;
}
return self::getNumberOfCardsToScore() > 0;
}

}
7 changes: 6 additions & 1 deletion modules/Innovation/Cards/Base/Card9.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ public function getInteractionOptions(): array
{
return [
'can_pass' => true,
'location_from' => Locations::HAND,
'return_keyword' => true,
'location_from' => Locations::HAND,
];
}

Expand All @@ -32,4 +32,9 @@ public function handleCardChoice(array $card)
self::drawAndScore(self::getValue($card) + 1);
}

public function nonDemandsMightBeEffective(): bool
{
return self::hasCards(Locations::HAND);
}

}

0 comments on commit cc0b91e

Please sign in to comment.