Example #1
0
        public string Status(int top = -1)
        {
            System.Text.StringBuilder sb = new System.Text.StringBuilder();
            if (top == -1)
            {
                top = Fighters.Count();
            }

            List <Fighter> fighters = Fighters.AllFighters();

            fighters.Sort((f1, f2) => Rating.Rating(f1).CompareTo(Rating.Rating(f2)));

            for (int f = 0; f < top; ++f)
            {
                Fighter curr = fighters[f];
                sb.AppendFormat($"{f + 1}. {curr.Name}\n\t{curr.Record} Rating: {Rating.Rating(curr)}\n");
                sb.AppendFormat($"\tSkill Level: {curr.OverallSkill()} Weight: {curr.Weight}");
                //sb.AppendLine();
                // sb.AppendLine(curr.ToString());
                sb.AppendLine();
            }

            return(sb.ToString());
        }
Example #2
0
        public async Task <List <CharacterFeatures> > Launch()
        {
            Fighters.ForEach(x =>
            {
                x.OnPower += (sender, e) =>
                {
                    if (Fighters.Count <= 1)
                    {
                        return;
                    }

                    var fighter = sender as CharacterFeatures;

                    if (fighter.CurrentLife > 0)
                    {
                        //Console.WriteLine($"{fighter} utilise son pouvoir");

                        CharacterFeatures enemy;
                        switch (fighter)
                        {
                        case Zombie:
                            enemy = GetDeadEnemy(fighter);
                            fighter.Power(enemy.MaximumLife);
                            break;

                        case Vampire:
                            enemy = GetEnemy(fighter);
                            fighter.Power(enemy);
                            break;

                        case Pretre:
                            fighter.Power();
                            break;

                        case Assassin:
                            if (GetNumberOfAliveFighter() > 5)
                            {
                                fighter.Power();
                            }
                            break;

                        case Necromancien:
                            if (DeadFighters.Count == 0)
                            {
                                fighter.Power();
                            }
                            else
                            {
                                fighter.IsHide = false;
                            }
                            break;

                        default:
                            //fighter.Power();
                            break;
                        }
                    }
                };

                x.OnDeath += (sender, args) =>
                {
                    var deadGuy = sender as CharacterFeatures;
                    if (DeadFighters.All(dead => deadGuy != null && dead.Id != deadGuy.Id))
                    {
                        DeadFighters.Add(deadGuy);
                        Fighters.Remove(deadGuy);

                        Console.WriteLine($"Bouhouhou {deadGuy} is dead");
                    }
                };

                x.OnAttack += (sender, e) =>
                {
                    if (Fighters.Count <= 1)
                    {
                        return;
                    }

                    var fighter = sender as CharacterFeatures;

                    if (fighter.CurrentLife > 0)
                    {
                        var enemy = GetEnemy(fighter);

                        //Console.WriteLine($"{fighter} attaque {enemy}");

                        enemy.SufferAttack(fighter, fighter.DamageType);

                        if (enemy.IsDead())
                        {
                            Death(enemy);
                        }

                        if (fighter.IsDead())
                        {
                            Death(fighter);
                        }
                    }
                };

                x.StartFight();
            });

            do
            {
                await Task.Delay(2000);
            } while (Fighters.Count(x => !x.IsDead()) > 1);

            await Task.Delay(5000);

            return(DeadFighters.Distinct().ToList());
        }
Example #3
0
 private int GetNumberOfAliveFighter()
 {
     return(Fighters.Count(x => !x.IsDead()));
 }