/* /inherit/describe_object.c - object describtion functions * These functions are supposed to work for all objects, * with or without the new article functions (those in * /inherit/basic_object). * Latest change to this file: Oct 18, 1992, by Padrone */ #pragma strict_types /* #define ERROR(str) 0 */ #define ERROR(str) write("Error in " + file_name(this_object()) + ": " + str + "\n") /* Maybe we should put these functions in 'obj/simul_efun.c' or somewhere? */ /*---------------------------------------------------------------------------*/ string describe_an_object(mixed obj, string str) { string temp, temp2; if (!obj) obj = str; if (!obj) { ERROR("Illegal arguments (0, 0) to describe_an_object"); return 0; } if (stringp(obj)) { if (sscanf(obj, "the %s", temp) == 1) return "a " + temp; if (sscanf(obj, "a %s", temp) == 1) return obj; if (sscanf(obj, "an %s", temp) == 1) return obj; if (sscanf(obj, "The %s", temp) == 1) return "a " + temp; if (sscanf(obj, "A %s", temp) == 1) return obj; if (sscanf(obj, "An %s", temp) == 1) return obj; return "a " + obj; } if (!objectp(obj)) { ERROR("Illegal arguments to describe_an_object"); return 0; } temp = (string)obj->query_indefinite_form(); if (temp) return temp; temp = (string)obj->short(); if (temp) { if (sscanf(temp, "the %s", temp2) == 1) return "a " + temp2; if (sscanf(temp, "a %s", temp2) == 1) return temp; if (sscanf(temp, "an %s", temp2) == 1) return temp; if (sscanf(temp, "The %s", temp2) == 1) return "a " + temp2; if (sscanf(temp, "A %s", temp2) == 1) return temp; if (sscanf(temp, "An %s", temp2) == 1) return temp; return "a " + temp; } temp = (string)obj->query_name(); if (temp) return temp; return str; } /* describe_an_object */ /*---------------------------------------------------------------------------*/ string describe_the_object(mixed obj, string str) { string temp, temp2; if (!obj) obj = str; if (!obj) { ERROR("Illegal arguments (0, 0) to describe_an_object"); return 0; } if (stringp(obj)) { if (sscanf(obj, "the %s", temp) == 1) return obj; if (sscanf(obj, "a %s", temp) == 1) return "the " + temp; if (sscanf(obj, "an %s", temp) == 1) return "the " + temp; if (sscanf(obj, "The %s", temp) == 1) return obj; if (sscanf(obj, "A %s", temp) == 1) return "the " + temp; if (sscanf(obj, "An %s", temp) == 1) return "the " + temp; return "the " + obj; } if (!objectp(obj)) { ERROR("Illegal arguments to describe_an_object"); return 0; } temp = (string)obj->query_definite_form(); if (temp) return temp; temp = (string)obj->short(); if (temp) { if (sscanf(temp, "the %s", temp2) == 1) return temp; if (sscanf(temp, "a %s", temp2) == 1) return "the " + temp2; if (sscanf(temp, "an %s", temp2) == 1) return "the " + temp2; if (sscanf(temp, "The %s", temp2) == 1) return temp; if (sscanf(temp, "A %s", temp2) == 1) return "the " + temp2; if (sscanf(temp, "An %s", temp2) == 1) return "the " + temp2; return "the " + temp; } temp = (string)obj->query_name(); if (temp) return temp; return str; } /* describe_the_object */