Blame


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