Exemplo n.º 1
0
        public Task SortTitles()
        {
            if (Character.Titles == null)
            {
                return(Task.CompletedTask);
            }
            if (Character.Titles.Count < 2)
            {
                return(Task.CompletedTask);
            }

            int index = 0;

            while (true)
            {
                for (int i = 0; i < Character.Titles.Count - index; i++)
                {
                    if (i < Character.Titles.Count - index - 1)
                    {
                        if (Character.Titles[i].titleType > Character.Titles[i + 1].titleType)
                        {
                            ITitle tempTitle = Character.Titles[i + 1];
                            Character.Titles[i + 1] = Character.Titles[i];
                            Character.Titles[i]     = tempTitle;
                        }
                    }
                }
                index++;

                if (index == Character.Titles.Count)
                {
                    return(Task.CompletedTask);
                }
            }
        }
Exemplo n.º 2
0
        public ITitle(int ID)
        {
            ITitle t = TitleCollection[ID];

            name      = t.name;
            reason    = t.reason;
            titleType = t.titleType;
            this.ID   = t.ID;
        }
Exemplo n.º 3
0
        public static void RemoveTile(Player player, ITitle title)
        {
            if (player.Character.ActiveTitle != null)
            {
                if (player.Character.ActiveTitle.name.Equals(title.name))
                {
                    player.Character.ActiveTitle = null;
                }
            }

            for (int i = 0; i < player.Character.Titles.Count; i++)
            {
                if (player.Character.Titles[i].name == title.name)
                {
                    player.Character.Titles.RemoveAt(i);
                    break;
                }
            }
        }
Exemplo n.º 4
0
        public static async Task Send(Player player, SendType type, string message = null, int reward = 0, ITitle title = null, QuestReport report = null)
        {
            if (type == SendType.Title)
            {
                if (!player.Character.Titles.Exists(x => x.ID == title.ID))
                {
                    player.Character.Titles.Add(title);
                    await player.SortTitles();
                }
                return;
            }

            if (Program.botType == Program.BotType.Experimental)
            {
                return;
            }

            bool found = false;

            foreach (SocketGuild guild in Program.client.Guilds)
            {
                if (found)
                {
                    break;
                }
                foreach (IGuildUser u in guild.Users)
                {
                    if (u.Id == player.User.UserID)
                    {
                        found = true;

                        string toReturn = "";

                        switch (type)
                        {
                        case SendType.LevelUp:
                            toReturn = $"```cs\nYou have just leveled up!\n{player.Character.Level - 1}->{player.Character.Level}```";
                            break;

                        case SendType.Work:
                            toReturn = $":pick: **You have completed your work and got**`{reward}`**gold** :pick:";
                            break;

                        case SendType.QuestCooldown:
                            toReturn = $":alarm_clock: **Your Quest cooldown is over** :alarm_clock:";
                            break;

                        case SendType.Quest:

                            if (report.SendQuestCompleted && !report.QuestFailed)
                            {
                                toReturn = $"```cs\nHello, you have completed your quest - {report.QuestName}\nHp: [ {player.Character.HP}/{player.Character.MAX_HP} ] - {report.LostHealthOnTrip}\nProtection: [ {report.TotalProtection}/{report.TotalProtectionMax}] - {report.TotalProtectionMax - report.TotalProtection}\nGold(+{report.ObtainedGold})\nXp(+{report.ObtainedXp})```";
                            }
                            else if (report.SendQuestCompleted && report.QuestFailed)
                            {
                                if (report.ObtainedXp > 0)
                                {
                                    toReturn = $"```cs\nHello, unfortunately your character has died on the quest - {report.QuestName}\nYou still managed to kill some monsters!\nGold(+{report.ObtainedGold})\nXp(+{report.ObtainedXp})```";
                                }
                                else
                                {
                                    toReturn = $"```cs\nHello, unfortunately your character has died on the quest - {report.QuestName}\nStrong advice - Improve your character first or wait for you character's health to replenish fully before going on this quest again.```";
                                }
                            }
                            break;

                        case SendType.Message:
                            toReturn = message;
                            break;
                        }

                        await u.SendMessageAsync(toReturn);

                        break;
                    }
                }
            }
        }
