Ejemplo n.º 1
0
        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
            });
        }
Ejemplo n.º 2
0
 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;
     });
 }
Ejemplo n.º 3
0
        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);
            }
        }
Ejemplo n.º 4
0
 public long?GetDamageTypeDamage(DamageType damageType) => FightCharacters.NullableSum(c => c.GetDamageTypeDamageDone(damageType));
Ejemplo n.º 5
0
 public int?GetDamageTypeHits(DamageType damageType) => FightCharacters.NullableSum(c => c.GetDamageTypeHitsDone(damageType));
Ejemplo n.º 6
0
 public bool HasDamageTypeDamage(DamageType damageType) => FightCharacters.Any(c => c.HasDamageTypeDamageDone(damageType));