Added edit tab to base dialogs, added edit screen to attribute dialog

This commit is contained in:
Stefan Zermatten
2019-02-18 13:41:21 +02:00
parent 5d45788521
commit d30ee06e33
7 changed files with 57 additions and 30 deletions

View File

@@ -18,12 +18,12 @@ const getRacialBonusEffect = function(charId, attribute, bonus){
name: "Race Bonus",
stat: attribute,
operation: "add",
calculation: bonus,
calculation: bonus.toString(),
enabled: true,
parent: {
collection: "Creatures",
id: charId,
group: "racial",
group: "race",
},
charId: charId,
};

View File

@@ -91,6 +91,7 @@ let updateAttributeSchema = pickKeysAsOptional(attributeSchema, [
'type',
'baseValue',
'decimal',
'adjustment',
'reset',
'resetMultiplier',
'color',
@@ -109,13 +110,18 @@ const updateAttribute = new ValidatedMethod({
}).validator(),
run({_id, update}) {
let currentAttribute = Attributes.findOne(_id);
let currentAttribute = Attributes.findOne(_id, {fields: {value: 1, charId: 1}});
if (!currentAttribute){
throw new Meteor.Error("Attributes.methods.update.denied",
`No attributes exist with the id: ${_id}`);
}
let charId = currentAttribute.charId;
if (canEditCreature(charId, this.userId)){
if (typeof update.adjustment === 'number'){
let val = currentAttribute.value;
if (update.adjustment < -val) update.adjustment = -val;
if (update.adjustment > 0) update.adjustment = 0;
}
Attributes.update(_id, {$set: update});
recomputeCreatureById(charId);
}