protected List<ResourceCard> SRCardInitializer(PlayerState p) { List<ResourceCard> tempList = new List<ResourceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() > 7) && (p.getPlayedCards()[i].getNumber() < 14)) { tempList.Add((ResourceCard)p.getPlayedCards()[i]); } } return tempList; }
/* * Input: A Player and a Card * * * Output: True or False -> Does the player have enough resources to play given card already? */ public bool ValidateCard(PlayerState p, Card c) { //_logger.ValidatingCard(p, c); //_logger.CheckDictionary(p,hashtable); //c.toString(); //Check for duplicity for (int i = 0; i < p.getPlayedCards().Count; i++) { if (c.getCardName() == p.getPlayedCards()[i].getCardName()) { if (p.getName().Equals("P0")) { System.Console.WriteLine("!Can't play card with the same name!"); } return(false); } } //Check for precards if (preCardCheck(p, c)) { return(true); } // First check what the coin costs and total resource cost are if (c.getCoinCost() == 0 && c.getTotalResourceCost() == 0) { //_logger.print(p,"Card dosn't cost anything"); UpdateResources(p, c); return(true); } // If the coin cost is not equal to 0 then does the player have enoguh coins ? if (c.getCoinCost() != 0 && c.getTotalResourceCost() == 0) { //_logger.CheckingCoins(p, c); if (c.getCoinCost() <= p.getCoins()) { UpdateResources(p, c); p.updateCoins(-c.getCoinCost()); // _logger.CheckingPlayersCoins(p); return(true); } return(false); } if (c.getTotalResourceCost() != 0) { //_logger.print(p,"Now we are working on the players Resources"); return(CheckResourceCost(p, c.getCost())); } return(false); }
private Card SetStrategy(PlayerState p, List<Card> hand) { Card bestCard = null; int currentAge = ResourceManager.GetInstance().getGameState().getAge(); if (p.getPlayedCards().Count() == 0) bestCard = BuildWonder(p, hand); if (bestCard == null) if (noOfPlayers == 3 || noOfPlayers == 7) if (p.getBoard().getCurrentWonderLevel() != currentAge) bestCard = BuildWonder(p, hand); if (bestCard == null) SetMilitaryStrategy(p, hand); if (bestCard == null) bestCard = SetScienceStrategy(p, hand); if (bestCard == null) bestCard = SetCommerceStrategy(p, hand); if (bestCard == null) bestCard = SetCivilianStrategy(p, hand); if (bestCard == null) { strategy = new RandomStrategy(); bestCard = strategy.getNextCard(p, hand); } return bestCard; }
private int civScore(PlayerState p) { List<CivilianCard> civlist; //Civilian Structures civlist = new List<CivilianCard>(); int score = 0; //Cycle through played cards //Add all civilian cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 3) { civlist.Add((CivilianCard)p.getPlayedCards()[i]); } } //Cycle through civ card list to add points for (int i = 0; i < civlist.Count; i++) { score = score + civlist[i].getVictoryPoints(); } return score; }
//Missing Code in this Function public void resetCommerceCards(PlayerState p) { List <CommerceCard> tempList = new List <CommerceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 4) { CommerceCard c = (CommerceCard)p.getPlayedCards()[i]; if (((c.getNumber() > 30) && (c.getNumber() < 37)) || ((c.getNumber() > 70) && (c.getNumber() < 77))) { tempList.Add(c); } } } ComCards[p.getName()] = tempList; }
public int countCardType(int cType, PlayerState pState) { int count = 0; foreach (Card cCard in pState.getPlayedCards()) { if (cCard.getType() == cType) { count++; } } return count; }
//preCardCheck checks if the player p has the prerequisite card for free play protected bool preCardCheck(Card c, PlayerState p) { //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards console.writeline(preCard[0] + " " + preCard[1] + " " + preCard[2] + " " + preCard[3]); for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] > 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } //else return false return false; }
/* * Input: A Player * * Output: void -> Given a player, This is the helper function to resetResources. * This looks through the list of played cards and adds special card values to a temporary * list of special resources. */ public void resetSpecialResourceSingular(PlayerState p) { List <ResourceCard> tempList = new List <ResourceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() < 3) { ResourceCard c = (ResourceCard)p.getPlayedCards()[i]; if (((c.getNumber() > 7) && (c.getNumber() < 14))) { tempList.Add(c); } } } if (p.getBoard().getName() == "WB2") { if (p.getBoard().getCurrentWonderLevel() > 0) { if (p.getBoard().getCurrentWonderLevel() > 1) { wonderBoardExceptionManGood = true; wonderBoardExceptionResource = true; } else { for (int j = 0; j < 7; j++) { wonderBoardExceptionResource = true; } } } } if ((p.getBoard().getName() == "WB1") && (p.getBoard().getCurrentWonderLevel() > 1)) { wonderBoardExceptionResource = true; } SResources[p.getName()] = tempList; }
public int countCardType(int cType, PlayerState pState) { int count = 0; foreach (Card cCard in pState.getPlayedCards()) { if (cCard.getType() == cType) { count++; } } return(count); }
/* * Input: A Player and a Card * * * Output: True or False -> Can the player play this card for free? If they have correct pre-card -> True */ private bool preCardCheck(PlayerState p, Card c) { //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] < 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return(true); } } } } return(false); }
private int sciScore(PlayerState p) { List<ScienceCard> scilist; scilist = new List<ScienceCard>(); int score = 0; //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 3) { scilist.Add((ScienceCard)p.getPlayedCards()[i]); } } //Cycle through science card list to add up sciencetype totals int[] sciTotals = new int[3] { 0, 0, 0 }; for (int i = 0; i < scilist.Count; i++) { sciTotals[scilist[i].getSciType()]++; } //Set points score = score + (sciTotals.Min() * 7); //Points for types score = score + (sciTotals[0] * sciTotals[0]); score = score + (sciTotals[1] * sciTotals[1]); score = score + (sciTotals[2] * sciTotals[2]); return score; }
private Card SetStrategy(PlayerState p, List <Card> hand) { Card bestCard = null; int currentAge = ResourceManager.GetInstance().getGameState().getAge(); if (p.getPlayedCards().Count() == 0) { bestCard = BuildWonder(p, hand); } if (bestCard == null) { if (noOfPlayers == 3 || noOfPlayers == 7) { if (p.getBoard().getCurrentWonderLevel() != currentAge) { bestCard = BuildWonder(p, hand); } } } if (bestCard == null) { bestCard = SetMilitaryStrategy(p, hand); } if (bestCard == null) { bestCard = SetScienceStrategy(p, hand); } if (bestCard == null) { bestCard = SetCommerceStrategy(p, hand); } if (bestCard == null) { bestCard = SetCivilianStrategy(p, hand); } if (bestCard == null) { strategy = new RandomStrategy(); bestCard = strategy.getNextCard(p, hand); } return(bestCard); }
private int CivilianScore(PlayerState p) { List <CivilianCard> civlist; //Civilian Structures civlist = new List <CivilianCard>(); int score = 0; //Cycle through played cards //Add all civilian cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == Card._CIVILIAN) { civlist.Add((CivilianCard)p.getPlayedCards()[i]); } } //Cycle through civ card list to add points for (int i = 0; i < civlist.Count; i++) { score = score + civlist[i].getVictoryPoints(); } return(score); }
int g_index = 0;//needed to reset ZIndex to original value upon mouse events public PlayerGameBoard(Grid gameGrid, PlayerState p, GameState g) { player = p; parent = gameGrid;//only 1 child if (parent.Children.Count > 1)//handle the case where there is existing child when we change views { parent.Children.Remove(parent.Children[1]); //System.Console.WriteLine("Child Removed"); } game = g; if (game.getAge() == 4)//game is over { ScoreWindow s = new ScoreWindow(game, parent); s.Show(); ; } playBoard = new Canvas(); parent.Children.Add(playBoard);//now child[1], two children createCardStack("R", 179, 10, playBoard);//0-9 createCardStack("M", 336, 10, playBoard);//10-19 createCardStack("S", 493, 10, playBoard);//20-29 createCardStack("Civ", 650, 10, playBoard);//30-39 createCardStack("Com", 807, 10, playBoard);//40-49 createCardStack("G", 964, 6, playBoard);//50-55 createHandStack();//56-62 updateAge(game.getAge());//63 createWonderBoard(player.getBoard().getName());//64 createPlayerButtons();//65-71 createPlayerRedCircles();//72-78 createPlayerBlueCircles();//79-85 createMoveButtons();//86-89 updateMoney();//90 createWonderSpots(player.getBoard().getMaxWonderLevel());//[91-94] variable length createRulesButton();//variable base on above wonder updateWonderSpots(player.getWonderCards()); updateHand(player.getHand()); updateCards(player.getPlayedCards()); }
public PlayerGameBoard(Grid gameGrid, PlayerState p, GameState g) { player = p; parent = gameGrid; //only 1 child if (parent.Children.Count > 1) //handle the case where there is existing child when we change views { parent.Children.Remove(parent.Children[1]); //System.Console.WriteLine("Child Removed"); } game = g; if (game.getAge() == 4)//game is over { ScoreWindow s = new ScoreWindow(game, parent); s.Show();; } playBoard = new Canvas(); parent.Children.Add(playBoard); //now child[1], two children createCardStack("R", 179, 10, playBoard); //0-9 createCardStack("M", 336, 10, playBoard); //10-19 createCardStack("S", 493, 10, playBoard); //20-29 createCardStack("Civ", 650, 10, playBoard); //30-39 createCardStack("Com", 807, 10, playBoard); //40-49 createCardStack("G", 964, 6, playBoard); //50-55 createHandStack(); //56-62 updateAge(game.getAge()); //63 createWonderBoard(player.getBoard().getName()); //64 createPlayerButtons(); //65-71 createPlayerRedCircles(); //72-78 createPlayerBlueCircles(); //79-85 createMoveButtons(); //86-89 updateMoney(); //90 createWonderSpots(player.getBoard().getMaxWonderLevel()); //[91-94] variable length createRulesButton(); //variable base on above wonder updateWonderSpots(player.getWonderCards()); updateHand(player.getHand()); updateCards(player.getPlayedCards()); }
private int CommerceScore(PlayerState p) { int score = 0; List <CommerceCard> comlist; //Commercial Structure comlist = new List <CommerceCard>(); //Cycle through played cards //Add all Commerce cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getType() == Card._MERCHANT) && (p.getPlayedCards()[i].getAct() == Card._CIVILIAN)) { comlist.Add((CommerceCard)p.getPlayedCards()[i]); } } for (int i = 0; i < comlist.Count; i++) { //Victorypoints per wonder if (comlist[i].getPerWonder() == 2) { score = score + p.getBoard().getCurrentWonderLevel(); } //Victorypoint per card if ((comlist[i].getCollect()[2] > 0)) { //crawl through all played cards of player for (int j = 0; j < p.getPlayedCards().Count; j++) { //if card type matches victorypoint condition of commercial card if (p.getPlayedCards()[j].getType() == comlist[i].getCollect()[0]) { //add points appropriate to commercial card parameters score = score + comlist[i].getCollect()[2]; System.Console.WriteLine(comlist[i].getCollect()[2]); } } } } return(score); }
//initial baseResources build up, SRCard initializer protected int[] ResourceInitializer(PlayerState p) { int[] rTotals = p.getBoard().getResources(); int[] tempResource = new int[7]; //Fill rTotals first, Wonder then Cards //Cards for (int i = 0; i < p.getPlayedCards().Count; i++) { //resource/manufactured good cards only if ((p.getPlayedCards()[i].getType() == 1) || (p.getPlayedCards()[i].getType() == 2)) { //remove optional resource cards from total if ((p.getPlayedCards()[i].getNumber() < 7) || (p.getPlayedCards()[i].getNumber() > 14)) { ResourceCard tempCard = (ResourceCard)p.getPlayedCards()[i]; System.Console.WriteLine("tempCard: " + tempCard.getResources()); addResources(rTotals,tempCard.getResources()); } } } return rTotals; }
private int ScienceScore(PlayerState p) { //System.Console.WriteLine("sciencescore start"); List<ScienceCard> scilist = new List<ScienceCard>(); //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == Card._SCIENCE) { scilist.Add((ScienceCard)p.getPlayedCards()[i]); } } //Cycle through science card list to add up sciencetype totals int[] sciTotals = new int[3] { 0, 0, 0 }; for (int i = 0; i < scilist.Count; i++) { //System.Console.WriteLine(scilist[i].getSciType()); sciTotals[scilist[i].getSciType()]++; } int score = 0; if (scienceguildCard == true) { if (sciTotals.Max() > 5) { sciTotals[Array.IndexOf(sciTotals, sciTotals.Max())]++; } else { sciTotals[Array.IndexOf(sciTotals, sciTotals.Min())]++; } } //Set points score = score + (sciTotals.Min() * 7); //System.Console.WriteLine("Min Score" + sciTotals.Min()); //Points for types //System.Console.WriteLine("Type 0" + sciTotals[0]); score = score + (sciTotals[0] * sciTotals[0]); //System.Console.WriteLine("Type 1" + sciTotals[1]); score = score + (sciTotals[1] * sciTotals[1]); //System.Console.WriteLine("Type 2" + sciTotals[2]); score = score + (sciTotals[2] * sciTotals[2]); System.Console.WriteLine(score); return score; }
/* * Input: A Player, a Card and a direction(0 = right, 1 = left) * * * Output: number of coins required to trade for resources for card with the player * at the given direction. negitive number if impossible */ public int validateTrade(PlayerState p, Card c, int direction) { int recCost = 2; int comCost = 2; //checkes to see if a player can play card with thier own resources if (ValidateCard(p, c)) { return(0); } PlayerState trader; if ((p.getBoard().getName().Equals("WB10") && (p.getBoard().getCurrentWonderLevel() >= 1))) { recCost = 1; } if (direction == 0) { trader = gameState.getRightPlayer(p); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 31) || (p.getPlayedCards()[i].getNumber() == 32)) { recCost = 1; break; } } } else { trader = gameState.getLeftPlayer(p); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 33) || (p.getPlayedCards()[i].getNumber() == 34)) { recCost = 1; break; } } } for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 35) || (p.getPlayedCards()[i].getNumber() == 36)) { comCost = 1; } } if (!baseResources.ContainsKey(trader.getName())) { return(-1); } int cost = 0; List <int> traderResources = baseResources[trader.getName()]; int[] requiredResources = new int[c.getCost().Length]; for (int i = 0; i < c.getCost().Length; i++) { requiredResources[i] = c.getCost()[i]; requiredResources[i] -= baseResources[p.getName()][i];//p.getResources()[i]; if (requiredResources[i] < 0) { requiredResources[i] = 0; } if (traderResources[i] < requiredResources[i]) { return(-1); } if (i < 4) { cost += requiredResources[i] * recCost; } else { cost += requiredResources[i] * comCost; } //Console.WriteLine("cost " + cost + " cur rec " + requiredResources[i]); } return(cost); }
private int GuildScore(PlayerState p, GameState g) { int score = 0; List <GuildCard> glist = new List <GuildCard>(); //GameState g = ; //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == Card._GUILD) { glist.Add((GuildCard)p.getPlayedCards()[i]); } } //Cycle through guild cards for (int i = 0; i < glist.Count; i++) { //worker if (glist[i].getNumber() == 98) { score = score + (2 * (g.getLeftPlayer(p).countCardType(2) + g.getRightPlayer(p).countCardType(2))); } //craft if (glist[i].getNumber() == 99) { score = score + (g.getLeftPlayer(p).countCardType(1) + g.getRightPlayer(p).countCardType(1)); } //trader if (glist[i].getNumber() == 100) { score = score + (g.getLeftPlayer(p).countCardType(4) + g.getRightPlayer(p).countCardType(4)); } //Philospher if (glist[i].getNumber() == 101) { score = score + (g.getLeftPlayer(p).countCardType(6) + g.getRightPlayer(p).countCardType(6)); } //Spies if (glist[i].getNumber() == 102) { score = score + (g.getLeftPlayer(p).countCardType(5) + g.getRightPlayer(p).countCardType(5)); } //strat if (glist[i].getNumber() == 103) { score = score + (g.getLeftPlayer(p).getNumLosses()) + (g.getRightPlayer(p).getNumLosses()); } //ship if (glist[i].getNumber() == 104) { score = score + (p.countCardType(1)) + (p.countCardType(2)) + (p.countCardType(7)); } //Science if (glist[i].getNumber() == 105) { scienceguildCard = true; } //magistrat if (glist[i].getNumber() == 106) { score = score + (g.getLeftPlayer(p).countCardType(3) + g.getRightPlayer(p).countCardType(3)); } //builders if (glist[i].getNumber() == 107) { score = score + (g.getRightPlayer(p).getBoard().getCurrentWonderLevel()); score = score + (g.getLeftPlayer(p).getBoard().getCurrentWonderLevel()); score = score + (p.getBoard().getCurrentWonderLevel()); } } return(score); }
public void resetSpecialResourceSingular(PlayerState p) { List<ResourceCard> tempList = new List<ResourceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() < 3) { ResourceCard c = (ResourceCard)p.getPlayedCards()[i]; if (((c.getNumber() > 7) && (c.getNumber() < 14))) { tempList.Add(c); } } } SResources[p.getName()] = tempList; }
public bool ValidateCard (PlayerState p, Card c) { //_logger.ValidatingCard(p, c); //_logger.CheckDictionary(p,hashtable); //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] < 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } // First check what the coin costs and total resource cost are if (c.getCoinCost() == 0 && c.getTotalResourceCost() == 0) { //_logger.print(p,"Card dosn't cost anything"); UpdateResources(p, c); return true; } // If the coin cost is not equal to 0 then does the player have enoguh coins ? if (c.getCoinCost() != 0 && c.getTotalResourceCost() == 0) { //_logger.CheckingCoins(p, c); if (c.getCoinCost() <= p.getCoins()) { UpdateResources(p, c); p.updateCoins(-c.getCoinCost()); // _logger.CheckingPlayersCoins(p); return true; } return false; } if (c.getTotalResourceCost() != 0) { //_logger.print(p,"Now we are working on the players Resources"); return CheckResourceCost(p,c); } return false; }
private int GuildScore(PlayerState p, GameState g) { int score = 0; List<GuildCard> glist = new List<GuildCard>(); //GameState g = ; //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == Card._GUILD) { glist.Add((GuildCard)p.getPlayedCards()[i]); } } //Cycle through guild cards for (int i = 0; i < glist.Count; i++) { //worker if (glist[i].getNumber() == 98) { score = score + (2 * (g.getLeftPlayer(p).countCardType(2) + g.getRightPlayer(p).countCardType(2)));} //craft if (glist[i].getNumber() == 99) { score = score + (g.getLeftPlayer(p).countCardType(1) + g.getRightPlayer(p).countCardType(1)); } //trader if (glist[i].getNumber() == 100) { score = score + (g.getLeftPlayer(p).countCardType(4) + g.getRightPlayer(p).countCardType(4)); } //Philospher if (glist[i].getNumber() == 101) { score = score + (g.getLeftPlayer(p).countCardType(6) + g.getRightPlayer(p).countCardType(6)); } //Spies if (glist[i].getNumber() == 102) { score = score + (g.getLeftPlayer(p).countCardType(5) + g.getRightPlayer(p).countCardType(5)); } //strat if (glist[i].getNumber() == 103) { score = score + (g.getLeftPlayer(p).getNumLosses()) + (g.getRightPlayer(p).getNumLosses());} //ship if (glist[i].getNumber() == 104) { score = score + (p.countCardType(1)) + (p.countCardType(2)) + (p.countCardType(7));} //Science if (glist[i].getNumber() == 105) { scienceguildCard = true; } //magistrat if (glist[i].getNumber() == 106) { score = score + (g.getLeftPlayer(p).countCardType(3) + g.getRightPlayer(p).countCardType(3)); } //builders if (glist[i].getNumber() == 107) { score = score + (g.getRightPlayer(p).getBoard().getCurrentWonderLevel()); score = score + (g.getLeftPlayer(p).getBoard().getCurrentWonderLevel()); score = score + (p.getBoard().getCurrentWonderLevel()); } } return score; }
private int comScore(PlayerState p) { int score = 0; List<CommerceCard> comlist; //Commercial Structure comlist = new List<CommerceCard>(); //Cycle through played cards //Add all Commerce cards to list for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getType() == 4) && (p.getPlayedCards()[i].getAct() == 3)) { comlist.Add((CommerceCard)p.getPlayedCards()[i]); } } for (int i = 0; i < comlist.Count; i++){ //Victorypoints per wonder if (comlist[i].getPerWonder() == 2) { score = score + p.getBoard().getCurrentWonderLevel(); } //Victorypoint per card if((comlist[i].getCollect()[2] > 0)){ //crawl through all played cards of player for (int j = 0; j < p.getPlayedCards().Count; j++) { //if card type matches victorypoint condition of commercial card if (p.getPlayedCards()[j].getType() == comlist[i].getCollect()[0]) { //add points appropriate to commercial card parameters score = score + comlist[i].getCollect()[2]; } } } } return score; //Guilds }
private int ScienceScore(PlayerState p) { //System.Console.WriteLine("sciencescore start"); List <ScienceCard> scilist = new List <ScienceCard>(); int[] sciTotals = new int[3] { 0, 0, 0 }; //Cycle through played cards for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == Card._SCIENCE) { scilist.Add((ScienceCard)p.getPlayedCards()[i]); } } //Cycle through science card list to add up sciencetype totals for (int i = 0; i < scilist.Count; i++) { //System.Console.WriteLine(scilist[i].getSciType()); sciTotals[scilist[i].getSciType()]++; } int score = 0; if (scienceguildCard == true) { if (sciTotals.Max() > 5) { sciTotals[Array.IndexOf(sciTotals, sciTotals.Max())]++; } else { sciTotals[Array.IndexOf(sciTotals, sciTotals.Min())]++; } } if (p.getBoard().getName() == "WB3") { if (((WB3)p.getBoard()).getScienceActivated()) { if (sciTotals.Max() > 5) { sciTotals[Array.IndexOf(sciTotals, sciTotals.Max())]++; } else { sciTotals[Array.IndexOf(sciTotals, sciTotals.Min())]++; } } } if (p.getBoard().getName() == "WB4") { if (((WB4)p.getBoard()).getScienceActivated()) { if (sciTotals.Max() > 5) { sciTotals[Array.IndexOf(sciTotals, sciTotals.Max())]++; } else { sciTotals[Array.IndexOf(sciTotals, sciTotals.Min())]++; } } } //Set points score = score + (sciTotals.Min() * 7); //System.Console.WriteLine("Min Score" + sciTotals.Min()); //Points for types //System.Console.WriteLine("Type 0" + sciTotals[0]); score = score + (sciTotals[0] * sciTotals[0]); //System.Console.WriteLine("Type 1" + sciTotals[1]); score = score + (sciTotals[1] * sciTotals[1]); //System.Console.WriteLine("Type 2" + sciTotals[2]); score = score + (sciTotals[2] * sciTotals[2]); System.Console.WriteLine(score); return(score); }
/* * Input: A Player, a Card and a direction(0 = right, 1 = left) * * * Output: number of coins required to trade for resources for card with the player * at the given direction. negitive number if impossible */ public int validateTrade(PlayerState p, Card c, int direction) { int recCost = 2; int comCost = 2; //checkes to see if a player can play card with thier own resources if (ValidateCard(p, c)) { return 0; } PlayerState trader; if ((p.getBoard().getName().Equals("WB10") && (p.getBoard().getCurrentWonderLevel() >= 1))) { recCost = 1; } if (direction == 0) { trader = gameState.getRightPlayer(p); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 31) || (p.getPlayedCards()[i].getNumber() == 32)) { recCost = 1; break; } } } else { trader = gameState.getLeftPlayer(p); for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 33) || (p.getPlayedCards()[i].getNumber() == 34)) { recCost = 1; break; } } } for (int i = 0; i < p.getPlayedCards().Count; i++) { if ((p.getPlayedCards()[i].getNumber() == 35) || (p.getPlayedCards()[i].getNumber() == 36)) { comCost = 1; } } if (!baseResources.ContainsKey(trader.getName())) { return -1; } int cost = 0; List<int> traderResources = baseResources[trader.getName()]; int[] requiredResources = new int[c.getCost().Length]; for (int i = 0; i < c.getCost().Length; i++) { requiredResources[i] = c.getCost()[i]; requiredResources[i] -= baseResources[p.getName()][i];//p.getResources()[i]; if (requiredResources[i] < 0) { requiredResources[i] = 0; } if (traderResources[i] < requiredResources[i]) { return -1; } if (i < 4) { cost += requiredResources[i] * recCost; } else { cost += requiredResources[i] * comCost; } Console.WriteLine("cost " + cost + " cur rec " + requiredResources[i]); } return cost; }
//Missing Code in this Function public void resetCommerceCards(PlayerState p) { List<CommerceCard> tempList = new List<CommerceCard>(); for (int i = 0; i < p.getPlayedCards().Count; i++) { if (p.getPlayedCards()[i].getType() == 4) { CommerceCard c = (CommerceCard)p.getPlayedCards()[i]; if (((c.getNumber() > 30) && (c.getNumber() < 37)) || ((c.getNumber() > 70) && (c.getNumber() < 77))) { tempList.Add(c); } } } ComCards[p.getName()] = tempList; }
//Actual Important Functions //Checks for precard within the player's hand private bool preCardCheck(PlayerState p, Card c) { //Get a list of preCards int[] preCard = c.getPreCard(); //Go through list of preCards for (int i = 0; i < preCard.Length; i++) { //Check if preCard Value is valid if (preCard[i] < 150) { //cycle through player's playedcards for (int j = 0; j < p.getPlayedCards().Count; j++) {//if the cards match then return true if (p.getPlayedCards()[j].getNumber() == preCard[i]) { return true; } } } } return false; }
/* * Input: A Player and a Card * * * Output: True or False -> Does the player have enough resources to play given card already? */ public bool ValidateCard (PlayerState p, Card c) { //_logger.ValidatingCard(p, c); //_logger.CheckDictionary(p,hashtable); //c.toString(); //Check for duplicity for (int i = 0; i < p.getPlayedCards().Count; i++) { if (c.getCardName() == p.getPlayedCards()[i].getCardName()) { if (p.getName().Equals("P0")) { System.Console.WriteLine("!Can't play card with the same name!"); } return false; } } //Check for precards if (preCardCheck(p, c)) { return true; } // First check what the coin costs and total resource cost are if (c.getCoinCost() == 0 && c.getTotalResourceCost() == 0) { //_logger.print(p,"Card dosn't cost anything"); UpdateResources(p, c); return true; } // If the coin cost is not equal to 0 then does the player have enoguh coins ? if (c.getCoinCost() != 0 && c.getTotalResourceCost() == 0) { //_logger.CheckingCoins(p, c); if (c.getCoinCost() <= p.getCoins()) { UpdateResources(p, c); p.updateCoins(-c.getCoinCost()); // _logger.CheckingPlayersCoins(p); return true; } return false; } if (c.getTotalResourceCost() != 0) { //_logger.print(p,"Now we are working on the players Resources"); return CheckResourceCost(p,c.getCost()); } return false; }