Minor wishing alias improvement
Previously when wishing for "ring of protection from shape shifters", you got a random ring instead of the protection from shape changers, because the string matching alias was "protection from shape shifters" without the object class. Now, we'll check if the wish matched any object class, but not existing object or alias, and try matching the aliases again, but only those of the already matching obj class. Add an alias for the ring of increase accuracy: "ring of accuracy", and tests for it.
This commit is contained in:
16
src/objnam.c
16
src/objnam.c
@@ -3306,6 +3306,7 @@ static const struct alt_spellings {
|
||||
{ "grapnel", GRAPPLING_HOOK },
|
||||
{ "grapple", GRAPPLING_HOOK },
|
||||
{ "protection from shape shifters", RIN_PROTECTION_FROM_SHAPE_CHAN },
|
||||
{ "accuracy", RIN_INCREASE_ACCURACY },
|
||||
/* if we ever add other sizes, move this to o_ranges[] with "bag" */
|
||||
{ "box", LARGE_BOX },
|
||||
/* normally we wouldn't have to worry about unnecessary <space>, but
|
||||
@@ -4746,6 +4747,21 @@ readobjnam_postparse3(struct _readobjnam_data *d)
|
||||
}
|
||||
}
|
||||
|
||||
/* got a class, but not specific type;
|
||||
check alternate spellings of items with matching classes */
|
||||
if (d->oclass && !d->typ) {
|
||||
const struct alt_spellings *as = spellings;
|
||||
|
||||
while (as->sp) {
|
||||
if (objects[as->ob].oc_class == d->oclass
|
||||
&& wishymatch(d->bp, as->sp, TRUE)) {
|
||||
d->typ = as->ob;
|
||||
return 2; /*goto typfnd;*/
|
||||
}
|
||||
as++;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -60,6 +60,9 @@ local wishtest_objects = {
|
||||
["blessed fireproof +2 pair of speed boots"] = { otyp_name = "speed boots", oclass = "[", oerodeproof = 1, blessed = 1, spe = 2 },
|
||||
["tooled horn"] = { otyp_name = "tooled horn", oclass = "(" },
|
||||
["meat ring"] = { otyp_name = "meat ring", oclass = "%" },
|
||||
["cursed +3 ring of increase accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 3, cursed = 1 },
|
||||
["ring of accuracy"] = { otyp_name = "increase accuracy", oclass = "=", spe = 5 },
|
||||
["accuracy"] = { otyp_name = "increase accuracy", oclass = "=" },
|
||||
["beartrap"] = { otyp_name = "beartrap", oclass = "(" },
|
||||
["bear trap"] = { otyp_name = "beartrap", oclass = "(" },
|
||||
["landmine"] = { otyp_name = "land mine", oclass = "(" },
|
||||
@@ -94,3 +97,4 @@ for str, tbl in pairs(wishtest_objects) do
|
||||
end
|
||||
end
|
||||
end
|
||||
pline("testwish: OK");
|
||||
|
||||
Reference in New Issue
Block a user