/* * 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); }
public void ValidatingCard(PlayerState p, Card c) { if (Log(p)) { System.Console.WriteLine("\n\n============================================================================================================="); System.Console.WriteLine("{0}:: \nValidateCard( Player [{1}] Card [{2}] Coin Cost [{3}] Resource Cost [{4}])" , _class.GetType().Name , p.getName() , c.getName() , c.getCoinCost() , c.getTotalResourceCost()); System.Console.WriteLine("============================================================================================================="); } }
public void CheckCommerceCard(PlayerState p, Card c) { if (Log(p)) { Console.WriteLine("\n--------------------------------------------------------------------------------------------------------"); CommerceCard card = (CommerceCard)c; int totalResourceCost = c.getTotalResourceCost(); int[] costs = card.getCost(); int[] collect = card.getCollect(); int[] resourceTradable = card.getResourceTradable(); Console.WriteLine("[{0}] Commerce Card [{1}] Total Resource Cost [{2}]", _class.GetType().Name , c.getName() , totalResourceCost); var resources = Enum.GetValues(typeof(Resource)); // Get the cost and display it Console.WriteLine("[Card.getCost() ] "); foreach (var resource in resources) { int index = (int)resource; Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), costs[index]); } Console.WriteLine(); //0 = none, 1 = resource card, 2 = manufactured good int resourceType = card.getResources(); Console.WriteLine("[Card.getCollect()] RT [{0}] ] ", resourceType); // resources = Enum.GetValues(typeof(Resource)); for (int index = 0; index < collect.Count(); index++) { Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), collect[index]); } Console.WriteLine(); // resources = Enum.GetValues(typeof(Resource)); // Console.WriteLine("[Card.getResourceTradable ({0})] ", card.hasTradableResources()); for (int index = 0; index < resourceTradable.Count(); index++) { Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), resourceTradable[index]); } Console.WriteLine(); Console.WriteLine("--------------------------------------------------------------------------------------------------------\n"); } }
//Initial call to check for card validity public bool ValidateCard (PlayerState p, Card c) { //_logger.ValidatingCard(p, c); //_logger.CheckDictionary(p,hashtable); //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; }
public void CheckCommerceCard(PlayerState p, Card c) { if (Log(p)) { Console.WriteLine("\n--------------------------------------------------------------------------------------------------------"); CommerceCard card = (CommerceCard)c; int totalResourceCost = c.getTotalResourceCost(); int[] costs = card.getCost(); int[] collect = card.getCollect(); int[] resourceTradable = card.getResourceTradable(); Console.WriteLine("[{0}] Commerce Card [{1}] Total Resource Cost [{2}]", _class.GetType().Name , c.getName() , totalResourceCost); var resources = Enum.GetValues(typeof(Resource)); // Get the cost and display it Console.WriteLine("[Card.getCost() ] "); foreach (var resource in resources) { int index = (int)resource; Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), costs[index]); } Console.WriteLine(); //0 = none, 1 = resource card, 2 = manufactured good int resourceType = card.getResources(); Console.WriteLine("[Card.getCollect()] RT [{0}] ] ", resourceType); // resources = Enum.GetValues(typeof(Resource)); for (int index = 0; index < collect.Count(); index++) { Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), collect[index]); } Console.WriteLine(); // resources = Enum.GetValues(typeof(Resource)); // Console.WriteLine("[Card.getResourceTradable ({0})] ", card.hasTradableResources()); for (int index = 0; index < resourceTradable.Count(); index++) { Console.Write("[{0} : {1}] ", ((Resource)index).ToString(), resourceTradable[index]); } Console.WriteLine(); Console.WriteLine("--------------------------------------------------------------------------------------------------------\n"); } }
public void ValidatingCard(PlayerState p, Card c) { if (Log(p)) { System.Console.WriteLine("\n\n============================================================================================================="); System.Console.WriteLine("{0}:: \nValidateCard( Player [{1}] Card [{2}] Coin Cost [{3}] Resource Cost [{4}])" , _class.GetType().Name , p.getName() , c.getName() , c.getCoinCost() , c.getTotalResourceCost()); System.Console.WriteLine("============================================================================================================="); } }
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; }
/* * 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; }