Beispiel #1
0
        /// <summary> Returns a summarised form of the player's awards </summary>
        /// <returns> [number of awards player has] / [number of awards] (% of total) </returns>
        public static string Summarise(string player)
        {
            int           total  = AwardsList.Awards.Count;
            List <string> awards = Get(player);

            if (awards == null || total == 0)
            {
                return("0/" + total + " (0%)");
            }

            // Some awards the player has may have been deleted
            int count = 0;

            for (int i = 0; i < awards.Count; i++)
            {
                if (AwardsList.Exists(awards[i]))
                {
                    count++;
                }
            }

            double percentHas = Math.Round(((double)count / total) * 100, 2);

            return(count + "/" + total + " (" + percentHas + "%)");
        }
Beispiel #2
0
        public override void Use(Player p, string message, CommandData data)
        {
            string[] args = message.SplitSpaces(2);
            if (args.Length < 2)
            {
                Help(p); return;
            }

            if (IsCreateCommand(args[0]))
            {
                args = args[1].Split(awardArgs, 2);
                if (args.Length == 1)
                {
                    p.Message("&WUse a : to separate the award name from its description.");
                    Help(p); return;
                }

                string award = args[0].Trim();
                string desc  = args[1].Trim();

                if (!AwardsList.Add(award, desc))
                {
                    p.Message("This award already exists."); return;
                }
                else
                {
                    Chat.MessageGlobal("Award added: &6{0} : {1}", award, desc);
                    AwardsList.Save();
                }
            }
            else if (IsDeleteCommand(args[0]))
            {
                if (!AwardsList.Remove(args[1]))
                {
                    p.Message("This award does not exist."); return;
                }
                else
                {
                    Chat.MessageGlobal("Award removed: &6{0}", args[1]);
                    AwardsList.Save();
                }
            }
            else
            {
                Help(p);
            }
        }