From 3d122e062f21f01b0c59370b398864d7dca6eb15 Mon Sep 17 00:00:00 2001 From: Stefan Zermatten Date: Thu, 22 Apr 2021 15:39:14 +0200 Subject: [PATCH] Added the distinction between half rounded up or down for proficiencies --- .../computation/engine/combineStat.js | 25 +++++++++++++------ app/imports/api/properties/Proficiencies.js | 3 ++- .../components/skills/SkillProficiency.vue | 15 ++++++++--- .../forms/shared/ProficiencySelect.vue | 7 ++++-- .../ui/properties/viewers/SkillViewer.vue | 4 ++- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/app/imports/api/creature/computation/engine/combineStat.js b/app/imports/api/creature/computation/engine/combineStat.js index eea810e5..800fe1ce 100644 --- a/app/imports/api/creature/computation/engine/combineStat.js +++ b/app/imports/api/creature/computation/engine/combineStat.js @@ -108,6 +108,14 @@ function combineSkill(stat, aggregator, memo){ let profBonusStat = memo.statsByVariableName['proficiencyBonus']; let profBonus = profBonusStat && profBonusStat.value; + if (profBonusStat){ + stat.dependencies = union( + stat.dependencies, + [profBonusStat._id], + profBonusStat.dependencies, + ); + } + if (typeof profBonus !== 'number' && memo.statsByVariableName['level']){ let levelProp = memo.statsByVariableName['level']; let level = levelProp.value; @@ -118,15 +126,16 @@ function combineSkill(stat, aggregator, memo){ if (levelProp.dependencies){ stat.dependencies = union(stat.dependencies, levelProp.dependencies); } - } else { - stat.dependencies = union( - stat.dependencies, - [profBonusStat._id], - profBonusStat.dependencies, - ); } + // Multiply the proficiency bonus by the actual proficiency - profBonus *= stat.proficiency; + if(stat.proficiency === 0.49){ + // Round down proficiency bonus in the special case + profBonus = Math.floor(profBonus * 0.5); + } else { + profBonus = Math.ceil(profBonus * stat.proficiency); + } + // Combine everything to get the final result let result = (aggregator.base + stat.abilityMod + profBonus + aggregator.add) * aggregator.mul; if (result < aggregator.min) result = aggregator.min; @@ -161,6 +170,8 @@ function combineSkill(stat, aggregator, memo){ stat.baseValue === undefined && stat.proficiency == 0 || undefined; + + console.log(stat); } function combineDamageMultiplier(stat){ diff --git a/app/imports/api/properties/Proficiencies.js b/app/imports/api/properties/Proficiencies.js index 02a8f0ed..1099b97a 100644 --- a/app/imports/api/properties/Proficiencies.js +++ b/app/imports/api/properties/Proficiencies.js @@ -14,9 +14,10 @@ let ProficiencySchema = new SimpleSchema({ type: String, }, // A number representing how proficient the character is + // where 0.49 is half rounded down and 0.5 is half rounded up value: { type: Number, - allowedValues: [0.5, 1, 2], + allowedValues: [0.49, 0.5, 1, 2], defaultValue: 1, }, }); diff --git a/app/imports/ui/properties/components/skills/SkillProficiency.vue b/app/imports/ui/properties/components/skills/SkillProficiency.vue index f7b69911..a2782b73 100644 --- a/app/imports/ui/properties/components/skills/SkillProficiency.vue +++ b/app/imports/ui/properties/components/skills/SkillProficiency.vue @@ -58,8 +58,10 @@ }, computed: { icon(){ - if (this.model.value == 0.5){ - return 'brightness_2'; + if (this.model.value == 0.49){ + return 'brightness_3'; + } else if (this.model.value == 0.5) { + return 'brightness_2' } else if (this.model.value == 1) { return 'brightness_1' } else if (this.model.value == 2){ @@ -70,7 +72,8 @@ }, proficiencyText(){ switch (this.model.value){ - case 0.5: return 'Half proficiency bonus'; + case 0.49: return 'Half proficiency bonus rounded down'; + case 0.5: return 'Half proficiency bonus rounded up'; case 1: return 'Proficient'; case 2: return 'Double proficiency bonus'; default: return ''; @@ -78,7 +81,11 @@ }, proficiencyValue(){ if (!this.proficiencyBonus) return; - return Math.ceil(this.model.value * this.proficiencyBonus); + if (this.model.value === 0.49){ + return Math.floor(0.5 * this.proficiencyBonus); + } else { + return Math.ceil(this.model.value * this.proficiencyBonus); + } }, }, methods: { diff --git a/app/imports/ui/properties/forms/shared/ProficiencySelect.vue b/app/imports/ui/properties/forms/shared/ProficiencySelect.vue index 92dd81b7..8183c00b 100644 --- a/app/imports/ui/properties/forms/shared/ProficiencySelect.vue +++ b/app/imports/ui/properties/forms/shared/ProficiencySelect.vue @@ -22,7 +22,9 @@