#include #include #include "adventure.h" int move_object(struct param *par, struct object *from, struct object *to) { struct object *obj = par->object; enum distance dist = par->distance; if (obj == NULL || dist == dist_unknown_obj || dist == dist_not_here) printf("I don't understand what item you mean.\n"); else if (to == NULL) printf("There is nobody here to give that to.\n"); else if (obj == to) printf("What's the meaning of putting a %s inside itself?\n", par->tag); else if (from != obj->location) { /* give the appropriate error message */ switch (dist) { case dist_player: printf("You should not be doing that to yourself.\n"); break; case dist_held: printf("You already have %s.\n", obj->description); break; case dist_location: case dist_overthere: printf("That's not an item.\n"); break; case dist_here: if (from == player) printf("You have no %s.\n", par->tag); else printf("Sorry, %s has no %s.\n", from->description, par->tag); break; case dist_held_contained: case dist_here_contained: printf("Sorry, %s is holding it.\n", obj->location->description); break; default: /* we should have handled all other cases * before this point */ abort(); } } else if (obj->weight > to->capacity) { printf("That is way too heavy.\n"); } else if (obj->weight + weight_of_contents(to) > to->capacity) { printf("That would becamo too heavy.\n"); } else { obj->location = to; printf("OK.\n"); } return 1; }