private Button hotelToButton(StockCard.Type hotel)
        {
            switch (hotel)
            {
                case StockCard.Type.American:
                    return (Button)hotelChainGroupbox.Controls["americaButton"];

                case StockCard.Type.Fusion:
                    return (Button)hotelChainGroupbox.Controls["fusionButton"];

                case StockCard.Type.Hydra:
                    return (Button)hotelChainGroupbox.Controls["hydraButton"];

                case StockCard.Type.Phoenix:
                    return (Button)hotelChainGroupbox.Controls["phoenixButton"];

                case StockCard.Type.Quantum:
                    return (Button)hotelChainGroupbox.Controls["quantumButton"];

                case StockCard.Type.Sackson:
                    return (Button)hotelChainGroupbox.Controls["sacksonButton"];

                case StockCard.Type.Zeta:
                    return (Button)hotelChainGroupbox.Controls["zetaButton"];

                default:
                    return null;
            }
        }
Example #2
0
        public int getHotelChainLength(StockCard.Type type)
        {
            int toReturn = 0;

            foreach (Tile t in Tiles)
            {
                if (t.Hotel == type)
                {
                    toReturn++;
                }
            }
            return toReturn;
        }
        public PostMergerChoice(Player p, StockCard.Type overtakingHotel, StockCard.Type overtakenHotel)
        {
            InitializeComponent();
            player = p;
            overtaken = overtakenHotel;
            overtaking = overtakingHotel;

            //set up additional UI based on the player
            questionLabel.Text = p.Name + Constants.PostMergerChoiceUILabel;
            mergeLabel.Text = overtaking.ToString() + " has acquired " + overtaken.ToString() + ".";
            sell1Button.Text = "Sell one (1) " + overtaken.ToString() + " stock for $" +
                StockCard.getStockValue(overtaken, gm.Board.getHotelChainLength(overtaken)) + ".";
            sellAllButton.Text = "Sell all for $" + p.numStock(overtaken) * StockCard.getStockValue(overtaken, gm.Board.getHotelChainLength(overtaken)) + ".";
            trade2Button.Text = "Trade two (2) " + overtaken.ToString() + " stock for one (1) " + overtaking.ToString() + " stock.";
            updateUI();

            // add event listeners to the buttons
            sell1Button.Click += new EventHandler(sell1Button_Click);
            sellAllButton.Click += new EventHandler(sellAllButton_Click);
            trade2Button.Click += new EventHandler(trade2Button_Click);
        }
Example #4
0
        private ArrayList sortPlayersbyStock(StockCard.Type stock)
        {
            // uses a quicksort alogirthm
            ArrayList toReturn = new ArrayList();
            int[] keys = new int[Players.Count];
            Player[] values = new Player[Players.Count];

            int i = 0;
            foreach (Player p in Players.Values)
            {
                keys[i] = p.numStock(stock);
                values[i] = p;
                i++;
            }

            //sort arrays
            Array.Sort(keys, values);
            Array.Reverse(values);

            for (i = 0; i < Players.Count; i++)
            {
                toReturn.Add(values[i]);
            }

            return toReturn;
        }
Example #5
0
        private void recursiveSetHotel(Tile t, StockCard.Type hotel, ArrayList calledTiles)
        {
            if (calledTiles != null)
            { calledTiles.Add(t); }
            else { calledTiles = new ArrayList(); }

            ArrayList BorderingTiles = Board.GetNeighborsforTile(t);
            ArrayList toCall = new ArrayList();
            foreach (Tile borderingTile in BorderingTiles)
            {
                if (!calledTiles.Contains(borderingTile))
                {
                    toCall.Add(borderingTile);
                }
            }

            foreach (Tile tile in toCall)
            {
                recursiveSetHotel(tile, hotel, calledTiles);
            }

            t.Hotel = hotel;
        }
Example #6
0
 private int getRemainingStock(StockCard.Type stock)
 {
     int toReturn = 25;
     foreach (Player p in Players.Values)
     {
         toReturn -= p.numStock(stock);
     }
     return toReturn;
 }
Example #7
0
        private ArrayList getMinorityHolders(StockCard.Type hotel)
        {
            ArrayList toReturn = new ArrayList();
            ArrayList majorityHolders = getMajorityHolders(hotel);
            ArrayList sortedPlayers = sortPlayersbyStock(hotel);

            // do a quick check to see if there was more than one majority - in that case,
            // no minority players get bonuses
            if (majorityHolders.Count > 1)
                return new ArrayList();

            // there's only one majority holder, so he should be on the top of the sorted list
            sortedPlayers.RemoveAt(0);

            // now we have remaining sorted players, so get the player
            // from the top and call him minority holder

            Player minority = (Player)sortedPlayers[0];
            toReturn.Add(minority);

            foreach (Player nextPlayer in sortedPlayers)
            {
                if (nextPlayer != sortedPlayers[0])
                {
                    if (nextPlayer.numStock(hotel) == minority.numStock(hotel))
                    {
                        toReturn.Add(nextPlayer);
                    }
                    else
                    {
                        // we've found all the minority players, return immediately
                        return toReturn;
                    }
                }
            }

            return toReturn;
        }
Example #8
0
        private ArrayList getMajorityHolders(StockCard.Type hotel)
        {
            ArrayList toReturn = new ArrayList();

            Player majority = Players[(string)PlayerOrder[0]];

            foreach (Player nextPlayer in Players.Values)
            {
                if (nextPlayer != Players[(string)PlayerOrder[0]])
                {
                    if (nextPlayer.numStock(hotel) > majority.numStock(hotel))
                    {
                        majority = nextPlayer;
                    }
                }
            }

            // now see if there are multiple players with the same majority of stock
            foreach (Player p in Players.Values)
            {
                if (p.numStock(hotel) == majority.numStock(hotel))
                {
                    toReturn.Add(p);
                }
            }

            return toReturn;
        }
Example #9
0
 internal int stockLeft(StockCard.Type t)
 {
     int toReturn = 25;
     foreach (Player p in Players.Values)
     {
         toReturn -= p.numStock(t);
     }
     return toReturn;
 }
Example #10
0
        internal void takeStock(int num, StockCard.Type type)
        {
            Stock[type] -= num;

            if (Stock[type] < 0)
            {
                throw new Exception("Removed more stock than the player has.");
            }
        }
Example #11
0
 public int numStock(StockCard.Type type)
 {
     return Stock[type];
 }
Example #12
0
 public void giveStock(int num, StockCard.Type type)
 {
     if (Stock.ContainsKey(type))
     {
         Stock[type] += num;
     }
     else
     {
         Stock.Add(type, num);
     }
 }
Example #13
0
 internal bool isHotelSafe(StockCard.Type hotel)
 {
     if (getHotelChainLength(hotel) >= 11)
     {
         return true;
     }
     else
     {
         return false;
     }
 }