コード例 #1
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);
 }
コード例 #2
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;
		}