Example #1
0
        public EmbedBuilder Pause(SocketCommandContext context)
        {
            var start_embed = new EmbedBuilder();

            if (context.User == Hoster)
            {
                if (IsPaused)
                {
                    return(start_embed
                           .WithTitle(ResultMessages.PauseError)
                           .WithDescription(ResultMessages.PauseError_AlreadyPaused));
                }
                PhaseTimer.Change(Timeout.Infinite, Timeout.Infinite);
                TimerPaused = DateTime.Now;
                IsPaused    = true;
                return(start_embed.WithTitle(ResultMessages.PauseSuccess)
                       .WithDescription(ResultMessages.PauseSuccess_Desc));
            }
            else
            {
                return(start_embed
                       .WithTitle(ResultMessages.PauseError)
                       .WithDescription(string.Format(ResultMessages.PauseError_NotAuthorized, Hoster.Mention)));
            }
        }
Example #2
0
        public EmbedBuilder Continue(SocketCommandContext context)
        {
            var start_embed = new EmbedBuilder();

            if (context.User == Hoster)
            {
                if (!IsPaused)
                {
                    return(start_embed
                           .WithTitle(ResultMessages.ContError)
                           .WithDescription(ResultMessages.ContError_NotPaused));
                }
                PhaseTimer.Change((TimerStarted + Phase_Interval - TimerPaused), Phase_Interval);
                IsPaused = false;
                return(start_embed
                       .WithTitle(ResultMessages.ContSuccess)
                       .WithDescription(ResultMessages.ContSuccess_Desc));
            }
            else
            {
                return(start_embed
                       .WithTitle(ResultMessages.ContError)
                       .WithDescription(ResultMessages.ContError_NotAuthorized));
            }
        }
Example #3
0
 public async Task CancelGame(IUser user, bool forceClose = false)
 {
     if (Status > GameStatus.Cancelled && (user.Id == Hoster?.Id || forceClose))
     {
         if (Status < GameStatus.GaiaEnding)
         {
             await(await ServerHost.GetTextChannelsAsync()).First((x) => x.Name == "public_gvg").SendMessageAsync("The game has been cancelled by the host.");
         }
         Status = GameStatus.Cancelled;
         foreach (var mem in GaiaMembers.Concat(GuardianMembers).Concat(OCMembers).Concat(Civilians))
         {
             try
             {
                 await mem.RemoveRolesAsync(new IRole[] { GvG_Player, GvG_Dead_Player });
             } catch (Exception)
             {
                 // do nothing
             }
         }
         GaiaMembers.Clear();
         GuardianMembers.Clear();
         OCMembers.Clear();
         Civilians.Clear();
         PhaseTimer?.Change(Timeout.Infinite, Timeout.Infinite);
     }
 }
        private void FinishNextPhase()
        {
            PhaseTimer.Stop();

            GameState.CurrentSpeed      = PhaseSpeed;
            GameState.ShowCorrectSquare = false;

            InitializeLoadingBar();

            SetZulrahImage();

            SetInformationLabels(Rotation.CurrentPhase.PlayerBlockIDs.Count > 1);

            lblTimeLeft.Location = new Point(731, 39);
            lblTimeLeft.Font     = new Font(lblTimeLeft.Font.FontFamily, 20.25f);
            lblTimeLeft.Text     = "";

            PhaseTimer.Tick -= PhaseTimer_TickDown;
            PhaseTimer.Tick += PhaseTimer_TickUp;

            loadingBar.BackColor = Color.FromArgb(46, 252, 56);

            Refresh();

            PhaseTimer.Start();
        }
        private void btnStart_Click(object sender, EventArgs e)
        {
            if (PhaseTimer.Enabled)
            {
                PhaseTimer.Stop();
            }

            ResetGame();

            StartTimer();
        }
        private void PreNextPhase()
        {
            lblTimeLeft.Location = new Point(686, 51);
            lblTimeLeft.Font     = new Font(lblTimeLeft.Font.FontFamily, 12);
            lblTimeLeft.Text     = "Next Phase...";

            PhaseTimer.Tick -= PhaseTimer_TickUp;
            PhaseTimer.Tick += PhaseTimer_TickDown;

            GameState.CurrentSpeed = NextPhaseSpeed;

            loadingBar.BackColor = Color.Blue;
            pbZulrah.Visible     = false;

            InitializeLoadingBar();

            PhaseTimer.Start();
        }
        public void StepThroughBlocks()
        {
            PhaseTimer.Stop();

            GameState.PhaseBlock++;

            GameState.CurrentSpeed = PhaseStepSpeed;

            SetInformationLabels(true);

            InitializeLoadingBar();

            PhaseTimer.Start();

            if (GameState.Debug_mode)
            {
                Refresh();
            }
        }
        private void NextPhase()
        {
            PhaseTimer.Stop();

            GameState.PhaseBlock   = 0;
            GameState.CurrentSpeed = PhaseSpeed;

            if (GameState.Correct)
            {
                GameState.CorrectCount++;
            }
            else
            {
                GameState.IncorrectCount++;
            }

            SetScoreLabel();

            cbJadPhase.Checked = false;

            bool done = Rotation.NextPhase();

            if (done)
            {
                loadingBar.BackColor = Color.FromArgb(46, 252, 56);
                InitializeLoadingBar();
                loadingBar.Refresh();
                lblRotation.Text = "Rotation Complete";

                if (cbLoop.Checked)
                {
                    SetRotation();

                    PreNextPhase();
                }
            }
            else
            {
                PreNextPhase();
            }
        }
Example #9
0
        public async Task <EmbedBuilder> StartGame(IUser invoker)
        {
            if (invoker.Id != (Hoster?.Id ?? 0))
            {
                return(new EmbedBuilder()
                       .WithTitle("StartGameError")
                       .WithDescription("ErrorCreateGameFirst"));
            }
            // placeholder for Storymaker.
            var start_embed = new EmbedBuilder().WithTitle("Game Start!");

            await AssignRoles();

            Day++;
            Status = GameStatus.IdlePhase;
            if (PhaseTimer != null)
            {
                PhaseTimer?.Change(Phase_Interval, Phase_Interval);
            }
            else
            {
                PhaseTimer = new Timer(_ => MovePhase(), null, Phase_Interval, Phase_Interval);
                PhaseTimer.Change(Phase_Interval, Phase_Interval);
                TimerStarted = DateTime.Now;
            }

            await Public_GvG.SendMessageAsync("", false, start_embed.Build());

            await Guardian_Channel.SendMessageAsync("", false, start_embed.Build());

            await Gaia_Channel.SendMessageAsync("", false, start_embed.Build());

            await OC_Channel.SendMessageAsync("", false, start_embed.Build());

            return(null);
        }
 private void btnStop_Click(object sender, EventArgs e)
 {
     PhaseTimer.Stop();
 }
        private void StartTimer()
        {
            InitializeLoadingBar();

            PhaseTimer.Start();
        }