Exemplo n.º 5
0
        public async Task Update(Handler handler)
        {
            await ITitle.TitleRewarder(this, handler);

            if (Character.Stats.Work.isWorking)
            {
                Character.Stats.Work.workProgress++;
            }
            if (Character.Stats.Work.isWorking && Character.Stats.Work.workProgress == Character.Stats.Work.workToMake * 60)
            {
                int multiplier = 2;

                multiplier += (Character.Level / 15) * 2;

                int goldGained = Character.Level * multiplier * Character.Stats.Work.workToMake;
                if (Character.Titles.Exists(x => x.name == ITitle.Titles.Supporter.name))
                {
                    goldGained += goldGained / 5;
                }
                Character.Gold += goldGained;
                Character.Stats.Work.isWorking  = false;
                Character.Stats.Work.totalWork += Character.Stats.Work.workToMake;
                await SendMessage.Send(this, SendType.Work, reward : goldGained);
            }
            if (!Character.Stats.Quests.isInQuest && Character.Stats.Quests.questCooldown < 5)
            {
                Character.Stats.Quests.questCooldown++;
                if (Character.Stats.Quests.questCooldown == 5 && User.additionalAlertsOn)
                {
                    await SendMessage.Send(this, SendType.QuestCooldown);
                }
            }

            int    player_damage = Character.Gear.Sword.Damage + 1 + Character.Level;
            Random random        = new Random();
            Quest  quest         = Quest.getQuest(Program.handler, Character.Stats.Quests.questID);

            if (!Character.Stats.Quests.isInQuest && !Character.Stats.HP.dead)
            {
                Character.Stats.HP.hpRegenCounter++;
            }
            else
            {
                Character.Stats.HP.hpRegenCounter = 0;
            }

            //--------HP REGENERATION
            if (Character.Stats.HP.hpRegenCounter == 5)
            {
                if (!Character.Stats.Quests.isInQuest && !Character.Stats.HP.dead)
                {
                    if (Character.HP < Character.MAX_HP)
                    {
                        if (Character.HP + Character.Level > Character.MAX_HP)
                        {
                            Character.HP = Character.MAX_HP;
                        }
                        else
                        {
                            Character.HP += Character.Level;
                        }
                    }
                }

                Character.Stats.HP.hpRegenCounter = 0;
            }

            if (Character.HP > Character.MAX_HP)
            {
                Character.HP = Character.MAX_HP;
            }
            //QUEST_COMPLETED-check
            if (Character.Stats.Quests.isInQuest)
            {
                if (Character.Stats.Quests.minutesInQuest == quest.Duration)
                {
                    Character.Stats.Quests.minutesInQuest = 0;
                    Character.Stats.Quests.questCooldown  = 0;
                    Character.Stats.Quests.isInQuest      = false;
                    await Quest.OnCompleted(this, quest, handler);
                }
                Character.Stats.Quests.minutesInQuest++;
            }

            if (Character.HP < 0)
            {
                Character.HP = 0;
            }

            int totalProtection    = Character.Protection;
            int totalProtectionMax = totalProtection;

            if (Character.Stats.HP.dead && Character.Stats.HP.deathCooldown < 60)
            {
                Character.Stats.HP.deathCooldown++;
            }
            if (Character.Stats.HP.dead && Character.Stats.HP.deathCooldown == 60)
            {
                Character.Stats.HP.dead           = false;
                Character.Stats.HP.deathCooldown  = 0;
                Character.Stats.HP.hpRegenCounter = 0;
                Character.HP = Character.MAX_HP / 10;
            }
            if (Character.Stats.PvP.pvpCooldown != 0)
            {
                Character.Stats.PvP.pvpCooldown--;
            }

            if (Character.Stats.PvP.bountyTitleTimer > 0)
            {
                Character.Stats.PvP.bountyTitleTimer--;
            }
            if (Character.Stats.PvP.reasonlessKillTimer > 0)
            {
                Character.Stats.PvP.reasonlessKillTimer--;
            }
        }