PETCardFunctionsTrait

trait SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait
Trait holding functions relative to cards handling
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#24

Used traits

SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETScoreFunctionsTrait SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETSkillFunctionsTrait SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETPowerFunctionsTrait SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETActionFunctionsTrait

Methods

public SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::decreaseDrawCardNumber($playerId)
Decreases the number of cards to be drawn
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#39

Parameters
  • $playerId (int)

Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getNumberOfCardsToDraw($playerId)
This method returns the number of cards to draw during the current action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#56

Parameters
  • $playerId (int)

Returns

int

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getNumberOfCardsToDrawAndDiscard($playerId)
Method responsible for returning an array containing the number of cards a players still has to draw and discard.
Array structure:
array(
player_card_draw_number => int,
player_card_discard_number => int,
);
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#72

Parameters
  • $playerId (int)

Returns

int[]

public SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::setNumberOfCardsToDrawAndDiscard($playerId, $drawNumber=null, $discardNumber=null)
Method to set the numbers of cards that have to be drawn and/or discarded during the player's action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#87

Parameters
  • $playerId (int)

  • $drawNumber (int | null)

  • $discardNumber (int | null)

Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyCardBenefits($PETAgeCard, $playerId)
Apply card benefits to the player
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#114

Parameters
Returns

array The array containing the notification arguments

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applySkillBenefit($PETAgeCard, $playerId, &$benefits)
Apply skill benefit from card
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#145

Parameters
Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyTokenBenefit($PETAgeCard, $playerId, &$benefitsArray)
Apply tokens benefit (knowledge and age) from card
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#173

Parameters
Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyKnowledgeTokenBenefit($PETToken, $playerId)
Apply knowledge token benefit
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#199

Parameters
Returns

\SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETToken | null

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyAgeTokenBenefit($PETToken, $playerId)
Apply age token benefit (take a token from the reserve if necessary, if it is the last one, means that the game
needs to transition to openNextAge state, and if there are none, return a token without id so that it can still
be substituted in the log)
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#222

Parameters
Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyPowerBenefit($PETAgeCard, $playerId, &$benefits)
Apply power track benefits from a card
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#245

Parameters
Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::benefitsArrayToGainsSentence($benefits)
Create the notification log for a card discovery from the benefits array
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#268

Parameters
  • $benefits (array)

Returns

array | array[]

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getValidDrawLocationsGetAllDatas()
Returns the array needed by JS frontend to create deck locations
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#326

Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getValidDrawLocations()
Method responsible for returning an array of available draw location based on game progression
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#357

Returns

string[]

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkValidDrawLocation($location)
Check if location is a valid draw location
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#386

Parameters
  • $location (string)

Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::decreaseDiscardCardNumber($playerId)
Decreases the number of cards to be discarded
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#398

Parameters
  • $playerId (int)

Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getNumberOfCardsToDiscard($playerId)
This method returns the number of cards to discard during the current action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#415

Parameters
  • $playerId (int)

Returns

int

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getUpkeepNumberOfCardsToDiscard()
Method responsible for getting the number of cards a player should discard during their upkeep phase
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#425

Returns

int

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::setRemainingValues($remainingValues, $playerId)
Sets the remaining array values in the DB for player whose id is $playerId
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#447

Parameters
  • $remainingValues (array)

  • $playerId (int)

Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getDiscoveringCard($playerId)
Returns the card being discovered
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#467

Parameters
  • $playerId (int)

Returns

\SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::setDiscoveringCard($PETAgeCard, $playerId)
Sets the card being discovered
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#485

Parameters
Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkCardInResearchArea($PETAgeCard, $playerId)
Checks if a card of the same type is already in the player's research area
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#510

Parameters
Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkCardOfTypeInLocation($PETAgeCard, $location)
Checks if a card of the same type is already present in the given location
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#523

Parameters
Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkCardInActiveCards($PETAgeCard, $playerId)
Checks if a card of the same type is already present in the player's active cards
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#537

Parameters
Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkDiscardedValueCoversCost($discardedArray, $PETAgeCard, $playerId)
Checks whether the costs are covered by the discarded cards and used tokens
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#551

Parameters
Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::computeDiffBetweenCostAndRemainingValue($discardedArray, $PETAgeCard, $playerId)
Computes the difference between the costs and remainingValues + discardedValues, and place the result in the cost
array. Should the discarded and remaining values cover the cost, the resulting cost array should have all its values
set to 0.
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#568

Parameters
Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::computeDiscardedCardTokenValues($discardedArray, $playerId)
Computes the value of the cards discarded by the player and the token they used
Returns an array, whose structure is:
array(
“Culture” => int,
“Engineering” => int,
“Science” => int,
“General knowledge” => int
)
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#621

Parameters
  • $discardedArray (array)

  • $playerId (int)

Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getRemainingValuesArray($playerId)
Gets the remaining values array from the DB for $playerId
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#649

Parameters
  • $playerId (int)

Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::computeCardCostForPlayer($PETAgeCard, $playerId)
Method responsible for computing the cost of a card for the given player.
Return array structure:
array(
TYPE_CULTURE => int,
TYPE_ENGINEERING => int,
TYPE_SCIENCE => int,
TYPE_GENERAL_KNOWLEDGE => int
)
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#676

Parameters
Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::discardCardFromHand($PETAgeCard, $playerId, $action=null, $returnArray=false)
Discard a card from the hand to be counted for discover action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#721

Parameters
Returns

array | void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkCardsInPlayerHand($cards, $playerId)
Check whether the supplied cards really belong to the player who says they play/discard them
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#751

Parameters
Returns

bool

public SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkCardsInLocation($cards, $location, $locationArg=null)
Check whether the supplied card(s) are in the supplied location or not
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#765

Parameters
Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::addDiscardedCardOrToken($PETDeckCard, $playerId)
Adds a card to the discarded cards during the discover action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#801

Parameters
Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getDiscardedCardsAndUsedTokens()
Returns the cards discarded during the discover action
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#825

Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::canDrawAdditionalCard()
Returns whether a player drawing cards can still draw cards from the decks and discards or if all are empty
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#837

Returns

bool

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::drawCardFromLocationAndNotifyPlayers($playerId, $location, $notificationName)
Helper function to draw cards from a location and then notify players that a card has been drawn
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#857

Parameters
  • $playerId (int)

  • $location (string)

  • $notificationName (string)

Returns

void

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::discardCardsUseTokensAndBuildNotificationArray( $playerId, $PETAgeCards=\[\], $PETTokens=\[\])
Helper function to discard cards and/or use tokens for an action, and build the corresponding notification array
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#893

Parameters
Returns

array

private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getCardNameArray()
Returns an array with the card name for a notification
Source

modules/php/Traits/Utility/PETCardFunctionsTrait.php#934

Returns

array