Пример #1
0
        void OnClaimUpkeepCommand(User user)
        {
            if (!Options.Upkeep.Enabled)
            {
                user.SendChatMessage(Messages.UpkeepDisabled);
                return;
            }

            Faction faction = Factions.GetByMember(user);

            if (faction == null)
            {
                user.SendChatMessage(Messages.NotMemberOfFaction);
                return;
            }

            if (faction.MemberCount < Options.Claims.MinFactionMembers)
            {
                user.SendChatMessage(Messages.FactionTooSmallToOwnLand, Options.Claims.MinFactionMembers);
                return;
            }

            Area[] areas = Areas.GetAllClaimedByFaction(faction);

            if (areas.Length == 0)
            {
                user.SendChatMessage(Messages.NoAreasClaimed);
                return;
            }

            int upkeep           = faction.GetUpkeepPerPeriod();
            var nextPaymentHours = (int)faction.NextUpkeepPaymentTime.Subtract(DateTime.UtcNow).TotalHours;

            if (nextPaymentHours > 0)
            {
                user.SendChatMessage(Messages.UpkeepCost, upkeep, areas.Length, faction.Id, nextPaymentHours);
            }
            else
            {
                user.SendChatMessage(Messages.UpkeepCostOverdue, upkeep, areas.Length, faction.Id, nextPaymentHours);
            }
        }
Пример #2
0
        void OnClaimListCommand(User user, string[] args)
        {
            if (args.Length != 1)
            {
                user.SendChatMessage(Messages.Usage, "/claim list FACTION");
                return;
            }

            string  factionId = Util.NormalizeFactionId(args[0]);
            Faction faction   = Factions.Get(factionId);

            if (faction == null)
            {
                user.SendChatMessage(Messages.FactionDoesNotExist, factionId);
                return;
            }

            Area[] areas        = Areas.GetAllClaimedByFaction(faction);
            Area   headquarters = areas.FirstOrDefault(a => a.Type == AreaType.Headquarters);

            var sb = new StringBuilder();

            if (areas.Length == 0)
            {
                sb.AppendFormat(String.Format("<color=#ffd479>[{0}]</color> has no land holdings.", factionId));
            }
            else
            {
                float percentageOfMap = (areas.Length / (float)Areas.Count) * 100;
                sb.AppendLine(String.Format("<color=#ffd479>[{0}] owns {1} tiles ({2:F2}% of the known world)</color>", faction.Id, areas.Length, percentageOfMap));
                sb.AppendLine(String.Format("Headquarters: {0}", (headquarters == null) ? "Unknown" : headquarters.Id));
                sb.AppendLine(String.Format("Areas claimed: {0}", Util.Format(areas)));
            }

            user.SendChatMessage(sb);
        }