コード例 #1
0
            protected override void OnTarget(Mobile from, object targ)
            {
                if (!(targ is Item))
                {
                    from.SendMessage("You can only create rares from items.");
                    return;
                }

                // Create the rare from the item
                RareFactory.AddRare((Item)targ);

                // Give it a name! Viewing DOD will be the one we're after now
                from.SendMessage("Enter the name you wish to use to represent the rare :");
                from.Prompt = new RareNamePrompt(from, RareFactory.ViewingDOD);
            }
コード例 #2
0
            public override void Execute(CommandEventArgs e, object obj)
            {
                try
                {
                    Item item = obj as Item;

                    if (!RareFactory.InUse)
                    {
                        if (e.Arguments.Length == 4)
                        {
                            int iRarity = 0;
                            if (int.TryParse(e.Arguments[1], out iRarity) == true && iRarity >= 0 && iRarity <= 10)
                            {
                                DODGroup match;
                                if ((match = FindGroup(e.Arguments[0], iRarity)) != null)
                                {
                                    int iStartIndex = 0;
                                    if (int.TryParse(e.Arguments[2], out iStartIndex) == true && iStartIndex > 0 && iStartIndex <= 255)
                                    {
                                        int iLastIndex = 0;
                                        if (int.TryParse(e.Arguments[3], out iLastIndex) == true && iLastIndex > 0 && iLastIndex <= 255)
                                        {
                                            if (item != null)
                                            {
                                                LogHelper Logger = null;
                                                try
                                                {
                                                    DODInstance di = RareFactory.AddRare(match, item);    // rarity is defined by the group
                                                    di.LastIndex  = (short)iLastIndex;
                                                    di.StartIndex = (short)iStartIndex;
                                                    di.StartDate  = DateTime.MinValue;  // valid now
                                                    di.EndDate    = DateTime.MaxValue;  // valid forever

                                                    // default the name to the name of the item
                                                    if (item.Name != null && item.Name != "")
                                                    {
                                                        di.Name = item.Name;
                                                    }
                                                    else
                                                    {
                                                        di.Name = item.GetType().Name;
                                                    }

                                                    AddResponse("Sucessfully defined new rare '" + di.Name + "'!");
                                                }
                                                catch (Exception ex)
                                                {
                                                    LogHelper.LogException(ex);
                                                    e.Mobile.SendMessage(ex.Message);
                                                }
                                                finally
                                                {
                                                    if (Logger != null)
                                                    {
                                                        Logger.Finish();
                                                    }
                                                }
                                            }
                                            else
                                            {
                                                LogFailure("Only an item may be converted into a rare.");
                                            }
                                        }
                                        else
                                        {
                                            LogFailure("The LastIndex must be a numeric value between 1 and 255 inclusive.");
                                        }
                                    }
                                    else
                                    {
                                        LogFailure("The StartIndex must be a numeric value between 1 and 255 inclusive.");
                                    }
                                }
                                else
                                {
                                    LogFailure(String.Format("Could not find the group \"{0}\" with a rarity of {1}", e.Arguments[0], iRarity));
                                }
                            }
                            else
                            {
                                LogFailure("The rarity must be a numeric value between 0 and 10 inclusive.");
                            }
                        }
                        else
                        {
                            LogFailure("AddRare sGroup iRarity iStartIndex iLastIndex");
                        }
                    }
                    else
                    {
                        LogFailure("Rare Factory is currently being configured by another administrator! Please wait. ");
                    }
                }
                catch (Exception exe)
                {
                    LogHelper.LogException(exe);
                    e.Mobile.SendMessage(exe.Message);
                }
            }