Ejemplo n.º 1
0
        public async Task InitiateRaid(SocketGuildChannel channel)
        {
            ContextIds idList = new ContextIds(Context);

            idList.ChannelId = channel.Id;
            var user = UserHandler.GetUser(idList.UserId);

            //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location)
            try
            {
                await UserHandler.UserInCombat(idList);

                await UserHandler.UserHasNoCards(idList, user);
            }
            catch (InvalidUserStateException)
            {
                return;
            }

            //Start raid
            CombatInstance combat = new CombatInstance(idList);

            combat.IsDuel = false;
            var combatId = CombatHandler.NumberOfInstances();

            combat.CombatId = combatId;

            user.CombatRequest = 0;
            user.CombatID      = combatId;
            await combat.AddPlayerToCombat(user, combat.CreateNewTeam());

            //await MessageHandler.SendMessage(idList, $"{user.ActiveCards[0].Name} is attacking #{channel.Name}! Combat will begin in 10 minutes.\n```\nUse 0.joincombat to join\n```");
            await MessageHandler.SendMessage(idList, $"{user.ActiveCards[0].Name} challenges the party! Combat will begin in 3 minutes.\n```\nUse 0.joincombat to join\n```");

            CombatHandler.StoreInstance(combatId, combat);
        }
Ejemplo n.º 2
0
        public async Task Duel(SocketGuildUser target)
        {
            var fromUser = UserHandler.GetUser(Context.User.Id);
            var toUser   = UserHandler.GetUser(target.Id);

            ContextIds idList = new ContextIds(Context);

            //Tests each case to make sure all circumstances for the execution of this command are valid (character exists, in correct location)
            try
            {
                await UserHandler.UserInCombat(idList);

                await UserHandler.OtherUserInCombat(idList, toUser);

                await UserHandler.UserHasNoCards(idList, fromUser);

                await UserHandler.OtherUserHasNoCards(idList, fromUser, toUser);
            }
            catch (InvalidUserStateException)
            {
                return;
            }

            //Check that the user did not target themself with the command
            if (fromUser.UserId != toUser.UserId)
            {
                //Set the current user's combat request ID to the user specified
                fromUser.CombatRequest = toUser.UserId;

                //Check if the specified user has a combat request ID that is the current user's ID
                if (toUser.CombatRequest == fromUser.UserId)
                {
                    //Start duel
                    CombatInstance combat = new CombatInstance(idList);

                    combat.IsDuel = true;
                    var combatId = CombatHandler.NumberOfInstances();
                    combat.CombatId = combatId;

                    fromUser.CombatRequest = 0;
                    fromUser.CombatID      = combatId;
                    await combat.AddPlayerToCombat(fromUser, combat.CreateNewTeam());

                    toUser.CombatRequest = 0;
                    toUser.CombatID      = combatId;
                    await combat.AddPlayerToCombat(toUser, combat.CreateNewTeam());

                    CombatHandler.StoreInstance(combatId, combat);

                    await CombatHandler.InitiateDuel(combat);
                }
                else
                {
                    //Challenge the specified user
                    await Context.Channel.SendMessageAsync($"{target.Mention}, you have been challenged to a duel by {Context.User.Mention}\nUse the \"0.duel [mention target]\" command to accept.");
                }
            }
            else
            {
                //Tell the current user they have are a dum dum
                await Context.Channel.SendMessageAsync($"{Context.User.Mention}, stop hitting yourself!");
            }
        }