public CombatResult AddMove(CombatMove NewMove) { _moveMutex.WaitOne(); try { if (CombatRounds.Count == 0 || CombatRounds[CombatRounds.Count - 1].Moves.Count % 2 == 0) { CombatRound newCombatRound = new CombatRound(NewMove); CombatRounds.Add(newCombatRound); return(null); //add the move } else { CombatRound thisRound = CombatRounds[CombatRounds.Count - 1]; thisRound.Moves.Add(NewMove); CombatResolverFactory combatResolverFactory = new CombatResolverFactory(this); ICombatInstanceResolver combatInstanceResolver = combatResolverFactory.GetCombatResolver(CombatRounds[CombatRounds.Count - 1].Moves); CombatResult combatResult = combatInstanceResolver.Resolve(CombatRounds[CombatRounds.Count - 1].Moves); thisRound.Result = combatResult; return(combatResult); //add the move and get a CombatResult } } finally { _moveMutex.ReleaseMutex(); } }
public CombatRound(CombatMove PlayerMove) { _moves.Add(PlayerMove); }