Esempio n. 1
0
        public double GetSuccessChance(Mobile from, Type typeRes, CraftSystem craftSystem, bool gainSkills,
                                       ref bool allRequiredSkills)
        {
            double minMainSkill = 0.0;
            double maxMainSkill = 0.0;
            double valMainSkill = 0.0;

            allRequiredSkills = true;

            for (int i = 0; i < m_arCraftSkill.Count; i++)
            {
                CraftSkill craftSkill = m_arCraftSkill.GetAt(i);

                double minSkill = craftSkill.MinSkill;
                double maxSkill = craftSkill.MaxSkill;
                double valSkill = from.Skills[craftSkill.SkillToMake].Value;

                if (valSkill < minSkill)
                {
                    allRequiredSkills = false;
                }

                if (craftSkill.SkillToMake == craftSystem.MainSkill)
                {
                    minMainSkill = minSkill;
                    maxMainSkill = maxSkill;
                    valMainSkill = valSkill;
                }

                if (gainSkills) // This is a passive check. Success chance is entirely dependant on the main skill
                {
                    from.CheckSkill(craftSkill.SkillToMake, minSkill, maxSkill);
                }
            }

            double chance;

            if (allRequiredSkills)
            {
                chance = craftSystem.GetChanceAtMin(this) + (valMainSkill - minMainSkill) /
                         (maxMainSkill - minMainSkill) * (1.0 - craftSystem.GetChanceAtMin(this));
            }
            else
            {
                chance = 0.0;
            }

            if (allRequiredSkills && valMainSkill == maxMainSkill)
            {
                chance = 1.0;
            }

            return(chance);
        }
Esempio n. 2
0
 public void Add(CraftSkill craftSkill)
 {
     List.Add(craftSkill);
 }
Esempio n. 3
0
        public void OnBlueprintPotentiallyChanged( )
        {
            Debug.Log("Blueprint potentially changed");
            //set blueprint to null in case we don't find a new one
            Blueprint = null;
            //generate a pattern based on the arrangement of items
            //use that pattern to look up potential matches
            //use the blueprints skill to find a real match
            int pattern = 0;

            for (int i = 0; i < mPatternSquares.Count; i++)
            {
                if (mPatternSquares[i].Stack.HasTopItem)
                {
                    pattern |= 1 << i;
                }
            }
            mPotentialMatches.Clear();
            int numCraftableItems = 0;

            if (Blueprints.Get.BlueprintsByPattern(pattern, mPotentialMatches))
            {
                Blueprint = null;
                //we've found some potential matches
                //see if any actually match
                for (int i = 0; i < mPotentialMatches.Count; i++)
                {
                    WIBlueprint potentialMatch = mPotentialMatches[i];
                    bool        matches        = true;
                    Debug.Log("Checking potential match " + potentialMatch.Name);
                    //check each square
                    for (int s = 0; s < mPatternSquares.Count; s++)
                    {
                        //we only have to check squares that aren't null
                        //if they're null the pattern has ruled them out already
                        if (mPatternSquares[s].HasStack && mPatternSquares[s].Stack.HasTopItem)
                        {
                            //here we perform an actual strictness check
                            //if we blow it, it doesn't match
                            //just pass '1' to the requirements
                            if (!CraftSkill.AreRequirementsMet(
                                    mPatternSquares[s].Stack.TopItem,
                                    potentialMatch.Rows[s],
                                    potentialMatch.Strictness,
                                    mPatternSquares[s].Stack.NumItems,
                                    out numCraftableItems))
                            {
                                matches = false;
                                break;
                            }
                        }
                    }

                    if (matches)
                    {
                        Debug.Log("MATCH! setting blueprint to " + potentialMatch.Name);
                        //hooray, we're done
                        OnSelectBlueprint(potentialMatch);
                        break;
                    }
                }
            }
            else
            {
                //if we didn't find ANY blueprints that match
                //just clear the blueprint
                RefreshRequest();
            }
        }
Esempio n. 4
0
        public void AddSkill(SkillName skillToMake, double minSkill, double maxSkill)
        {
            CraftSkill craftSkill = new CraftSkill(skillToMake, minSkill, maxSkill);

            m_arCraftSkill.Add(craftSkill);
        }
Esempio n. 5
0
		public void Add( CraftSkill craftSkill )
		{
			List.Add( craftSkill );
		}