Blob


1 #include <stdio.h>
2 #include <stdlib.h>
4 #include "adventure.h"
6 int
7 move_object(struct param *par, struct object *from, struct object *to)
8 {
9 struct object *obj = par->object;
10 enum distance dist = par->distance;
12 if (obj == NULL || dist == dist_unknown_obj || dist == dist_not_here)
13 printf("I don't understand what item you mean.\n");
14 else if (to == NULL)
15 printf("There is nobody here to give that to.\n");
16 else if (obj == to)
17 printf("What's the meaning of putting a %s inside itself?\n",
18 par->tag);
19 else if (from != obj->location) {
20 /* give the appropriate error message */
21 switch (dist) {
22 case dist_player:
23 printf("You should not be doing that to yourself.\n");
24 break;
26 case dist_held:
27 printf("You already have %s.\n", obj->description);
28 break;
30 case dist_location:
31 case dist_overthere:
32 printf("That's not an item.\n");
33 break;
35 case dist_here:
36 if (from == player)
37 printf("You have no %s.\n", par->tag);
38 else
39 printf("Sorry, %s has no %s.\n",
40 from->description, par->tag);
41 break;
43 case dist_held_contained:
44 case dist_here_contained:
45 printf("Sorry, %s is holding it.\n",
46 obj->location->description);
47 break;
49 default:
50 /* we should have handled all other cases
51 * before this point */
52 abort();
53 }
54 } else if (obj->weight > to->capacity) {
55 printf("That is way too heavy.\n");
56 } else if (obj->weight + weight_of_contents(to) > to->capacity) {
57 printf("That would becamo too heavy.\n");
58 } else {
59 obj->location = to;
60 printf("OK.\n");
61 }
63 return 1;
64 }