void PlayerCashCharge(ChargeCash charge) { var player = _context.GetPlayer(charge.PlayerChargedId); if (player.Cash >= charge.Amount) { player.Cash -= charge.Amount; _context.Add(new PrintCashCharge(charge)); if (charge.PlayerChargerId != null) { PlayerCashGive((int)charge.PlayerChargerId, charge.Amount); } } else { Debug.WriteLine($"{player.DisplayName} doesn't have enough money to pay, so now they've got a debt"); _context.Add(new PrintLine($"{player.DisplayName} doesn't have enough money to pay, so now they've got a debt", OutputStream.GameLog)); if (!EnoughPropertyToPayOff(player, charge.Amount)) { Debug.WriteLine($"{player.DisplayName} is bankrupt"); _context.Add(new PrintLine($"{player.DisplayName} is bankrupt", OutputStream.GameLog)); _context.Add(new AssetTransferRequest(charge.PlayerChargerId, player)); _context.Add(new PlayerBankrupt(player.Id)); } else { Debug.WriteLine($"{player.DisplayName} has enough property to pay off so now he has to do just that"); _context.Add(new PrintLine($"{player.DisplayName} has enough property to pay off so now he has to do just that", OutputStream.GameLog)); _context.Add(new PlayerDebt(player.Id, charge.Amount, charge.PlayerChargerId)); } } }
public PrintCashCharge(ChargeCash chargeCash) : this(chargeCash.Amount, chargeCash.PlayerChargedId, chargeCash.PlayerChargerId, chargeCash.Message) { }