New feature idea, assuming this can't already be done somehow: Some sort of feature where you can query for multiple different items at once. For example, I have a tagging feature for statuses where they can be tagged with such things as "ailment", "debuff", etc. There doesn't seem to be a simple way to run a query that checks for multiple tags at once. Here's an example of something I'm currently doing with Link:
BattleUnit.prototype.liftStatusTag = function(tag)
{
var statusIDs = Link(this.statuses)
.where(function(status) { return Link(status.statusDef.tags).contains(tag); })
.pluck('statusID')
.toArray();
for (var i = 0; i < statusIDs.length; ++i) {
this.liftStatus(statusIDs[i]);
}
};
For reference, a status definition in Specs looks like this:
disarray: {
name: "Disarray",
tags: [ 'acute' ],
initialize: function(unit) {
this.actionsTaken = 0;
},
acting: function(unit, eventData) {
if (eventData.action.rank != Infinity) {
eventData.action.rank = Math.floor(Math.min(Math.random() * 5 + 1, 5));
}
++this.actionsTaken;
if (this.actionsTaken >= 3) {
unit.liftStatus('disarray');
}
}
},
Basically what I want to be able to do is query a unit's list of active statuses, and then filter the result based on whether any status's tags array contains any tags listed in ANOTHER array (example: querying for both debuffs and ailments), and then operating on the result (to continue the example, lifting those statuses returned by the query).
I guess essentially what I'm asking for is a vector version of .filterBy(), now that I think about it. filterBy takes the name of a scalar member and passes any item for which that member's value matches one specified, whereas this would take the name of an
array member and pass any item for which that array contained any value in a specified array. e.g.:
Link(statuses).vectorFilterBy('tags', [ 'ailment', 'debuff' ]).each(function(item) {
// ...
}
Maybe even have a hybrid scalar/vector version as well, that checks whether a scalar member matches any of a list of values.