I am confused. I have many options. I want to input multiple objects in a single command, such as
[1] BUY 3 torches
[2] BUY 2 swords and 1 torch
[3] BUY torch
I understand that there are many parsing UNDERSTAND options:
Understand "BUY [number][something]" as buying for option 1.
Understand "BUY [things]" as buying for option 2.
Understand "BUY [something]" as buying for option 3.
I can also say BUYING is groupable action if I want to use the Action on Groups extension.
However, is any of this redundant? Should I perhaps make a new command:
Bulk-buying is an action that applies to one number and one thing.
Understand "BUY [number][something]" as buying for option 1.
Bulk-buying is groupable action.
And then write rules for option 2 and 3 in parallel with option 1?
Anyone have some clarity here?
After much experimenting, I think I have a general solution.
[1] The key is that the Action on Groups rule doesn’t trigger unless the multiple object list is triggered by multiple nouns. It ignores the single-version phrases for buying, like Before-After-Check buying-Carry out buying, etc, as documented in the extension docs.
[2] There is no need to define a bulk-buying action because with a single noun version and the Action on Groups version, all cases are handled. One only needs
Understand "buy [things]" as buying. [buy N things]
Understand "buy [something]" as buying. [buy 1 things]
Buying is groupable action.
For the single case, Check, Carry out, and Report work as usual.
For the multiple case,
Action on groups rule for buying in Emporium:
let MOL be the multiple object list;
let N be the number of entries in MOL;
[Convert from object to thing type]
let L be a list of things;
repeat with Item running through MOL:
add Item to L;
say "L = [L]";
abide by the check multiple buying rule;
[If you reached here, all is ok]
attempt purchase of N items from L;
[3] Note that there is a conversion routine to convert the MOL (multiple object list) from a list of objects to a list of things. Only things can be bought, but the MOL might contains rooms and non-things.
[4] Instead of calling a rule and checking its fail/succeed status, the abide by the check multiple buying rule; activity is called. Make that the check rule will not return is it fails, and only returns on success. Making the check rule contain a list of error conditions is much cleaner.
[5] The actual work is done in the attempt purchase of N items from L;, which can do whatever is needed to execute the action understood.
[6] Yes, within the work rule (attempt purchase), one must walk the list of things, although a bulk actions of all-at-once is available, e.g., collecting the bill for the collection of things.
This is a template for all other actions using both the single and multiple forms. All three of the inputs in my original problem now work.