Skip to content

Commit b2eafe3

Browse files
authored
Merge pull request #32 from orffen/v10-devel
r7 - FoundryVTT v10 required
2 parents 854a871 + 973b7a7 commit b2eafe3

18 files changed

+71
-61
lines changed

module/basicfantasyrpg.mjs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,10 @@ Hooks.on("createActor", async function(actor) {
9696

9797
Hooks.on("createToken", async function(token, options, id) {
9898
if (token.actor.type === "monster") {
99-
let newHitPoints = new Roll(`${token.actor.data.data.hitDice.number}${token.actor.data.data.hitDice.size}+${token.actor.data.data.hitDice.mod}`);
99+
let newHitPoints = new Roll(`${token.actor.system.hitDice.number}${token.actor.system.hitDice.size}+${token.actor.system.hitDice.mod}`);
100100
await newHitPoints.evaluate({ async: true });
101-
token.actor.data.data.hitPoints.value = Math.max(1, newHitPoints.total);
102-
token.actor.data.data.hitPoints.max = Math.max(1, newHitPoints.total);
101+
token.actor.system.hitPoints.value = Math.max(1, newHitPoints.total);
102+
token.actor.system.hitPoints.max = Math.max(1, newHitPoints.total);
103103
}
104104
});
105105

module/documents/actor.mjs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ export class BasicFantasyRPGActor extends Actor {
2929
* is queried and has a roll executed directly from it).
3030
*/
3131
prepareDerivedData() {
32-
const actorData = this.data;
33-
const data = actorData.data;
32+
const actorData = this;
33+
const data = actorData.system;
3434
const flags = actorData.flags.basicfantasyrpg || {};
3535

3636
// Make separate methods for each Actor type (character, monster, etc.) to keep
@@ -46,7 +46,7 @@ export class BasicFantasyRPGActor extends Actor {
4646
if (actorData.type !== 'character') return;
4747

4848
// Make modifications to data here. For example:
49-
const data = actorData.data;
49+
const data = actorData.system;
5050

5151
// Loop through ability scores, and add their modifiers to our sheet output.
5252
for (let [key, ability] of Object.entries(data.abilities)) {
@@ -82,7 +82,7 @@ export class BasicFantasyRPGActor extends Actor {
8282
_prepareMonsterData(actorData) {
8383
if (actorData.type !== 'monster') return;
8484

85-
const data = actorData.data;
85+
const data = actorData.system;
8686
data.xp.value = function () {
8787
let xpLookup = [10, 25, 75, 145, 240, 360, 500, 670, 875, 1075, 1300, 1575, 1875, 2175, 2500, 2850, 3250, 3600, 4000, 4500, 5250, 6000, 6750, 7500, 8250, 9000];
8888
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];
@@ -106,10 +106,10 @@ export class BasicFantasyRPGActor extends Actor {
106106
* Calculate monster attack bonus
107107
*/
108108
_calculateMonsterAttackBonus() {
109-
if (this.data.data.hitDice.number < 1) {
109+
if (this.system.hitDice.number < 1) {
110110
return 0;
111111
}
112-
switch (this.data.data.hitDice.number) {
112+
switch (this.system.hitDice.number) {
113113
case 9: return 8;
114114
case 10:
115115
case 11: return 9
@@ -133,7 +133,7 @@ export class BasicFantasyRPGActor extends Actor {
133133
case 29:
134134
case 30:
135135
case 31: return 15;
136-
default: return this.data.data.hitDice.number;
136+
default: return this.system.hitDice.number;
137137
}
138138
}
139139

@@ -155,7 +155,7 @@ export class BasicFantasyRPGActor extends Actor {
155155
* Prepare character roll data.
156156
*/
157157
_getCharacterRollData(data) {
158-
if (this.data.type !== 'character') return;
158+
if (this.system.type !== 'character') return;
159159

160160
// Copy the ability scores to the top level, so that rolls can use
161161
// formulas like `@str.bonus + 4`.
@@ -175,7 +175,7 @@ export class BasicFantasyRPGActor extends Actor {
175175
* Prepare NPC roll data.
176176
*/
177177
_getMonsterRollData(data) {
178-
if (this.data.type !== 'monster') return;
178+
if (this.system.type !== 'monster') return;
179179

180180
// Process additional NPC data here.
181181

module/documents/item.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export class BasicFantasyRPGItem extends Item {
2020
// If present, return the actor's roll data.
2121
if ( !this.actor ) return null;
2222
const rollData = this.actor.getRollData();
23-
rollData.item = foundry.utils.deepClone(this.data.data);
23+
rollData.item = foundry.utils.deepClone(this.system);
2424

2525
return rollData;
2626
}
@@ -31,20 +31,20 @@ export class BasicFantasyRPGItem extends Item {
3131
* @private
3232
*/
3333
async roll() {
34-
const item = this.data;
34+
const item = this;
3535

3636
// Initialize chat data.
3737
const speaker = ChatMessage.getSpeaker({ actor: this.actor });
3838
const rollMode = game.settings.get('core', 'rollMode');
3939
const label = `Roll: ${game.i18n.localize('ITEM.Type' + item.type.capitalize())} - ${item.name}`;
4040

4141
// If there's no roll data, or the formula is empty, send a chat message.
42-
if (!this.data.data.formula || !this.data.data.formula.value) {
42+
if (!this.system.formula || !this.system.formula.value) {
4343
ChatMessage.create({
4444
speaker: speaker,
4545
rollMode: rollMode,
4646
flavor: label,
47-
content: item.data.description ?? ''
47+
content: item.description ?? ''
4848
});
4949
} else { // Otherwise, create a roll and send a chat message from it.
5050
// Retrieve roll data.

module/sheets/actor-sheet.mjs

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -19,24 +19,27 @@ export class BasicFantasyRPGActorSheet extends ActorSheet {
1919

2020
/** @override */
2121
get template() {
22-
return `systems/basicfantasyrpg/templates/actor/actor-${this.actor.data.type}-sheet.html`;
22+
return `systems/basicfantasyrpg/templates/actor/actor-${this.actor.type}-sheet.html`;
2323
}
2424

2525
/* -------------------------------------------- */
2626

2727
/** @override */
28-
getData() {
28+
async getData() {
2929
// Retrieve the data structure from the base sheet. You can inspect or log
3030
// the context variable to see the structure, but some key properties for
3131
// sheets are the actor object, the data object, whether or not it's
3232
// editable, the items array, and the effects array.
3333
const context = super.getData();
3434

35+
//enrichedBiography -- enriches system.biography for editor
36+
context.enrichedBiography = await TextEditor.enrichHTML(this.object.system.biography, {async: true});
37+
3538
// Use a safe clone of the actor data for further operations.
36-
const actorData = this.actor.data.toObject(false);
39+
const actorData = this.actor.toObject(false);
3740

3841
// Add the actor's data to context.data for easier access, as well as flags.
39-
context.data = actorData.data;
42+
context.data = actorData.system;
4043
context.flags = actorData.flags;
4144

4245
// Prepare character data and items.
@@ -137,16 +140,16 @@ export class BasicFantasyRPGActorSheet extends ActorSheet {
137140
// Append to gear.
138141
if (i.type === 'item') {
139142
gear.push(i);
140-
carriedWeight._addWeight(i.data.weight.value, i.data.quantity.value);
143+
carriedWeight._addWeight(i.system.weight.value, i.system.quantity.value);
141144
} else if (i.type === 'weapon') { // Append to weapons.
142145
weapons.push(i);
143-
carriedWeight._addWeight(i.data.weight.value, 1); // Weapons are always quantity 1
146+
carriedWeight._addWeight(i.system.weight.value, 1); // Weapons are always quantity 1
144147
} else if (i.type === 'armor') { // Append to armors.
145148
armors.push(i);
146-
carriedWeight._addWeight(i.data.weight.value, 1); // Armor is always quantity 1
149+
carriedWeight._addWeight(i.system.weight.value, 1); // Armor is always quantity 1
147150
} else if (i.type === 'spell') { // Append to spells.
148-
if (i.data.spellLevel.value != undefined) {
149-
spells[i.data.spellLevel.value].push(i);
151+
if (i.system.spellLevel.value != undefined) {
152+
spells[i.system.spellLevel.value].push(i);
150153
}
151154
} else if (i.type === 'feature') { // Append to features.
152155
features.push(i);
@@ -199,12 +202,12 @@ export class BasicFantasyRPGActorSheet extends ActorSheet {
199202

200203
// Prepare Spells
201204
html.find('.spell-prepare').click(ev => {
202-
const change = event.currentTarget.dataset.change;
205+
const change = ev.currentTarget.dataset.change;
203206
if (parseInt(change)) {
204207
const li = $(ev.currentTarget).parents(".item");
205208
const item = this.actor.items.get(li.data("itemId"));
206-
let newValue = item.data.data.prepared.value + parseInt(change);
207-
item.update({"data.prepared.value": newValue});
209+
let newValue = item.system.prepared.value + parseInt(change);
210+
item.update({"system.prepared.value": newValue});
208211
}
209212
});
210213

@@ -276,14 +279,14 @@ export class BasicFantasyRPGActorSheet extends ActorSheet {
276279
const item = this.actor.items.get(itemId);
277280
let label = dataset.label ? `Roll: ${dataset.label}` : `Roll: ${dataset.attack.capitalize()} attack with ${item.name}`;
278281
let rollFormula = 'd20+@ab';
279-
if (this.actor.data.type == 'character') {
282+
if (this.actor.type == 'character') {
280283
if (dataset.attack == 'melee') {
281284
rollFormula += '+@str.bonus';
282285
} else if (dataset.attack == 'ranged') {
283286
rollFormula += '+@dex.bonus';
284287
}
285288
}
286-
rollFormula += '+' + item.data.data.bonusAb.value;
289+
rollFormula += '+' + item.system.bonusAb.value;
287290
let roll = new Roll(rollFormula, this.actor.getRollData());
288291
roll.toMessage({
289292
speaker: ChatMessage.getSpeaker({ actor: this.actor }),

module/sheets/item-sheet.mjs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,21 @@ export class BasicFantasyRPGItemSheet extends ItemSheet {
2121

2222
// Alternatively, you could use the following return statement to do a
2323
// unique item sheet by type, like `weapon-sheet.html`.
24-
return `${path}/item-${this.item.data.type}-sheet.html`;
24+
return `${path}/item-${this.item.type}-sheet.html`;
2525
}
2626

2727
/* -------------------------------------------- */
2828

2929
/** @override */
30-
getData() {
30+
async getData() {
3131
// Retrieve base data structure.
3232
const context = super.getData();
3333

34+
// enrichedDescription - enriches system.description for editor
35+
context.enrichedDescription = await TextEditor.enrichHTML(this.object.system.description, {async: true});
36+
3437
// Use a safe clone of the item data for further operations.
35-
const itemData = context.item.data;
38+
const itemData = context.item;
3639

3740
// Retrieve the roll data for TinyMCE editors.
3841
context.rollData = {};
@@ -42,7 +45,7 @@ export class BasicFantasyRPGItemSheet extends ItemSheet {
4245
}
4346

4447
// Add the actor's data to context.data for easier access, as well as flags.
45-
context.data = itemData.data;
48+
context.data = itemData.system;
4649
context.flags = itemData.flags;
4750

4851
return context;

system.json

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
{
2-
"name": "basicfantasyrpg",
2+
"id": "basicfantasyrpg",
33
"title": "Basic Fantasy RPG",
44
"description": "The Basic Fantasy RPG system for FoundryVTT!",
5-
"version": "r6",
6-
"minimumCoreVersion": "0.8.9",
7-
"compatibleCoreVersion": "9",
8-
"author": "Orffen",
5+
"version": "r7",
6+
"compatibility": {
7+
"minimum": "10",
8+
"verified": "10",
9+
"maximum": "10"
10+
},
11+
"authors": [
12+
{
13+
"name": "Orffen",
14+
"email": "orffen@orffenspace.com",
15+
"discord": "Orffen#4571"
16+
}
17+
],
918
"esmodules": ["module/basicfantasyrpg.mjs"],
1019
"styles": ["styles/basicfantasyrpg.css"],
1120
"scripts": [],
@@ -23,6 +32,6 @@
2332
"secondaryTokenAttribute": null,
2433
"url": "https://github.com/orffen/basicfantasyrpg",
2534
"manifest": "https://raw.githubusercontent.com/orffen/basicfantasyrpg/main/system.json",
26-
"download": "https://github.com/orffen/basicfantasyrpg/archive/refs/tags/r6.zip",
35+
"download": "https://github.com/orffen/basicfantasyrpg/archive/refs/tags/r7.zip",
2736
"license": "LICENSE.txt"
28-
}
37+
}

templates/actor/actor-monster-sheet.html

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,8 @@ <h1 class="charname"><input name="name" type="text" value="{{actor.name}}" place
100100

101101
{{!-- Description Tab --}}
102102
<div class="tab description" data-group="primary" data-tab="description">
103-
{{!-- If you want TinyMCE editors to output inline rolls when rendered, you need to pass the actor's roll data to the rollData property. --}}
104-
{{editor content=data.biography target="data.biography" rollData=rollData button=true owner=owner editable=editable}}
103+
{{editor enrichedBiography target="system.biography" button=true editable=editable}}
105104
</div>
106105

107106
</section>
108107
</form>
109-
110-
<!-- <script>document.getElementsByName('data.attackBonus.value')[0].disabled = true;</script> -->

templates/actor/parts/actor-combat.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ <h4>{{weapon.name}}</h4>
5050
<a class="rollable" data-roll-type="weapon" data-attack="melee"><img src="systems/basicfantasyrpg/styles/melee.svg" title="{{localize 'BASICFANTASYRPG.Melee'}} {{localize 'BASICFANTASYRPG.Attack'}}" width="24" height="24"/></a>
5151
<a class="rollable" data-roll-type="weapon" data-attack="ranged"><img src="systems/basicfantasyrpg/styles/ranged.svg" title="{{localize 'BASICFANTASYRPG.Ranged'}} {{localize 'BASICFANTASYRPG.Attack'}}" width="24" height="24"/></a>
5252
<span class="flexshrink">/</span>
53-
<a class="rollable" data-roll-type="damage" data-roll="{{weapon.data.damage.value}}" data-label="{{weapon.name}} {{localizeLowerCase weapon.data.damage.label}}"><img src="systems/basicfantasyrpg/styles/damage.svg" title="{{weapon.data.damage.value}}" width="24" height="24"/></a>
53+
<a class="rollable" data-roll-type="damage" data-roll="{{weapon.system.damage.value}}" data-label="{{weapon.name}} {{localizeLowerCase weapon.system.damage.label}}"><img src="systems/basicfantasyrpg/styles/damage.svg" title="{{weapon.system.damage.value}}" width="24" height="24"/></a>
5454
</div>
5555
<div class="item-controls">
5656
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
@@ -76,7 +76,7 @@ <h4>{{weapon.name}}</h4>
7676
</div>
7777
<h4>{{armor.name}}</h4>
7878
</div>
79-
<div class="item-prop">{{localize armor.data.armorClass.abbr}} {{armor.data.armorClass.value}}</div>
79+
<div class="item-prop">{{localize armor.system.armorClass.abbr}} {{armor.system.armorClass.value}}</div>
8080
<div class="item-controls">
8181
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
8282
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>

templates/actor/parts/actor-description.html

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,4 @@
2323

2424
</section>
2525

26-
{{!-- If you want TinyMCE editors to output inline rolls when rendered, you need to pass the actor's roll data to the rollData property. --}}
27-
{{editor content=data.biography target="data.biography" rollData=rollData button=true owner=owner editable=editable}}
26+
{{editor enrichedBiography target="system.biography" button=true editable=editable}}

templates/actor/parts/actor-features.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
</div>
1515
<h4>{{item.name}}</h4>
1616
</div>
17-
<div class="item-formula item-prop rollable" data-roll-type="item">{{item.data.formula.value}}</div>
17+
<div class="item-formula item-prop rollable" data-roll-type="item">{{item.system.formula.value}}</div>
1818
<div class="item-controls">
1919
<a class="item-control item-edit" title="Edit Item"><i class="fas fa-edit"></i></a>
2020
<a class="item-control item-delete" title="Delete Item"><i class="fas fa-trash"></i></a>

0 commit comments

Comments
 (0)