/// <summary>
        /// Lets players attempt to add houses/hotels onto their properties
        /// </summary>
        /// <param name="p">Player Callee</param>t
        /// <param name="tile">Tile that the player wishes to upgrade</param>
        /// <returns></returns>
        public bool buyAssets(Player p, Game_Tile_Safe tile)
        {
            Game_Tile_Safe t = new Game_Tile_Safe(board[tile.index]);

            if (t.associatedProperties.Count != 0)
            {
                for (int i = 0; i < t.associatedProperties.Count; i++)
                {
                    if (tileOwners[t.associatedProperties[i]] != p)
                    {
                        return(false);
                    }
                }
            }
            else
            {
                return(false);
            }

            if (tileOwners[t.index] == p && playersMoney[p.index] >= t.assetPrice && t.assets < 5)
            {
                //check to make sure other properties dont differ by more than 1
                for (int i = 0; i < board[t.index].associatedProperties.Count; i++)
                {
                    if (Math.Abs(board[t.index].assets - board[board[t.index].associatedProperties[i]].assets) > 1)
                    {
                        return(false);
                    }
                }

                if (t.assets == 4)
                {
                    if (numHotels == 0)
                    {
                        return(false);
                    }
                    numHouses += 4;
                    numHotels -= 1;
                }
                else
                {
                    if (numHouses == 0)
                    {
                        return(false);
                    }
                    numHouses--;
                }
                payPlayer(p, -t.assetPrice);
                if (t.assets < 5)
                {
                    board[t.index].assets++;
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 2
0
        public override void MyTurn()
        {
            //Console.WriteLine("My Balance: ${0}", banker.balanceInquiry(this));
            //Console.WriteLine("My Properties:");
            foreach (Game_Tile_Safe prop in banker.getPropertiesOwned(this))
            {
                Game_Tile_Safe property = banker.getPropertyInfo(prop.index);
                if (banker.buyAssets(this, prop))
                {
                    //Console.WriteLine("Asset purchased on: {0}", property.name);
                }

                //Console.WriteLine("Name: {0}  Color: {1} NumAssets: {2}", property.name, property.color, property.assets);
            }
            //int[] otherPlayers = banker.getPlayerList(this);
            //foreach (int i in otherPlayers)
            //{
            //    Console.WriteLine("Player {0} Balance: {1}", i, banker.playerMoneyLookup(i));
            //    Console.WriteLine("Player {0} Properties:", i);
            //    foreach (Game_Tile_Safe prop in banker.getPlayerPropertyInfo(i))
            //    {
            //        Game_Tile_Safe property = banker.getPropertyInfo(prop.index);
            //        Console.WriteLine("Name: {0}  Color: {1} NumAssets: {2}", property.name, property.color, property.assets);
            //    }
            //}



            if (banker.canBuy(this) && banker.balanceInquiry(this) > 200)
            {
                banker.buyProperty(this);
            }



            //Console.ReadLine();
            //banker.tradeProperty(this, this.banker.getPropertyInfo(1));
        }
Esempio n. 3
0
 /// <summary>
 /// This method is called if another player would like to trade a property
 /// The property being traded will be passed as a game_tile_safe for informational purposes
 /// </summary>
 /// <param name="t"></param>
 /// <returns>return a valid amount of money, return -1 if not interested</returns>
 public virtual int TradeMoney(Game_Tile_Safe t)
 {
     return(-1);
 }
Esempio n. 4
0
        /// <summary>
        /// This method is called if another player would like to trade a property
        /// The property being traded will be passed as a game_tile_safe for informational purposes
        /// </summary>
        /// <param name="t"></param>
        /// <returns>return the ID of a tile owned by the tradee, return -1 if not interested</returns>
        public virtual List <Game_Tile_Safe> TradeProperty(Game_Tile_Safe t)
        {
            List <Game_Tile_Safe> propertOffers = new List <Game_Tile_Safe>();

            return(propertOffers);
        }
 /// <summary>
 /// Allows players to trade a property they own.
 /// </summary>
 /// <param name="p"></param>
 /// <param name="t">Property to trade</param>
 public void tradeProperty(Player p, Game_Tile_Safe t)
 {
     if (p == tileOwners[t.index])
     {
         List <int> playerTraders = new List <int>();
         List <int> moneyOffers   = new List <int>();
         List <List <Game_Tile_Safe> > propertyOffers = new List <List <Game_Tile_Safe> >();
         if (tileOwners[t.index] == p)
         {
             for (int i = 0; i < players.Count; i++)
             {
                 if (players[i] != p && deadPlayers[i] != true)
                 {
                     playerTraders.Add(i);
                     propertyOffers.Add(players[i].TradeProperty(t));
                     moneyOffers.Add(players[i].TradeMoney(t));
                 }
             }
         }
         else
         {
             return;
         }
         //GOTTA CHECK THOSE OFFERS TO MAKE SURE THEY ARE VALID
         for (int i = 0; i < playerTraders.Count; i++)
         {
             //check moneys
             if (playersMoney[playerTraders[i]] < moneyOffers[i])
             {
                 moneyOffers[i] = -1;
             }
             //check properties
             for (int j = 0; j < propertyOffers[i].Count; j++)
             {
                 if (tileOwners[propertyOffers[i][j].index] != players[playerTraders[i]])
                 {
                     propertyOffers[i].RemoveAt(j);
                 }
             }
         }
         int playerNumber    = -1;
         int moneyORproperty = -1;
         p.receiveOffer(new List <int>(playerTraders), new List <int>(moneyOffers), new List <List <Game_Tile_Safe> >(propertyOffers), out playerNumber, out moneyORproperty);
         if (playerNumber != -1 && moneyORproperty != -1)
         {
             if (moneyORproperty == 0) //If the player accepted the money
             {
                 if (playersMoney[playerNumber] >= moneyOffers[playerNumber])
                 {
                     payPlayer(p, moneyOffers[playerNumber]);
                     payPlayer(players[playerNumber], -moneyOffers[playerNumber]);
                     tileOwners[t.index] = players[playerNumber];
                 }
             }
             if (moneyORproperty == 1) //If the player accepted the property
             {
                 tileOwners[t.index] = players[playerNumber];
                 for (int i = 0; i < propertyOffers[playerNumber].Count; i++)
                 {
                     tileOwners[propertyOffers[playerNumber][i].index] = p;
                 }
             }
         }
     }
 }
Esempio n. 6
0
        public override List <Game_Tile_Safe> TradeProperty(Game_Tile_Safe t)
        {
            List <Game_Tile_Safe> propertOffers = new List <Game_Tile_Safe>();

            return(propertOffers);
        }
Esempio n. 7
0
 public override int TradeMoney(Game_Tile_Safe t)
 {
     return(1);
 }