PETCardFunctionsTrait
- trait SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait
- Trait holding functions relative to cards handling
- Source
- 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
- 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
- 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
- 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
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
) PETAgeCard object to apply benefits from$playerId (int) Id of the player the card benefits are applied to
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
$benefits (array)
- Returns
void
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyTokenBenefit($PETAgeCard, $playerId, &$benefitsArray)
- Apply tokens benefit (knowledge and age) from card
- Source
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
$benefitsArray (array)
- Returns
void
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyKnowledgeTokenBenefit($PETToken, $playerId)
- Apply knowledge token benefit
- Source
- Parameters
$PETToken (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETToken
)$playerId (int)
- 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 gameneeds to transition to openNextAge state, and if there are none, return a token without id so that it can stillbe substituted in the log)
- Source
- Parameters
$PETToken (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETToken
)$playerId (int)
- Returns
array
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::applyPowerBenefit($PETAgeCard, $playerId, &$benefits)
- Apply power track benefits from a card
- Source
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
$benefits (array)
- Returns
void
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::benefitsArrayToGainsSentence($benefits)
- Create the notification log for a card discovery from the benefits array
- Source
- 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
- 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
- Returns
string[]
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::checkValidDrawLocation($location)
- Check if location is a valid draw location
- Source
- Parameters
$location (string)
- Returns
bool
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::decreaseDiscardCardNumber($playerId)
- Decreases the number of cards to be discarded
- Source
- 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
- 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
- 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
- Parameters
$remainingValues (array)
$playerId (int)
- Returns
void
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getDiscoveringCard($playerId)
- Returns the card being discovered
- Source
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$location (string)
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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
- Parameters
$discardedArray (array)
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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 costarray. Should the discarded and remaining values cover the cost, the resulting cost array should have all its valuesset to 0.
- Source
- Parameters
$discardedArray (array)
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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 usedReturns an array, whose structure is:array(“Culture” => int,“Engineering” => int,“Science” => int,“General knowledge” => int)
- Source
- 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
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
- 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
- Parameters
$PETAgeCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
)$playerId (int)
$action (int | null)
$returnArray (bool)
- 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
- Parameters
$cards (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
|\SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard[]
) One or several cards$playerId (int) id of the player to check the card is really in the hand of
- 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
- Parameters
$cards (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard
|\SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard[]
)$location (string)
$locationArg (int | null)
- Returns
bool
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::addDiscardedCardOrToken($PETDeckCard, $playerId)
- Adds a card to the discarded cards during the discover action
- Source
- Parameters
$PETDeckCard (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Interfaces\PETDeckCardInterface
)$playerId (int)
- Returns
array
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getDiscardedCardsAndUsedTokens()
- Returns the cards discarded during the discover action
- Source
- 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
- 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
- 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
- Parameters
$playerId (int)
$PETAgeCards (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETAgeCard[]
)$PETTokens (
SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Object\PETToken[]
)
- Returns
array
- private SwHawk\ProgressEvolutionOfTechnologySWH\Modules\Traits\Utility\PETCardFunctionsTrait::getCardNameArray()
- Returns an array with the card name for a notification
- Source
- Returns
array