Exemple #1
0
        public override async Task Reset()
        {
            Battle = new ColossoBattle();

            foreach (var k in PlayerMessages.Keys)
            {
                await k.DeleteAsync();
            }

            PlayerMessages.Clear();

            if (EnemyMessage == null)
            {
                await Initialize();
            }
            else
            {
                await EnemyMessage.ModifyAsync(c => { c.Content = GetEnemyMessageString(); c.Embed = null; });

                await EnemyMessage.RemoveAllReactionsAsync();

                _ = EnemyMessage.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight:536919792813211648>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });
                wasJustReset = true;
            }
            if (StatusMessage != null)
            {
                _             = StatusMessage.DeleteAsync();
                StatusMessage = null;
            }
            SetNextEnemy();

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }
            autoTurn = new Timer()
            {
                Interval  = 25000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += TurnTimeElapsed;
            resetIfNotActive  = new Timer()
            {
                Interval  = 120000,
                AutoReset = false,
                Enabled   = false
            };
            resetIfNotActive.Elapsed += BattleWasNotStartetInTime;

            Console.WriteLine("Battle was reset.");
        }
Exemple #2
0
        internal async Task Reset()
        {
            Battle = new ColossoBattle();

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }

            foreach (var k in Messages.Keys)
            {
                await k.DeleteAsync();
            }

            Messages.Clear();

            if (EnemyMsg != null)
            {
                _ = EnemyMsg.ModifyAsync(c => { c.Content = $"Welcome to {Name} Battle!\n\nReact with <:Fight:536919792813211648> to join the {Name} Battle and press <:Battle:536954571256365096> when you are ready to battle!"; c.Embed = null; });
                await EnemyMsg.RemoveAllReactionsAsync();

                _ = EnemyMsg.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight:536919792813211648>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });
            }
            if (StatusMsg != null)
            {
                _         = StatusMsg.DeleteAsync();
                StatusMsg = null;
            }
            winsInARow = 0;
            LureCaps   = 0;
            SetRandomEnemies(ColossoBattle.Team.B);

            autoTurn = new Timer()
            {
                Interval  = 25000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += OnTimerTicked;
            resetIfNotActive  = new Timer()
            {
                Interval  = 120000,
                AutoReset = false,
                Enabled   = false
            };
            resetIfNotActive.Elapsed += BattleWasNotStartetInTime;

            Console.WriteLine("Battle was reset.");
        }
Exemple #3
0
        public override async Task Reset()
        {
            Battle = new ColossoBattle();
            if (!IsPersistent && WasReset)
            {
                Dispose(); return;
            }
            WasReset = true;
            foreach (var k in PlayerMessages.Keys)
            {
                PlayerMessages[k].Moves.OfType <Djinn>().ToList().ForEach(d =>
                {
                    d.CoolDown = 0; d.Summon(PlayerMessages[k]);
                });
                await k.DeleteAsync();
            }
            Factory.uniqueDjinn.Clear();
            Factory.summons.Clear();
            PlayerMessages.Clear();

            if (EnemyMessage == null)
            {
                await Initialize();
            }
            else
            {
                await EnemyMessage.ModifyAsync(c => { c.Content = GetEnemyMessageString(); c.Embed = null; });

                await EnemyMessage.RemoveAllReactionsAsync();

                _ = EnemyMessage.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight:536919792813211648>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });
                wasJustReset = true;
            }

            if (SummonsMessage == null)
            {
                await Initialize();
            }
            else
            {
                _ = SummonsMessage.ModifyAsync(m => { m.Content = "Good Luck!"; m.Embed = null; });
                _ = SummonsMessage.RemoveAllReactionsAsync();
            }

            if (StatusMessage != null)
            {
                _             = StatusMessage.DeleteAsync();
                StatusMessage = null;
            }
            SetNextEnemy();

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }
            autoTurn = new Timer()
            {
                Interval  = 45000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += TurnTimeElapsed;
            resetIfNotActive  = new Timer()
            {
                Interval  = 120000,
                AutoReset = false,
                Enabled   = false
            };
            resetIfNotActive.Elapsed += BattleWasNotStartetInTime;

            Console.WriteLine("Battle was reset.");
        }
