Пример #1
0
        private async Task <TwitchChatReplyMessage> ParticipateInBossFight(TwitchChatMessage twitchChatMessage)
        {
            LogOutput.LogInformation($"[Bossfight] User requested to particpate in boss fight: {twitchChatMessage.TwitchUsername}, ID {twitchChatMessage.TwitchUserId}");

            TransferTwitchuser user_entered_battle = await userService.GetUser(twitchChatMessage.TwitchUserId);

            if (user_entered_battle == null)
            {
                LogOutput.LogInformation($"[Bossfight] User is not registered: {twitchChatMessage.TwitchUsername}, ID {twitchChatMessage.TwitchUserId}");
                return(new TwitchChatReplyMessage(twitchChatMessage.TwitchUsername, "Du bist noch nicht registriert. Schreibe !registrieren [Glumanda/Schiggy/Bisasam/Pikachu/Evoli] in den Chat, um dich zu registrieren."));
            }

            if (!bossService.IsBattleReady())
            {
                LogOutput.LogInformation($"[Bossfight] Battle is not ready: {twitchChatMessage.TwitchUsername}, ID {twitchChatMessage.TwitchUserId}");
                return(new TwitchChatReplyMessage(twitchChatMessage.TwitchUsername, "Aktuell streift kein Pokemon durch die Gegend. Versuche es in " + bossService.GetRemainingCoolDown().Minutes + " Minute(n) und " + bossService.GetRemainingCoolDown().Seconds + " Sekunde(n) erneut."));;
            }

            if (!bossService.IsBattleWaiting())
            {
                LogOutput.LogInformation($"[Bossfight] Creating a new boss round: {twitchChatMessage.TwitchUsername}, ID {twitchChatMessage.TwitchUserId}");
                bossService.StartNewBattleRound();
                chatOutputService.SendMessage(twitchChatMessage.TwitchUsername + " hat ein wildes Pokemon entdeckt! Schreibe !boss in den Chat, um ihm im Kampf beizustehen.");
            }

            bossService.AddUserToCurrentRound(user_entered_battle);
            LogOutput.LogInformation($"[Bossfight] User entered bossfight: {twitchChatMessage.TwitchUsername}, ID {twitchChatMessage.TwitchUserId}");

            return(null);
        }
Пример #2
0
 public static FightParticipant ToFightParticipantRandomFightTeam(this TransferTwitchuser user)
 {
     return(new FightParticipant()
     {
         User = user,
         Pokemon = user.GetRandomTeam()
     });
 }
Пример #3
0
        public void AddUserToCurrentRound(TransferTwitchuser enteredUser)
        {
            if (currentRound == null || currentRound.Participants.Contains(enteredUser))
            {
                return;
            }

            currentRound.Participants.Add(enteredUser);
        }
Пример #4
0
        public UserfightRound(UserService userService, TransferTwitchuser attacker, TransferTwitchuser defender, bool withExchange, bool isSelectedFight = false)
        {
            this.Attacker = attacker;
            this.Defender = defender;

            this.createdDt       = DateTimeOffset.Now;
            this.randomGenerator = new Random();
            this.userService     = userService;
            this.isSelectedFight = isSelectedFight;
            this.withExchange    = withExchange;
        }
Пример #5
0
 public static FightParticipant ToFightParticipantRandomPokemon(this TransferTwitchuser user)
 {
     return(new FightParticipant()
     {
         User = user,
         Pokemon = new List <TransferPokemon>()
         {
             user.GetRandomPokemon()
         }
     });
 }
Пример #6
0
        //TODO: Zeit in Setting auslagern und dynamisch laden/ausgeben!
        public async Task StartNPCFight(TransferTwitchuser user, TransferTwitchuser npc, string avName)
        {
            var result       = await(new UserfightRound(userService, user, npc, false).Fight());
            var resultString = $"Aus dem Kampf zwischen { user.DisplayName } und {npc.DisplayName} konnte {result.Winner.DisplayName} erfolgreich hervorgehen.";

            if (result.Winner.Equals(user))
            {
                chatOutputService.SendMessage($"{resultString} {result.Winner.DisplayName} erhält als Gewinn eine Lootbox!");
            }
            else
            {
                chatOutputService.SendMessage($"{resultString} Versuche es in 48h erneut!");
            }

            await userService.SetLastAVFightDt(user.Id, avName);
        }
