public FightUpdateResult UpdateFight() { var deadChars = FightCharacters.Where(c => c.Character.Stats.IsDead).ToList(); foreach (var deadChar in deadChars) { Queue.Remove(deadChar); } FightOutcome?fightOutcome = null; var aliveChars = FightCharacters.Where(c => !c.Character.Stats.IsDead).ToList(); if (aliveChars.All(c => c.Faction == FightCharacterFaction.Enemy)) { fightOutcome = FightOutcome.PlayerLose; } if (aliveChars.All(c => c.Faction == FightCharacterFaction.Ally || c.Faction == FightCharacterFaction.Player)) { fightOutcome = FightOutcome.PlayerWin; } return(new FightUpdateResult { DeadChars = deadChars, FightOutcome = fightOutcome }); }
public void PostFight() { FightCharacters .Where(c => !c.Character.Stats.IsDead) .ForEach(c => { c.Character.Stats.Health = c.Character.Stats.MaxHealth; c.Character.Stats.Mana = c.Character.Stats.MaxMana; c.Character.Stats.ActionPoints = c.Character.Stats.MaxActionPoints; }); }
private void UpdateQueue() { for (int i = 0; i < QueueSize - Queue.Count; ++i) { FightCharacter toPut = null; while (toPut == null) { var eligibleChars = FightCharacters .Where(qp => _random.NextDouble() < qp.QueueProbability) .ToList(); toPut = eligibleChars.ElementAtOrDefault(_random.Next(0, eligibleChars.Count)); } Queue.Add(toPut); } }