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