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", obj->tags[0]);
18 else if (from != obj->location) {
19 /* give the appropriate error message */
20 switch (dist) {
21 case dist_player:
22 printf("You should not be doing that to yourself.\n");
23 break;
25 case dist_held:
26 printf("You already have %s.\n", obj->description);
27 break;
29 case dist_location:
30 case dist_overthere:
31 printf("That's not an item.\n");
32 break;
34 case dist_here:
35 if (from == player)
36 printf("You have no %s.\n", par->tag);
37 else
38 printf("Sorry, %s has no %s.\n",
39 from->description,
40 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 }