Esempio n. 1
0
        protected override void GetDisplayContent(ChannelLink link, out List <Tuple <string, DiscordEmbed> > tagAndContent)
        {
            tagAndContent = new List <Tuple <string, DiscordEmbed> >();
            DiscordEmbedBuilder builder = new DiscordEmbedBuilder();

            builder.WithColor(MessageBuilder.EmbedColor);
            foreach (Election election in ElectionManager.Obj.CurrentElections.Where(x => x.Valid() && x.State == Shared.Items.ProposableState.Active))
            {
                string tag = BaseTag + " [" + election.Id + "]";
                builder.WithTitle(election.Name);

                // Proposer name
                builder.AddField("Proposer", election.Creator.Name);

                // Time left
                builder.AddField("Time Left", TimeFormatter.FormatSpan(election.TimeLeft));

                // Process
                builder.AddField("Process", election.Process.Name);

                // Choices
                if (!election.BooleanElection && election.Choices.Count > 0)
                {
                    string choiceDesc = string.Empty;
                    foreach (ElectionChoice choice in election.Choices)
                    {
                        choiceDesc += choice.Name + "\n";
                    }
                    builder.AddField("Choices", choiceDesc);
                }

                // Votes
                string voteDesc = string.Empty;
                foreach (RunoffVote vote in election.Votes)
                {
                    string topChoiceName = null;
                    int    topChoiceID   = vote.RankedVotes.FirstOrDefault();
                    foreach (ElectionChoice choice in election.Choices)
                    {
                        if (choice.ID == topChoiceID)
                        {
                            topChoiceName = choice.Name;
                            break;
                        }
                    }
                    voteDesc += vote.Voter.Name + ": " + topChoiceName + "\n";
                }
                if (string.IsNullOrEmpty(voteDesc))
                {
                    voteDesc = "--- No Votes Recorded ---";
                }
                builder.AddField("Votes (" + election.TotalVotes + ")", voteDesc);

                if (builder.Fields.Count > 0)
                {
                    tagAndContent.Add(new Tuple <string, DiscordEmbed>(tag, builder.Build()));
                }
                builder.ClearFields();
            }
        }
Esempio n. 2
0
        public static void Avatarcmd(User user, string playername = "")
        {
            Player targetplayer;
            User   targetuser;

            if (playername == "")
            {
                targetplayer = user.Player;
                targetuser   = user;
            }
            else
            {
                targetuser = UserManager.FindUserByName(playername);
                if (targetuser == null)
                {
                    user.Player.SendTemporaryErrorAlreadyLocalized("Player " + playername + " not found!");
                    return;
                }
                targetplayer = targetuser.Player;
            }

            string newline        = "<br>";
            string title          = "Stats for " + targetuser.Name;
            string skillsheadline = "<b>SKILLRATES:</b>" + newline;
            string housinginfo;
            string foodinfo;
            string totalsp;
            string onlineinfo;
            string superskillsinfo = string.Empty;
            string professioninfo;
            string currencyinfo = "<b>CURRENCIES:</b>" + newline;
            string propertyinfo;
            string admininfo = string.Empty;

            if (targetuser.IsAdmin)
            {
                admininfo = "<color=red><b>ADMIN</b></color> ";
            }


            /* old currencies (pre bank accounts)
             * foreach (Currency currency in EconomyManager.Currency.Currencies)
             * {
             *  if (currency.HasAccount(targetuser.Name))
             *  {
             *      if (currency.GetAccount(targetuser.Name).Val > 0f)
             *      {
             *          currencyinfo += currency.UILink(currency.GetAccount(targetuser.Name).Val) + newline;
             *      }
             *  }
             * }
             */
            foreach (BankAccount account in BankAccountManager.Obj.AccessibleAccounts(targetplayer))  //not yet working as expected
            {
                currencyinfo += account.UILink() + newline;
            }


            /* no superskills atm
             * List<Skill> superskills = SkillUtils.GetSuperSkills(targetuser);
             * if (superskills.Count > 0)
             * {
             *  superskillsinfo = "<b>SUPERSKILLS:</b>" + newline;
             *  foreach (Skill skill in superskills)
             *  {
             *      superskillsinfo += skill.UILink() + newline;
             *  }
             *  superskillsinfo += newline;
             * }
             */

            float foodsp  = targetuser.Stomach.NutrientSkillRate;
            float housesp = targetuser.CachedHouseValue.HousingSkillRate;

            professioninfo = newline + "<b>PROFESSION:</b> " + newline + SkillUtils.FindProfession(targetuser).UILink() + newline;
            housinginfo    = "House SP: " + targetuser.CachedHouseValue.UILink() + newline;
            foodinfo       = "Food SP: " + Math.Round(foodsp, 2) + newline;
            totalsp        = "Total SP: " + Math.Round(housesp + foodsp, 2) + newline;
            propertyinfo   = "<b>PROPERTY:</b>" + newline + MiscUtils.CountPlots(targetuser) * 25 + " sqm of land." + newline;
            onlineinfo     = targetuser.LoggedIn ? "is online. Located at " + new Vector3Tooltip(targetuser.Position).UILink() : "is offline. Last online " + TimeFormatter.FormatSpan(WorldTime.Seconds - targetuser.LogoutTime) + " ago";
            onlineinfo    += newline;

            user.Player.OpenInfoPanel(title, admininfo + targetuser.UILink() + " " + onlineinfo + newline + skillsheadline + foodinfo + housinginfo + totalsp + professioninfo + newline + propertyinfo + newline + superskillsinfo + currencyinfo);
        }
