コード例 #1
0
 /**
  * When a player makes a trade offer, it displays it and prompts
  * another player to accept or reject the offer.
  */
 private void MakeTradeOffer()
 {
     if (window.GetSelectedItem() != null)
     {
         ListViewItem lvi = window.GetSelectedItem();
         selectedItem = (Card)lvi.Tag;
         float offeredMoney = window.GetOfferedMoney();
         window.ShowTradeOffer(((Card)selectedItem).Name, offeredMoney,
                               propertyManager.WhoOwns(selectedItem));
         GameState = GameStage.TRADE_CONFIRM;
         if (propertyManager.WhoOwns(selectedItem) is AIPlayer)
         {
             window.SetTextBox("");
             Thread.Sleep(500);
             window.Update();
             if (AIDecider.TradeOfferDecide((Card)selectedItem, offeredMoney, propertyManager, (AIPlayer)propertyManager.WhoOwns(selectedItem)))
             {
                 window.SetTextBox("Your trade offer was accepted.");
                 Thread.Sleep(700);
                 propertyManager.ChangeOwner(currentPlayer,
                                             selectedItem, window.GetOfferedMoney());
             }
             else
             {
                 window.SetTextBox("Your trade offer was declined.");
                 Thread.Sleep(700);
             }
             ShowWhatNext(currentPlayer);
             return;
         }
     }
 }