예제 #1
0
        internal bool addSkill(string name, Dictionary <string, TMUsedInfo> values)
        {
            SkillSettings.DoTell("Key (name): " + name);
            IEnumerator ie = values.GetEnumerator();

            while (ie.MoveNext())
            {
                TMUsedInfo ui = ((KeyValuePair <string, TMUsedInfo>)ie.Current).Value;
                SkillSettings.DoTell(" - values: " + ui.SkillName + " val: " + ui.SkillValue);
            }
            if (SelectedSkills.ContainsKey(name))
            {
                SkillSettings.DoTell("Key in dictionary. " + name + " Current sum: " + getCurrentSum(name));
                totalSelectedPoints = revaluePoints(name);
                SelectedSkills.Remove(name);
            }
            SkillSettings.DoTell("Pre count: " + SelectedSkills.Count);
            SelectedSkills.Add(name, values);
            SkillSettings.DoTell("Current count: " + SelectedSkills.Count);
            Dictionary <string, TMUsedInfo> info = SelectedSkills[name];

            ie = info.GetEnumerator();
            while (ie.MoveNext())
            {
                TMUsedInfo ui = ((KeyValuePair <string, TMUsedInfo>)ie.Current).Value;
                SkillSettings.DoTell(" - info: " + ui.SkillName + " val: " + ui.SkillValue);
            }
            return(!verifyEntries(name));
        }
예제 #2
0
        private bool checkCaps()
        {
            if (!Profile.CapEnable)
            {
                return(true);
            }
            IEnumerator ie     = SelectedCaps.GetEnumerator();
            int         capsum = 0;

            while (ie.MoveNext())
            {
                string     name = ((KeyValuePair <string, TMUsedInfo>)ie.Current).Key;
                TMUsedInfo inf  = ((KeyValuePair <string, TMUsedInfo>)ie.Current).Value;
                if (Profile.MasterHash[name].SkillCap < inf.SkillValue)
                {
                    capsum += inf.SkillCap;
                }
                else
                {
                    CurrentErrorMessage = "Cap for " + name + " is too high. Please revise down to " + Profile.MasterHash[name].SkillCap; return(false);
                }
            }
            if (capsum > Profile.CapSum)
            {
                CurrentErrorMessage = "Caps are too high. Please revise total caps down to " + Profile.CapSum; return(false);
            }
            return(true);
        }
예제 #3
0
        private void CommitSession()
        {
            Mobile m = Mobile;

            if (Profile.StatEnable)
            {
                m.Str = m_Stats["Strength"];
                m.Dex = m_Stats["Dexterity"];
                m.Int = m_Stats["Intelligence"];
            }
            if (Profile.SkillEnable)
            {
                if (!NoReset)
                {
                    ResetZero();
                }
                IEnumerator ie = SelectedSkills.GetEnumerator();
                while (ie.MoveNext())
                {
                    Dictionary <string, TMUsedInfo> inf = ((KeyValuePair <string, Dictionary <string, TMUsedInfo> >)ie.Current).Value;
                    IEnumerator subie = inf.GetEnumerator();
                    while (subie.MoveNext())
                    {
                        TMUsedInfo inf2 = ((KeyValuePair <string, TMUsedInfo>)subie.Current).Value;
                        SkillSettings.DoTell("Mobile: " + m + " Skills: " + m.Skills + " SkillID: " + inf2.SkillID + " SkillValue: " + inf2.SkillValue + " Skills[inf2.SkillID] " + m.Skills[inf2.SkillID]);
                        if (m != null && inf2.SkillValue != 0.0 && inf2.SkillID >= 0 && inf2.SkillID < m.Skills.Length)
                        {
                            m.Skills[inf2.SkillID].Base = inf2.SkillValue;
                            SkillSettings.DoTell("BLAH! " + inf2.SkillName);
                        }
                    }
                }
            }
            if (Profile.CapEnable)
            {
                IEnumerator ie = SelectedSkills.GetEnumerator();
                while (ie.MoveNext())
                {
                    Dictionary <string, TMUsedInfo> inf = ((KeyValuePair <string, Dictionary <string, TMUsedInfo> >)ie.Current).Value;
                    IEnumerator subie = inf.GetEnumerator();
                    while (subie.MoveNext())
                    {
                        TMUsedInfo inf2 = ((KeyValuePair <string, TMUsedInfo>)subie.Current).Value;
                        SkillSettings.DoTell("Mobile: " + m + " Skills: " + m.Skills + " SkillID: " + inf2.SkillID + " SkillValue: " + inf2.SkillValue + " Skills[inf2.SkillID] " + m.Skills[inf2.SkillID]);
                        if (m != null && inf2.SkillCap >= 0.0 && inf2.SkillID >= 0 && inf2.SkillID < m.Skills.Length)
                        {
                            m.Skills[inf2.SkillID].Cap = inf2.SkillCap;
                            SkillSettings.DoTell("BLAH! " + inf2.SkillName + "capped at: " + inf2.SkillCap);
                        }
                    }
                }
            }
        }
