Gave effects their own collection, they no longer live in arrays attached to skills/attributes
Also improved the display of features and generally iterated on their manipulation. Characters now fetch the relevant effects directly when making a calculation, simplifying almost everything. Effects now store a reference to their source if they have one. Effect names are now optional, they can be fetched from the source's name if the source exists.
This commit is contained in:
@@ -1,22 +0,0 @@
|
||||
Meteor.methods({
|
||||
updateAction: function (charId, oldAction, newAction) {
|
||||
var selector = {_id: charId, "actions._id": oldAction._id};
|
||||
var setter = {"actions.$": newAction};
|
||||
Characters.update(
|
||||
selector,
|
||||
{ $set: setter }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
pullAction = function(id, action){
|
||||
var pullObject = {};
|
||||
pullObject["actions"] = {_id: action._id};
|
||||
Characters.update(id, {$pull: pullObject });
|
||||
};
|
||||
|
||||
pushAction = function(id, action){
|
||||
var pushObject = {};
|
||||
pushObject["actions"] = action;
|
||||
Characters.update(id, {$push: pushObject});
|
||||
};
|
||||
@@ -1,22 +0,0 @@
|
||||
Meteor.methods({
|
||||
updateAttack: function (charId, oldAttack, newAttack) {
|
||||
var selector = {_id: charId, "attacks._id": oldAttack._id};
|
||||
var setter = {"attacks.$": newAttack};
|
||||
Characters.update(
|
||||
selector,
|
||||
{ $set: setter }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
pullAttack = function(id, attack){
|
||||
var pullObject = {};
|
||||
pullObject["attacks"] = {_id: attack._id};
|
||||
Characters.update(id, {$pull: pullObject });
|
||||
};
|
||||
|
||||
pushAttack = function(id, attack){
|
||||
var pushObject = {};
|
||||
pushObject["attacks"] = attack;
|
||||
Characters.update(id, {$push: pushObject});
|
||||
};
|
||||
@@ -1,41 +0,0 @@
|
||||
Meteor.methods({
|
||||
updateEffect: function (charId, attributeName, effectId, newEffect) {
|
||||
var selector = {_id: charId};
|
||||
selector[attributeName + ".effects._id"] = effectId;
|
||||
var setter = {};
|
||||
setter[attributeName + ".effects.$"] = newEffect
|
||||
Characters.update(
|
||||
selector,
|
||||
{ $set: setter }
|
||||
)
|
||||
},
|
||||
updateFeatureEffect: function (featureId, newEffect) {
|
||||
var selector = {_id: featureId};
|
||||
selector["effects._id"] = newEffect._id;
|
||||
var setter = {};
|
||||
setter["effects.$"] = newEffect
|
||||
Features.update(
|
||||
selector,
|
||||
{ $set: setter }
|
||||
)
|
||||
}
|
||||
});
|
||||
|
||||
//pull a single effect by stat and id
|
||||
pullEffect = function(id, effect){
|
||||
if(effect.stat){
|
||||
var pullObject = {};
|
||||
pullObject[effect.stat + ".effects"] = {_id: effect._id};
|
||||
Characters.update(id, {$pull: pullObject });
|
||||
}
|
||||
},
|
||||
|
||||
pushEffect = function(id, effect){
|
||||
if(effect.stat){
|
||||
var pushObject = {};
|
||||
pushObject[effect.stat + ".effects"] = effect;
|
||||
Characters.update(id, {$push: pushObject});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
addFeatureEffects = function(charId, newFeature){
|
||||
_.each(newFeature.effects, function(effect){
|
||||
if(newFeature.name) effect.name = newFeature.name;
|
||||
pushEffect(charId, effect);
|
||||
});
|
||||
_.each(newFeature.actions, function(action){
|
||||
pushAction(charId, action);
|
||||
});
|
||||
_.each(newFeature.attacks, function(attack){
|
||||
pushAttack(charId, attack);
|
||||
});
|
||||
_.each(newFeature.spells, function(spell){
|
||||
pushSpell(charId, spell);
|
||||
});
|
||||
}
|
||||
|
||||
removeFeatureEffects = function(charId, oldFeature){
|
||||
_.each(oldFeature.effects, function(effect){
|
||||
pullEffect(charId, effect);
|
||||
});
|
||||
_.each(oldFeature.actions, function(action){
|
||||
pullAction(charId, action);
|
||||
});
|
||||
_.each(oldFeature.attacks, function(attack){
|
||||
pullAttack(charId, attack);
|
||||
});
|
||||
_.each(oldFeature.spells, function(spell){
|
||||
pullSpell(charId, spell);
|
||||
});
|
||||
};
|
||||
@@ -1,22 +0,0 @@
|
||||
Meteor.methods({
|
||||
updateSpell: function (charId, oldSpell, newSpell) {
|
||||
var selector = {_id: charId, "spells._id": oldSpell._id};
|
||||
var setter = {"spells.$": newSpell};
|
||||
Characters.update(
|
||||
selector,
|
||||
{ $set: setter }
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
pullSpell = function(id, spell){
|
||||
var pullObject = {};
|
||||
pullObject["spells"] = {_id: spell._id};
|
||||
Characters.update(id, {$pull: pullObject });
|
||||
};
|
||||
|
||||
pushSpell = function(id, spell){
|
||||
var pushObject = {};
|
||||
pushObject["spells"] = spell;
|
||||
Characters.update(id, {$push: pushObject});
|
||||
};
|
||||
Reference in New Issue
Block a user