~jb55/protoverse

ac654e95e69881d76b7c17d60cfe00c1707bc294 — William Casarin 3 months ago 1b9a46c
describe: fix some buggy stuff
4 files changed, 25 insertions(+), 15 deletions(-)

M satoshis-citadel.space
M src/describe.c
M src/parse.c
M src/parse.h
M satoshis-citadel.space => satoshis-citadel.space +4 -2
@@ 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"))


M src/describe.c => src/describe.c +18 -13
@@ 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;
}



M src/parse.c => src/parse.c +2 -0
@@ 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)

M src/parse.h => src/parse.h +1 -0
@@ 29,6 29,7 @@ enum cell_type {
};

enum object_type {
	O_OBJECT,
	O_TABLE,
	O_CHAIR,
	O_DOOR,