Made carry capacity an attribute, migrations need testing

This commit is contained in:
Stefan Zermatten
2015-08-31 15:51:52 +02:00
parent c08cf83096
commit 9e200db7b9
4 changed files with 59 additions and 4 deletions

View File

@@ -33,6 +33,7 @@ Schemas.Character = new SimpleSchema({
age: {type: Schemas.Attribute}, age: {type: Schemas.Attribute},
ageRate: {type: Schemas.Attribute}, ageRate: {type: Schemas.Attribute},
armor: {type: Schemas.Attribute}, armor: {type: Schemas.Attribute},
carryMultiplier: {type: Schemas.Attribute},
//resources //resources
level1SpellSlots: {type: Schemas.Attribute}, level1SpellSlots: {type: Schemas.Attribute},

View File

@@ -107,6 +107,18 @@ if (Meteor.isServer) Characters.after.insert(function(userId, char) {
group: "Inate", group: "Inate",
}, },
}); });
Effects.insert({
charId: char._id,
name: "Natural Carrying Capacity",
stat: "carryMultiplier",
operation: "base",
value: "1",
parent: {
id: char._id,
collection: "Characters",
group: "Inate",
},
});
}); });
Effects.attachBehaviour("softRemovable"); Effects.attachBehaviour("softRemovable");

View File

@@ -2,19 +2,19 @@
<table class="carryCapacityTable strengthTable"> <table class="carryCapacityTable strengthTable">
<tr> <tr>
<td>Encumbered</td> <td>Encumbered</td>
<td>&gt;{{evaluate charId "strength * 5"}}lbs</td> <td>&gt;{{evaluate charId "strength * 5 * carryMultiplier"}}lbs</td>
<td class="caption">Variant rule, encumbered characters move 10 feet slower</td> <td class="caption">Variant rule, encumbered characters move 10 feet slower</td>
</tr> </tr>
<tr> <tr>
<td>Heavily encumbered</td> <td>Heavily encumbered</td>
<td>&gt;{{evaluate charId "strength * 10"}}lbs</td> <td>&gt;{{evaluate charId "strength * 10 * carryMultiplier"}}lbs</td>
<td class="caption"> <td class="caption">
Variant rule, heavily encumbered characters move 20 feet slower and have disadvantage on ability checks, attack rolls, and saving thows that use Strength, Dexterity, or Constitution Variant rule, heavily encumbered characters move 20 feet slower and have disadvantage on ability checks, attack rolls, and saving thows that use Strength, Dexterity, or Constitution
</td> </td>
</tr> </tr>
<tr> <tr>
<td>Over Encumbered</td> <td>Over Encumbered</td>
<td>&gt;{{evaluate charId "strength * 15"}}lbs</td> <td>&gt;{{evaluate charId "strength * 15 * carryMultiplier"}}lbs</td>
<td class="caption"> <td class="caption">
Characters that can only just lift, push or drag their current load can only move at 5 feet. Characters that can only just lift, push or drag their current load can only move at 5 feet.
</td> </td>
@@ -25,4 +25,4 @@
<td class="caption"></td> <td class="caption"></td>
</tr> </tr>
</table> </table>
</template> </template>

View File

@@ -108,3 +108,45 @@ Migrations.add({
); );
}, },
}); });
Migrations.add({
version: 4,
name: "Adds an effect to give characters a base carry capacity",
up: function() {
//update characters
Characters.find().forEach(function(char){
Characters.update(char._id, {
$set: {
carryMultiplier: {
adjustment: 0,
reset: "longRest",
}
}
});
var effect = Effects.findOne({
charId: char._id, name: "Natural Carrying Capacity"
});
if (effect) return;
Effects.insert({
charId: char._id,
name: "Natural Carrying Capacity",
stat: "carryMultiplier",
operation: "base",
value: "1",
parent: {
id: char._id,
collection: "Characters",
group: "Inate",
},
});
effect = Effects.findOne({
charId: char._id, name: "Natural Carrying Capacity"
});
if (!effect) throw "Carry capacity effect should be set by now."
});
},
down: function(){
return;
},
});