protoverse

A metaverse protocol
git clone git://jb55.com/protoverse
Log | Files | Refs | README | LICENSE

commit ac654e95e69881d76b7c17d60cfe00c1707bc294
parent 1b9a46ce622a18e8b294884b3b0c64066653b647
Author: William Casarin <jb55@jb55.com>
Date:   Mon,  9 Aug 2021 07:57:34 -0700

describe: fix some buggy stuff

Diffstat:
Msatoshis-citadel.space | 6++++--
Msrc/describe.c | 31++++++++++++++++++-------------
Msrc/parse.c | 2++
Msrc/parse.h | 1+
4 files changed, 25 insertions(+), 15 deletions(-)

diff --git a/satoshis-citadel.space b/satoshis-citadel.space @@ -14,8 +14,10 @@ (location center) (light (name "desk"))) - (chair (id welcome-desk-chair) - (name "fancy")) + (chair (id a)) + (chair (id b)) + (chair (id c)) + (chair (id d)) (chair (name "throne") (material "invisible")) diff --git a/src/describe.c b/src/describe.c @@ -218,7 +218,7 @@ static int describe_amount(struct describe *desc, int nobjs) ok = push_word(desc->strs, "a single"); if (!ok) return 0; } else if (nobjs == 2) { - ok = push_word(desc->strs, "a couple"); + ok = push_word(desc->strs, "a couple of"); if (!ok) return 0; } else if (nobjs == 3) { ok = push_word(desc->strs, "three"); @@ -249,9 +249,13 @@ static int describe_object_name(struct cursor *strs, struct cursor *attrs, struc if (!ok) return 0; } - return push_word(strs, cell->type == C_OBJECT - ? object_type_str(cell->obj_type) - : cell_type_str(cell->type)); + if (cell->type == C_OBJECT) { + if (cell->obj_type == O_OBJECT) + return 1; + return push_word(strs, object_type_str(cell->obj_type)); + } + + return push_word(strs, cell_type_str(cell->type)); } static int describe_group(struct describe *desc) @@ -304,8 +308,11 @@ static int describe_group(struct describe *desc) static int describe_object(struct describe *desc) { - (void)desc; - return 0; + if (!push_word(desc->strs, "a")) + return 0; + + return describe_object_name(desc->strs, &desc->parsed->attributes, + desc->cell); } int describe_cell(struct cell *cell, struct parser *parsed, struct cursor *strbuf) @@ -348,15 +355,13 @@ int describe_cells(struct cell *cell, struct parser *parsed, struct cursor *strs return 1; if (cell->type == C_ROOM || cell->type == C_SPACE) { - ok = push_word(strs, "It contains"); - if (!ok) return 0; + if (!push_word(strs, "It contains")) + return 0; + cell = get_cell(&parsed->cells, cell->children[0]); + return describe_cells(cell, parsed, strs, max_depth, depth+1); } - /* TODO: for each cell ? for now we just care about the group */ - cell = get_cell(&parsed->cells, cell->children[0]); - assert(cell); - - return describe_cells(cell, parsed, strs, max_depth, depth+1); + return 1; } diff --git a/src/parse.c b/src/parse.c @@ -1067,6 +1067,7 @@ const char *object_type_str(enum object_type type) case O_TABLE: return "table"; case O_CHAIR: return "chair"; case O_LIGHT: return "light"; + case O_OBJECT: return ""; } return "unknown"; @@ -1231,6 +1232,7 @@ static struct object_def object_defs[] = { {"chair", O_CHAIR}, {"door", O_DOOR}, {"light", O_LIGHT}, + {"object", O_OBJECT}, }; static int parse_object(struct parser *parser, u16 *index) diff --git a/src/parse.h b/src/parse.h @@ -29,6 +29,7 @@ enum cell_type { }; enum object_type { + O_OBJECT, O_TABLE, O_CHAIR, O_DOOR,