aboutsummaryrefslogtreecommitdiff
path: root/worlds
diff options
context:
space:
mode:
authorFranklin Wei <git@fwei.tk>2016-03-31 17:05:37 -0400
committerFranklin Wei <git@fwei.tk>2016-03-31 17:05:37 -0400
commit207850187986568b17ea9b2d9c29510cb00bf9da (patch)
treeaee87cf74280e8f9dd29aca88d12a638f37b2493 /worlds
parentb3699dd5df18db3c060bb88a74c1b05e37154c76 (diff)
downloadnetcosm-207850187986568b17ea9b2d9c29510cb00bf9da.zip
netcosm-207850187986568b17ea9b2d9c29510cb00bf9da.tar.gz
netcosm-207850187986568b17ea9b2d9c29510cb00bf9da.tar.bz2
netcosm-207850187986568b17ea9b2d9c29510cb00bf9da.tar.xz
lots of things
Diffstat (limited to 'worlds')
-rw-r--r--worlds/test.c162
1 files changed, 133 insertions, 29 deletions
diff --git a/worlds/test.c b/worlds/test.c
index 7425d81..f662c1f 100644
--- a/worlds/test.c
+++ b/worlds/test.c
@@ -9,13 +9,20 @@ static void deadend_init(room_id id)
struct object_t *new = obj_new("/generic");
new->name = strdup("shovel");
new->userdata = strdup("It is a normal shovel with a price tag attached that says $19.99.");
+
room_obj_add(id, new);
-#if 0
- new = obj_copy(new);
+ new = obj_new("/generic/notake");
+ new->name = strdup("trees");
+ new->userdata = strdup("They are palm trees with a bountiful supply of coconuts in them.");
+ new->hidden = true;
+
room_obj_add(id, new);
-#endif
+ room_obj_add_alias(id, new, "tree");
+ room_obj_add_alias(id, new, "palm");
+ room_obj_add_alias(id, new, "palm tree");
+ /* add global verbs */
struct verb_t *verb = verb_new("dig");
verb->name = strdup("dig");
world_verb_add(verb);
@@ -24,6 +31,13 @@ static void deadend_init(room_id id)
verb->name = strdup("put");
world_verb_add(verb);
+ verb = verb_new("eat");
+ verb->name = strdup("eat");
+ world_verb_add(verb);
+
+ verb = verb_new("shake");
+ verb->name = strdup("shake");
+ world_verb_add(verb);
}
static void ew_road_init(room_id id)
@@ -93,6 +107,7 @@ static void hidden_init(room_id id)
static bool building_enter(room_id id, user_t *user)
{
+ (void) id;
if(multimap_lookup(userdb_lookup(user->user)->objects, "shiny brass key", NULL))
return true;
else
@@ -107,7 +122,7 @@ static void mailroom_init(room_id id)
struct object_t *new = obj_new("/generic/notake");
new->name = strdup("bins");
new->hidden = true;
-
+
/* insert IAC NOP to prevent the extra whitespace from being dropped */
new->userdata = strdup("All of the bins are empty. Looking closely you can see that there are names written at the bottom of each bin, but most of them are faded away so that you cannot read them. You can only make out three names:\n\377\361 Jeffrey Collier\n\377\361 Robert Toukmond\n\377\361 Thomas Stock\n");
room_obj_add(id, new);
@@ -261,13 +276,13 @@ const struct roomdata_t netcosm_world[] = {
{
"computer_room",
"Computer room",
- "You are in a computer room. It seems like most of the equipment has been removed. There is a VAX 11/780 in front of you, however, with one of the cabinets wide open. A sign on the front of the machine says: This VAX is named 'pokey'. To type on the console, use the 'type' command. The exit is to the east.\nThe panel lights are steady and motionless.",
+ "You are in a computer room. It seems like most of the equipment has been removed. There is a VAX 11/780 in front of you, however, with one of the cabinets wide open. A sign on the front of the machine says: This VAX is named 'pokey'. To type on the console, use the 'type' command. The exit is to the east.\nThe panel lights are steady and motionless.",
{ NONE_N, NONE_NE, "building_hallway", NONE_SE, NONE_S, NONE_SW, NONE_W, NONE_NW, NONE_UP, NONE_DN, NONE_IN, NONE_OT },
computer_room_init,
NULL,
NULL,
bool_ser,
- bool_deser,
+ bool_deser,
bool_destroy,
},
};
@@ -406,7 +421,7 @@ static void dig_exec(struct verb_t *verb, char *args, user_t *user)
}
}
else
- send_msg(user, "Digging here reveals nothing.\n");
+ send_msg(user, "Digging here reveals nothing.\n");
return;
@@ -416,43 +431,45 @@ nothing:
static void put_exec(struct verb_t *verb, char *args, user_t *user)
{
+ (void) verb;
char *save;
const char *obj_name = strtok_r(args, WSPACE, &save);
if(!obj_name)
{
- send_msg(user, "You must supply an object\n");
- return;
+ send_msg(user, "You must supply an object\n");
+ return;
}
args = NULL;
const struct multimap_list *list = multimap_lookup(userdb_lookup(user->user)->objects,
- obj_name, NULL);
+ obj_name, NULL);
if(!list)
{
- send_msg(user, "You don't have that.\n");
- return;
+ send_msg(user, "You don't have that.\n");
+ return;
}
-
+
struct object_t *obj = list->val;
/* original dunnet ignores the preposition */
const char *prep = strtok_r(args, WSPACE, &save);
+ (void) prep;
const char *ind_obj_name = strtok_r(args, WSPACE, &save);
if(!ind_obj_name)
{
- send_msg(user, "You must supply an indirect object.\n");
- return;
+ send_msg(user, "You must supply an indirect object.\n");
+ return;
}
list = room_obj_get(user->room, ind_obj_name);
-
+
if(!list)
{
- send_msg(user, "I don't know what that indirect object is.\n");
- return;
+ send_msg(user, "I don't know what that indirect object is.\n");
+ return;
}
struct object_t *ind_obj = list->val;
@@ -460,33 +477,120 @@ static void put_exec(struct verb_t *verb, char *args, user_t *user)
/* now execute the verb */
if(!strcmp(obj->name, "CPU card") && !strcmp(ind_obj->name, "computer") && user->room == room_get_id("computer_room"))
{
- userdb_del_obj_by_ptr(user->user, obj);
- send_msg(user, "As you put the CPU board in the computer, it immediately springs to life. The lights start flashing, and the fans seem to startup.\n");
- bool *b = room_get(user->room)->userdata;
- *b = true;
+ userdb_del_obj_by_ptr(user->user, obj);
+ send_msg(user, "As you put the CPU board in the computer, it immediately springs to life. The lights start flashing, and the fans seem to startup.\n");
+ bool *b = room_get(user->room)->userdata;
+ *b = true;
+
+ room_get(user->room)->data.desc = strdup("You are in a computer room. It seems like most of the equipment has been removed. There is a VAX 11/780 in front of you, however, with one of the cabinets wide open. A sign on the front of the machine says: This VAX is named 'pokey'. To type on the console, use the 'type' command. The exit is to the east.\nThe panel lights are flashing in a seemingly organized pattern.");
+ }
+ else
+ {
+ send_msg(user, "I don't know how to combine those objects. Perhaps you should just try dropping it.\n");
+ }
+}
+
+static void eat_exec(struct verb_t *verb, char *args, user_t *user)
+{
+ (void) verb;
+ char *save;
+ char *obj_name = strtok_r(args, WSPACE, &save);
+ if(!obj_name)
+ {
+ send_msg(user, "You must supply an object.\n");
+ return;
+ }
+
+ size_t n_objs;
+ const struct multimap_list *list = multimap_lookup(userdb_lookup(user->user)->objects, obj_name, &n_objs);
+
+ if(!list)
+ {
+ if(!room_obj_get(user->room, obj_name))
+ send_msg(user, "I don't know what that is.\n");
+ else
+ send_msg(user, "You don't have that.\n");
+ return;
+ }
+
+ struct object_t *obj = list->val;
- room_get(user->room)->data.desc = strdup("You are in a computer room. It seems like most of the equipment has been removed. There is a VAX 11/780 in front of you, however, with one of the cabinets wide open. A sign on the front of the machine says: This VAX is named 'pokey'. To type on the console, use the 'type' command. The exit is to the east.\nThe panel lights are flashing in a seemingly organized pattern.");
+ if(!strcmp(obj->name, "some food"))
+ {
+ send_msg(user, "That tasted horrible.\n");
}
else
{
- send_msg(user, "I don't know how to combine those objects. Perhaps you should just try dropping it.\n");
+ char buf[MSG_MAX];
+ send_msg(user, "You forcibly shove %s down your throat, and start choking.\n",
+ format_noun(buf, sizeof(buf), obj->name, n_objs, obj->default_article, false));
+
+ /* TODO: kill player */
+ }
+
+ userdb_del_obj(user->user, obj_name);
+}
+
+static void shake_exec(struct verb_t *verb, char *args, user_t *user)
+{
+ (void) verb;
+ char *save;
+ char *obj_name = strtok_r(args, WSPACE, &save);
+
+ if(!obj_name)
+ {
+ send_msg(user, "You must supply an object.\n");
+ return;
+ }
+
+ size_t n_objs_room, n_objs_inv;
+ const struct multimap_list *list_room = room_obj_get_size(user->room, obj_name, &n_objs_room);
+
+ const struct multimap_list *list_inv = multimap_lookup(userdb_lookup(user->user)->objects, obj_name, &n_objs_inv);
+
+ if(!list_room && !list_inv)
+ {
+ send_msg(user, "I don't know what that is.\n");
+ return;
+ }
+
+ if(list_room)
+ {
+ struct object_t *obj = list_room->val;
+ if(!strcmp(obj->name, "trees"))
+ send_msg(user, "You begin to shake a tree, and notice a coconut begin to fall from the air. As you try to get your hand up to block it, you feel the impact as it lands on your head.\n");
+ else
+ send_msg(user, "You don't have that.\n");
+ }
+ else if(list_inv)
+ {
+ struct object_t *obj = list_inv->val;
+ char buf[MSG_MAX];
+ send_msg(user, "Shaking %s seems to have no effect.\n",
+ format_noun(buf, sizeof(buf), obj->name,
+ n_objs_room, obj->default_article,
+ false));
}
}
-/* global verbs */
+/* verb classes */
const struct verb_class_t netcosm_verb_classes[] = {
{ "dig",
dig_exec },
{ "put",
- put_exec },
- /*
+ put_exec },
+ { "eat",
+ eat_exec },
{ "shake",
shake_exec },
+ /*
+ { "type",
+ type_exec },
{ "climb",
climb_exec },
- { "eat",
- eat_exec },
+ */
+ /*
{ "feed",
feed_exec },
*/