BattleUnit.prototype.liftStatusTags = function(tags){ var me = this; var statusIDs = Link(this.statuses) .where(function(status) { return Link(status.statusDef.tags).some(tags); }) .pluck('statusID') .each(function(statusID) { me.liftStatus(statusID); }};
var statuses = [ { id: 0, statDef: { tags: ["heal", "death", "burn"] } }, { id: 1, statDef: { tags: ["heal", "spark"] } }, { id: 2, statDef: { tags: ["drain", "turn"] } }];Link(statuses).where(function(status) { return Link(status.statDef.tags).some(["burn", "drain"]); }).each(function(status) { console.log(status.id); // I get 0 and 2 in chrome; nothing in Sphere});
Also I love how your little example alludes to a status tagged both 'heal' and 'death'. Consider its other tag is 'burn', I can't even imagine what kind of unholy status ailment that's supposed to represent.
Hey, what value exactly do methods like .first() return in case no matching item is found? It must be something other than null or undefined, because my engine is choking when an AI battler attempts to target a unit by name that doesn't exist, despite a null check on the search result.
liftStatusTags: function(actor, targets, effect) { for (var i = 0; i < targets.length; ++i) { targets[i].liftStatusTags(effect.tags); } },
liftStatusTags: function(actor, targets, effect) { Link(targets).invoke("liftStatusTags", effect.tags); },
So then TurboSphere would be the same deal as Chrome speed-wise? Since both use V8...