示例#1
0
        /*private static void CMConfig()
         * {
         *  SetEvents();
         * }
         *
         * private static void CMEnabled()
         * {
         *  SetEvents();
         * }
         *
         * private static void CMDisabled()
         * {
         *  UnsetEvents();
         * }*/

        private static void CMInvoke()
        {
            CommandUtility.Register(
                "Conquests",
                AccessLevel.Player,
                e =>
            {
                if (!CMOptions.ModuleEnabled && e.Mobile.AccessLevel < Access)
                {
                    e.Mobile.SendMessage(0x22, "Conquests are currently unavailable.");
                    return;
                }

                if (e.Mobile is PlayerMobile)
                {
                    SendConquestsGump((PlayerMobile)e.Mobile);
                }
            });

            CommandUtility.Register(
                "ConsolidateConquests",
                AccessLevel.Developer,
                e =>
            {
                if (!CMOptions.ModuleEnabled && e.Mobile.AccessLevel < Access)
                {
                    e.Mobile.SendMessage(0x22, "Conquests are currently unavailable.");
                    return;
                }

                if (e.Mobile is PlayerMobile)
                {
                    ConsolidateConquests();
                }
            });

            CommandUtility.Register(
                "CheckAccountsConquests",
                AccessLevel.Developer,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }
                foreach (PlayerMobile player in Profiles.Keys)
                {
                    IAccount account = player.Account;
                    foreach (PlayerMobile checkplayer in Profiles.Keys)
                    {
                        if (player != checkplayer)
                        {
                            IAccount checkaccount = checkplayer.Account;
                            if (account == checkaccount)
                            {
                                e.Mobile.SendMessage(54, "THIS SHOULDN'T HAPPEN");
                            }
                        }
                    }
                }
            });

            CommandUtility.Register(
                "PruneConquests",
                AccessLevel.Developer,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }
                PruneConquestProfiles();
            });

            //Removed until we can get VNC lists to handle large amounts of entries

            /*
             *          CommandUtility.Register(
             *                  "ConquestProfiles",
             *                  Access,
             *                  e =>
             *                  {
             *                          if (!CMOptions.ModuleEnabled && e.Mobile.AccessLevel < Access)
             *                          {
             *                                  e.Mobile.SendMessage(0x22, "Conquests are currently unavailable.");
             *                                  return;
             *                          }
             *
             *                          if (e.Mobile is PlayerMobile)
             *                          {
             *                                  SendConquestProfilesGump((PlayerMobile)e.Mobile);
             *                          }
             *                  });
             */

            CommandUtility.Register(
                "ConquestAdmin",
                Access,
                e =>
            {
                if (e.Mobile is PlayerMobile)
                {
                    SendConquestAdminGump((PlayerMobile)e.Mobile);
                }
            });

            CommandUtility.Register(
                "IncreaseConquestState",
                AccessLevel.Developer,
                e =>
            {
                if (!(e.Mobile is PlayerMobile))
                {
                    return;
                }

                if (e.Arguments.Length < 2)
                {
                    e.Mobile.SendMessage(0x22, "Format: <PlayerName> <ConquestName> <Amount>");
                    return;
                }

                string name     = e.Arguments[0];
                string conquest = e.Arguments[1];
                int value;

                if (!Int32.TryParse(e.Arguments[2], out value))
                {
                    e.Mobile.SendMessage(0x22, "Format: <PlayerName> <ConquestName> <Amount>");
                    return;
                }

                if (e.Arguments.Length > 3)
                {
                    e.Mobile.SendMessage(0x22, "Format: <PlayerName> <ConquestName> <Amount>");
                    return;
                }

                Mobile mobile =
                    World.Mobiles.Values.FirstOrDefault(x => x.RawName == name && x is PlayerMobile);
                if (mobile is PlayerMobile)
                {
                    ConquestProfile profile = EnsureProfile(mobile as PlayerMobile);
                    ConquestState state;
                    if (profile.TryGetState(ConquestRegistry.Values.FirstOrDefault(x => x.Name == conquest),
                                            out state))
                    {
                        state.Progress += value;
                    }
                }
            });
        }
示例#2
0
        public virtual void GiveRewards(ConquestState s)
        {
            if (!Enabled || Deleted || s == null || s.Conquest != this || s.User == null)
            {
                return;
            }

            if (AccountBound)
            {
                var account = s.User.Account as Account;

                if (account == null)
                {
                    return;
                }

                string tag = account.GetTag(TagKey);

                if (!String.IsNullOrWhiteSpace(tag))
                {
                    return;
                }

                // Look for all players in the account that aren't the owner of the current conquest state.
                for (int i = 0; i < account.Length; i++)
                {
                    var pm = account[i] as PlayerMobile;

                    if (pm == null || pm == s.User)
                    {
                        continue;
                    }

                    ConquestProfile prof = Conquests.EnsureProfile(pm);

                    ConquestState state;

                    if (!prof.TryGetState(this, out state) || state == null || state == s || !state.Completed)
                    {
                        continue;
                    }

                    account.SetTag(TagKey, state.CompletedDate.ToSimpleString("t@h:m@ d-m-y"));
                    return;                     // get outta here, no rewards!
                }

                account.SetTag(TagKey, s.CompletedDate.ToSimpleString("t@h:m@ d-m-y"));
            }
            else
            {
                var account = s.User.Account as Account;

                if (account != null)
                {
                    account.RemoveTag(TagKey);                     // Remove the tag, just in case it was bound previously but isn't now.
                }
            }

            InvalidateRewardInfo();

            if (Rewards.Count == 0)
            {
                return;
            }

            var rewards     = new List <IEntity>();
            var attachments = new List <IXmlAttachment>();

            Rewards.ForEach(
                type =>
            {
                if (type == null)
                {
                    return;
                }

                int count = ScaleRewards ? s.Tier : 1;

                while (--count >= 0)
                {
                    var reward = type.CreateInstanceSafe <object>();

                    if (reward is Item)
                    {
                        var rewardItem = (Item)reward;

                        if (!OnBeforeGiveReward(s, rewardItem))
                        {
                            rewardItem.Delete();
                            return;
                        }

                        OnGiveReward(s, rewardItem);

                        if (!rewardItem.Deleted)
                        {
                            rewards.Add(rewardItem);
                        }
                    }
                    else if (reward is BaseCreature)
                    {
                        var rewardCreature = (BaseCreature)reward;

                        if (!OnBeforeGiveReward(s, rewardCreature))
                        {
                            rewardCreature.Delete();
                            return;
                        }

                        OnGiveReward(s, rewardCreature);

                        if (!rewardCreature.Deleted)
                        {
                            rewards.Add(rewardCreature);
                        }
                    }
                    else if (reward is Mobile)
                    {
                        var rewardMobile = (Mobile)reward;

                        if (!OnBeforeGiveReward(s, rewardMobile))
                        {
                            rewardMobile.Delete();
                            return;
                        }

                        OnGiveReward(s, rewardMobile);

                        if (!rewardMobile.Deleted)
                        {
                            rewards.Add(rewardMobile);
                        }
                    }
                    else if (reward is XmlAttachment)
                    {
                        var a = (XmlAttachment)reward;

                        if (!OnBeforeGiveReward(s, a))
                        {
                            a.Delete();
                            return;
                        }

                        OnGiveReward(s, a);

                        if (!a.Deleted)
                        {
                            attachments.Add(a);
                        }
                    }
                }
            });

            OnRewarded(s, rewards, attachments, true);
        }