Пример #7
0
        public async Task <TransferTwitchuser> GetUser(string userid)
        {
            if (await IsUserRegistered(userid))
            {
                var dbUser = await db.Twitchuser.Where(tu => tu.Twitchuser_Id == userid).Select(u => new Twitchuser()
                {
                    DisplayName       = u.DisplayName,
                    Dt_Last_Userfight = u.Dt_Last_Userfight,
                    Kz_Log_Enabled    = u.Kz_Log_Enabled,
                    Twitchuser_Id     = u.Twitchuser_Id,
                    CatchedPokemon    = u.CatchedPokemon.Select(c => new CatchedPokemon()
                    {
                        Twitchuser_Id                = c.Twitchuser_Id,
                        SdPokemon_Id                 = c.SdPokemon_Id,
                        CatchedPokemon_Id            = c.CatchedPokemon_Id,
                        Pokemon_AmountCatched        = c.Pokemon_AmountCatched,
                        Pokemon_AmountOnFightingTeam = c.Pokemon_AmountOnFightingTeam,
                        SdPokemon = new SdPokemon()
                        {
                            SdPokemon_Id = c.SdPokemon_Id,
                            ATK          = c.SdPokemon.ATK,
                            Description  = c.SdPokemon.Description,
                            HP           = c.SdPokemon.HP,
                            Name         = c.SdPokemon.Name,
                            Rarity       = c.SdPokemon.Rarity,
                            Type         = c.SdPokemon.Type
                        }
                    })
                })
                             .FirstOrDefaultAsync();

                var returnUser = new TransferTwitchuser()
                {
                    Id           = dbUser.Twitchuser_Id,
                    DisplayName  = dbUser.DisplayName,
                    KzLogEnabled = dbUser.Kz_Log_Enabled
                };

                returnUser.CatchedPokemonList = dbUser.CatchedPokemon.Select(cp => ConvertCatchedPokemonToTransfer(cp)).ToList();

                return(returnUser);
            }
            else
            {
                return(null);
            }
        }
Пример #8
0
        /// <summary>
        /// Start a fight between two users.
        /// </summary>
        /// <param name="challenger_user">Challenging twitch user.</param>
        /// <param name="challanged_user">Challenged twitch user.</param>
        public async Task StartFight(TransferTwitchuser challengerUser, TransferTwitchuser challengedUser)
        {
            var fightround = onGoingFights.Where(arf => arf.Defender.Equals(challengerUser) && arf.Attacker.Equals(challengedUser)).FirstOrDefault();

            if (null != fightround)
            {
                var result = await fightround.Fight();

                //Twitch output
                chatOutputService.SendMessage("Aus dem Kampf zwischen " + challengerUser.DisplayName + " und " + challengedUser.DisplayName + " konnte " + result.Winner.DisplayName + " erfolgreich hervorgehen. " + result.Winner.DisplayName + " erhält als Gewinn " + result.ExchangePokemon.Name + "!");

                //Clean up
                onGoingFights.Remove(fightround);
                await userService.SetLastFightDt(challengerUser.Id);

                await userService.SetLastFightDt(challengedUser.Id);
            }
        }
Пример #9
0
        public async Task <TransferTwitchuser> CreateVirtualNPC(string achievementName)
        {
            TransferTwitchuser virtualNPC;

            var sdAchievement = await db.SdAchievement.Where(a => a.NPCName == achievementName).FirstOrDefaultAsync();

            var transferPokemonList = sdAchievement.SdAchievementPokemon.Select(a => a.SdPokemon).Select(p => p.ConvertSdPokemonToTransfer());

            virtualNPC = new TransferTwitchuser()
            {
                DisplayName        = sdAchievement.NPCName,
                KzLogEnabled       = false,
                Id                 = "-1NPC",
                LastUserFight      = DateTime.Now,
                CatchedPokemonList = transferPokemonList.Select(t => t.ConvertToCatchedPokemon()).ToList()
            };

            return(virtualNPC);
        }
Пример #10
0
 public bool User_IsChallenger(TransferTwitchuser challenger)
 {
     return(onGoingFights.Where(ar => ar.Attacker.Equals(challenger)).FirstOrDefault() != null);
 }
Пример #11
0
 public bool User_IsChallengedBy(TransferTwitchuser user_isChallenged, TransferTwitchuser user_isChallenging)
 {
     return(onGoingFights.Where(ar => ar.Attacker.Equals(user_isChallenging) && ar.Defender.Equals(user_isChallenged)).FirstOrDefault() != null);
 }
Пример #12
0
 public void CreateFightRound(TransferTwitchuser challenger_user, TransferTwitchuser challenged_user, bool isSelectedFight)
 {
     onGoingFights.Add(new UserfightRound(userService, challenger_user, challenged_user, isSelectedFight));
 }
Пример #13
0
 public FightResult(TransferTwitchuser winner, TransferPokemon exchangePokemon)
 {
     this.Winner          = winner;
     this.ExchangePokemon = exchangePokemon;
 }