コード例 #1
0
 private void ShowActions(Player player, BoardSpace space)
 {
     if (space is Property prop)
     {
         var options = new List <string>();
         var action  = PromptMemberOf($"Enter action for {prop.Name}", new List <string>
         {
             "None",
             "Buy a house"
         });
         if (action == "Buy a house")
         {
             if (prop.CanAddHouse())
             {
                 player.Charge(prop.HouseCost);
                 player.NumHouses++;
                 prop.NumHouses++;
             }
             else
             {
                 Console.WriteLine("Can't add a house!");
             }
         }
     }
 }
コード例 #2
0
        public bool CheckPlayerBuy(Player player, BoardSpace property, decimal cost)
        {
            if (player.Auto)
            {
                return(cost < player.Money);
            }
            var shouldBuy = PromptBool($"Does {player} ({player.Money:C}) want to buy property {property.Name} {cost:C}? (true / false)\n");

            if (shouldBuy)
            {
                var props = player.OwnedProperties.Count == 0 ? "no" : string.Join(", ", player.OwnedProperties.Select(p => p.Name));
                Console.WriteLine($"{player} bought {property.Name}. Now has {player.Money - cost:C} and owns {props}");
            }
            return(shouldBuy);
        }
コード例 #3
0
 internal void AddProperty(BoardSpace space)
 {
     ownedProperties.Add(space);
 }
コード例 #4
0
 public void ShowPlayerPaidRent(Player player, Player owner, BoardSpace space, decimal amount)
 {
     Console.WriteLine($"{player} gave {space.Name} owner {owner} {amount:C}!");
 }
コード例 #5
0
 public void ShowPlayerLanded(Player player, BoardSpace space)
 {
     Console.WriteLine($"{player} moved by {player.LastSpacesMoved}: landed on {space.Name}!");
 }