Skip to content

Commit

Permalink
Merge pull request #38 from orffen/r8
Browse files Browse the repository at this point in the history
R8
  • Loading branch information
orffen committed Sep 26, 2022
2 parents b2eafe3 + 736a30a commit 857d886
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 10 deletions.
20 changes: 12 additions & 8 deletions module/documents/actor.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,20 @@ export class BasicFantasyRPGActor extends Actor {
let specialAbilityLookup = [3, 12, 25, 30, 40, 45, 55, 65, 70, 75, 90, 95, 100, 110, 115, 125, 135, 145, 160, 175, 200, 225, 250, 275, 300, 325];
let xpValue = 0;
let xpSpecialAbilityBonus = 0;
if (data.hitDice.size == "d8" && data.hitDice.mod >= 0) {
xpValue = xpLookup[data.hitDice.number];
xpSpecialAbilityBonus = specialAbilityLookup[data.hitDice.number] * data.specialAbility.value;
} else {
if (data.hitDice.number < 1 || (data.hitDice.number == 1 && data.hitDice.mod < 0) || data.hitDice.size < "d8") {
xpValue = xpLookup[0];
xpSpecialAbilityBonus = specialAbilityLookup[0] * data.specialAbility.value;
} else if (data.hitDice.number > 25) {
xpValue = 9000 + (data.hitDice.number - 25) * 750;
xpSpecialAbilityBonus = (325 + (data.hitDice.number - 25) * 25) * data.specialAbility.value;
} else {
xpValue = xpLookup[data.hitDice.number];
xpSpecialAbilityBonus = specialAbilityLookup[data.hitDice.number] * data.specialAbility.value;
}
return xpValue + xpSpecialAbilityBonus;
return xpValue + Math.max(0, xpSpecialAbilityBonus); // never return a negative special ability bonus
};

data.attackBonus.value = this._calculateMonsterAttackBonus();

}

/**
Expand All @@ -108,7 +110,9 @@ export class BasicFantasyRPGActor extends Actor {
_calculateMonsterAttackBonus() {
if (this.system.hitDice.number < 1) {
return 0;
}
} else if (this.system.hitDice.number > 31) {
return 16;
}
switch (this.system.hitDice.number) {
case 9: return 8;
case 10:
Expand All @@ -133,7 +137,7 @@ export class BasicFantasyRPGActor extends Actor {
case 29:
case 30:
case 31: return 15;
default: return this.system.hitDice.number;
default: return this.system.hitDice.number; // this handles 1-9
}
}

Expand Down
4 changes: 2 additions & 2 deletions system.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"id": "basicfantasyrpg",
"title": "Basic Fantasy RPG",
"description": "The Basic Fantasy RPG system for FoundryVTT!",
"version": "r7",
"version": "r8",
"compatibility": {
"minimum": "10",
"verified": "10",
Expand Down Expand Up @@ -32,6 +32,6 @@
"secondaryTokenAttribute": null,
"url": "https://github.com/orffen/basicfantasyrpg",
"manifest": "https://raw.githubusercontent.com/orffen/basicfantasyrpg/main/system.json",
"download": "https://github.com/orffen/basicfantasyrpg/archive/refs/tags/r7.zip",
"download": "https://github.com/orffen/basicfantasyrpg/archive/refs/tags/r8.zip",
"license": "LICENSE.txt"
}

0 comments on commit 857d886

Please sign in to comment.