Ejemplo n.º 1
0
 public List<StockPurchase> GetSelectedStocks(Player player)
 {
     this.BeginInvoke(new Action<Player>(SelectingStocks), player);
     _toggle.WaitOne();
     _toggle.Reset();
     return _curReturnObject as List<StockPurchase>;
 }
Ejemplo n.º 2
0
 public StockSelectionDialog(Player player)
 {
     InitializeComponent();
     _player = player;
     _cash = player.Cash;
     InitPlayer();
     label1.Text = String.Format("${0}",_cash);
 }
Ejemplo n.º 3
0
 public static void SellStocksToPlayer(Player player, List<StockPurchase> list)
 {
     foreach (var p in list)
     {
         player.Cash -= p.Quantity * p.Hotel.CurrentStockValue;
         GiveStocksToPlayer(player, p.Hotel.Name, p.Quantity);
     }
 }
Ejemplo n.º 4
0
 public void PlayerReceivedCard(Player player, TileCard card, DidPlayerReceiveCard didPlayerReceiveCard)
 {
     if (didPlayerReceiveCard == DidPlayerReceiveCard.Received && card != null)
     {
         Log(string.Format("{0}: {1} received {2}", nameof(PlayerReceivedCard), player, card));
     }
     else
     {
         Log(string.Format("{0}: {1} did not take a card, reason - {2}", nameof(PlayerReceivedCard), player, didPlayerReceiveCard));
     }
 }
Ejemplo n.º 5
0
 public StockDecision(Player player, Hotel mergingHotel, Hotel mergerHotel, int keeping, int exchanging, int selling)
 {
     Player = player;
     MergingHotel = mergingHotel;
     MergerHotel = mergerHotel;
     TotalStocks = player.StockBank.NameStocksDictionary[mergingHotel.Name].Quantity;
     Keeping = keeping;
     Exchanging = exchanging;
     Selling = selling;
     Debug.Assert(this.Correct());
 }
Ejemplo n.º 6
0
 public void CanPlayerBuyStocks(Player player, IsPlayerAbleToBuyStocks isPlayerAbleToBuyStocks)
 {
     Log(string.Format("{0}: {1} - {2}", nameof(CanPlayerBuyStocks), player, isPlayerAbleToBuyStocks));
 }
Ejemplo n.º 7
0
 public StockDecision GetStockDecision(Player player, Hotel mergingHotel, Hotel mergerHotel)
 {
     return new StockDecision(player, mergingHotel, mergerHotel, player.StockBank.NameStocksDictionary[mergingHotel.Name].Quantity, 0, 0);
 }
