Пример #1
0
        public void ShowTopMenu()
        {
            // build a menu of the different Blacksmithy Options
            //	i.e., Repair, Smelt Tools, Armor, Weapons
            List <Selection> temp = new List <Selection>();

            temp.Add(new Selection(new ItemListEntry("Tools", (int)TopMenuSelectionID.Tools, 0), (int)Context.TopMenu));
            temp.Add(new Selection(new ItemListEntry("Parts", (int)TopMenuSelectionID.Parts, 0), (int)Context.TopMenu));
            temp.Add(new Selection(new ItemListEntry("Utensils", (int)TopMenuSelectionID.Utensils, 0), (int)Context.TopMenu));
            temp.Add(new Selection(new ItemListEntry("Miscellaneous", (int)TopMenuSelectionID.Miscellaneous, 0), (int)Context.TopMenu));
            temp.Add(new Selection(new ItemListEntry("Jewelry", (int)TopMenuSelectionID.Jewelry, 0), (int)Context.TopMenu));

            #region MAKE LAST (turned off)
            // turn off make last since we cannot find any evidence that thie existed in-era
            if (false && Craft.From is Mobiles.PlayerMobile && (Craft.From as Mobiles.PlayerMobile).LastCraftObject is itemTable)
            {
                itemTable found             = (Craft.From as Mobiles.PlayerMobile).LastCraftObject as itemTable;
                bool      allRequiredSkills = false;
                if (found.CraftItem.GetSuccessChance(Craft.From, typeof(IronIngot), Craft.CraftSystem, false, ref allRequiredSkills) > 0.0 && allRequiredSkills)
                {                       // user can make this
                    temp.Add(new Selection(new ItemListEntry("Make Last Item", (int)TopMenuSelectionID.MakeLast, 0), (int)Context.TopMenu));
                }
            }
            #endregion

            Selection[] bsOptions = temp.ToArray();

            Craft.From.SendMenu(new ItemMenu(this, bsOptions, "What do you want to make?"));
        }
Пример #2
0
            public static itemTable Copy(itemTable[] table, int itemId)
            {
                itemTable f = Find(table, itemId);

                if (f == null)
                {
                    return(null);
                }

                // suitable for modification.
                return(new itemTable(f.ItemID, f.GroupName, f.ItemName, f.MinSkill, f.MaxSkill, f.TypeRes, f.NameRes, f.Amount, f.FailMessage, f.Name, f.TypeItem));
            }
Пример #3
0
        public void MakeItem(int itemID, itemTable[] table)
        {               // find the item we want to create
            itemTable temp = itemTable.Find(table, itemID);

            // save the item to make as our Last Item
            if (Craft.From is Mobiles.PlayerMobile)
            {
                (Craft.From as Mobiles.PlayerMobile).LastCraftObject = temp;
            }

            // recall the selected resource
            Type type = GetResource(itemID, table);

            // make it baby!
            temp.CraftItem.Craft(Craft.From, Craft.CraftSystem, type, Craft.Tool);
        }
Пример #4
0
        /// <summary>
        /// Gets the list of indexes into the item table of appropriate items
        /// </summary>
        /// <param name="list"></param>
        /// <param name="table"></param>
        /// <param name="context"></param>
        public void ShowItemMenu(int group, itemTable[] table, Context context)
        {
            // sort item tables on ingot cost - this is the order of display
            //Array.Sort<itemTable>(table, CompareItemsByIngotCostAndName);	// sort by ingot cost then name

            // filter the incoming list on abilility
            List <Selection> selections = new List <Selection>();

            for (int ix = 0; ix < table.Length; ix++)
            {
                itemTable found = table[ix];

                // is it in the right gropup?
                if (found.GroupName == group)
                {
                    // just check and see if they have the resources
                    int resHue = 0; int maxAmount = 0; object message = null;
                    if (!found.CraftItem.ConsumeRes(Craft.From, GetResource(found.ItemID, table), Craft.CraftSystem, ref resHue, ref maxAmount, ConsumeType.None, ref message))
                    {
                        continue;
                    }

                    // can the user make this?
                    bool allRequiredSkills = false;
                    if (found.CraftItem.GetSuccessChance(Craft.From, typeof(IronIngot), Craft.CraftSystem, false, ref allRequiredSkills) > 0.0 && allRequiredSkills)
                    {
                        selections.Add(new Selection(new ItemListEntry(String.Format("{0}: {1} {2}", found.Name, found.Amount, "Ingots"), found.ItemID), (int)context));
                    }
                }
            }

            Selection[] Options = selections.ToArray();

            // build a menu of the different armor Options
            //	i.e., gloves, leggings, sleeves, etc.
            if (Options.Length > 0)
            {
                Craft.From.SendMenu(new ItemMenu(this, Options, "What do you want to make?"));
            }
            else
            {
                Craft.From.SendLocalizedMessage(500586);                        // You do not have enough skill or resources to build anything!
            }
        }
