New characters get the appropriate attributes/skills/damageMultipliers
This commit is contained in:
@@ -36,6 +36,7 @@ Schemas.Attribute = new SimpleSchema({
|
|||||||
value: {
|
value: {
|
||||||
type: Number,
|
type: Number,
|
||||||
decimal: true,
|
decimal: true,
|
||||||
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
adjustment: {
|
adjustment: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
@@ -1,7 +1,5 @@
|
|||||||
// TODO recalculate carried weight method
|
// TODO recalculate carried weight method
|
||||||
// TODO Add attribute, skill, damageMultiplier and bundle library models
|
// TODO actually write the recomputed character to the database
|
||||||
// Bundle libraries should support races, classes, and rulesets
|
|
||||||
// TODO Add monster library
|
|
||||||
|
|
||||||
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import { ValidatedMethod } from 'meteor/mdg:validated-method';
|
||||||
|
|
||||||
//set up the collection for characters
|
//set up the collection for characters
|
||||||
Characters = new Mongo.Collection("characters");
|
Characters = new Mongo.Collection("characters");
|
||||||
|
|
||||||
@@ -17,8 +19,9 @@ Schemas.Character = new SimpleSchema({
|
|||||||
backstory: {type: String, defaultValue: "", trim: false, optional: true},
|
backstory: {type: String, defaultValue: "", trim: false, optional: true},
|
||||||
|
|
||||||
//mechanics
|
//mechanics
|
||||||
deathSave: {type: Schemas.DeathSave},
|
deathSave: {type: Schemas.DeathSave},
|
||||||
xp: {type: Number, defaultValue: 0},
|
xp: {type: Number, defaultValue: 0},
|
||||||
|
carriedWeight: {type: Number, defaultValue: 0},
|
||||||
|
|
||||||
//permissions
|
//permissions
|
||||||
party: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true},
|
party: {type: String, regEx: SimpleSchema.RegEx.Id, optional: true},
|
||||||
@@ -68,6 +71,87 @@ Characters.calculate = {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const insertCharacterMethod = new ValidatedMethod({
|
||||||
|
|
||||||
|
name: "Characters.methods.insert", // DDP method name
|
||||||
|
|
||||||
|
validate: new SimpleSchema({
|
||||||
|
name: {
|
||||||
|
type: String,
|
||||||
|
optional: true,
|
||||||
|
},
|
||||||
|
}).validator(),
|
||||||
|
|
||||||
|
run({name}) {
|
||||||
|
if (!this.userId) {
|
||||||
|
throw new Meteor.Error("Characters.methods.insert.denied",
|
||||||
|
"You need to be logged in to insert a character");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create the character document
|
||||||
|
Characters.insert({name, owner: this.userId});
|
||||||
|
//Add all the required attributes to it
|
||||||
|
addDefaultAttributes(charId);
|
||||||
|
},
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
const addDefaultAttributes function(charId){
|
||||||
|
const stats = DEFAULT_CHARACTER_STATS;
|
||||||
|
let order = 0;
|
||||||
|
const baseParent = {
|
||||||
|
collection: "Characters",
|
||||||
|
id: charId,
|
||||||
|
group: "default",
|
||||||
|
};
|
||||||
|
let name, variableName, parent, attribute, skill, ability, dm;
|
||||||
|
for (type in stats.attributes){
|
||||||
|
for (let i in stats.attributes[type]){
|
||||||
|
attribute = stats.attributes[type][i];
|
||||||
|
if (_.isString(attribute)){
|
||||||
|
name = attribute;
|
||||||
|
variableName = attribute.toLowerCase();
|
||||||
|
} else {
|
||||||
|
name = attribute.name;
|
||||||
|
variableName = attribute.variableName;
|
||||||
|
}
|
||||||
|
parent = _.clone(baseParent);
|
||||||
|
// TODO Inserting documets in a for-loop is slow
|
||||||
|
// conider using the raw collection to bulk insert
|
||||||
|
// Including a callback makes the operation async, 3x faster
|
||||||
|
Attributes.insert({
|
||||||
|
charId, name, variableName, order, type, parent
|
||||||
|
}, function(error, _id){}));
|
||||||
|
order++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
order = 0;
|
||||||
|
for (type in stats.skills){
|
||||||
|
for (let i in stats.skills[type]){
|
||||||
|
skill = stats.skills[type][i];
|
||||||
|
Skills.insert({
|
||||||
|
charId,
|
||||||
|
type,
|
||||||
|
order,
|
||||||
|
name: skill.name,
|
||||||
|
variableName: skill.variableName,
|
||||||
|
ability: skill.ability,
|
||||||
|
parent: _.clone(baseParent),
|
||||||
|
}, function(error, _id){}));
|
||||||
|
order++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let i in stats.damageMultipliers){
|
||||||
|
dm = stats.damageMultipliers[i];
|
||||||
|
DamageMultipliers.insert({
|
||||||
|
charId,
|
||||||
|
name: dm.name,
|
||||||
|
variableName = dm.variableName,
|
||||||
|
parent: _.clone(baseParent),
|
||||||
|
}, function(error, _id){}));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
//clean up all data related to that character before removing it
|
//clean up all data related to that character before removing it
|
||||||
if (Meteor.isServer){
|
if (Meteor.isServer){
|
||||||
Characters.after.remove(function(userId, character) {
|
Characters.after.remove(function(userId, character) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ Schemas.DamageMultiplier = new SimpleSchema({
|
|||||||
value: {
|
value: {
|
||||||
type: Number,
|
type: Number,
|
||||||
decimal: true,
|
decimal: true,
|
||||||
|
defaultValue: 1,
|
||||||
},
|
},
|
||||||
parent: {
|
parent: {
|
||||||
type: Schemas.Parent
|
type: Schemas.Parent
|
||||||
|
|||||||
@@ -34,9 +34,14 @@ Schemas.Skill = new SimpleSchema({
|
|||||||
"utility", //not displayed anywhere
|
"utility", //not displayed anywhere
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
// Skills need to store their order to keep the sheet consistent
|
||||||
|
order: {
|
||||||
|
type: Number,
|
||||||
|
},
|
||||||
value: {
|
value: {
|
||||||
type: Number,
|
type: Number,
|
||||||
decimal: true,
|
decimal: true,
|
||||||
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
advantage: {
|
advantage: {
|
||||||
type: Number,
|
type: Number,
|
||||||
@@ -50,6 +55,7 @@ Schemas.Skill = new SimpleSchema({
|
|||||||
proficiency: {
|
proficiency: {
|
||||||
type: Number,
|
type: Number,
|
||||||
allowedValues: [0, 0.5, 1, 2],
|
allowedValues: [0, 0.5, 1, 2],
|
||||||
|
defaultValue: 0,
|
||||||
},
|
},
|
||||||
conditionalBenefits: {
|
conditionalBenefits: {
|
||||||
type: Number,
|
type: Number,
|
||||||
|
|||||||
96
app/lib/constants/defaultCharacterStats.js
Normal file
96
app/lib/constants/defaultCharacterStats.js
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
DEFAULT_CHARACTER_STATS = {
|
||||||
|
"attributes": {
|
||||||
|
"ability": [
|
||||||
|
"Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"
|
||||||
|
],
|
||||||
|
"stat": [
|
||||||
|
"Speed",
|
||||||
|
{"name": "Armor Class", "variableName": "armor"},
|
||||||
|
],
|
||||||
|
"hitDice": [
|
||||||
|
{"name": "d6 Hit Dice", "variableName": "d6HitDice"},
|
||||||
|
{"name": "d8 Hit Dice", "variableName": "d8HitDice"},
|
||||||
|
{"name": "d10 Hit Dice", "variableName": "d10HitDice"},
|
||||||
|
{"name": "d12 Hit Dice", "variableName": "d12HitDice"},
|
||||||
|
],
|
||||||
|
"healthBar": [
|
||||||
|
{"name": "Hit Points", "variableName": "hitPoints"},
|
||||||
|
{"name": "Temporary Hit Points", "variableName": "tempHitPoints"},
|
||||||
|
],
|
||||||
|
"resource": [
|
||||||
|
"Ki", "Rages",
|
||||||
|
{"name": "Sourcery Points", "variableName": "sorceryPoints"},
|
||||||
|
{"name": "Superiority Dice", "variableName": "superiorityDice"},
|
||||||
|
{"name": "Expertise Dice", "variableName": "expertiseDice"},
|
||||||
|
],
|
||||||
|
"spellSlot": [
|
||||||
|
{"name": "Level 1 Spell Slots", "variableName": "level1SpellSlots"},
|
||||||
|
{"name": "Level 2 Spell Slots", "variableName": "level2SpellSlots"},
|
||||||
|
{"name": "Level 3 Spell Slots", "variableName": "level3SpellSlots"},
|
||||||
|
{"name": "Level 4 Spell Slots", "variableName": "level4SpellSlots"},
|
||||||
|
{"name": "Level 5 Spell Slots", "variableName": "level5SpellSlots"},
|
||||||
|
{"name": "Level 6 Spell Slots", "variableName": "level6SpellSlots"},
|
||||||
|
{"name": "Level 7 Spell Slots", "variableName": "level7SpellSlots"},
|
||||||
|
{"name": "Level 8 Spell Slots", "variableName": "level8SpellSlots"},
|
||||||
|
{"name": "Level 9 Spell Slots", "variableName": "level9SpellSlots"},
|
||||||
|
],
|
||||||
|
"utility": [
|
||||||
|
{"name": "Carry Capacity Multiplier", "variableName": "carryMultiplier"},
|
||||||
|
{"name": "Rage Damage", "variableName": "rageDamage"},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
"skills": {
|
||||||
|
"skill": [
|
||||||
|
{"name": "Acrobatics", "variableName": "acrobatics", "ability": "dexterity"},
|
||||||
|
{"name": "Animal Handling", "variableName": "animalHandling", "ability": "wisdom"},
|
||||||
|
{"name": "Arcana", "variableName": "arcana", "ability": "intelligence"},
|
||||||
|
{"name": "Athletics", "variableName": "athletics", "ability": "strength"},
|
||||||
|
{"name": "Deception", "variableName": "deception", "ability": "charisma"},
|
||||||
|
{"name": "History", "variableName": "history", "ability": "intelligence"},
|
||||||
|
{"name": "Insight", "variableName": "insight", "ability": "wisdom"},
|
||||||
|
{"name": "Intimidation", "variableName": "intimidation", "ability": "charisma"},
|
||||||
|
{"name": "Investigation", "variableName": "investigation", "ability": "intelligence"},
|
||||||
|
{"name": "Medicine", "variableName": "medicine", "ability": "wisdom"},
|
||||||
|
{"name": "Nature", "variableName": "nature", "ability": "intelligence"},
|
||||||
|
{"name": "Perception", "variableName": "perception", "ability": "wisdom"},
|
||||||
|
{"name": "Performance", "variableName": "performance", "ability": "charisma"},
|
||||||
|
{"name": "Persuasion", "variableName": "persuasion", "ability": "charisma"},
|
||||||
|
{"name": "Religion", "variableName": "religion", "ability": "intelligence"},
|
||||||
|
{"name": "Sleight of Hand", "variableName": "sleightOfHand", "ability": "dexterity"},
|
||||||
|
{"name": "Stealth", "variableName": "stealth", "ability": "dexterity"},
|
||||||
|
{"name": "Survival", "variableName": "survival", "ability": "wisdom"},
|
||||||
|
],
|
||||||
|
"save": [
|
||||||
|
{"name": "Strength Save", "variableName": "strengthSave", "ability": "strength"},
|
||||||
|
{"name": "Dexterity Save", "variableName": "dexteritySave", "ability": "dexterity"},
|
||||||
|
{"name": "Constitution Save", "variableName": "constitutionSave", "ability": "constitution"},
|
||||||
|
{"name": "Intelligence Save", "variableName": "intelligenceSave", "ability": "intelligence"},
|
||||||
|
{"name": "Wisdom Save", "variableName": "wisdomSave", "ability": "wisdom"},
|
||||||
|
{"name": "Charisma Save", "variableName": "charismaSave", "ability": "charisma"},
|
||||||
|
],
|
||||||
|
"stat": [
|
||||||
|
{"name": "Proficiency Bonus", "variableName": "proficiencyBonus"},
|
||||||
|
{"name": "initiative", "variableName": "initiative"},
|
||||||
|
],
|
||||||
|
"utility": [
|
||||||
|
{"name": "Dexterity Armor", "variableName": "dexterityArmor", "ability": "dexterity"},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
|
"damageMultipliers": [
|
||||||
|
{"name": "Acid Multiplier", "variableName":"acidMultiplier"},
|
||||||
|
{"name": "Bludgeoning Multiplier", "variableName":"bludgeoningMultiplier"},
|
||||||
|
{"name": "Cold Multiplier", "variableName":"coldMultiplier"},
|
||||||
|
{"name": "Fire Multiplier", "variableName":"fireMultiplier"},
|
||||||
|
{"name": "Force Multiplier", "variableName":"forceMultiplier"},
|
||||||
|
{"name": "Lightning Multiplier", "variableName":"lightningMultiplier"},
|
||||||
|
{"name": "Necrotic Multiplier", "variableName":"necroticMultiplier"},
|
||||||
|
{"name": "Piercing Multiplier", "variableName":"piercingMultiplier"},
|
||||||
|
{"name": "Poison Multiplier", "variableName":"poisonMultiplier"},
|
||||||
|
{"name": "Psychic Multiplier", "variableName":"psychicMultiplier"},
|
||||||
|
{"name": "Radiant Multiplier", "variableName":"radiantMultiplier"},
|
||||||
|
{"name": "Slashing Multiplier", "variableName":"slashingMultiplier"},
|
||||||
|
{"name": "Thunder Multiplier", "variableName":"thunderMultiplier"},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -15,16 +15,19 @@ Meteor.publish("singleCharacter", function(characterId){
|
|||||||
//get all the assets for this character including soft deleted ones
|
//get all the assets for this character including soft deleted ones
|
||||||
Actions.find ({charId: characterId}, {removed: true}),
|
Actions.find ({charId: characterId}, {removed: true}),
|
||||||
Attacks.find ({charId: characterId}, {removed: true}),
|
Attacks.find ({charId: characterId}, {removed: true}),
|
||||||
|
Attributes.find ({charId: characterId}, {removed: true}),
|
||||||
Buffs.find ({charId: characterId}, {removed: true}),
|
Buffs.find ({charId: characterId}, {removed: true}),
|
||||||
Classes.find ({charId: characterId}, {removed: true}),
|
Classes.find ({charId: characterId}, {removed: true}),
|
||||||
Conditions.find ({charId: characterId}, {removed: true}),
|
Conditions.find ({charId: characterId}, {removed: true}),
|
||||||
Containers.find ({charId: characterId}, {removed: true}),
|
Containers.find ({charId: characterId}, {removed: true}),
|
||||||
CustomBuffs.find ({charId: characterId}, {removed: true}),
|
CustomBuffs.find ({charId: characterId}, {removed: true}),
|
||||||
|
DamageMultipliers.find ({charId: characterId}, {removed: true}),
|
||||||
Effects.find ({charId: characterId}, {removed: true}),
|
Effects.find ({charId: characterId}, {removed: true}),
|
||||||
Experiences.find ({charId: characterId}, {removed: true}),
|
Experiences.find ({charId: characterId}, {removed: true}),
|
||||||
Features.find ({charId: characterId}, {removed: true}),
|
Features.find ({charId: characterId}, {removed: true}),
|
||||||
Items.find ({charId: characterId}, {removed: true}),
|
Items.find ({charId: characterId}, {removed: true}),
|
||||||
Notes.find ({charId: characterId}, {removed: true}),
|
Notes.find ({charId: characterId}, {removed: true}),
|
||||||
|
Skills.find ({charId: characterId}, {removed: true}),
|
||||||
Spells.find ({charId: characterId}, {removed: true}),
|
Spells.find ({charId: characterId}, {removed: true}),
|
||||||
SpellLists.find ({charId: characterId}, {removed: true}),
|
SpellLists.find ({charId: characterId}, {removed: true}),
|
||||||
TemporaryHitPoints.find ({charId: characterId}, {removed: true}),
|
TemporaryHitPoints.find ({charId: characterId}, {removed: true}),
|
||||||
|
|||||||
Reference in New Issue
Block a user