Ejemplo n.º 1
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);
     }
 }
Ejemplo n.º 2
0
        // stated to change.

        public async Task CreateGame(IUser Hoster, IGuild Host, ITextChannel public_GvG, ITextChannel guardian_Channel, ITextChannel gaia_Channel, ITextChannel oC_Channel)
        {
            if (Status > GameStatus.Cancelled && Status < GameStatus.GaiaEnding)
            {
                throw new AlreadyOngoingGameGvGGameException();
            }

            Day = 0;

            this.Hoster = Hoster;

            Guardian        = Host.Roles.First((x) => x.Name == Parent.config.guardian_chan_name);
            Gaia            = Host.Roles.First((x) => x.Name == Parent.config.gaia_chan_name);
            Occult_Club     = Host.Roles.First((x) => x.Name == Parent.config.oc_chan_name);
            GvG_Player      = Host.Roles.First((x) => x.Name == Parent.config.gvg_player_role_name);
            GvG_Dead_Player = Host.Roles.First((x) => x.Name == Parent.config.gvg_dead_player_role_name);

            ServerHost       = Host;
            Public_GvG       = public_GvG;
            Gaia_Channel     = gaia_Channel;
            Guardian_Channel = guardian_Channel;
            OC_Channel       = oC_Channel;

            GaiaMembers.Clear();
            GuardianMembers.Clear();
            OCMembers.Clear();
            Civilians.Clear();
            DeadPeople.Clear();

            RoleAssignments.Clear();

            Status = GameStatus.GamePreparation;

            await(await Host.GetTextChannelsAsync()).First((x) => x.Name == Parent.config.pub_gvg_chan_name)
            .SendMessageAsync(null, false, new EmbedBuilder()
                              .WithTitle(ResultMessages.CreateGameSuccess)
                              .WithDescription(string.Format(ResultMessages.CreateGameSuccess_Desc, Hoster.Mention))
                              .Build());
        }