class Event;
struct State;
struct CardPlayInfo
{
CardPlayInfo() {}
explicit CardPlayInfo(Card *c, int _turnsLeft)
{
card = c;
copies = 1;
turnsLeft = _turnsLeft;
}
Card *card;
int copies;
int turnsLeft;
};
struct PlayerState
{
void NewGame(const GameData &data);
int ActionCount() const;
int TreasureCount() const;
int VictoryCount() const;
int TotalCards() const;
int MoneyTotal() const;
bool CardInPlay(Card *c) const
{
for(const CardPlayInfo &play : playArea) if(play.card == c) return true;
return false;
}
Vector<Card*> hand;
Vector<Card*> deck;
Vector<Card*> discard;
Vector<CardPlayInfo> playArea;
Vector<Card*> islandZone;
int actions;
int buys;
int money;
int VPTokens;
int turns;
};
struct DecisionResponse
{
DecisionResponse()
{
choice = -1;
singleCard = NULL;
}
UINT choice;
Card *singleCard;
Vector<Card*> cards;
};
class DecisionState
{
public:
bool IsTrivial() const;
DecisionResponse TrivialResponse() const;
void SelectCards(Card *c, UINT minCards, UINT maxCards)
{
activeCard = c;
type = DecisionSelectCards;
minimumCards = minCards;
maximumCards = maxCards;
controllingPlayer = -1;
cardChoices.FreeMemory();
}
void MakeDiscreteChoice(Card *c, UINT optionCount)
{
activeCard = c;
type = DecisionDiscreteChoice;
minimumCards = optionCount;
maximumCards = optionCount;
controllingPlayer = -1;
}
void GainCardFromSupply(State &s, Card *c, int minCost, int maxCost, CardFilter filter = FilterAny);
void GainTreasureFromSupply(State &s, Card *c, int minCost, int maxCost);
void GainVictoryFromSupply(State &s, Card *c, int minCost, int maxCost);
__forceinline void AddUniqueCard(Card *c)
{
if(!cardChoices.Contains(c)) cardChoices.PushEnd(c);
}
__forceinline void AddUniqueCards(Vector<Card*> cards)
{
for(Card *c : cards) AddUniqueCard(c);
}
DecisionType type;
Card *activeCard;
Vector<Card*> cardChoices;
UINT minimumCards;
UINT maximumCards;
int controllingPlayer;
String text;
};
struct SupplyEntry
{
UINT count;
UINT tradeRouteToken;
};
struct State
{
static const UINT playerMaximum = 2;
static const UINT maxSupply = 20;
void NewGame(const GameData &_data);
void AdvanceToNextDecision(UINT recursionDepth);
void AdvancePhase();
void ProcessDecision(const DecisionResponse &response);
void DrawCards(UINT playerIndex, UINT cardCount);
Card* DrawCard(UINT playerIndex);
void DiscardCard(UINT playerIndex, Card *c);
void PlayCard(UINT playerIndex, Card *c);
void Shuffle(UINT playerIndex);
void ProcessAction(Card *c);
void ProcessTreasure(Card *c);
void CheckEndConditions();
void ReorderDeck(Card *source, UINT playerIndex, UINT cardCount);
bool GameDone() const;
int PlayerScore(UINT playerIndex) const;
UINT SupplyCost(int supplyIndex) const;
UINT SupplyCost(Card *c) const;
UINT SupplyCount(Card *c) const;
UINT EmptySupplyPiles() const;
UINT ActionsPlayedThisTurn() const;
Vector<int> WinningPlayers() const;
void Log(UINT playerIndex, const String &s);
void Log(const String &s);
void LogIndent(UINT indentLevel, UINT playerIndex, const String &s);
void LogIndent(UINT indentLevel, const String &s);
void BuyPhaseStart();
const GameData *data;
UINT player;
Phase phase;
DecisionState decision;
PlayerState players[playerMaximum];
Vector<Event*> stack;
Vector<Card*> gainList;
Vector<Card*> prevGainList;
int tradeRouteValue;
SupplyEntry supply[maxSupply];
};