Пример #5
0
        private static int CompareItemsByIngotCostAndName(itemTable x, itemTable y)
        {
            if (x == null)
            {
                if (y == null)
                {
                    // If x is null and y is null, they're
                    // equal.
                    return(0);
                }
                else
                {
                    // If x is null and y is not null, y
                    // is greater.
                    return(-1);
                }
            }
            else
            {
                // If x is not null...
                //
                if (y == null)
                // ...and y is null, x is greater.
                {
                    return(1);
                }
                else
                {
                    // ...and y is not null, compare the
                    // lengths of the two strings.
                    //
                    int retval = x.Amount.CompareTo(y.Amount);

                    if (retval != 0)
                    {
                        return(retval);
                    }

                    // secondary sort on name
                    return((x.Name as string).CompareTo(y.Name as string));
                }
            }
        }
Пример #6
0
        public Type GetResource(int itemID, itemTable[] table)
        {
            itemTable temp = itemTable.Find(table, itemID);

            // recall the selected resource
            CraftContext context = Craft.CraftSystem.GetContext(Craft.From);
            Type         type    = null;

            if (context != null)
            {
                CraftSubResCol res      = (temp.CraftItem.UseSubRes2 ? Craft.CraftSystem.CraftSubRes2 : Craft.CraftSystem.CraftSubRes);
                int            resIndex = (temp.CraftItem.UseSubRes2 ? context.LastResourceIndex2 : context.LastResourceIndex);

                if (resIndex > -1)
                {
                    type = res.GetAt(resIndex).ItemType;
                }
            }

            return(type);
        }
Пример #7
0
        public void HandleTopMenu(int operation)
        {
            int prompt = 0;

            switch ((TopMenuSelectionID)operation)
            {
            case TopMenuSelectionID.Tools:
                //prompt = 1044276;	// Target an item to repair.
                DoToolsClassMenu(null);
                //break;
                return;

            case TopMenuSelectionID.Parts:
                prompt = 1044273;                               // Target an item to recycle.
                break;

            case TopMenuSelectionID.Utensils:
            case TopMenuSelectionID.Miscellaneous:
            case TopMenuSelectionID.Jewelry:
                prompt = 502928;                                // What materials would you like to work with?
                break;

            case TopMenuSelectionID.MakeLast:
                itemTable found = (Craft.From as Mobiles.PlayerMobile).LastCraftObject as itemTable;
                if (found is itemTable)
                {
                    itemTable[] table = GetGroupTable(found.GroupName);
                    if (table is itemTable[])
                    {
                        MakeItem(found.ItemID, table);
                        return;
                    }
                }
                return;
            }
            Craft.From.SendLocalizedMessage(prompt);
            Craft.From.Target = new ItemTarget(this, (int)Context.PickResource, (int)operation);
        }
Пример #8
0
 private static int CompareItemsByGroup(itemTable x, itemTable y)
 {
     if (x == null)
     {
         if (y == null)
         {
             // If x is null and y is null, they're
             // equal.
             return(0);
         }
         else
         {
             // If x is null and y is not null, y
             // is greater.
             return(-1);
         }
     }
     else
     {
         // If x is not null...
         //
         if (y == null)
         // ...and y is null, x is greater.
         {
             return(1);
         }
         else
         {
             // ...and y is not null, compare the
             // lengths of the two strings.
             //
             int retval = x.GroupName.CompareTo(y.GroupName);
             return(retval);
         }
     }
 }
        public void HandleTopMenu(int operation)
        {
            int prompt = 0;

            switch ((TopMenuSelectionID)operation)
            {
            case TopMenuSelectionID.Repair:
                prompt = 1044276;                               // Target an item to repair.
                break;

            case TopMenuSelectionID.Smelt:
                prompt = 1044273;                               // Target an item to recycle.
                break;

            case TopMenuSelectionID.Armor:
            case TopMenuSelectionID.Shields:
            case TopMenuSelectionID.Weapons:
                prompt = 502928;                                // What materials would you like to work with?
                break;

            case TopMenuSelectionID.MakeLast:
                itemTable found = (Craft.From as Mobiles.PlayerMobile).LastCraftObject as itemTable;
                if (found is itemTable)
                {
                    itemTable[] table = GetGroupTable(found.GroupName);
                    if (table is itemTable[])
                    {
                        MakeItem(found.ItemID, table);
                        return;
                    }
                }
                return;
            }
            Craft.From.SendLocalizedMessage(prompt);
            Craft.From.Target = new ItemTarget(this, (int)Context.PickResource, (int)operation);
        }