예제 #4
0
        private bool checkSkills()
        {
            Dictionary <string, Dictionary <string, TMUsedInfo> > sk = SelectedSkills;
            IEnumerator ie = Profile.subProfiles.GetEnumerator();

            if (!Profile.SkillEnable)
            {
                return(true);
            }
            int masterSum = 0;

            while (ie.MoveNext())
            {
                double       profSum = 0.0;
                string       name    = ((KeyValuePair <string, SkillProfile>)ie.Current).Key;
                SkillProfile prof    = ((KeyValuePair <string, SkillProfile>)ie.Current).Value;
                Dictionary <string, TMUsedInfo> profInfo = null;
                if (sk.ContainsKey(name))
                {
                    profInfo = sk[name];
                    IEnumerator en = profInfo.GetEnumerator();
                    while (en.MoveNext())
                    {
                        TMUsedInfo inf = ((KeyValuePair <string, TMUsedInfo>)en.Current).Value;
                        profSum += inf.SkillValue;
                    }
                    if (Math.Ceiling(profSum) > prof.SkillPoints)
                    {
                        CurrentErrorMessage = "Skill Points for " + prof.ProfileName + " are higher than allowed, at " + profSum + ". Please revise down to " + prof.SkillPoints + " after weighting.";
                        return(false);
                    }
                }
                masterSum += (int)Math.Ceiling(profSum);
            }
            if (masterSum > totalAllowedPoints)
            {
                CurrentErrorMessage = "Skill Points are higher than maximum allowed value. Please revise downward by " + (masterSum - totalAllowedPoints) + ". The maximum is: " + totalAllowedPoints;
                return(false);
            }
            if (Profile.SkillForce && masterSum < totalAllowedPoints)
            {
                CurrentErrorMessage = "Skill Points are lower than the required value. Please revise upward by " + (totalAllowedPoints - masterSum) + ".";
                return(false);
            }
            return(true);
        }
예제 #5
0
        private double getCurrentSum(string p)
        {
            if (!SelectedSkills.ContainsKey(p))
            {
                return(0.0);
            }
            double sum = 0.0;
            Dictionary <string, TMUsedInfo> inf = SelectedSkills[p];
            IEnumerator ie = inf.GetEnumerator();

            while (ie.MoveNext())
            {
                TMUsedInfo uif = (TMUsedInfo)((KeyValuePair <string, TMUsedInfo>)ie.Current).Value;
                sum += (uif.SkillValue * uif.SkillWeight);
            }
            return(sum);
        }
예제 #6
0
 private bool verifyEntries(string p)
 {
     //TODO: Add verification info for:
     //Skills - get profile, and compare values to caps, minimums.
     //Stats - take main profile, compare stat vals to caps, minimums.
     //Skillcaps - take main profile, compare caps to caps caps, minimums.
     SkillSettings.DoTell("verify: " + p);
     if (p == "stats")
     {
         return(checkStats());
     }
     if (p == "caps")
     {
         return(false);
     }
     else             //For skill profiles.
     {
         try
         {
             Dictionary <string, TMUsedInfo> vals = (Dictionary <string, TMUsedInfo>)SelectedSkills[p];
             SkillProfile rules = (SkillProfile)Profile.subProfiles[p];
             IEnumerator  ie    = vals.GetEnumerator();
             double       sum   = 0.0;
             while (ie.MoveNext())
             {
                 TMUsedInfo inf = (TMUsedInfo)((KeyValuePair <string, TMUsedInfo>)ie.Current).Value;
                 SkillSettings.DoTell("Skill debug: " + inf.SkillName + " " + inf.SkillValue + " " + (inf.SkillValue * inf.SkillWeight));
                 sum += (inf.SkillValue * inf.SkillWeight);
             }
             if ((double)rules.SkillPoints >= sum && totalSelectedPoints + sum <= totalAllowedPoints)
             {
                 totalSelectedPoints += sum;
                 SkillSettings.DoTell("Points are valid, and will be added. Sum: " + sum + " TSP: " + totalSelectedPoints + " TAP: " + totalAllowedPoints);
                 TMAlertGump g = new TMAlertGump("The points you selected were added successfully.");
                 Mobile.SendGump(g);
                 return(true);
             }
             else
             {
                 if ((double)totalAllowedPoints < (sum + totalSelectedPoints))
                 {
                     CurrentErrorMessage = "The points you entered are too high for the overall setting. Please adjust your points downward by " + (totalAllowedPoints - (sum + totalSelectedPoints));
                 }
                 if ((double)rules.SkillPoints < sum)
                 {
                     CurrentErrorMessage = "The points you entered are too high for this profile. Please adjust this profile down by " + (rules.SkillPoints - sum);
                 }
                 else if (!((double)totalAllowedPoints < (sum + totalSelectedPoints)))
                 {
                     CurrentErrorMessage = "Another error was encountered.";
                     SkillSettings.DoTell("rules.SkillPoints: " + rules.SkillPoints + " sum: " + sum + " totalSelectedPoints: " + totalSelectedPoints + " totalAllowedPoints: " + totalAllowedPoints + " (double)rules.SkillPoints >= sum: " + ((double)rules.SkillPoints >= sum) + " totalSelectedPoints + sum <= totalAllowedPoints: " + ((totalSelectedPoints + sum) <= totalAllowedPoints));
                 }
                 return(false);
             }
         }
         catch (Exception e)
         {
             SkillSettings.DoTell("Invalid name to attempt verification on. Exception: " + e);
         }
     }
     return(false);
 }
