public override (IAction, bool) Interact(ICommand another, IReadOnlyList <State.Player> players, State.IProvinces provinces) { if (another is Commands.Reinforce reinf && Army.IsControlledBy(reinf.Player) && reinf.To.Id == Province) { return(new Reinforcement(Province, Army.Join(reinf.Army)), false); } if (another is Commands.Recruit recr && Army.IsControlledBy(recr.Player) && recr.Land == Province) { return(new Reinforcement(Province, Army.Join(recr.Army)), false); } return(this, true); }
public override (IAction, bool) Interact(ICommand another, IReadOnlyList <State.Player> players, State.IProvinces provinces) { if (another is Commands.Attack attack && Army.IsControlledBy(attack.Player) && attack.To.Id == Province) { return(new Battle(Province, Army.Join(attack.Army)), false); } if (another is Commands.Purchase purchase && Army.IsControlledBy(purchase.Player.Id) && purchase.Land == Province) { return(new Reinforcement(Province, Army), true); } return(this, true); }
public (IAction[], State.Player) Perform(State.Player player, State.Player active, State.IProvinces provinces) { return(player.Id == Player ? (System.Array.Empty <IAction>(), player.ChangeIncome(Change)) : (new[] { this }, player)); }
public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces) { return(Amount <= settings.DebtLimit && Amount > 0); }
public (IAction[], State.Player) Perform(State.Player player, State.IProvinces provinces) { return(player.Id == Player ? (new[] { new Actions.Loan(Player, Amount, settings) }, player.GainMoney(Amount)) : (System.Array.Empty <IAction>(), player)); }
public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces) => players[Player].Money >= Amount && Amount > 0;
public (IAction[], State.Player) Perform(State.Player player, State.IProvinces provinces) { return(System.Array.Empty <IAction>(), player.Id == Player ? player.Pay(Amount) : player.Id == Recipient ? player.GainMoney(Amount) : player); }
public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces) { return(provinces[Land].IsControlledBy(Player) && players[Player].Money >= Army.Soldiers.Price && Army.Soldiers.Any); }
public abstract (IAction, bool) Interact(ICommand another, IReadOnlyList <State.Player> players, State.IProvinces provinces);
public (IAction[], State.Player) Perform(State.Player player, State.IProvinces provinces) { return(player.Id == Player ? (new[] { new Actions.Reinforcement(Land, Army) }, player.Pay(Army.Soldiers.Price)) : (System.Array.Empty <IAction>(), player)); }
public (IAction[], State.Player) Perform(State.Player player, State.Player active, State.IProvinces provinces) { return(new[] { this }, player == active ? player.Earn() : player); }
public (IAction[], State.Player) Perform(State.Player player, State.IProvinces provinces) { return(System.Array.Empty <IAction>(), player.Id == Debtor ? player.Pay(Amount) : player); }
public (IAction?, bool) Interact(ICommand another, IReadOnlyList <State.Player> players, State.IProvinces provinces) { return(another switch { Commands.Borrow Loan when Loan.Player == Debtor => (new Loan(Debtor, Debt + Loan.Amount, settings), false), Commands.Repay Rep when Rep.Debtor == Debtor => (Rep.Amount >= Debt ? null : new Loan(Debtor, Debt - Rep.Amount, settings), false), _ => (this, true) });
public (IAction[], State.Player) Perform(State.Player player, State.Player active, State.IProvinces provinces) { if (player == active && player.Id == Debtor) { if (Debt > settings.DebtLimit) { return(Array.Empty <IAction>(), player.Pay(player.Money)); } return(new[] { new Loan(Debtor, (int)Math.Ceiling(Debt * (1 + settings.Interest)), settings) }, player); } return(new[] { this }, player); }