Added edit tab to base dialogs, added edit screen to attribute dialog
This commit is contained in:
@@ -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,
|
||||
};
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user