コード例 #1
0
ファイル: PlaceWithEvent.cs プロジェクト: halfdb/MyMonopoly
 public override void Trigger(Player player)
 {
     PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
     string[] choices = { "Welcom to the bank! How can I help you?", "1.Deposit", "2.Withdraw", "3.Leave" };
     int choice = player.Choose(choices);
     while (choice != 3)
     {
         switch (choice)
         {
             case 1:
                 if (player.Deposit(player.InputInt("How much?")))
                 {
                     player.Inform("Done!");
                 }
                 else
                 {
                     player.Inform("Failed!");
                 }
                 break;
             case 2:
                 if (player.Withdraw(player.InputInt("How much?")))
                 {
                     player.Inform("Done!");
                 }
                 else
                 {
                     player.Inform("Failed!");
                 }
                 break;
             default:
                 throw new Exception();
         }
         choice = player.Choose(choices);
     }
 }
コード例 #2
0
 public override void Trigger(Player player)
 {
     PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
     if (player.Confirm("I want to play a game..."))
     {
         int invest = player.InputInt("How much do you want to bet?");
         player.SpendCash(invest);
         int revenue = Calculate(invest);
         player.AddCash(revenue);
         if (invest >= revenue)
         {
             player.Inform("Poor guy...");
             ResultEvent(player, new CasinoEventArgs(false));
         }
         else
         {
             player.Inform("Lucky you...");
             ResultEvent(player, new CasinoEventArgs(true));
         }
     }
 }
コード例 #3
0
 //methods
 public override void Trigger(Player player)
 {
     PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
     if (Owner == null)
     {
         if (player.Cash >= Price)
         {
             if (player.Confirm("Would you like to buy the estate? Price: " + Price))
             {
                 player.BuyEstate(this);
             }
         }
         else
         {
             player.Inform("Sorry, but you cannot afford this estate. Price: " + Price);
         }
     }
     else if (Owner == player)
     {
         if (player.Cash >= Price && Level != 6)
         {
             if (player.Confirm("Would you like to upgrade the estate? Price: " + Price))
             {
                 Upgrade(player);
             }
         }
         else if (Level == 6)
         {
             player.Inform("The estate is fully upgraded!");
         }
         else
         {
             player.Inform("Sorry, but you cannot afford upgrading this estate. Price: " + Price);
         }
     }
     else
     {
         player.PayRent();
     }
 }
コード例 #4
0
        public override void Trigger(Player player)
        {
            PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
            string[] choices = { "Welcom to the bank! How can I help you?", "1.Deposit", "2.Withdraw", "3.Leave" };
            int      choice  = player.Choose(choices);

            while (choice != 3)
            {
                switch (choice)
                {
                case 1:
                    if (player.Deposit(player.InputInt("How much?")))
                    {
                        player.Inform("Done!");
                    }
                    else
                    {
                        player.Inform("Failed!");
                    }
                    break;

                case 2:
                    if (player.Withdraw(player.InputInt("How much?")))
                    {
                        player.Inform("Done!");
                    }
                    else
                    {
                        player.Inform("Failed!");
                    }
                    break;

                default:
                    throw new Exception();
                }
                choice = player.Choose(choices);
            }
        }
コード例 #5
0
 protected virtual void Upgrade(Player player)
 {
     if (player != Owner)
     {
         return;
     }
     if (Level < 6)
     {
         if (player.SpendCash(Price))
         {
             UpgradeEvent(this);
             ++Level;
             player.Inform("Congratulations! You have upgraded this estate!");
         }
     }
 }
コード例 #6
0
ファイル: Places.cs プロジェクト: halfdb/MyMonopoly
 public override void Trigger(Player player)
 {
     player.Inform("Here is empty, have a rest.");
 }
コード例 #7
0
ファイル: PlaceWithEvent.cs プロジェクト: halfdb/MyMonopoly
 public override void Trigger(Player player)
 {
     PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
     if (player.Confirm("I want to play a game..."))
     {
         int invest = player.InputInt("How much do you want to bet?");
         player.SpendCash(invest);
         int revenue = Calculate(invest);
         player.AddCash(revenue);
         if (invest >= revenue)
         {
             player.Inform("Poor guy...");
             ResultEvent(player,new CasinoEventArgs(false));
         }
         else
         {
             player.Inform("Lucky you...");
             ResultEvent(player,new CasinoEventArgs(true));
         }
     }
 }
コード例 #8
0
ファイル: PlaceWithEvent.cs プロジェクト: halfdb/MyMonopoly
 protected virtual void Upgrade(Player player)
 {
     if (player != Owner)
     {
         return;
     }
     if (Level < 6)
     {
         if (player.SpendCash(Price))
         {
             UpgradeEvent(this);
             ++Level;
             player.Inform("Congratulations! You have upgraded this estate!");
         }
     }
 }
コード例 #9
0
ファイル: PlaceWithEvent.cs プロジェクト: halfdb/MyMonopoly
 //methods
 public override void Trigger(Player player)
 {
     PlayerArrivedEvent(this, new PlayerArrivedEventArgs(player));
     if (Owner == null)
     {
         if (player.Cash >= Price)
         {
             if (player.Confirm("Would you like to buy the estate? Price: " + Price))
             {
                 player.BuyEstate(this);
             }
         }
         else
         {
             player.Inform("Sorry, but you cannot afford this estate. Price: " + Price);
         }
     }
     else if (Owner == player)
     {
         if (player.Cash >= Price && Level != 6)
         {
             if (player.Confirm("Would you like to upgrade the estate? Price: " + Price))
             {
                 Upgrade(player);
             }
         }
         else if (Level == 6)
         {
             player.Inform("The estate is fully upgraded!");
         }
         else
         {
             player.Inform("Sorry, but you cannot afford upgrading this estate. Price: " + Price);
         }
     }
     else
     {
         player.PayRent();
     }
 }