Exemple #1
0
 private static double CalculateDamage(AbstractCreature creature)
 {
     var rand = new Random();
     if (creature.Type == CreatureType.Melee)
     {
         return creature.Damage * creature.Count * 3 + rand.Next(1, 25);
     }
     return creature.Damage * creature.Count * 2 + rand.Next(1, 50);
 }
Exemple #2
0
        public void SelectUnits(Units units)
        {
            var hero = _heroesRepository.GetHeroWithName(units.HeroName);
            var abstractHero = Mapper.Map<Hero, AbstractHero>(hero);
            abstractHero.HeroTeam = units.Team;
            _selectedHeroes.Add(abstractHero);

            var creatureNameGroup = new List<string>
            {
                units.Creature1,
                units.Creature2,
                units.Creature3,
                units.Creature4
            };

            var creatures = _creaturesRepository.GetCreaturesByName(creatureNameGroup);
            foreach (var creatureName in creatureNameGroup)
            {
                var creatureType = creatures[creatureName];
                var abstractCreature = new AbstractCreature()
                {
                    Damage = creatureType.Damage,
                    Luck = creatureType.Luck,
                    Name = creatureType.Name,
                    Range =  creatureType.Range ?? 0.0,
                    MaxHealth = creatureType.MaxHealth,
                    Speed = creatureType.Speed,
                    Armor = creatureType.Armor,
                    Type = (CreatureType)(creatureType.CombatModeId - 1),
                    Team = units.Team,
                    Status = CreatureStatus.Alive
                };
                _selectedCreatures.Add(abstractCreature);
            }
        }