Exemplo n.º 1
0
        public static void Normalize(this Skill skill)
        {
            if (skill.IsCapped())
            {
                skill.BaseFixedPoint = skill.CapFixedPoint;
            }

            if (skill.IsZero())
            {
                skill.BaseFixedPoint = 0;
            }
        }
Exemplo n.º 2
0
        public static bool DecreaseBase(this Skill skill, double value, bool ignoreZero = false, bool trim = true)
        {
            if (trim)
            {
                value = Math.Min(skill.Base, value);
            }

            if (ignoreZero || (!skill.IsZero() && !skill.WillZero(value, false)))
            {
                skill.Base -= value;
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public static bool SetBase(this Skill skill, double value, bool ignoreLimits = false, bool trim = true)
        {
            if (trim)
            {
                value = Math.Max(0, Math.Min(skill.Cap, value));
            }

            if (ignoreLimits || (value < skill.Base && !skill.IsZero() && !skill.WillZero(skill.Base - value, false)) ||
                (value > skill.Base && !skill.IsCapped() && !skill.WillCap(value - skill.Base, false)))
            {
                skill.Base = value;
                return(true);
            }

            return(false);
        }
Exemplo n.º 4
0
		public virtual bool ValidateSkill(Mobile user, Skill skill, bool message)
		{
			if (user == null || user.Deleted || skill == null)
			{
				return false;
			}

			switch (Mode)
			{
				case SkillCodexMode.Increase:
				{
					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (user.SkillsTotal + ValueFixed > user.SkillsCap)
						{
							if (!CanReduceSkills(user))
							{
								if (message)
								{
									user.SendMessage(
										SuperGump.DefaultErrorHue,
										"You already know everything this codex can offer, reduce some skills to make room for more knowledge.");
								}

								return false;
							}
						}

						if (skill.IsCapped() || skill.WillCap(Value, false))
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}

						if (!skill.IsLocked(SkillLock.Up))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
				case SkillCodexMode.Decrease:
				{
					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (user.SkillsTotal - ValueFixed < 0)
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "You already forgot everything this codex can offer.");
							}

							return false;
						}

						if (skill.IsZero() || skill.WillZero(Value, false))
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already forgot everything this codex can offer about {0}, any further and you'll forget how to breath!",
									skill.Name);
							}

							return false;
						}

						if (!skill.IsLocked(SkillLock.Down))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
				case SkillCodexMode.Fixed:
				{
					if (Flags == SkillCodexFlags.Cap)
					{
						if (skill.CapFixedPoint == ValueFixed)
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}
					}

					if (Flags == SkillCodexFlags.Base || Flags == SkillCodexFlags.Both)
					{
						if (ValueFixed < skill.BaseFixedPoint)
						{
							if (user.SkillsTotal - (skill.BaseFixedPoint - ValueFixed) < 0)
							{
								if (message)
								{
									user.SendMessage(
										SuperGump.DefaultErrorHue,
										"You already forgot everything this codex can offer, any further and you'll forget how to breath!");
								}

								return false;
							}
						}
						else if (ValueFixed > skill.BaseFixedPoint)
						{
							if (user.SkillsTotal + (ValueFixed - skill.BaseFixedPoint) > user.SkillsCap)
							{
								if (!CanReduceSkills(user))
								{
									if (message)
									{
										user.SendMessage(
											SuperGump.DefaultErrorHue,
											"You already know everything this codex can offer, reduce some skills to make room for more knowledge.");
									}

									return false;
								}
							}
						}
						else
						{
							if (message)
							{
								user.SendMessage(
									SuperGump.DefaultErrorHue,
									"You already know everything this codex can offer about {0}.",
									skill.Name);
							}

							return false;
						}

						if (skill.IsLocked(SkillLock.Locked))
						{
							if (message)
							{
								user.SendMessage(SuperGump.DefaultErrorHue, "The skill {0} is locked.", skill.Name);
							}

							return false;
						}
					}
				}
					break;
			}

			return true;
		}
Exemplo n.º 5
0
 public static bool IsZeroOrCapped(this Skill skill)
 {
     return(skill.IsZero() || skill.IsCapped());
 }