public void SetOptions(String optionString) { this.combatOptions = new CombatOptions(); string[] options = optionString.Split(','); foreach (string option in options) { SetOption(option.ToLower()); } }
public void InitCombat(CombatOptions options = null) { if (options == null) { options = new CombatOptions(); } combatOptions = options; Attacker.Init(); Defender.Init(); foreach (Card card in combatOptions.DefenderCards) { Defender.Hand.Add(card); } foreach (Card card in combatOptions.AttackerCards) { Attacker.Hand.Add(card); } }
public Result Resolve(CombatOptions options=null, int? repeat = null) { Result result = new Result(); result.Attacker = Attacker; result.Defender = Defender; bool isAttackerTurn = true; if (repeat == null) repeat = Repeat; if (options == null) options = new CombatOptions(); this.combatOptions = options; for (int i = 0; i < repeat; i++) { turn = 0; Attacker.Init(); Defender.Init(); foreach (Card card in combatOptions.DefenderCards) { Defender.Hand.Add(card.Clone()); } foreach (Card card in combatOptions.AttackerCards) { Attacker.Hand.Add(card); } while (Attacker.IsAlive && Defender.IsAlive) { turn++; isAttackerTurn = (turn % 2) == 1; try { if (isAttackerTurn) { DoTurn(Attacker, Defender); } else { DoTurn(Defender, Attacker); } } catch (DeadPlayerExeption dpex) { result.RecordLoss(dpex.DeadPlayer.Id); break; } if (turn > MAX_TURNS) { result.RecordLoss(Attacker.Id); break; } } } return result; }
public void InitCombat(CombatOptions options = null) { if (options == null) options = new CombatOptions(); combatOptions = options; Attacker.Init(); Defender.Init(); foreach(Card card in combatOptions.DefenderCards) { Defender.Hand.Add(card); } foreach (Card card in combatOptions.AttackerCards) { Attacker.Hand.Add(card); } }
public Result Resolve(CombatOptions options = null, int?repeat = null) { Result result = new Result(); result.Attacker = Attacker; result.Defender = Defender; bool isAttackerTurn = true; if (repeat == null) { repeat = Repeat; } if (options == null) { options = new CombatOptions(); } this.combatOptions = options; for (int i = 0; i < repeat; i++) { turn = 0; Attacker.Init(); Defender.Init(); foreach (Card card in combatOptions.DefenderCards) { Defender.Hand.Add(card.Clone()); } foreach (Card card in combatOptions.AttackerCards) { Attacker.Hand.Add(card); } while (Attacker.IsAlive && Defender.IsAlive) { turn++; isAttackerTurn = (turn % 2) == 1; try { if (isAttackerTurn) { DoTurn(Attacker, Defender); } else { DoTurn(Defender, Attacker); } } catch (DeadPlayerExeption dpex) { result.RecordLoss(dpex.DeadPlayer.Id); break; } if (turn > MAX_TURNS) { result.RecordLoss(Attacker.Id); break; } } } return(result); }