Esempio n. 3
0
        public static async void UnclaimPlayerAsync(User user, User owner = null)
        {
            bool   inactive  = true;
            bool   confirmed = false;
            double inactivetime;

            if (!user.IsAdmin && !user.GetState <bool>("Moderator"))//admin/mod only
            {
                ChatUtils.SendMessage(user, "Not Authorized to use this command!");
                return;
            }

            if (owner == null)
            {
                if (PropertyManager.GetPlot(user.Position.XZi) != null)
                {
                    owner = PropertyManager.GetPlot(user.Position.XZi).Owner;
                }
            }

            if (owner == null)
            {
                user.Player.SendTemporaryMessageAlreadyLocalized("Plot not owned");
                return;
            }

            inactivetime = (WorldTime.Seconds - owner.LogoutTime);
            if (inactivetime < REYmodSettings.Obj.Config.Maxinactivetime * 3600)
            {
                inactive = false;
            }
            if (owner.LoggedIn)
            {
                inactivetime = 0;
            }

            IEnumerable <Deed> allDeeds    = PropertyManager.GetAllDeeds();
            IEnumerable <Deed> targetDeeds = allDeeds.Where(x => x.OwnerUser == owner);
            int ownedplots    = PropertyManager.PropertyForUser(owner).Count();
            int ownedvehicles = targetDeeds.Sum(x => x.OwnedObjects.Count) - ownedplots;

            string textbox = "";

            textbox += "You are going to unclaim all property of " + owner.UILink() + "<br>";
            textbox += "Owned Plots: " + ownedplots + "<br>";
            textbox += "Owned Vehicles: " + ownedvehicles + "<br>";
            textbox += "<br>Player offline for " + TimeFormatter.FormatSpan(inactivetime);
            if (!inactive)
            {
                textbox += "<br>WARNING! Player not inactive!".Color("red");
            }
            textbox += "<br><br>";
            if (!inactive && !user.IsAdmin)
            {
                textbox += "<b><color=red>You can't unclaim this player! Not inactive for long enough.</color></b>";
                user.Player.PopupOKBoxLoc(Localizer.DoStr(textbox));
                return;
            }
            else
            {
                //  textbox += new Button(x => { MiscUtils.UnclaimUser(owner, user); IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime)); }, "", "Click here to unclaim all property of " + owner.UILink(), "Confirm Unclaiming".Color("green")).UILink();
                FormattableString textboxformattable = FormattableStringFactory.Create(textbox);
                confirmed = await user.Player.PopupConfirmBoxLoc(textboxformattable);
            }

            if (confirmed)
            {
                MiscUtils.UnclaimUser(owner, user);
                IOUtils.WriteCommandLog(user, "UnclaimUser", "Unclaimed " + owner.Name + " (" + ownedplots + " plots/" + ownedvehicles + " vehicles)" + "Inactive for " + TimeFormatter.FormatSpan(inactivetime));
            }


            //user.Player.OpenInfoPanel("Unclaim Player", textbox);
        }
        protected override void GetDisplayContent(DiscordTarget target, out List <Tuple <string, DiscordLinkEmbed> > tagAndContent)
        {
            tagAndContent = new List <Tuple <string, DiscordLinkEmbed> >();
            DiscordLinkEmbed embed = new DiscordLinkEmbed();

            embed.WithFooter(MessageBuilder.Discord.GetStandardEmbedFooter());
            foreach (Election election in EcoUtil.ActiveElections)
            {
                string tag = $"{BaseTag} [{election.Id}]";
                embed.WithTitle(MessageUtil.StripTags(election.Name));

                // Proposer name
                embed.AddField("Proposer", election.Creator.Name);

                // Time left
                embed.AddField("Time Left", TimeFormatter.FormatSpan(election.TimeLeft));

                // Process
                embed.AddField("Process", MessageUtil.StripTags(election.Process.Name));

                // Choices
                if (!election.BooleanElection && election.Choices.Count > 0)
                {
                    string choiceDesc = string.Empty;
                    foreach (ElectionChoice choice in election.Choices)
                    {
                        choiceDesc += $"{choice.Name}\n";
                    }
                    embed.AddField("Choices", choiceDesc);
                }

                // Votes
                string voteDesc = string.Empty;
                if (!election.Process.AnonymousVoting)
                {
                    foreach (RunoffVote vote in election.Votes)
                    {
                        string topChoiceName = null;
                        int    topChoiceID   = vote.RankedVotes.FirstOrDefault();
                        foreach (ElectionChoice choice in election.Choices)
                        {
                            if (choice.ID == topChoiceID)
                            {
                                topChoiceName = choice.Name;
                                break;
                            }
                        }
                        voteDesc += $"{vote.Voter.Name} : {topChoiceName}\n";
                    }
                }
                else
                {
                    voteDesc = "--- Anonymous Voting ---";
                }

                if (string.IsNullOrEmpty(voteDesc))
                {
                    voteDesc = "--- No Votes Recorded ---";
                }

                embed.AddField($"Votes ({election.TotalVotes})", voteDesc);

                if (embed.Fields.Count > 0)
                {
                    tagAndContent.Add(new Tuple <string, DiscordLinkEmbed>(tag, new DiscordLinkEmbed(embed)));
                }

                embed.ClearFields();
            }
        }