Skip to content

Commit

Permalink
Merge pull request #81 from McGregor777/1.0.1
Browse files Browse the repository at this point in the history
1.0.1
  • Loading branch information
McGregor777 authored Jul 15, 2024
2 parents 44bb97c + 6967ee7 commit b5abe73
Show file tree
Hide file tree
Showing 26 changed files with 398 additions and 412 deletions.
3 changes: 3 additions & 0 deletions lang/en-EN.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
"CHARACTER.IMPAIRMENT.Stress": "Stress",
"CHARACTER.IMPAIRMENT.FatigueTokens": "Fatigue Tokens",
"CHARACTER.IMPAIRMENT.StressTokens": "Stress Tokens",
"CHARACTER.SHEET.AddRemoveConservativeSegment": "Add/Remove Conservative Segment",
"CHARACTER.SHEET.AddRemoveRecklessSegment": "Add/Remove Reckless Segment",
"CHARACTER.SHEET.MinimumSegmentWarning": "You cannot remove any more segment.",
"CHARACTER.SHEET.NoExperienceLeft": "You have no Experience left.",

"CHARACTERGENERATOR.Actions": "Action Cards",
Expand Down
3 changes: 3 additions & 0 deletions lang/fr-FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@
"CHARACTER.IMPAIRMENT.Stress": "Stress",
"CHARACTER.IMPAIRMENT.FatigueTokens": "Jetons de Fatigue",
"CHARACTER.IMPAIRMENT.StressTokens": "Jetons de Stress",
"CHARACTER.SHEET.AddRemoveConservativeSegment": "Ajouter/retirer un segment de prudence",
"CHARACTER.SHEET.AddRemoveRecklessSegment": "Ajouter/retirer un segment de témérité",
"CHARACTER.SHEET.MinimumSegmentWarning": "Vous ne pouvez pas retirer davantage de segments.",
"CHARACTER.SHEET.NoExperienceLeft": "Vous n'avez pas d'expérience à dépenser.",

