Added the distinction between half rounded up or down for proficiencies

This commit is contained in:
Stefan Zermatten
2021-04-22 15:39:14 +02:00
parent e9a273244a
commit 3d122e062f
5 changed files with 39 additions and 15 deletions

View File

@@ -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){

View File

@@ -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,
},
});

View File

@@ -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: {

View File

@@ -22,7 +22,9 @@
<script lang="js">
const ICON_SPIN_DURATION = 300;
let proficiencyIcon = function(value){
if (value == 0.5){
if (value == 0.49){
return 'brightness_3';
} else if (value == 0.5){
return 'brightness_2';
} else if (value == 1) {
return 'brightness_1'
@@ -49,7 +51,8 @@
iconClass: '',
values: [
{value: 1, text: 'Proficient'},
{value: 0.5, text: 'Half proficiency bonus'},
{value: 0.49, text: 'Half proficiency bonus rounded down'},
{value: 0.5, text: 'Half proficiency bonus rounded up'},
{value: 2, text: 'Double proficiency bonus'},
],
}},

View File

@@ -109,7 +109,9 @@ export default {
}
},
icon(){
if (this.model.proficiency == 0.5){
if (this.model.proficiency == 0.49){
return 'brightness_3';
} else if (this.model.proficiency == 0.5){
return 'brightness_2';
} else if (this.model.proficiency == 1) {
return 'brightness_1'