Got creature computation working again after moving to imports dir
This commit is contained in:
166
app/imports/api/creature/creatureDefaultStats.js
Normal file
166
app/imports/api/creature/creatureDefaultStats.js
Normal file
@@ -0,0 +1,166 @@
|
||||
DEFAULT_CHARACTER_STATS = {
|
||||
"attributes": {
|
||||
"ability": [
|
||||
"Strength", "Dexterity", "Constitution", "Intelligence", "Wisdom", "Charisma"
|
||||
],
|
||||
"stat": [
|
||||
"Speed",
|
||||
{"name": "Armor Class", "variableName": "armor", "baseValue": 10},
|
||||
],
|
||||
"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", "baseValue": 1},
|
||||
{"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"},
|
||||
],
|
||||
},
|
||||
|
||||
"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"},
|
||||
],
|
||||
|
||||
"effects": [
|
||||
{
|
||||
"name": "Proficiency bonus by level",
|
||||
"stat": "proficiencyBonus",
|
||||
"operation": "add",
|
||||
"calculation": "floor(level / 4 + 1.75)",
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
getDefaultCreatureDocs = function(charId, creatureType = "pc"){
|
||||
let docs = {attributes: [], skills: [], damageMultipliers: []};
|
||||
if (creatureType === "pc"){
|
||||
const stats = DEFAULT_CHARACTER_STATS;
|
||||
} else {
|
||||
throw new Meteor.Error("Not implemented",
|
||||
"Default stats for non-player characters aren't implemented yet");
|
||||
}
|
||||
let order = 0;
|
||||
const baseParent = {
|
||||
collection: "Characters",
|
||||
id: charId,
|
||||
group: "default",
|
||||
};
|
||||
let name, variableName, parent, attribute, skill, ability, dm, type, baseValue;
|
||||
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;
|
||||
}
|
||||
baseValue = attribute.baseValue;
|
||||
parent = _.clone(baseParent);
|
||||
docs.attributes.push({
|
||||
_id: Random.id,
|
||||
charId, name, variableName, order, type, parent, baseValue,
|
||||
});
|
||||
order++;
|
||||
}
|
||||
}
|
||||
order = 0;
|
||||
for (type in stats.skills){
|
||||
for (let i in stats.skills[type]){
|
||||
skill = stats.skills[type][i];
|
||||
docs.skills.push({
|
||||
_id: Random.id,
|
||||
charId,
|
||||
type,
|
||||
order,
|
||||
name: skill.name,
|
||||
variableName: skill.variableName,
|
||||
ability: skill.ability,
|
||||
parent: _.clone(baseParent),
|
||||
});
|
||||
order++;
|
||||
}
|
||||
}
|
||||
for (let i in stats.damageMultipliers){
|
||||
dm = stats.damageMultipliers[i];
|
||||
docs.damageMultipliers.push({
|
||||
_id: Random.id,
|
||||
charId,
|
||||
name: dm.name,
|
||||
variableName: dm.variableName,
|
||||
parent: _.clone(baseParent),
|
||||
});
|
||||
}
|
||||
return docs;
|
||||
}
|
||||
Reference in New Issue
Block a user