"CHARACTERGENERATOR.Actions": "Cartes d'action",
Expand Down
25 changes: 14 additions & 11 deletions modules/CheckHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -403,8 +403,8 @@ export default class CheckHelper
if(targetActor) {
match = effectDescription.match(new RegExp(game.i18n.localize("ROLL.REGEX.ForPlusAmountDamage"), "u"));
if(match) {
let characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
outcome.targetDamages = actor.system.characteristics[characteristicName].value +
const characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
outcome.targetDamages = actor.system.characteristics[characteristicName].rating +
(checkData.weapon?.system.damageRating ?? 0) +
(actor.system.damageRating ?? 0) +
parseInt(match[1]);
Expand All @@ -421,17 +421,19 @@ export default class CheckHelper
}
match = effectDescription.match(new RegExp(game.i18n.localize("ROLL.REGEX.ForMinusAmountDamage"), "u"));
if(match) {
let characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
outcome.targetDamages = actor.system.characteristics[characteristicName].value +
const characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
console.
outcome.targetDamages = actor.system.characteristics[characteristicName].rating +
(checkData.weapon?.system.damageRating ?? 0) +
(actor.system.damageRating ?? 0) +
parseInt(match[1]);
}

match = effectDescription.match(new RegExp(game.i18n.localize("ROLL.REGEX.ForNormalDamage"), "u"));
if(match) {
let characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
outcome.targetDamages = actor.system.characteristics[characteristicName].value +
const characteristicName = checkData.action.system.type === "ranged" ? "agility" : "strength";
console.log(actor.system.characteristics[characteristicName].rating, checkData.weapon?.system.damageRating, actor.system.damageRating)
outcome.targetDamages = actor.system.characteristics[characteristicName].rating +
(checkData.weapon?.system.damageRating ?? 0) +
(actor.system.damageRating ?? 0);
}
Expand Down Expand Up @@ -503,7 +505,7 @@ export default class CheckHelper
if(targetActor) {
// If the attack inflicts damages, reduce them by Toughness and Soak values.
if(outcome.targetDamages > 0) {
outcome.targetDamages -= targetActor.system.characteristics.toughness.value +
outcome.targetDamages -= targetActor.system.characteristics.toughness.rating +
(targetActor.system.totalSoak ?? 0) +
(targetActor.system.soakValue ?? 0);

Expand Down Expand Up @@ -548,10 +550,11 @@ export default class CheckHelper
if(outcome.wounds > 0)
actorUpdates.system.wounds = actor.system.wounds.value - outcome.wounds;

outcome.criticalWounds = await Item.createDocuments(
await this.drawCriticalWoundsRandomly(outcome.criticalWounds),
{parent: actor}
);
if(outcome.criticalWounds > 0)
outcome.criticalWounds = await Item.createDocuments(
await this.drawCriticalWoundsRandomly(outcome.criticalWounds),
{parent: actor}
);

if(outcome.fatigue > 0 || outcome.fatigue < 0)
actorUpdates.system.impairments = {fatigue: actor.system.impairments.fatigue + outcome.fatigue};
Expand Down
2 changes: 1 addition & 1 deletion modules/DicePool.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default class DicePool
this.fortunePoints = 0;
this.specialisations = [];

mergeObject(this, options);
foundry.utils.mergeObject(this, options);
}

/**
Expand Down
6 changes: 3 additions & 3 deletions modules/WFRP3eRoll.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class WFRP3eRoll extends Roll
? game.actors.get(checkData.actor.actorId)
: game.scenes.get(checkData.actor.sceneId).collections.tokens.get(checkData.actor.tokenId).actor;

mergeObject(chatData, {
foundry.utils.mergeObject(chatData, {
action: checkData.action,
actorName: actor.token ? actor.token.name : actor.prototypeToken.name,
face: checkData.face,
Expand Down Expand Up @@ -277,7 +277,7 @@ export default class WFRP3eRoll extends Roll
/** @inheritDoc */
toJSON()
{
return mergeObject(super.toJSON(), {
return foundry.utils.mergeObject(super.toJSON(), {
effects: this.effects,
hasSpecialDice: this.hasSpecialDice,
hasStandardDice: this.hasStandardDice,
Expand All @@ -289,7 +289,7 @@ export default class WFRP3eRoll extends Roll
/** @inheritDoc */
static fromData(data)
{
return mergeObject(super.fromData(data), {
return foundry.utils.mergeObject(super.fromData(data), {
effects: data.effects,
hasSpecialDice: data.hasSpecialDice,
hasStandardDice: data.hasStandardDice,
Expand Down
2 changes: 1 addition & 1 deletion modules/applications/CareerSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default class CareerSelector extends FormApplication
});
}

this.allCareers = careers.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.allCareers = careers.sort((a, b) => a.name.localeCompare(b.name));

careers = careers.reduce((sortedCareers, career) => {
if(career.system.raceRestrictions.includes(this.object.system.race)
Expand Down
10 changes: 5 additions & 5 deletions modules/applications/CharacterGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ export default class CharacterGenerator extends FormApplication
});
}

this.talents = talents.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.insanities = insanities.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.actions = actions.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.talents = talents.sort((a, b) => a.name.localeCompare(b.name));
this.insanities = insanities.sort((a, b) => a.name.localeCompare(b.name));
this.actions = actions.sort((a, b) => a.name.localeCompare(b.name));
}

_onNextButtonClick(html, event)
Expand Down Expand Up @@ -309,7 +309,7 @@ export default class CharacterGenerator extends FormApplication
});
} while(drawnCareers.size < 3);

this.drawnCareers = [...drawnCareers.values()].sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.drawnCareers = [...drawnCareers.values()].sort((a, b) => a.name.localeCompare(b.name));

this.selectedCareer = this.drawnCareers[0];

Expand Down Expand Up @@ -464,7 +464,7 @@ export default class CharacterGenerator extends FormApplication
this.careerSkills = await game.packs.get("wfrp3e.items").getDocuments({type: "skill"}).then(skills => {
return skills
.filter(skill => this.selectedCareer.system.careerSkills.includes(skill.name))
.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
.sort((a, b) => a.name.localeCompare(b.name));
});

// If a skill has been trained for free, add it to the list of Career Skills.
Expand Down
12 changes: 6 additions & 6 deletions modules/applications/DicePoolBuilder.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default class DicePoolBuilder extends FormApplication
value = element.value;
}

setProperty(this.object, event.currentTarget.name, Array.isArray(value) || isNaN(value) ? value : Number(value));
foundry.utils.setProperty(this.object, event.currentTarget.name, Array.isArray(value) || isNaN(value) ? value : Number(value));

this._updatePreview();
}
Expand Down Expand Up @@ -200,7 +200,7 @@ export default class DicePoolBuilder extends FormApplication
entityData = {_id: embeddedId};
}

setProperty(entityData, "flags.ffgsound", sound);
foundry.utils.setProperty(entityData, "flags.ffgsound", sound);
entity.updateOwnedItem(entityData);
}
}
Expand Down Expand Up @@ -254,7 +254,7 @@ export default class DicePoolBuilder extends FormApplication
_synchronizeInputs(html)
{
html.find(".dice-pool-table input, .symbols-pool-container input").each((key, input) => {
input.value = getProperty(this.object, input.name);
input.value = foundry.utils.getProperty(this.object, input.name);
});

this._updatePreview();
Expand Down Expand Up @@ -297,7 +297,7 @@ export default class DicePoolBuilder extends FormApplication

if(event.target !== input) {
input.value++;
setProperty(this.object, input.name, parseInt(input.value));
foundry.utils.setProperty(this.object, input.name, parseInt(input.value));
this._updatePreview();
}
}
Expand All @@ -316,7 +316,7 @@ export default class DicePoolBuilder extends FormApplication