Exemple #4
0
        public override async Task Reset()
        {
            Battle = new ColossoBattle();
            var A = Teams[Team.A];
            var B = Teams[Team.B];

            playersWithBRole.Where(p => p.Roles.Any(r => r.Name == "TeamB")).ToList().ForEach(a => _ = a.RemoveRoleAsync(TeamBRole));

            foreach (var k in A.PlayerMessages.Keys)
            {
                await k.DeleteAsync();
            }
            foreach (var k in B.PlayerMessages.Keys)
            {
                await k.DeleteAsync();
            }

            A.PlayerMessages.Clear();
            B.PlayerMessages.Clear();

            if (A.EnemyMessage != null)
            {
                await A.EnemyMessage.RemoveAllReactionsAsync();

                _ = A.EnemyMessage.ModifyAsync(m =>
                {
                    m.Content = $"Welcome to {Name}. Join Team A or Team B.";
                    m.Embed   = null;
                });
                _ = A.EnemyMessage.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight_A:592374736479059979>"),
                    Emote.Parse("<:Fight_B:592374736248373279>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });
            }
            if (B.EnemyMessage != null)
            {
                _ = B.EnemyMessage.RemoveAllReactionsAsync();
                _ = B.EnemyMessage.ModifyAsync(m =>
                {
                    m.Content = $"Welcome to {Name}, Team B. Please wait til the battle has started.";
                    m.Embed   = null;
                });
            }
            if (A.StatusMessage != null)
            {
                _ = A.StatusMessage.DeleteAsync();
                A.StatusMessage = null;
            }

            if (B.StatusMessage != null)
            {
                _ = B.StatusMessage.DeleteAsync();
                B.StatusMessage = null;
            }

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }
            autoTurn = new Timer()
            {
                Interval  = 25000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += TurnTimeElapsed;
            resetIfNotActive  = new Timer()
            {
                Interval  = 120000,
                AutoReset = false,
                Enabled   = false
            };
            resetIfNotActive.Elapsed += BattleWasNotStartetInTime;

            Console.WriteLine("Battle was reset.");
        }
Exemple #5
0
        public override async Task Reset(string msg = "")
        {
            Battle = new ColossoBattle();
            var A = Teams[Team.A];
            var B = Teams[Team.B];

            playersWithBRole.Where(p => p.Roles.Any(r => r.Name == "TeamB")).ToList().ForEach(a => _ = a.RemoveRoleAsync(TeamBRole));

            foreach (var team in new[] { A, B })
            {
                foreach (var k in team.PlayerMessages.Keys)
                {
                    foreach (var d in team.PlayerMessages[k].Moves.OfType <Djinn>())
                    {
                        d.CoolDown = 0;
                        d.Summon(team.PlayerMessages[k]);
                    }
                    await k.DeleteAsync();
                }
                team.Factory.djinn.Clear();
                team.Factory.summons.Clear();
                team.PlayerMessages.Clear();

                if (team.StatusMessage != null)
                {
                    _ = team.StatusMessage.DeleteAsync();
                    team.StatusMessage = null;
                }

                if (team.SummonsMessage != null)
                {
                    _ = team.SummonsMessage.ModifyAsync(m => { m.Content = "Good Luck!"; m.Embed = null; });
                    _ = team.SummonsMessage.RemoveAllReactionsAsync();
                }
            }

            if (A.EnemyMessage != null)
            {
                await A.EnemyMessage.RemoveAllReactionsAsync();

                _ = A.EnemyMessage.ModifyAsync(m =>
                {
                    m.Content = $"Welcome to {Name}. Join Team A or Team B.";
                    m.Embed   = null;
                });
                _ = A.EnemyMessage.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight_A:592374736479059979>"),
                    Emote.Parse("<:Fight_B:592374736248373279>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });
            }
            if (B.EnemyMessage != null)
            {
                _ = B.EnemyMessage.RemoveAllReactionsAsync();
                _ = B.EnemyMessage.ModifyAsync(m =>
                {
                    m.Content = $"Welcome to {Name}, Team B. Please wait til the battle has started.";
                    m.Embed   = null;
                });
            }

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }
            autoTurn = new Timer()
            {
                Interval  = 60000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += TurnTimeElapsed;
            resetIfNotActive  = new Timer()
            {
                Interval  = 240000,
                AutoReset = false,
                Enabled   = false
            };
            resetIfNotActive.Elapsed += BattleWasNotStartedInTime;

            Console.WriteLine("Battle was reset.");
        }
        public override async Task Reset(string msg = "")
        {
            Battle = new ColossoBattle();

            PlayerMessages
            .Values
            .SelectMany(u => u.Moves.OfType <Djinn>())
            .ToList()
            .ForEach(d => d.Reset());

            foreach (var k in PlayerMessages.Keys)
            {
                await k.DeleteAsync();
            }
            Factory.djinn.Clear();
            Factory.summons.Clear();
            PlayerMessages.Clear();

            if (!IsPersistent && WasReset)
            {
                Console.WriteLine($"{Name} was disposed: {msg}");
                Dispose(); return;
            }

            if (EnemyMessage == null)
            {
                await Initialize();
            }
            else
            {
                await EnemyMessage.ModifyAsync(c => { c.Content = GetEnemyMessageString(); c.Embed = null; });

                await EnemyMessage.RemoveAllReactionsAsync();

                await EnemyMessage.AddReactionsAsync(new IEmote[]
                {
                    Emote.Parse("<:Fight:536919792813211648>"),
                    Emote.Parse("<:Battle:536954571256365096>")
                });

                wasJustReset = true;
            }

            if (SummonsMessage == null)
            {
                await Initialize();
            }
            else
            {
                _ = SummonsMessage.ModifyAsync(m => { m.Content = $"Good Luck!\n{tutorialTips.Random()}"; m.Embed = null; });
                _ = SummonsMessage.RemoveAllReactionsAsync();
            }

            if (StatusMessage != null)
            {
                _             = StatusMessage.DeleteAsync();
                StatusMessage = null;
            }
            SetNextEnemy();

            if (autoTurn != null)
            {
                autoTurn.Dispose();
            }
            if (resetIfNotActive != null)
            {
                resetIfNotActive.Dispose();
            }
            autoTurn = new Timer()
            {
                Interval  = 45000,
                AutoReset = false,
                Enabled   = false
            };
            autoTurn.Elapsed += TurnTimeElapsed;
            resetIfNotActive  = new Timer()
            {
                Interval  = 120000,
                AutoReset = false,
                Enabled   = !IsPersistent
            };
            resetIfNotActive.Elapsed += BattleWasNotStartetInTime;

            WasReset = true;
            Console.WriteLine($"{Name} was reset: {msg}");
        }