Exemplo n.º 1
0
 public override void Execute(FreneticScript.CommandSystem.CommandQueue queue, CommandEntry entry)
 {
     try
     {
         IntegerTag num = IntegerTag.TryFor(entry.GetArgumentObject(queue, 1));
         if (num == null)
         {
             queue.HandleError(entry, "Invalid amount number!");
             return;
         }
         PlayerTag player = PlayerTag.For(entry.GetArgument(queue, 0));
         if (player == null)
         {
             queue.HandleError(entry, "Invalid player!");
             return;
         }
         int        amount = (int)num.Internal;
         PlayerLife life   = player.Internal.player.life;
         if (amount >= 0)
         {
             life.askEat((byte)amount);
         }
         else
         {
             life.askStarve((byte)-amount);
         }
         if (entry.ShouldShowGood(queue))
         {
             entry.Good(queue, "Successfully adjusted the food level of a player!");
         }
     }
     catch (Exception ex) // TODO: Necessity?
     {
         queue.HandleError(entry, "Failed to adjust player's food level: " + ex.ToString());
     }
 }