//Checks whether a player can build a card from a chain public static bool canChainBuild(Player player, Card card) { foreach (string cardID in player.getPlayed()) if (card.chains.Contains(CardLibrary.getCard(cardID).name)) return true; return false; }
// Returns the best Guild Card to copy from the player's neighbours private static Card GetGuildCopyCard(Player p, Player east, Player west) { List<string> guilds = new List<string>(); Dictionary<string, int> guildScore = new Dictionary<string, int>(); string bestCard = null; int bestScore = 0; // Guild Cards taken from East Player foreach (string c in east.getPlayed()) if (CardLibrary.getCard(c).colour.Equals(CardColour.PURPLE)) guilds.Add(c); // Guild Cards taken from West Player foreach (string c in west.getPlayed()) if (CardLibrary.getCard(c).colour.Equals(CardColour.PURPLE)) guilds.Add(c); // Looping through the Guild Cards available to calculate the best guild foreach (string cardID in guilds) { guildScore.Add(cardID, 0); foreach (Effect e in CardLibrary.getCard(cardID).effects) { if (e.type.Equals(Effect.TypeType.VICTORY) && e.from.Equals(Effect.FromType.NEIGHBOURS)) { if (cardType.ContainsKey(e.basis)) guildScore[cardID] = GetVictoryNeighboursColour(east, west, cardType[e.basis], e.amount); else if (e.basis.Equals(Effect.BasisType.DEFEAT)) { //Need to finish the function called here guildScore[cardID] = GetVictoryNeighboursConflict(east, west); } } else if (e.type.Equals(Effect.TypeType.VICTORY) && e.from.Equals(Effect.FromType.PLAYER) && cardType.ContainsKey(e.basis)) guildScore[cardID] += GetVictoryColour(p, cardType[e.basis], e.amount); // Added multiple times else if (e.type.Equals(Effect.TypeType.VICTORY) && e.from.Equals(Effect.FromType.ALL) && e.basis.Equals(Effect.BasisType.WONDER)) guildScore[cardID] = GetVictoryAllWonders(p, east, west); else if (e.type.Equals(Effect.TypeType.SCHOICE)) { //CalculateScience(g c t) int gear = p.getScoreNum(Score.GEAR); int comp = p.getScoreNum(Score.COMPASS); int tab = p.getScoreNum(Score.TABLET); int maxScience = Math.Max(Math.Max( CalculateScience(gear + 1, comp, tab), CalculateScience(gear, comp + 1, tab)), CalculateScience(gear, comp, tab + 1)); guildScore[cardID] = maxScience; } } } // End Foreach string cardID in guilds // Finding the best guild Card foreach (KeyValuePair<string, int> key in guildScore) { if (key.Value > bestScore) { bestScore = key.Value; bestCard = key.Key; } } // Returning the Best Guild Card return CardLibrary.getCard(bestCard); }
// Returns the total score of the player, with the card or no card public static int GetScore(Player p, Player east, Player west, string cardID) { // Score for victory is automatically computing the Victory points for // Blue cards, Wonder stages, int score = 0; int schoiceCount = 0; Dictionary<Score, int> oldScore = new Dictionary<Score, int>(); List<Card> played = new List<Card>(); foreach (KeyValuePair<Score, int> k in p.getScore()) oldScore[k.Key] = k.Value; foreach (string card in p.getPlayed()) played.Add(CardLibrary.getCard(card)); // Card isn't NULL - returns the score of the player with the hypothetical card in the players // Played card list if (cardID != null) { Card card = CardLibrary.getCard(cardID); if (!p.cardPlayed(cardID)) played.Add(card); } // Check Wonder board effects first // This way if a player has guildCopy, it will take into account that the scientist guild // card is added into the players played hand and counted for (int i = 0; i < p.getBoard().getStagesBuilt(); i++) { foreach (Effect e in p.getBoard().getSide().getStageEffects(i)) { if (e.type.Equals(Effect.TypeType.SCHOICE)) schoiceCount += 1; // Loop through Wonder Effects for the players // GUILD COPY - not finished else if (e.type.Equals(Effect.TypeType.GUILD)) { played.Add(GetGuildCopyCard(p, east, west)); } } // Foreach loop through Wondestage effects } // For loop through the stages // Looping through the player's played cards foreach (Card card in played) { // Looping through the effects of each Card for End Game purposes foreach (Effect e in card.effects) { // Victory Points if (e.type.Equals(Effect.TypeType.VICTORY)) { // FROM: NEIGHBORS // and BASIS: CardColour, Wonderstages, Defeat if (e.from != Effect.FromType.NONE && e.from.Equals(Effect.FromType.NEIGHBOURS)) { // Apply victory points awarded for each // Wonderstage neigboring cities own if (e.basis.Equals(Effect.BasisType.WONDER)) score += GetVictoryAllWonders(p, east, west); //Victory points given per neighbor's conlfict token else if (e.basis.Equals(Effect.BasisType.DEFEAT)) score += GetVictoryNeighboursConflict(east, west); // Victory points awarded per certain structure built by neighbours else score += GetVictoryNeighboursColour(east, west, cardType[e.basis], e.amount); } // FROM: PLAYER // BASIS: CardColour, Wonderstages, else if (e.from != Effect.FromType.NONE && e.from.Equals(Effect.FromType.PLAYER)) { if (e.basis.Equals(Effect.BasisType.WONDER)) score += p.getBoard().getStagesBuilt(); else score += GetVictoryColour(p, cardType[e.basis], e.amount); } // FROM: ALL // BASIS: Wonderstages else if (e.from != Effect.FromType.NONE && e.from.Equals(Effect.FromType.ALL)) score += GetVictoryAllWonders(p, east, west); } // End Victory Points // SCIENCE CHOICE else if (e.type.Equals(Effect.TypeType.SCHOICE)) schoiceCount += 1; } // End Effect Loop for Cards } // End Current Player's Card Loop for (int i = 0; i < p.getBoard().getStagesBuilt(); i++) { foreach (Effect e in p.getBoard().getSide().getStageEffects(i)) { if (e.type.Equals(Effect.TypeType.VICTORY)) score += e.amount; } } // Max Function, will add onto the max science value foreach (KeyValuePair<Score, int> k in GetBestScienceChoice(p, schoiceCount)) { oldScore[k.Key] += k.Value; } score += CalculateScience(oldScore[Score.GEAR], oldScore[Score.COMPASS], oldScore[Score.TABLET]); score += p.getScoreNum(Score.CONFLICT); score += GetTreasuryScore(p); return score; }
public static int GetGuildsScore(Player p, Player east, Player west) { int guilds = 0; foreach (string c in p.getPlayed()) { Card current = CardLibrary.getCard(c); if (current.colour.Equals(CardColour.PURPLE)) foreach (Effect e in current.effects) { if (e.type.Equals(Effect.TypeType.VICTORY)) switch (e.from) { case Effect.FromType.ALL: if (e.basis.Equals(Effect.BasisType.WONDER)) guilds += GetVictoryAllWonders(p, east, west); break; case Effect.FromType.NEIGHBOURS: if (cardType.ContainsKey(e.basis)) guilds += GetVictoryNeighboursColour(east, west, cardType[e.basis], e.amount); else if (e.basis.Equals(Effect.BasisType.DEFEAT)) guilds += east.getScoreNum(Score.DEFEAT) + west.getScoreNum(Score.DEFEAT); break; case Effect.FromType.PLAYER: if (cardType.ContainsKey(e.basis)) guilds += GetVictoryColour(p, cardType[e.basis], e.amount); break; } } } return guilds; }
// Commercial structures // Some commercial structures from Age III grant victory points // Return the victory points from Commercial structures public static int GetCommercialScore(Player p) { int commercial = 0; foreach (string c in p.getPlayed()) { Card current = CardLibrary.getCard(c); if (current.colour.Equals(CardColour.YELLOW) && current.age.Equals(3)) foreach (Effect e in current.effects) { if (e.type.Equals(Effect.TypeType.VICTORY) && e.from.Equals(Effect.FromType.PLAYER)) { if (e.basis.Equals(Effect.BasisType.WONDER)) commercial += p.getBoard().getStagesBuilt(); else commercial += GetVictoryColour(p, cardType[e.basis], e.amount); } } } return commercial; }
// Commercial structures // Some commercial structures from Age III grant coins points // Return the number of coins gained from Commercial structures public static int GetCommercialCoin(Player p, Player east, Player west) { int commercial = 0; foreach (string c in p.getPlayed()) { Card current = CardLibrary.getCard(c); if (current.colour.Equals(CardColour.YELLOW)) { foreach (Effect e in current.effects) { if (e.type.Equals(Effect.TypeType.COIN)) { switch(e.from) { case Effect.FromType.ALL: commercial += GetCoinAllColour(p, east, west, cardType[e.basis], e.amount); break; case Effect.FromType.PLAYER: if (cardType.ContainsKey(e.basis)) commercial += GetCoinColour(p, cardType[e.basis], e.amount); else if (e.basis.Equals(Effect.BasisType.WONDER)) commercial += GetCoinWonder(p, e.amount); break; default: commercial += e.amount; break; } } } } } return commercial; }