/// <summary>Executes the command.</summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { IController sender = actionInput.Controller; //StatEffect effect; var statEffect = sender.Thing.Behaviors.FindFirst<StatEffect>(); if (statEffect != null) { // @@@ ?? } else { statEffect = new StatEffect(); //{ // Modifier = 15, // Name = "strength", //}; } }
/// <summary> /// Executes the command. /// TODO: Optionally allow the admin to create a new attribute if the target didn't /// already have the attribute available to modify. /// </summary> /// <param name="actionInput">The full input specified for executing the command.</param> public override void Execute(ActionInput actionInput) { IController sender = actionInput.Controller; var originator = sender.Thing; // Strings to be displayed when the effect is applied/removed. var buffString = new ContextualString(sender.Thing, this.target) { ToOriginator = string.Format("\r\nThe '{0}' stat of {1} has changed by {2}.\r\n", this.stat.Name, this.target.Name, this.modAmount), ToReceiver = string.Format("\r\nYour '{0}' stat has changed by {1}.\r\n", this.stat.Name, this.modAmount) }; var unbuffString = new ContextualString(sender.Thing, this.target) { ToReceiver = string.Format("\r\nYour '{0}' stat goes back to normal.", this.stat.Abbreviation) }; // Turn the above sets of strings into sensory messages. var sensoryMessage = new SensoryMessage(SensoryType.Sight, 100, buffString); var expirationMessage = new SensoryMessage(SensoryType.Sight, 100, unbuffString); // Remove all existing effects on stats with the same abbreviation // to prevent the effects from being stacked, at least for now. foreach (var effect in this.target.Behaviors.OfType<StatEffect>()) { if (effect.Stat.Abbreviation == this.stat.Abbreviation) { sender.Thing.Behaviors.Remove(effect); } } // Create the effect, based on the type of modification. StatEffect statEffect = null; switch (this.modType) { case "value": statEffect = new StatEffect(sender.Thing, this.stat, this.modAmount, 0, 0, this.duration, sensoryMessage, expirationMessage); break; case "min": statEffect = new StatEffect(sender.Thing, this.stat, 0, this.modAmount, 0, this.duration, sensoryMessage, expirationMessage); break; case "max": statEffect = new StatEffect(sender.Thing, this.stat, 0, 0, this.modAmount, this.duration, sensoryMessage, expirationMessage); break; } // Apply the effect. if (statEffect != null) { this.target.Behaviors.Add(statEffect); } }