コード例 #1
0
            public async Task Spar(IUser opponent)
            {
                Player player = GetPlayer();
                Player other  = GetPlayer(opponent);

                if (player.combatState != null)
                {
                    await ReplyAsync("You are already in combat!");

                    return;
                }

                if (other.combatState != null)
                {
                    await ReplyAsync($"{opponent.Username} is already in combat!");

                    return;
                }

                CombatInstance combat = new CombatInstance();

                combat.Add(player, 0);
                combat.Add(other, 1);

                player.spars++;
                other.spars++;

                await ReplyAsync($"{player.name} and {other.name} are now in combat!");
            }
コード例 #2
0
            public async Task Flee()
            {
                Player player = GetPlayer();

                if (player.combatState == null)
                {
                    await ReplyAsync("You aren't in combat!");

                    return;
                }

                CombatInstance combat = player.combatState.instance;

                combat.Flee(player);

                await ReplyAsync("You fled the fight!");

                if (combat.isOver)
                {
                    await ReplyAsync("The fight is over.");
                }
            }
コード例 #3
0
            public async Task State()
            {
                Player player = GetPlayer();

                if (player.combatState == null)
                {
                    await ReplyAsync("You are not in combat.");

                    return;
                }

                CombatInstance combat = player.combatState.instance;

                string attackState = null;

                if (player.combatState.isLeftHandAttacked && player.combatState.isRightHandAttacked)
                {
                    attackState = "You have already attacked.";
                }
                else if (!player.combatState.isLeftHandAttacked && !player.combatState.isRightHandAttacked)
                {
                    attackState = "You have not attacked.";
                }
                else if (player.combatState.isLeftHandAttacked)
                {
                    attackState = "You have not attacked with your right hand.";
                }
                else
                {
                    attackState = "You have not attacked with your left hand.";
                }

                string result = $"You are in battle!\nRound {combat.round}\n{attackState}\n**Team 1**\n{combat.teams[0]}\n**Team 2**\n{combat.teams[1]}";

                await ReplyAsync(result);
            }
コード例 #4
0
                public async Task AttackUser([Hand] Slot hand, [InCombatWith, Enemy] Unit target)
                {
                    Player player = GetPlayer();

                    bool isAttacked;
                    bool isLeft = hand.names.Contains("lh");

                    if (isLeft)
                    {
                        isAttacked = player.combatState.isLeftHandAttacked;
                        player.combatState.isLeftHandAttacked = true;
                    }
                    else
                    {
                        isAttacked = player.combatState.isRightHandAttacked;
                        player.combatState.isRightHandAttacked = true;
                    }

                    if (isAttacked)
                    {
                        await ReplyAsync("You have already attacked with that hand.");

                        return;
                    }

                    ItemCount held = player.equipped[hand];

                    int damage = 1;

                    if (held == null)
                    {
                        await ReplyAsync($"{player.name} punched {target.name} dealing {damage} damage.");
                    }
                    else
                    {
                        Item item = held.item;

                        Unit.StatGroup damageStat = player.GetStat("Damage");
                        damage = isLeft ? damageStat.LeftTotal : damageStat.RightTotal;

                        await ReplyAsync($"{player.name} attacked {target.name} with {item.name} dealing {damage} damage.");
                    }

                    Unit.StatGroup healthStat = target.GetStat("Health");
                    healthStat.Modify(-damage);

                    if (healthStat.Total > 0)
                    {
                        await ReplyAsync($"{target.name} is on {healthStat.Total} health.");
                    }
                    else
                    {
                        await ReplyAsync($"{target.name} was killed.");

                        CombatInstance combat = target.combatState.instance;

                        combat.Killed(target);

                        if (combat.isOver)
                        {
                            await ReplyAsync("The fight is over.");
                        }
                    }
                }