예제 #7
0
        public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;
            Dictionary <string, TMUsedInfo> selected = new Dictionary <string, TMUsedInfo>();

            if (info.ButtonID == 1)
            {
                bool man   = Profile.Manual;
                int  page  = 1;
                int  count = 0;
                int  csid  = (1000 * page) + (count % (Skin.NumPerPage - 1));
                if (man)
                {
                    while (count != Profile.MasterHash.Count)
                    {
                        string relaytext = "";
                        try
                        {
                            TextRelay relay = info.GetTextEntry(csid);
                            relaytext = relay.Text;
                        }
                        catch (Exception ex)
                        {
                            SkillSettings.DoTell2("Manual gathering problems: " + ex);
                        }
                        if (relaytext != "")
                        {
                            int value = -1;
                            try { value = Int32.Parse(relaytext); }
                            catch (Exception ex) { SkillSettings.DoTell2("Error on parse manual: " + ex); }
                            TMSkillInfo skinf = Profile.getAtRank(count);
                            if (skinf.SkillEnable)
                            {
                                TMUsedInfo inf = new TMUsedInfo(skinf.SkillName, value * skinf.SkillWeight, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID);
                                selected.Add(skinf.SkillName, inf);
                            }
                        }
                        if (count % Skin.NumPerPage == 0 && count != 0)
                        {
                            page++;
                        }
                        count++;
                        csid = 3000 + count;
                    }
                }
                else
                {
                    while (count != Profile.MasterHash.Count)                      //Make sure all text entries have a 0 in them.
                    {
                        if (info.IsSwitched(csid))
                        {
                            TMSkillInfo skinf = Profile.getAtRank(count);
                            TMUsedInfo  inf   = new TMUsedInfo(skinf.SkillName, skinf.SkillWeight * skinf.SkillValue, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID);
                            selected.Add(skinf.SkillName, inf);
                        }
                        if ((count + 1) % Skin.NumPerPage == 0)
                        {
                            page++;
                        }
                        count++;
                        csid = 1000 + count;
                    }
                }
            }
            else
            {
                return;
            }
            bool resend = Session.addSkill("" + Profile.ProfileName, selected);

            if (resend)
            {
                from.SendGump(Page.Clone());
                from.SendGump(new TMAlertGump(Session.CurrentErrorMessage));
            }
        }
예제 #8
0
		public override void OnResponse(NetState sender, RelayInfo info)
        {
            Mobile from = sender.Mobile;
			Dictionary<string, TMUsedInfo> selected = new Dictionary<string, TMUsedInfo>();
            if (info.ButtonID == 1)
            {
                bool man = Profile.Manual;
				int page = 1;
				int count = 0;
				int csid = (1000 * page) + (count % (Skin.NumPerPage-1));
				if (man)
				{
					while ( count != Profile.MasterHash.Count )
					{
						string relaytext = "";
						try
						{
							TextRelay relay = info.GetTextEntry(csid);
							relaytext = relay.Text;
						}
						catch (Exception ex)
						{
							SkillSettings.DoTell2("Manual gathering problems: " + ex);
						}
						if( relaytext != "" )
						{
							int value = -1;
							try { value = Int32.Parse(relaytext); }
							catch (Exception ex) { SkillSettings.DoTell2("Error on parse manual: " + ex); }
							TMSkillInfo skinf = Profile.getAtRank(count);
							if (skinf.SkillEnable)
							{
								TMUsedInfo inf = new TMUsedInfo(skinf.SkillName, value*skinf.SkillWeight, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID);
								selected.Add(skinf.SkillName, inf);
							}
						}
						if (count % Skin.NumPerPage == 0 && count != 0)
							page++;
						count++;
						csid = 3000 + count;
					}
				}
				else
				{
					while (count != Profile.MasterHash.Count)  //Make sure all text entries have a 0 in them.
					{
						if (info.IsSwitched(csid))
						{
							TMSkillInfo skinf = Profile.getAtRank( count );
							TMUsedInfo inf = new TMUsedInfo( skinf.SkillName, skinf.SkillWeight*skinf.SkillValue, skinf.SkillWeight, skinf.SkillCap, skinf.SkillID );
							selected.Add(skinf.SkillName, inf);
						}
						if ((count + 1) % Skin.NumPerPage == 0)
							page++;
						count++;
						csid = 1000 + count;
					}
				}
            }
			else
				return;
			bool resend = Session.addSkill( ""+Profile.ProfileName, selected );
			if (resend)
			{
				from.SendGump(Page.Clone());
				from.SendGump(new TMAlertGump(Session.CurrentErrorMessage));
			}
        }