protected ItemDrink(ItemDrink template) : base(template) { NumberOfDrinks = template.NumberOfDrinks; MagicPerDrink = template.MagicPerDrink; }
public override Handler DoDrink(ParsedInput input) { if (input.Words.Length == 1) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_WHAT, "Drink".ToParagraph())); } else if (input.Words.Length > 2) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } if (IsDead) { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_PLAYER_IS_DEAD)); } EntityHand hand = Hands.GetHandWithItem(input.Words[1], ITEM_TYPE.DRINK); if (hand != null) { MESSAGE_ENUM message = MESSAGE_ENUM.PLAYER_DRINK; // hand is holding a drink ItemDrink drink = hand.Item as ItemDrink; if (drink.NumberOfDrinks == 1) { message = MESSAGE_ENUM.PLAYER_DRINK_LAST; hand.Item = null; } else { drink.NumberOfDrinks--; } return(Handler.HANDLED(message, drink.NameAsParagraph, drink.MagicPerDrink.ToString().ToParagraph(), drink.NumberOfDrinks.ToString().ToParagraph())); } else { // not holding a drink; check room ItemDrink drink = CurrentRoom.Items.Find(input.Words[1], ITEM_TYPE.DRINK) as ItemDrink; if (drink != null) { MESSAGE_ENUM message = MESSAGE_ENUM.PLAYER_DRINK_GROUND_ITEM; if (drink.NumberOfDrinks == 1) { message = MESSAGE_ENUM.PLAYER_DRINK_LAST_GROUND_ITEM; CurrentRoom.Items.Remove(drink); } else { drink.NumberOfDrinks--; } return(Handler.HANDLED(message, drink.NameAsParagraph, drink.MagicPerDrink.ToString().ToParagraph(), drink.NumberOfDrinks.ToString().ToParagraph())); } else { return(Handler.HANDLED(MESSAGE_ENUM.ERROR_BAD_INPUT)); } } }