Ejemplo n.º 8
0
 void SelectingStocks(Player player)
 {
     _curReturnObject = new List<StockPurchase>();
     var stocksDialog = new StockSelectionDialog(player);//.ShowDialog();
     stocksDialog.OK_Clicked += stocksDialog_OK_Clicked;
     stocksDialog.ShowDialog();
     _toggle.Set();
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Putting a tile card on board, by removing the card from the player's bank, 
 /// and calling the BoardManager to handle the effect the card has on the board.  
 /// </summary>
 /// <param name="player">The player who puts the tile card.</param>
 /// <param name="card">The tile card being put.</param>
 /// <param name="effect">Which effect the tile card has on the board.</param>
 /// <param name="involvedHotel">The main hotel that is being affected by putting the tile card:
 /// In case of enlarging an hotel, the involved hotel is the hotel being enlarged. In case of setting up a new hotel, the involved hotel
 /// is the hotel the player decided to setup. In case of a merge effect, the involved hotel is the main hotel that swallows all his neighbor hotels.</param>
 private static void PutCardOnBoard(Player player, TileCard card, TileCardEffect effect, Hotel involvedHotel)
 {
     player.TileCardBank.Remove(card);
     Output.PlayerPutsCard(player, card, effect, involvedHotel);
     BoardManager.HandleEffect(card, effect, involvedHotel);
 }
Ejemplo n.º 10
0
 public void PlayerStockDecision(Player player, StockDecision decision)
 {
 }
Ejemplo n.º 11
0
 public static void GiveStocksToPlayer(Player player, string stockName, int quantity)
 {
     HotelsManager.StockBank.Remove(stockName, quantity);
     player.StockBank.Add(stockName, quantity);
 }
Ejemplo n.º 12
0
 public static void BuyStocksFromPlayer(Player player, Hotel hotel, int quantity)
 {
     TakeStocksFromPlayer(player, hotel.Name, quantity);
     player.Cash += hotel.CurrentStockValue * quantity;
 }
Ejemplo n.º 13
0
 private static void GivePrize(Player player, int prize, bool firstPrize)
 {
     player.Cash += prize;
 }
Ejemplo n.º 14
0
 private static void ExchangeStocks(Player player, Hotel mergingHotel, Hotel mergerHotel, int mergingHotelStocksExchangedNumber)
 {
     Debug.Assert(mergingHotelStocksExchangedNumber % 2 == 0);
     TakeStocksFromPlayer(player, mergingHotel.Name, mergingHotelStocksExchangedNumber);
     GiveStocksToPlayer(player, mergerHotel.Name, mergingHotelStocksExchangedNumber / 2);
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Gets the player whose turn it is after a certain player.
 /// </summary>
 /// <param name="player">The player to check.</param>
 /// <returns>The player who plays after the given player.</returns>
 public static Player GetNextPlayer(Player player)
 {
     int index = Players.IndexOf(player);
     var nextPlayer = index != Players.Count - 1 ? Players[index + 1] : Players[0];
     return nextPlayer;
 }
Ejemplo n.º 16
0
 public void ClosestToA1(Player closestToA1)
 {
     Log(string.Format("{0}: {1}", nameof(ClosestToA1), closestToA1));
 }
Ejemplo n.º 17
0
 public void PlayerPutsCard(Player player, TileCard card, TileCardEffect effect, Hotel involvedHotel)
 {
     Log(string.Format("{0}: {1} puts {2}", nameof(PlayerPutsCard), player, card));
 }
Ejemplo n.º 18
0
 public static void TakeStocksFromPlayer(Player player, string stockName, int quantity)
 {
     player.StockBank.Remove(stockName, quantity);
     HotelsManager.StockBank.Add(stockName, quantity);
 }
Ejemplo n.º 19
0
 public void PlayerSetsUpHotel(Player player, Hotel setUpHotel)
 {
     Log(string.Format("{0}: {1} sets up {2}", nameof(PlayerSetsUpHotel), player, setUpHotel));
 }
Ejemplo n.º 20
0
 /// <summary>
 /// Replaces an illegal tile card given by a player with a card from the TileCardBank, if there are still cards left.
 /// This method assumes that the tile card it receives is indeed illegal. 
 /// </summary>
 /// <param name="player">The player who wants to replace his illegal card.</param>
 /// <param name="card">The illegal card to replace.</param>
 public static void ReplaceCard(Player player, TileCard card)
 {
     GameManager.Output.ReplaceCard(player, card);
     player.TileCardBank.Remove(card);
     GiveCards(player, 1);
 }
Ejemplo n.º 21
0
 public void ReplaceCard(Player player, TileCard card)
 {
 }
Ejemplo n.º 22
0
 /// <summary>
 /// Gives certain amount of tile cards to a player, if there are still cards left in TileCardBank.
 /// </summary>
 /// <param name="player">The player to give the tile cards to.</param>
 /// <param name="quantity">How many tile cards to give to the player (If the amount exists in the TileCardBank).</param>
 public static void GiveCards(Player player, int quantity)
 {
     for (var i = 0; i < quantity; i++)
     {
         TileCard card;
         if (TileCardBank.Count > 0)
         {
             card = TileCardBank.First();
             TileCardBank.Remove(card);
             player.TileCardBank.Add(card);
             GameManager.Output.PlayerReceivedCard(player, card, DidPlayerReceiveCard.Received);
         }
         else
         {
             GameManager.Output.PlayerReceivedCard(player, null, DidPlayerReceiveCard.BankIsEmpty);
             return;
         }
     }
 }