Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Dec 4, 2024
2 parents 9d362e8 + 4063601 commit 9d86b3c
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 39 deletions.
7 changes: 7 additions & 0 deletions modules/apps/roll-dialog/cast-dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,13 @@ export default class CastDialog extends SkillDialog {
return super._computeAdvantage();
}
}

_defaultFields()
{
return mergeObject({
overchannelling : 0
}, super._defaultFields());
}

// Backwards compatibility for effects
get type()
Expand Down
6 changes: 4 additions & 2 deletions modules/apps/stat-parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,17 +59,19 @@ export default class StatBlockParser extends FormApplication {
let characteristicValues = blockArray[tableIndex + 1].split(" ")

for (let i = 0; i < characteristicNames.length; i++) {
const value = Number(characteristicValues[i]) || 0;

if (characteristicNames[i] == "Agi")
characteristicNames[i] = "Ag"
if (characteristicNames[i].toLowerCase() == "m") {
model.details.move.value = Number(characteristicValues[i]);
model.details.move.value = value;
continue;
}
if (characteristicNames[i].toLowerCase() == "w")
continue;

try {
model.characteristics[characteristicNames[i].toLowerCase()].initial = Number(characteristicValues[i])
model.characteristics[characteristicNames[i].toLowerCase()].initial = value
}
catch { }
}
Expand Down
2 changes: 1 addition & 1 deletion modules/hooks/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function() {
{

let tokenUpdate = {_id : mountId, x : updateData.x || token.x, y: updateData.y || token.y, sort : token.sort - 1 }
if (token.actor.details.size.value == token.actor.mount.details.size.value)
if (token.actor?.details.size.value == token.actor?.mount.details.size.value)
{
tokenUpdate.x += canvas.grid.size / 4
tokenUpdate.y += canvas.grid.size / 4
Expand Down
21 changes: 12 additions & 9 deletions modules/system/rolls/cast-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ export default class CastTest extends TestWFRP {
return

this.preData.itemData = data.itemData || this.item.toObject() // Store item data to avoid rerolls being affected by changed channeled SL
this.preData.unofficialGrimoire = data.unofficialGrimoire;
this.data.preData.malignantInfluence = data.malignantInfluence
this.preData.malignantInfluence = data.malignantInfluence;
this.preData.unofficialGrimoire = game.settings.get("wfrp4e", "unofficialgrimoire");
this.preData.overchannelling = data.overchannelling;
this.preData.ingredientMode = data.ingredientMode ?? "none";

this.data.context.templates = data.templates || [];

Expand All @@ -33,7 +35,7 @@ export default class CastTest extends TestWFRP {
await Promise.all(this.item.runScripts("preRollCastTest", { test: this, chatOptions: this.context.chatOptions }))

//@HOUSE
if (this.preData.unofficialGrimoire && this.preData.unofficialGrimoire.ingredientMode == 'power' && this.hasIngredient) {
if (this.preData.unofficialGrimoire && this.preData.ingredientMode == 'power' && this.hasIngredient) {
game.wfrp4e.utility.logHomebrew("unofficialgrimoire");
this.preData.canReverse = true;
}
Expand Down Expand Up @@ -116,7 +118,7 @@ export default class CastTest extends TestWFRP {
//@/HOUSE
}
//@/HOUSE
if (this.preData.unofficialGrimoire && this.preData.unofficialGrimoire.overchannelling > 0) {
if (this.preData.unofficialGrimoire && this.preData.overchannelling > 0) {
game.wfrp4e.utility.logHomebrew("overchannelling");
this.result.tooltips.miscast.push(game.i18n.localize("CHAT.OverchannellingMiscast"))
miscastCounter++;
Expand All @@ -128,7 +130,7 @@ export default class CastTest extends TestWFRP {
this.result.castOutcome = "failure"
this.result.description = game.i18n.localize("ROLL.CastingFailed")
//@/HOUSE
if (this.preData.unofficialGrimoire && this.preData.unofficialGrimoire.overchannelling > 0) {
if (this.preData.unofficialGrimoire && this.preData.overchannelling > 0) {
game.wfrp4e.utility.logHomebrew("overchannelling");
this.result.tooltips.miscast.push(game.i18n.localize("CHAT.OverchannellingMiscast"))
miscastCounter++;
Expand All @@ -151,9 +153,10 @@ export default class CastTest extends TestWFRP {
this.result.castOutcome = "success"
this.result.description = game.i18n.localize("ROLL.CastingSuccess");
//@/HOUSE
if (this.preData.unofficialGrimoire && this.preData.unofficialGrimoire.overchannelling > 0) {
if (this.preData.unofficialGrimoire && this.preData.overchannelling > 0) {
game.wfrp4e.utility.logHomebrew("overchannelling");
slOver += this.preData.unofficialGrimoire.overchannelling;
slOver += this.preData.overchannelling;
this.result.SL = "+" + slOver;
}
//@/HOUSE

Expand Down Expand Up @@ -195,7 +198,7 @@ export default class CastTest extends TestWFRP {

// TODO handle all tooltips (when they are added) in one place
// TODO Fix weird formatting in tooltips (indenting)
this.result.tooltips.miscast = this.result.tooltips.miscast.join("\n")
this.result.tooltips.miscast = "<ul style='text-align: left'>" + this.result.tooltips.miscast.map(t => `<li>${t}</li>`).join("") + "</ul>";

return this.result;
}
Expand Down Expand Up @@ -317,7 +320,7 @@ export default class CastTest extends TestWFRP {
//@/HOUSE
if (this.preData.unofficialGrimoire) {
game.wfrp4e.utility.logHomebrew("unofficialgrimoire");
if (this.preData.unofficialGrimoire.ingredientMode != 'none' && this.hasIngredient && this.item.ingredient?.quantity.value > 0 && !this.context.edited && !this.context.reroll) {
if (this.preData.ingredientMode != 'none' && this.hasIngredient && this.item.ingredient?.quantity.value > 0 && !this.context.edited && !this.context.reroll) {
await this.item.ingredient.update({ "system.quantity.value": this.item.ingredient.quantity.value - 1 })
ChatMessage.create({ speaker: this.context.speaker, content: game.i18n.localize("ConsumedIngredient") })
}
Expand Down
11 changes: 6 additions & 5 deletions modules/system/rolls/channel-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@ export default class ChannelTest extends TestWFRP {
if (!data)
return

this.preData.unofficialGrimoire = data.unofficialGrimoire;
this.data.preData.malignantInfluence = data.malignantInfluence
this.data.preData.malignantInfluence = data.malignantInfluence;
this.data.preData.unofficialGrimoire = game.settings.get("wfrp4e", "unofficialgrimoire");
this.data.preData.ingredientMode = data.ingredientMode ?? "none";
this.data.preData.skill = data.skill?.id;
this.data.context.channelUntilSuccess = data.channelUntilSuccess

Expand Down Expand Up @@ -112,7 +113,7 @@ export default class ChannelTest extends TestWFRP {

miscastCounter += this._checkInfluences() || 0
this._handleMiscasts(miscastCounter)
this.result.tooltips.miscast = this.result.tooltips.miscast.join("\n")
this.result.tooltips.miscast = "<ul style='text-align: left'>" + this.result.tooltips.miscast.map(t => `<li>${t}</li>`).join("") + "</ul>";
}

_checkInfluences()
Expand All @@ -138,7 +139,7 @@ export default class ChannelTest extends TestWFRP {

if (this.preData.unofficialGrimoire) {
game.wfrp4e.utility.logHomebrew("unofficialgrimoire");
if (this.preData.unofficialGrimoire.ingredientMode != 'none' && this.hasIngredient && this.item.ingredient?.quantity.value > 0 && !this.context.edited && !this.context.reroll) {
if (this.preData.ingredientMode != 'none' && this.hasIngredient && this.item.ingredient?.quantity.value > 0 && !this.context.edited && !this.context.reroll) {
await this.item.ingredient.update({ "system.quantity.value": this.item.ingredient.quantity.value - 1 })
this.result.ingredientConsumed = true;
ChatMessage.create({ speaker: this.data.context.speaker, content: game.i18n.localize("ConsumedIngredient") })
Expand Down Expand Up @@ -169,7 +170,7 @@ export default class ChannelTest extends TestWFRP {
}

//@HOUSE
if(this.preData.unofficialGrimoire && this.preData.unofficialGrimoire.ingredientMode == 'power' && this.result.ingredientConsumed && this.succeeded) {
if(this.preData.unofficialGrimoire && this.preData.ingredientMode == 'power' && this.result.ingredientConsumed && this.succeeded) {
game.wfrp4e.utility.logHomebrew("unofficialgrimoire");
SL = Number(SL) * 2
}
Expand Down
2 changes: 1 addition & 1 deletion modules/system/rolls/test-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ export default class TestWFRP extends WarhammerTestBase{

if(this.preData.unofficialGrimoire) {
game.wfrp4e.utility.logHomebrew("unofficialgrimoire");
let controlIngredient = this.preData.unofficialGrimoire.ingredientMode == 'control';
let controlIngredient = this.preData.ingredientMode == 'control';
if (miscastCounter == 1) {
if (this.hasIngredient && controlIngredient)
this.result.nullminormis = game.i18n.localize("ROLL.MinorMis")
Expand Down
4 changes: 2 additions & 2 deletions static/templates/dialog/base-dialog.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<label>{{localize "DIALOG.DialogModifiers"}}</label>
<ul class="modifier-list">
{{#each data.scripts}}
<li class="modifier {{#if this.isActive}}active {{else if this.isHidden}}hidden{{/if}}" data-tooltip="{{this.effect.name}} {{#if this.options.targeter}}(Target){{/if}}" data-tooltip-direction="RIGHT" data-index="{{@key}}" >&#8226; <a>{{this.Label}}</a></li>
<li class="modifier {{#if this.isActive}}active {{else if this.isHidden}}hidden{{/if}}" data-tooltip="{{this.effect.name}} {{#if this.options.targeter}}({{localize 'Target'}}){{/if}}" data-tooltip-direction="RIGHT" data-index="{{@key}}" >&#8226; <a>{{this.Label}}</a></li>
{{/each}}
</ul>
</div>
Expand Down Expand Up @@ -56,8 +56,8 @@
{{#each data.hitLocationTable as |loc key|}}
<option value="{{key}}">{{loc}}</option>
{{/each}}
</select>
{{/select}}
</select>
</div>
{{/if}}

Expand Down
12 changes: 7 additions & 5 deletions static/templates/dialog/channel-dialog.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
</label>
</div>

{{#if unofficialGrimoire}}
{{#if (settings "unofficialgrimoire")}}
<div class="form-group">
<label title="{{localize 'DIALOG.UseIngredientTooltip'}}">{{localize "DIALOG.UseIngredient"}}</label>
<select name="ingredientTypeSelected">
<option value="none">{{localize "IngredientNone"}}</option>
<option value="power">{{localize "IngredientPower"}}</option>
<option value="control">{{localize "IngredientControl"}}</option>
<select name="ingredientMode">
{{#select fields.ingredientMode}}
<option value="none">{{localize "IngredientNone"}}</option>
<option value="power">{{localize "IngredientPower"}}</option>
<option value="control">{{localize "IngredientControl"}}</option>
{{/select}}
</select>
</div>
{{/if}}
30 changes: 16 additions & 14 deletions static/templates/dialog/spell-dialog.hbs
Original file line number Diff line number Diff line change
@@ -1,28 +1,30 @@
<div class="form-group">
<label title="{{localize 'DIALOG.MalignantInfTT'}}">{{localize "DIALOG.MalignantInf"}}
<input type="checkbox" name="malignantInfluence" data-dtype="Boolean" {{checked fields.malignantInfluence}} />
<input type="checkbox" name="malignantInfluence" {{checked fields.malignantInfluence}} />
</label>
</div>

{{#if unofficialGrimoire}}
{{#if (settings "unofficialgrimoire")}}
<div class="form-group">
<label title="{{localize 'DIALOG.UseIngredientTooltip'}}">{{localize "DIALOG.UseIngredient"}}</label>
<select name="ingredientTypeSelected">
<option value="none">{{localize "IngredientNone"}}</option>
<option value="power">{{localize "IngredientPower"}}</option>
<option value="control">{{localize "IngredientControl"}}</option>
<select name="ingredientMode">
{{#select fields.ingredientMode}}
<option value="none">{{localize "IngredientNone"}}</option>
<option value="power">{{localize "IngredientPower"}}</option>
<option value="control">{{localize "IngredientControl"}}</option>
{{/select}}
</select>
</div>

<div class="form-group">
<label>{{localize "Overchannelling"}}</label>
<input type="text" title="{{localize 'DIALOG.OverchannellingTooltip'}}" name="overchannelling" value="0" />
</div>

<div class="form-group">
<label title="{{localize 'DIALOG.Quickcasting'}}">{{localize "DIALOG.Quickcasting"}}
<input title="{{localize 'DIALOG.QuickcastingTooltip'}}" type="checkbox" name="quickcasting" data-dtype="Boolean"
{{checked quickcasting}} />
</label>
<input class="input-text" type="text" name="overchannelling" value="{{fields.overchannelling}}" title="{{localize 'DIALOG.OverchannellingTooltip'}}" />
</div>
{{#if false}}
<div class="form-group">
<label>{{localize "DIALOG.Quickcasting"}}
<input title="{{localize 'DIALOG.QuickcastingTooltip'}}" type="checkbox" name="quickcasting" {{checked fields.quickcasting}} />
</label>
</div>
{{/if}}
{{/if}}

0 comments on commit 9d86b3c

Please sign in to comment.