Skip to content

Commit

Permalink
Fix more v12 breakage, for chargen abilities and items.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcglincy committed Jun 19, 2024
1 parent 4ef514c commit 9340d81
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
# 3.0.2

- Fix more v12 breakage, for chargen abilities and items.

# 3.0.1

- Fix more v12 breakage.
- Fix more v12 breakage, for async rolls and enriched html.

# 3.0.0

Expand Down
1 change: 1 addition & 0 deletions module/actor/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ export class CYCharacterSheet extends CYActorSheet {
/** @override */
async getData() {
const superData = await super.getData();
console.log("character superdata", superData);
// TODO: move this to prepareItems?
superData.data.items.forEach(item => {
item.system.equippable = (
Expand Down
10 changes: 5 additions & 5 deletions module/generator/scvmfactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async function randomNpc() {
const armor = npcArmor();
return {
name,
data: {
system: {
armor,
attack,
description,
Expand Down Expand Up @@ -133,7 +133,8 @@ export async function findAllowedClasses() {
};

async function abilityRoll(formula) {
return abilityBonus(await rollTotal(formula));
const total = await rollTotal(formula);
return abilityBonus(total);
}

const classStartingArmor = async (clazz) => {
Expand Down Expand Up @@ -261,7 +262,7 @@ async function startingEquipment(clazz) {

function simpleData(e) {
return {
data: e.system,
system: e.system,
img: e.img,
items: e.items?.map(i => simpleData(i)),
name: e.name,
Expand Down Expand Up @@ -362,7 +363,6 @@ async function rollScvmForClass(clazz) {
const npcData = npcs.map(n => simpleData(n));

const strength = await abilityRoll(clazz.system.strength);
console.log("strength", strength);
const agility = await abilityRoll(clazz.system.agility);
const presence = await abilityRoll(clazz.system.presence);
const toughness = await abilityRoll(clazz.system.toughness);
Expand Down Expand Up @@ -402,7 +402,7 @@ async function rollScvmForClass(clazz) {
function scvmToActorData(s) {
return {
name: s.name,
data: {
system: {
abilities: {
strength: { value: s.strength },
agility: { value: s.agility },
Expand Down
4 changes: 3 additions & 1 deletion module/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@ export const articalize = (str) => {
};

export async function rollTotal(formula, rollData={}) {
return await new Roll(formula, rollData).evaluate().total;
const roll = new Roll(formula, rollData);
await roll.evaluate();
return roll.total;
};

// https://stackoverflow.com/questions/4959975/generate-random-number-between-two-numbers-in-javascript
Expand Down

0 comments on commit 9340d81

Please sign in to comment.