if(event.target !== input && input.value > 0) {
input.value--;
setProperty(this.object, input.name, parseInt(input.value));
foundry.utils.setProperty(this.object, input.name, parseInt(input.value));
this._updatePreview();
}
}
Expand Down Expand Up @@ -493,7 +493,7 @@ export default class DicePoolBuilder extends FormApplication
};
const stance = this.object.checkData.actor.system.stance.current;

mergeObject(this.object.dice, {
foundry.utils.mergeObject(this.object.dice, {
characteristic: this.object.checkData.characteristic.value - Math.abs(stance),
fortune: this.object.checkData.characteristic.fortune,
conservative: stance < 0 ? Math.abs(stance) : 0,
Expand Down
2 changes: 1 addition & 1 deletion modules/applications/TalentSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default class TalentSelector extends FormApplication
});
}

this.allTalents = talents.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
this.allTalents = talents.sort((a, b) => a.name.localeCompare(b.name));

talents = Object.keys(CONFIG.WFRP3e.talentTypes).reduce((sortedTalents, talentType) => {
if(["focus", "reputation", "tactic", "tricks"].includes(talentType)
Expand Down
2 changes: 1 addition & 1 deletion modules/applications/TrainingSelector.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ export default class TrainingSelector extends FormApplication
.filter(skill => this.nonCareer
? !this.career.system.careerSkills.includes(skill.name)
: this.career.system.careerSkills.includes(skill.name))
.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
.sort((a, b) => a.name.localeCompare(b.name));
});

for(let i = 0; i < careerSkills.length; i++)
Expand Down
66 changes: 30 additions & 36 deletions modules/applications/actors/WFRP3eCharacterSheet.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import {capitalize} from "../../helpers.js";

/**
* Provides the data and general interaction with Actor Sheets - Abstract class.
* WFRP3CharacterSheet provides the general interaction and data organization shared among all actors sheets, as this is an abstract class, inherited by either Character or NPC specific actors sheet classes. When rendering an actors sheet, getData() is called, which is a large and key that prepares the actors data for display, processing the raw data and items and compiling them into data to display on the sheet. Additionally, this class contains all the main events that respond to sheet interaction in activateListeners()
* @see WFRP3CharacterSheet - Data and main computation model (this.actors)
*/
/** @inheritDoc */
export default class WFRP3eCharacterSheet extends ActorSheet
{
/** @inheritDoc */
Expand Down Expand Up @@ -88,7 +84,7 @@ export default class WFRP3eCharacterSheet extends ActorSheet

html.find(".advance-checkbox").change(this._onAdvanceCheckboxChange.bind(this));

html.find(".characteristic a").click(this._onCharacteristicLink.bind(this));
html.find(".characteristic a").click(this._onCharacteristicClick.bind(this));

html.find(".current-career-input").click(this._onCurrentCareerInput.bind(this));

Expand Down Expand Up @@ -117,6 +113,10 @@ export default class WFRP3eCharacterSheet extends ActorSheet
.click(this._onRechargeTokenLeftClick.bind(this))
.contextmenu(this._onRechargeTokenRightClick.bind(this));

html.find(".stance-meter .stance-meter-link")
.click(this._onStanceMeterLinkClick.bind(this, 1))
.contextmenu(this._onStanceMeterLinkClick.bind(this, -1));

html.find(".skill-training-level-input").change(this._onSkillTrainingLevelChange.bind(this));
}

Expand All @@ -129,7 +129,7 @@ export default class WFRP3eCharacterSheet extends ActorSheet
_buildItemLists(items)
{
const basicTrait = game.i18n.localize("ACTION.TRAITS.Basic");
const sortedItems = items.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
const sortedItems = items.sort((a, b) => a.name.localeCompare(b.name));
const actions = sortedItems.filter(item => item.type === "action").sort((a, b) => {
if(a.system.conservative.traits.includes(basicTrait) && !b.system.conservative.traits.includes(basicTrait))
return -1;
Expand Down Expand Up @@ -237,42 +237,29 @@ export default class WFRP3eCharacterSheet extends ActorSheet
}

/**
* Performs follow-up operations after changes on Advance checkbox.
* Performs follow-up operations after changes on advance checkbox.
* @param {Event} event
* @private
*/
_onAdvanceCheckboxChange(event)
{
if(this.actor.system.experience.current > 0) {
const career = this._getItemById(event);

if(event.currentTarget.checked) {
event.currentTarget.checked = false;
this.actor.buyAdvance(career, event.currentTarget.dataset.type);
}
else {
const updates = {system: {advances: career.system.advances}};

if(isNaN(event.currentTarget.dataset.type))
updates.system.advances[event.currentTarget.dataset.type] = "";
else
updates.system.advances.open[event.currentTarget.dataset.type] = "";

career.update(updates);
}
}
else {
const career = this._getItemById(event),
type = event.currentTarget.dataset.type;

if(event.currentTarget.checked) {
event.currentTarget.checked = false;
ui.notifications.warn(game.i18n.localize("CHARACTER.SHEET.NoExperienceLeft"));
this.actor.buyAdvance(career, type);
}
else
this.actor.removeAdvance(career, type);
}

/**
* Performs follow-up operations after clicks on a Characteristic link.
* Performs follow-up operations after clicks on a Characteristic.
* @param {MouseEvent} event
* @private
*/
_onCharacteristicLink(event)
_onCharacteristicClick(event)
{
this.actor.performCharacteristicCheck(event.currentTarget.dataset.characteristic);
}
Expand All @@ -284,7 +271,7 @@ export default class WFRP3eCharacterSheet extends ActorSheet
*/
_onCurrentCareerInput(event)
{
this._getItemById(event).update({"system.current": true});
this.actor.changeCurrentCareer(this._getItemById(event));
}

/**
Expand Down Expand Up @@ -331,9 +318,7 @@ export default class WFRP3eCharacterSheet extends ActorSheet
*/
_onQuantityLeftClick(event)
{
const item = this._getItemById(event);

item.update({"system.quantity": item.system.quantity + (event.ctrlKey ? 10 : 1)});
this._getItemById(event).changeQuantity(event.ctrlKey ? 10 : 1);
}

/**
Expand Down Expand Up @@ -384,11 +369,11 @@ export default class WFRP3eCharacterSheet extends ActorSheet
* @param {MouseEvent} event
* @private
*/
_onItemDelete(event)
async _onItemDelete(event)
{
const clickedItem = this._getItemById(event);

new Dialog({
await new Dialog({
title: game.i18n.localize("APPLICATION.TITLE.DeleteItem"),
content: "<p>" + game.i18n.format("APPLICATION.DESCRIPTION.DeleteItem", {item: clickedItem.name}) + "</p>",
buttons: {
Expand Down Expand Up @@ -538,6 +523,15 @@ export default class WFRP3eCharacterSheet extends ActorSheet
itemElement.toggleClass("expanded");
}

/**
* Performs follow-up operations after clicks on a stance meter link.
* @private
*/
_onStanceMeterLinkClick(amount, event)
{
this.actor.adjustStanceMeter(event.currentTarget.dataset.stance, amount);
}

/**
* Performs follow-up operations after changes on a Skill's training level checkbox.
* @param {Event} event
Expand Down
6 changes: 3 additions & 3 deletions modules/applications/actors/WFRP3eCreatureSheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export default class WFRP3eCreatureSheet extends ActorSheet
_buildItemLists(items)
{
const basicTrait = game.i18n.localize("ACTION.TRAITS.Basic");
const sortedItems = items.sort((a, b) => a.name < b.name ? -1 : a.name > b.name ? 1 : 0);
const sortedItems = items.sort((a, b) => a.name.localeCompare(b.name));
const actions = sortedItems.filter(item => item.type === "action").sort((a, b) => {
if(a.system.conservative.traits.includes(basicTrait) && !b.system.conservative.traits.includes(basicTrait))
return -1;
Expand Down Expand Up @@ -177,11 +177,11 @@ export default class WFRP3eCreatureSheet extends ActorSheet
* @param {MouseEvent} event
* @private
*/
_onItemDelete(event)
async _onItemDelete(event)
{
const item = this._getItemById(event);

new Dialog({
await new Dialog({
title: game.i18n.localize("APPLICATION.TITLE.DeleteItem"),
content: "<p>" + game.i18n.format("APPLICATION.DESCRIPTION.DeleteItem", {item: item.name}) + "</p>",
buttons: {
Expand Down
Loading

0 comments on commit b5abe73

Please sign in to comment.