Example #1
0
        public async Task Attack(int index = 0)
        {
            Player player;
            string log;

            if (IsPrivate(Context.Channel, out log))
            {
                if (CheckPlayer(out player, out log) && IsInBattle(player))
                {
                    Battling task   = player.task as Battling;
                    Battle   battle = BattleManager.Instance.GetBattle(task.battleId);

                    if (index == 0)
                    {
                        index++;
                    }
                    if (IsValidIndex(index - 1, battle.monsters.Cast <Character>().ToList(), out log))
                    {
                        Attack action = new Attack(player, battle.monsters[index - 1]);
                        battle.AddAction(action);

                        await BattleManager.Instance.PerformBattle(battle, Context.Channel);
                    }
                }
            }

            if (log != "")
            {
                await ReplyAsync(log);
            }
        }
Example #2
0
        public async Task Cast(string skillName, int index)
        {
            Player player;
            string log;

            if (IsPrivate(Context.Channel, out log))
            {
                if (CheckPlayer(out player, out log) && IsInBattle(player))
                {
                    Skill skill = GameData.Instance.GetSkill(skillName);
                    if (skill != null)
                    {
                        if (player.HasSkill(skillName))
                        {
                            if (player.currentStats.MP >= skill.mpCost)
                            {
                                Battling task   = player.task as Battling;
                                Battle   battle = BattleManager.Instance.GetBattle(task.battleId);

                                List <Character> characters = skill.isFriendly ? battle.players.Cast <Character>().ToList() : battle.monsters.Cast <Character>().ToList();
                                if (IsValidIndex(index - 1, characters, out log))
                                {
                                    Cast action;
                                    if (skill.isAoe)
                                    {
                                        action = new Cast(player, characters, skill);
                                    }
                                    else
                                    {
                                        action = new Cast(player, characters[index - 1], skill);
                                    }
                                    battle.AddAction(action);

                                    await BattleManager.Instance.PerformBattle(battle, Context.Channel);
                                }
                            }
                            else
                            {
                                log = "Not enough mana...";
                            }
                        }
                        else
                        {
                            log = $"You have not learned {skillName}!";
                        }
                    }
                    else
                    {
                        log = "Unknown skill name...";
                    }
                }
            }

            if (log != "")
            {
                await ReplyAsync(log);
            }
        }
Example #3
0
        public async Task Use(string itemName, int index)
        {
            Player player;
            string log;

            if (IsPrivate(Context.Channel, out log))
            {
                if (CheckPlayer(out player, out log) && IsInBattle(player))
                {
                    Battling task   = player.task as Battling;
                    Battle   battle = BattleManager.Instance.GetBattle(task.battleId);

                    Item item = GameData.Instance.GetItem(itemName);
                    if (item != null && item is Consumable)
                    {
                        Consumable       consumable = item as Consumable;
                        List <Character> characters;
                        if (consumable.friendly)
                        {
                            characters = battle.players.Cast <Character>().ToList();
                        }
                        else
                        {
                            characters = battle.monsters.Cast <Character>().ToList();
                        }

                        if (IsValidIndex(index - 1, characters, out log))
                        {
                            Use action = new Use(consumable, player, characters[index - 1]);
                            battle.AddAction(action);

                            await BattleManager.Instance.PerformBattle(battle, Context.Channel);
                        }
                    }
                    else
                    {
                        log = "Unknown consumable item...";
                    }
                }
            }

            if (log != "")
            {
                await ReplyAsync(log);
            }
        }
Example #4
0
        public async Task Flee()
        {
            Player player;
            string log;

            if (!IsPrivate(Context.Channel, out log))
            {
                await ReplyAsync(log);

                return;
            }

            if (CheckPlayer(out player, out log) && IsInBattle(player))
            {
                Battling task   = player.task as Battling;
                Battle   battle = BattleManager.Instance.GetBattle(task.battleId);

                Random random = new Random();
                if (random.Next(0, 100) <= 50 + player.currentStats.EVA)
                {
                    await ReplyAsync("You have successfully fled!");

                    BattleManager.Instance.RemoveBattle(battle.id);
                    BattleManager.Instance.ResetPlayer(player);

                    battle = null;
                    task   = null;
                }
                else
                {
                    NoAction action = new NoAction(player);
                    battle.AddAction(action);

                    await BattleManager.Instance.PerformBattle(battle, Context.Channel);
                }
            }

            if (log != "")
            {
                await ReplyAsync(log);
            }
        }