Exemplo n.º 1
0
 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);
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces)
 {
     return(Amount <= settings.DebtLimit && Amount > 0);
 }
Exemplo n.º 5
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));
 }
Exemplo n.º 6
0
 public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces) => players[Player].Money >= Amount && Amount > 0;
Exemplo n.º 7
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);
 }
Exemplo n.º 8
0
 public bool Allowed(IReadOnlyList <State.Player> players, State.IProvinces provinces)
 {
     return(provinces[Land].IsControlledBy(Player) && players[Player].Money >= Army.Soldiers.Price && Army.Soldiers.Any);
 }
Exemplo n.º 9
0
 public abstract (IAction, bool) Interact(ICommand another, IReadOnlyList <State.Player> players, State.IProvinces provinces);
Exemplo n.º 10
0
 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));
 }
Exemplo n.º 11
0
 public (IAction[], State.Player) Perform(State.Player player, State.Player active, State.IProvinces provinces)
 {
     return(new[] { this }, player == active ? player.Earn() : player);
 }
Exemplo n.º 12
0
 public (IAction[], State.Player) Perform(State.Player player, State.IProvinces provinces)
 {
     return(System.Array.Empty <IAction>(), player.Id == Debtor ? player.Pay(Amount) : player);
 }
Exemplo n.º 13
0
 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)
     });
Exemplo n.º 14
0
 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);
 }