Example #1
0
        public BossService(UserService userService, PokemonService pokemonService, ChatOutputService chatOutputService, SettingsService settingsService)
        {
            this.userService       = userService;
            this.pokemonService    = pokemonService;
            this.chatOutputService = chatOutputService;
            this.settingsService   = settingsService;

            bossOutputFormatter = new BossOutputFormatter();
            cooldownTime        = new TimeSpan(0, 0, 0);
        }
Example #2
0
        private FightRoundResult CalulateOneVSOne(FightOptions input)
        {
            bool challengerAttackFirst = randomGenerator.Next(0, 2) == 0;
            var  challenger            = input.Challenger;
            var  defender = input.Defender;

            while (((challenger.Pokemon.FirstOrDefault()?.HP ?? 0) > 0) && (defender.Pokemon.FirstOrDefault()?.HP ?? 0) > 0)
            {
                var defender_pokemon = defender.Pokemon[0];
                var attacker_pokemon = challenger.Pokemon[0];

                if (challengerAttackFirst)
                {
                    var damage = input.ParticipantBonus + attacker_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(attacker_pokemon.Type, defender_pokemon.Type) + randomGenerator.Next(-2, 3);
                    defender_pokemon.HP -= damage;

                    if (defender_pokemon.HP <= 0)
                    {
                        return(new FightRoundResult(challenger));
                    }

                    damage = defender_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(defender_pokemon.Type, attacker_pokemon.Type) + randomGenerator.Next(-2, 3);
                    attacker_pokemon.HP -= damage;

                    if (attacker_pokemon.HP <= 0)
                    {
                        return(new FightRoundResult(defender));
                    }
                }
                else
                {
                    var damage = defender_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(defender_pokemon.Type, attacker_pokemon.Type) + randomGenerator.Next(-2, 3);
                    attacker_pokemon.HP -= damage;

                    if (attacker_pokemon.HP <= 0)
                    {
                        return(new FightRoundResult(defender));
                    }

                    damage = attacker_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(attacker_pokemon.Type, defender_pokemon.Type) + randomGenerator.Next(-2, 3);
                    defender_pokemon.HP -= damage;

                    if (defender_pokemon.HP <= 0)
                    {
                        return(new FightRoundResult(challenger));
                    }
                }
            }

            return(null);
        }
Example #3
0
        public FightParticipant CalulateOneVSOne(FightParticipant challenger, FightParticipant defender)
        {
            bool challengerAttackFirst = randomGenerator.Next(0, 2) == 0;

            while (((challenger.Pokemon.FirstOrDefault()?.HP ?? 0) > 0) && (defender.Pokemon.FirstOrDefault()?.HP ?? 0) > 0)
            {
                var defender_pokemon = defender.Pokemon.FirstOrDefault();
                var attacker_pokemon = defender.Pokemon.FirstOrDefault();

                if (challengerAttackFirst)
                {
                    var damage = attacker_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(attacker_pokemon.Type, defender_pokemon.Type) + randomGenerator.Next(-2, 3);
                    defender_pokemon.HP -= damage;

                    if (defender_pokemon.HP <= 0)
                    {
                        return(challenger);
                    }

                    damage = defender_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(defender_pokemon.Type, attacker_pokemon.Type) + randomGenerator.Next(-2, 3);
                    attacker_pokemon.HP -= damage;

                    if (attacker_pokemon.HP <= 0)
                    {
                        return(defender);
                    }
                }
                else
                {
                    var damage = defender_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(defender_pokemon.Type, attacker_pokemon.Type) + randomGenerator.Next(-2, 3);
                    attacker_pokemon.HP -= damage;

                    if (attacker_pokemon.HP <= 0)
                    {
                        return(defender);
                    }

                    damage = attacker_pokemon.ATK * PokemonService.GetTypeAdvantageMultiplikator(attacker_pokemon.Type, defender_pokemon.Type) + randomGenerator.Next(-2, 3);
                    defender_pokemon.HP -= damage;

                    if (defender_pokemon.HP <= 0)
                    {
                        return(challenger);
                    }
                }
            }

            return(null);
        }
Example #4
0
 public UserService(AppDbContext db, TwitchAPI api)
 {
     this.pokemonService = new PokemonService(db);
     this.db             = db;
     this.twitchAPI      = api;
 }