public void PayDebt(Player player, int debtAmount) { if (debtAmount > Balance) { player.IncreaseBalance(Balance); DecreaseBalance(Balance); } else { DecreaseBalance(debtAmount); player.IncreaseBalance(debtAmount); } }
public void Simulate(Player activePlayer, List <Player> players) { var currentCard = _cards[_cardIndexPointer]; switch (currentCard) { case CommunityChestCards.Move_Advance_to_Go: activePlayer.MoveToPositionByName(Name.Go); break; case CommunityChestCards.Move_Go_back_to_Mediterranean_Avenue: activePlayer.MoveToPositionByName(Name.MediterraneanAvenue); break; case CommunityChestCards.Move_Go_to_jail_Move_directly_to_jail_Do_not_pass_Go_Do_not_collect_200: activePlayer.Imprison(); break; case CommunityChestCards.Tax_Fine_Pay_hospital_100: activePlayer.DecreaseBalance(100); break; case CommunityChestCards.Tax_Fine_Doctors_fee_Pay_50: activePlayer.DecreaseBalance(50); break; case CommunityChestCards.Tax_Fine_Pay_your_insurance_premium_50: activePlayer.DecreaseBalance(50); break; case CommunityChestCards.Receipt_Bank_error_in_your_favour_Collect_200: activePlayer.IncreaseBalance(200); break; case CommunityChestCards.Receipt_Annuity_matures_Collect_100: activePlayer.IncreaseBalance(100); break; case CommunityChestCards.Receipt_You_inherit_100: activePlayer.IncreaseBalance(100); break; case CommunityChestCards.Receipt_From_sale_of_stock_you_get_50: activePlayer.IncreaseBalance(50); break; case CommunityChestCards.Receipt_Receive_interest_on_7percent_preference_shares_25: activePlayer.IncreaseBalance(25); break; case CommunityChestCards.Receipt_Income_tax_refund_Collect_20: activePlayer.IncreaseBalance(20); break; case CommunityChestCards.Receipt_You_have_won_second_prize_in_a_beauty_contest_Collect_10: activePlayer.IncreaseBalance(10); break; case CommunityChestCards.Receipt_It_is_your_birthday_Collect_10_from_each_player: foreach (var player in players.Where(p => p.PlayerIsAlive && p.Id != activePlayer.Id)) { player.PayDebt(activePlayer, 10); } break; case CommunityChestCards.Other_Get_out_of_jail_free_This_card_may_be_kept_until_needed_or_sold: activePlayer.RecieveGetOutOfJailFreeCard(); break; case CommunityChestCards.Other_Pay_a_10_fine_or_take_a_Chance: activePlayer.DecreaseBalance(10); break; default: throw new ArgumentOutOfRangeException(); } MovePointer(); }
public void Simulate(Player activePlayer) { var currentCard = _cards[_cardIndexPointer]; switch (currentCard) { case ChanceCards.Movement_Advance_to_Go: activePlayer.MoveToPositionByName(Name.Go); break; case ChanceCards.Movement_Go_to_jail_Move_directly_to_jail_Do_not_pass_Go_Do_not_collect_200: activePlayer.Imprison(); break; case ChanceCards.Movement_Advance_to_St_Charles_Place_If_you_pass_Go_collection_200: activePlayer.MoveToPositionByName(Name.StCharlesPlace); break; case ChanceCards.Movement_Take_a_trip_to_Pennsylvania_Railroad_and_if_you_pass_Go_collect_200: activePlayer.MoveToPositionByName(Name.PennsylvaniaRailroad); break; case ChanceCards.Movement_Advance_to_IllnoisAvenue_If_you_pass_Go_collect_200: activePlayer.MoveToPositionByName(Name.IllnoisAvenue); break; case ChanceCards.Movement_Advance_to_Boardwalk: activePlayer.MoveToPositionByName(Name.Boardwalk); break; case ChanceCards.Movement_Go_back_three_spaces: activePlayer.MoveBackward(3); break; case ChanceCards.Taxes_Fines_Make_general_repairs_on_all_of_your_houses_For_each_house_pay_25_For_each_hotel_pay_100: var repairsOnHouses = activePlayer.NumberOfHousesBought() * 25; var repairsOnHotels = activePlayer.NumberOfHotelsBought() * 100; activePlayer.DecreaseBalance(repairsOnHouses + repairsOnHotels); break; case ChanceCards.Taxes_Fines_You_are_assessed_for_street_repairs_40_per_house_115_per_hotel: var streetRepairsOnHouses = activePlayer.NumberOfHousesBought() * 40; var streetRepairsOnHotels = activePlayer.NumberOfHotelsBought() * 115; activePlayer.DecreaseBalance(streetRepairsOnHouses + streetRepairsOnHotels); break; case ChanceCards.Taxes_Fines_Pay_school_fees_of_150: activePlayer.DecreaseBalance(150); break; case ChanceCards.Taxes_Fines_Drunk_in_charge_fine_20: activePlayer.DecreaseBalance(20); break; case ChanceCards.Taxes_Fines_Speeding_fine_15: activePlayer.DecreaseBalance(15); break; case ChanceCards.Receipts_Your_building_loan_matures_Receive_150: activePlayer.IncreaseBalance(150); break; case ChanceCards.Receipts_You_have_won_a_crossword_competition_Collect_100: activePlayer.IncreaseBalance(100); break; case ChanceCards.Receipts_Bank_pays_you_dividend_of_50: activePlayer.IncreaseBalance(50); break; case ChanceCards.Other_Get_out_of_jail_free_This_card_may_be_kept_until_needed_or_sold: activePlayer.RecieveGetOutOfJailFreeCard(); break; default: throw new ArgumentOutOfRangeException(); } MovePointer(); }