/*
         * 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);
        }
Example #2
0
 public void CheckingCoins(PlayerState p, Card c)
 {
     if (Log(p))
     {
         Console.WriteLine("[{0}] Checking to see if we have enough coins: Cost {1} Has {2}"
                           , _class.GetType().Name
                           , c.getCoinCost()
                           , p.getCoins());
     }
 }
Example #3
0
 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("=============================================================================================================");
     }
 }
        //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;
        }
Example #5
0
 public void CheckingCoins(PlayerState p, Card c)
 {
     if (Log(p))
         Console.WriteLine("[{0}] Checking to see if we have enough coins: Cost {1} Has {2}"
                          , _class.GetType().Name
                          , c.getCoinCost()
                          , p.getCoins());
 }
Example #6
0
 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;
        }
Example #8
0
        /*
        * 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;
        }