void DrinkCommand::execute(Character *player, const QString &command) {
super::prepareExecute(player, command);
GameObjectPtrList pool = player->inventory() + currentRoom()->items();
GameObjectPtr item = takeObject(pool);
if (!requireSome(item, "Drink what?")) {
return;
}
if (!item->hasTrigger("ondrink")) {
send("You cannot drink that.");
return;
}
if (!item->invokeTrigger("ondrink", player)) {
return;
}
item->setDeleted();
}
DrinkCommand.prototype.execute = function(player, command) {
this.prepareExecute(player, command);
var pool = player.inventory.concat(player.currentRoom.items);
var item = this.takeObject(pool);
if (!this.requireSome(item, "Drink what?")) {
return;
}
if (!item.hasTrigger("ondrink")) {
this.send("You cannot drink that.");
return;
}
if (!item.invokeTrigger("ondrink", player)) {
return;
}
item.setDeleted();
};
while (true) {
}
DrinkCommand.execute = function(player, command) {
state = Parser.prepareExecute(player, command);
var pool = player.inventory.concat(player.currentRoom.items);
var item = state.takeObject(pool);
if (!state.requireSome(item, "Drink what?")) {
return;
}
if (!item.hasTrigger("ondrink")) {
player.send("You cannot drink that.");
return;
}
if (!item.invokeTrigger("ondrink", player)) {
return;
}
item.setDeleted();
};
Parser.registerCommand("drink", {
synonyms: ["chug", "sip", "slurp" ],
execute : function(player, state) {
var pool = player.inventory.concat(player.currentRoom.items);
var item = state.takeObject(pool);
if (!state.requireSome(item, "Drink what?")) {
return;
}
if (!item.hasTrigger("ondrink")) {
player.send("You cannot drink that.");
return;
}
if (!item.invokeTrigger("ondrink", player)) {
return;
}
item.setDeleted();
},
help_description: "Use DRINK to drink liquids out of any fountains, containers or bodies of water you may find."
});