Skip to content

Commit

Permalink
Bug fixes, grapple control cost, ritual archetype
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliharu committed Feb 25, 2024
1 parent 1b87dd1 commit e2e6b2c
Show file tree
Hide file tree
Showing 15 changed files with 196 additions and 71 deletions.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021 Christopher Dron
Copyright (c) 2024 Christopher Dron

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
1 change: 1 addition & 0 deletions lang/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"Ex3.HealthType": "Health Type",
"Ex3.Magnitude": "Magnitude",
"Ex3.HealthLevels": "Health Levels",
"Ex3.Colors": "Colors",
"Ex3.DotColors": "Dot Colors",
"Ex3.DotColor": "Dot Color",
"Ex3.AnimaColor": "Anima Color",
Expand Down
2 changes: 1 addition & 1 deletion module/actor/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ export class ExaltedThirdActorSheet extends ActorSheet {
};
buttons = [settingsButton, helpButton, ...buttons];
const colorButton = {
label: game.i18n.localize('Ex3.DotColors'),
label: game.i18n.localize('Ex3.Colors'),
class: 'set-color',
icon: 'fas fa-palette',
onclick: (ev) => this.pickColor(ev),
Expand Down
71 changes: 67 additions & 4 deletions module/apps/character-builder.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,47 @@ export default class CharacterBuilder extends FormApplication {
}
}
else if (itemType === 'merit') {
sectionList['merits'] = {
name: game.i18n.localize("Ex3.Merits"),
list: items
if (items.some(item => item.system.merittype === 'innate')) {
sectionList['innate'] = {
name: game.i18n.localize("Ex3.Innate"),
list: items.filter(item => item.system.merittype === 'innate')
};
}
if (items.some(item => item.system.merittype === 'purchased')) {
sectionList['purchased'] = {
name: game.i18n.localize("Ex3.Purchased"),
list: items.filter(item => item.system.merittype === 'purchased')
};
}
if (items.some(item => item.system.merittype === 'story')) {
sectionList['story'] = {
name: game.i18n.localize("Ex3.Story"),
list: items.filter(item => item.system.merittype === 'story')
};
}
if (items.some(item => item.system.merittype === 'thaumaturgy')) {
sectionList['thaumaturgy'] = {
name: game.i18n.localize("Ex3.Thaumaturgy"),
list: items.filter(item => item.system.merittype === 'thaumaturgy')
};
}
if (items.some(item => item.system.merittype === 'sorcery' && !item.system.archetypename)) {
sectionList['sorcery'] = {
name: game.i18n.localize("Ex3.Sorcery"),
list: items.filter(item => item.system.merittype === 'sorcery' && !item.system.archetypename)
};
}
for (const merit of items.filter(item => item.system.merittype === 'sorcery' && item.system.archetypename).sort(function (a, b) {
const sortValueA = a.system.archetypename.toLowerCase();
const sortValueB = b.system.archetypename.toLowerCase();
return sortValueA < sortValueB ? -1 : sortValueA > sortValueB ? 1 : 0
})) {
if (merit.system.archetypename) {
if (!sectionList[merit.system.archetypename]) {
sectionList[merit.system.archetypename] = { name: merit.system.archetypename, list: [] };
}
sectionList[merit.system.archetypename].list.push(merit);
}
}
}
else if (itemType === 'customability') {
Expand Down Expand Up @@ -671,7 +709,19 @@ export default class CharacterBuilder extends FormApplication {
else if (itemType === 'ritual') {
sectionList['rituals'] = {
name: game.i18n.localize("Ex3.Rituals"),
list: items
list: items.filter(item => !item.system.archetypename)
};
for (const ritual of items.filter(item => item.system.archetypename).sort(function (a, b) {
const sortValueA = a.system.archetypename.toLowerCase();
const sortValueB = b.system.archetypename.toLowerCase();
return sortValueA < sortValueB ? -1 : sortValueA > sortValueB ? 1 : 0
})) {
if (ritual.system.archetypename) {
if (!sectionList[ritual.system.archetypename]) {
sectionList[ritual.system.archetypename] = { name: ritual.system.archetypename, list: [] };
}
sectionList[ritual.system.archetypename].list.push(ritual);
}
}
}
else {
Expand Down Expand Up @@ -959,6 +1009,19 @@ export default class CharacterBuilder extends FormApplication {
return false;
});
}
if(itemType === "merit") {
items = items.filter(merit => {
if(merit.system.merittype !== "sorcery") {
return true;
}
if(this.object.character.ritual?.system?.archetypename) {
if(!merit.system.archetypename || merit.system.archetypename === this.object.character.ritual?.system?.archetypename) {
return true;
}
}
return false;
});
}
const itemIds = [
...Object.values(this.object.character.charms).map(charm => charm._id),
...Object.values(this.object.character.martialArtsCharms).map(charm => charm._id),
Expand Down
44 changes: 27 additions & 17 deletions module/apps/dice-roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export class RollForm extends FormApplication {
healthbashing: 0,
healthlethal: 0,
healthaggravated: 0,
grappleControl: 0,
silverxp: 0,
goldxp: 0,
whitexp: 0,
Expand Down Expand Up @@ -890,6 +891,8 @@ export class RollForm extends FormApplication {
this.object.cost.goldxp += item.system.cost.goldxp;
this.object.cost.whitexp += item.system.cost.whitexp;
this.object.cost.initiative += item.system.cost.initiative;
this.object.cost.grappleControl += item.system.cost.grapplecontrol;


if (item.system.cost.aura) {
this.object.cost.aura = item.system.cost.aura;
Expand Down Expand Up @@ -1415,6 +1418,7 @@ export class RollForm extends FormApplication {
this.object.cost.goldxp -= item.system.cost.goldxp;
this.object.cost.whitexp -= item.system.cost.whitexp;
this.object.cost.initiative -= item.system.cost.initiative;
this.object.cost.grappleControl -= item.system.cost.grapplecontrol;

if (item.system.cost.aura === this.object.cost.aura) {
this.object.cost.aura = "";
Expand Down Expand Up @@ -1777,7 +1781,7 @@ export class RollForm extends FormApplication {
}

// Dovie'andi se tovya sagain.
_rollTheDice(dice, diceModifiers, doublesRolled, numbersRerolled) {
async _rollTheDice(dice, diceModifiers, doublesRolled, numbersRerolled) {
var total = 0;
var tensTriggered = 0;
var onesTriggered = 0;
Expand Down Expand Up @@ -1806,7 +1810,7 @@ export class RollForm extends FormApplication {
rerolls.push(diceModifiers.reroll[rerollValue].number);
}
}
var roll = new Roll(`${dice}d10cs>=${diceModifiers.targetNumber}`).evaluate({ async: false });
var roll = await new Roll(`${dice}d10cs>=${diceModifiers.targetNumber}`).evaluate();
results = roll.dice[0].results;
total = roll.total;
if (rerolls.length > 0) {
Expand All @@ -1821,7 +1825,7 @@ export class RollForm extends FormApplication {
}
}
}
var rerollRoll = new Roll(`${toReroll}d10cs>=${diceModifiers.targetNumber}`).evaluate({ async: false });
var rerollRoll = await new Roll(`${toReroll}d10cs>=${diceModifiers.targetNumber}`).evaluate();
results = results.concat(rerollRoll.dice[0].results);
total += rerollRoll.total;
}
Expand Down Expand Up @@ -1853,7 +1857,7 @@ export class RollForm extends FormApplication {
return rollResult;
}

_calculateRoll(dice, diceModifiers) {
async _calculateRoll(dice, diceModifiers) {
const doublesRolled = {
7: 0,
8: 0,
Expand All @@ -1878,7 +1882,7 @@ export class RollForm extends FormApplication {
results = diceModifiers.preRollMacros.reduce((carry, macro) => macro(carry, dice, diceModifiers, doublesRolled, numbersRerolled), results);
}

let rollResults = this._rollTheDice(dice, diceModifiers, doublesRolled, numbersRerolled);
let rollResults = await this._rollTheDice(dice, diceModifiers, doublesRolled, numbersRerolled);
let diceRoll = rollResults.results;
let total = rollResults.total;
var possibleRerolls = 0;
Expand All @@ -1890,7 +1894,7 @@ export class RollForm extends FormApplication {
diceResult.rerolled = true;
}
}
var failedDiceRollResult = this._rollTheDice(possibleRerolls, diceModifiers, doublesRolled, numbersRerolled);
var failedDiceRollResult = await this._rollTheDice(possibleRerolls, diceModifiers, doublesRolled, numbersRerolled);
diceRoll = diceRoll.concat(failedDiceRollResult.results);
total += failedDiceRollResult.total;
}
Expand All @@ -1917,7 +1921,7 @@ export class RollForm extends FormApplication {
let rerolledDice = 0;
while (diceToReroll > 0 && (rerolledDice < diceModifiers.rerollNumber)) {
rerolledDice += possibleRerolls;
var rerollNumDiceResults = this._rollTheDice(diceToReroll, diceModifiers, doublesRolled, numbersRerolled);
var rerollNumDiceResults = await this._rollTheDice(diceToReroll, diceModifiers, doublesRolled, numbersRerolled);
diceToReroll = 0
for (const diceResult of rerollNumDiceResults.results.sort((a, b) => a.result - b.result)) {
if (diceModifiers.rerollNumber > possibleRerolls && !diceResult.rerolled && diceResult.result < this.object.targetNumber && (!diceModifiers.settings.excludeOnesFromRerolls || diceResult.result !== 1)) {
Expand All @@ -1933,7 +1937,7 @@ export class RollForm extends FormApplication {
let successRerolledDice = 0;
while (successesToReroll > 0 && (successRerolledDice < diceModifiers.rerollSuccesses)) {
successRerolledDice += possibleSuccessRerolls;
var rerollNumDiceResults = this._rollTheDice(successesToReroll, diceModifiers, doublesRolled, numbersRerolled);
var rerollNumDiceResults = await this._rollTheDice(successesToReroll, diceModifiers, doublesRolled, numbersRerolled);
successesToReroll = 0
for (const diceResult of rerollNumDiceResults.results.sort((a, b) => a.result - b.result)) {
if (diceModifiers.rerollSuccesses > possibleSuccessRerolls && !diceResult.rerolled && diceResult.result >= this.object.targetNumber) {
Expand All @@ -1956,7 +1960,7 @@ export class RollForm extends FormApplication {
let remainder = total % 3;
while (newCraftDice > 0) {
var rollSuccessTotal = 0;
var craftDiceRollResults = this._rollTheDice(newCraftDice, diceModifiers, doublesRolled, numbersRerolled);
var craftDiceRollResults = await this._rollTheDice(newCraftDice, diceModifiers, doublesRolled, numbersRerolled);
diceRoll = diceRoll.concat(craftDiceRollResults.results);
rollSuccessTotal += craftDiceRollResults.total;
total += craftDiceRollResults.total;
Expand Down Expand Up @@ -2193,14 +2197,14 @@ export class RollForm extends FormApplication {
}
}

const diceRollResults = this._calculateRoll(dice, rollModifiers);
const diceRollResults = await this._calculateRoll(dice, rollModifiers);
this.object.roll = diceRollResults.roll;
this.object.displayDice = diceRollResults.diceDisplay;
this.object.total = diceRollResults.total;
var diceRoll = diceRollResults.diceRoll;

if (this.object.rollTwice) {
const secondRoll = this._calculateRoll(dice, rollModifiers);
const secondRoll = await this._calculateRoll(dice, rollModifiers);
if (secondRoll.total > diceRollResults.total) {
this.object.roll = secondRoll.roll;
this.object.displayDice = secondRoll.diceDisplay;
Expand Down Expand Up @@ -2266,12 +2270,12 @@ export class RollForm extends FormApplication {
}

if (!this._isAttackRoll() && this.object.rollType !== 'base') {
this._updateCharacterResources();
await this._updateCharacterResources();
}
}

async _diceRoll() {
this._baseAbilityDieRoll();
await this._baseAbilityDieRoll();
let messageContent = `
<div class="dice-roll">
<div class="dice-result">
Expand Down Expand Up @@ -2617,7 +2621,7 @@ export class RollForm extends FormApplication {
}

async _accuracyRoll() {
this._baseAbilityDieRoll();
await this._baseAbilityDieRoll();
this.object.thereshholdSuccesses = this.object.total - this.object.defense;
this.object.attackSuccesses = this.object.total;
}
Expand Down Expand Up @@ -2727,9 +2731,9 @@ export class RollForm extends FormApplication {
});
}

var diceRollResults = this._calculateRoll(dice, rollModifiers);
var diceRollResults = await this._calculateRoll(dice, rollModifiers);
if (this.object.damage.rollTwice) {
const secondRoll = this._calculateRoll(dice, rollModifiers);
const secondRoll = await this._calculateRoll(dice, rollModifiers);
if (secondRoll.total > diceRollResults.total) {
diceRollResults = secondRoll;
}
Expand Down Expand Up @@ -3244,7 +3248,7 @@ export class RollForm extends FormApplication {
}

async _completeCraftProject() {
this._baseAbilityDieRoll();
await this._baseAbilityDieRoll();
let resultString = ``;
let projectStatus = ``;
let craftFailed = false;
Expand Down Expand Up @@ -3873,12 +3877,16 @@ export class RollForm extends FormApplication {
healthbashing: 0,
healthlethal: 0,
healthaggravated: 0,
grappleControl: 0,
silverxp: 0,
goldxp: 0,
whitexp: 0,
aura: "",
}
}
if(this.object.cost.grapplecontrol === undefined) {
this.object.cost.grapplecontrol = 0;
}
if (this.object.restore === undefined) {
this.object.restore = {
motes: 0,
Expand Down Expand Up @@ -4126,6 +4134,8 @@ export class RollForm extends FormApplication {
actorData.system.anima.value = newValue;

actorData.system.willpower.value = Math.max(0, actorData.system.willpower.value - this.object.cost.willpower);
actorData.system.grapplecontrolrounds.value = Math.max(0, actorData.system.grapplecontrolrounds.value - this.object.cost.grappleControl);

if (this.actor.type === 'character') {
actorData.system.craft.experience.silver.value = Math.max(0, actorData.system.craft.experience.silver.value - this.object.cost.silverxp);
actorData.system.craft.experience.gold.value = Math.max(0, actorData.system.craft.experience.gold.value - this.object.cost.goldxp);
Expand Down
Loading

0 comments on commit e2e6b2c

Please sign in to comment.