Aura.Channel.Skills.Skill.Train C# (CSharp) Method

Train() public method

Increases training condition count.
public Train ( int condition, int amount = 1 ) : void
condition int
amount int
return void
		public void Train(int condition, int amount = 1)
		{
			// Only characters can train skills.
			if (_creature.IsPet)
				return;

			var bonusMessage = "";

			// Add global bonus
			float bonusMultiplier;
			string bonuses;
			if (ChannelServer.Instance.GameEventManager.GlobalBonuses.GetBonusMultiplier(GlobalBonusStat.SkillTraining, out bonusMultiplier, out bonuses))
			{
				amount = (int)(amount * bonusMultiplier);
				if (!string.IsNullOrWhiteSpace(bonuses))
					bonusMessage += string.Format(Localization.Get(" ({0} Bonus: x{1})"), bonuses, bonusMultiplier);
			}

			// Apply skill exp multiplier
			var skillExpRateBonus = ChannelServer.Instance.Conf.World.SkillExpRate;
			if (skillExpRateBonus != 1)
			{
				amount = (int)(amount * skillExpRateBonus);
				bonusMessage += string.Format(Localization.Get(" ({0} Bonus: x{1})"), Localization.Get("Skill Exp Rate"), skillExpRateBonus);
			}

			// Change count and reveal the condition
			if (amount > 0)
			{
				switch (condition)
				{
					case 1: if (this.Info.ConditionCount1 == 0) return; this.Info.ConditionCount1 = (short)Math.Max(0, this.Info.ConditionCount1 - amount); this.Info.Flag |= SkillFlags.ShowCondition1; break;
					case 2: if (this.Info.ConditionCount2 == 0) return; this.Info.ConditionCount2 = (short)Math.Max(0, this.Info.ConditionCount2 - amount); this.Info.Flag |= SkillFlags.ShowCondition2; break;
					case 3: if (this.Info.ConditionCount3 == 0) return; this.Info.ConditionCount3 = (short)Math.Max(0, this.Info.ConditionCount3 - amount); this.Info.Flag |= SkillFlags.ShowCondition3; break;
					case 4: if (this.Info.ConditionCount4 == 0) return; this.Info.ConditionCount4 = (short)Math.Max(0, this.Info.ConditionCount4 - amount); this.Info.Flag |= SkillFlags.ShowCondition4; break;
					case 5: if (this.Info.ConditionCount5 == 0) return; this.Info.ConditionCount5 = (short)Math.Max(0, this.Info.ConditionCount5 - amount); this.Info.Flag |= SkillFlags.ShowCondition5; break;
					case 6: if (this.Info.ConditionCount6 == 0) return; this.Info.ConditionCount6 = (short)Math.Max(0, this.Info.ConditionCount6 - amount); this.Info.Flag |= SkillFlags.ShowCondition6; break;
					case 7: if (this.Info.ConditionCount7 == 0) return; this.Info.ConditionCount7 = (short)Math.Max(0, this.Info.ConditionCount7 - amount); this.Info.Flag |= SkillFlags.ShowCondition7; break;
					case 8: if (this.Info.ConditionCount8 == 0) return; this.Info.ConditionCount8 = (short)Math.Max(0, this.Info.ConditionCount8 - amount); this.Info.Flag |= SkillFlags.ShowCondition8; break;
					case 9: if (this.Info.ConditionCount9 == 0) return; this.Info.ConditionCount9 = (short)Math.Max(0, this.Info.ConditionCount9 - amount); this.Info.Flag |= SkillFlags.ShowCondition9; break;
					default:
						Log.Error("Skill.Train: Unknown training condition ({0})", condition);
						break;
				}
			}

			var exp = this.UpdateExperience();
			if (exp > 0)
				Send.SkillTrainingUp(_creature, this, exp, bonusMessage);

			this.CheckMaster();
		}