Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
moo-man committed Dec 19, 2023
2 parents da2b4e6 + 1dbb7d6 commit 5387bce
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 6 deletions.
7 changes: 7 additions & 0 deletions modules/actor/sheet/actor-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,12 @@ export default class ActorSheetWfrp4e extends ActorSheet {
inContainers = this._filterItemCategory(money, inContainers)
inContainers = this._filterItemCategory(containers, inContainers)

// Add names of containers to item.location object. Used for ammo selection
inContainers.forEach(i => {
const container = this.actor.getItemTypes("container").find(c => c.id === i.location.value);
i.location.name = container.name || false;
});

misc.totalShieldDamage = categories["weapons"].items.reduce((prev, current) => prev += current.damageToItem.shield, 0)

money.total = money.items.reduce((prev, current) => { return prev + (current.coinValue.value * current.quantity.value) }, 0)
Expand Down Expand Up @@ -721,6 +727,7 @@ export default class ActorSheetWfrp4e extends ActorSheet {
html.on("click", ".chat-roll", WFRP_Utility.handleRollClick.bind(WFRP_Utility))
html.on("click", ".symptom-tag", WFRP_Utility.handleSymptomClick.bind(WFRP_Utility))
html.on("click", ".condition-chat", WFRP_Utility.handleConditionClick.bind(WFRP_Utility))
html.on("click", ".property-chat", WFRP_Utility.handlePropertyClick.bind(WFRP_Utility))
html.on('mousedown', '.table-click', WFRP_Utility.handleTableClick.bind(WFRP_Utility))
html.on('mousedown', '.pay-link', WFRP_Utility.handlePayClick.bind(WFRP_Utility))
html.on('mousedown', '.credit-link', WFRP_Utility.handleCreditClick.bind(WFRP_Utility))
Expand Down
2 changes: 1 addition & 1 deletion modules/actor/sheet/character-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default class ActorSheetWfrp4eCharacter extends ActorSheetWfrp4e {
async getData() {
const sheetData = await super.getData();

this.addCharacterData(sheetData)
this.addCharacterData(sheetData);

return sheetData;
}
Expand Down
1 change: 1 addition & 0 deletions modules/hooks/journal.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default function() {
html.find(".chat-roll").click(WFRP_Utility.handleRollClick.bind(WFRP_Utility))
html.find(".symptom-tag").click(WFRP_Utility.handleSymptomClick.bind(WFRP_Utility))
html.find(".condition-chat").click(WFRP_Utility.handleConditionClick.bind(WFRP_Utility))
html.find(".property-chat").click(WFRP_Utility.handlePropertyClick.bind(WFRP_Utility))
html.find('.table-click').mousedown(WFRP_Utility.handleTableClick.bind(WFRP_Utility))
html.find('.pay-link').mousedown(WFRP_Utility.handlePayClick.bind(WFRP_Utility))
html.find('.credit-link').mousedown(WFRP_Utility.handleCreditClick.bind(WFRP_Utility))
Expand Down
1 change: 1 addition & 0 deletions modules/item/item-sheet.js
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ export default class ItemSheetWfrp4e extends ItemSheet {
html.on("click", ".chat-roll", WFRP_Utility.handleRollClick.bind(WFRP_Utility))
html.on("click", ".symptom-tag", WFRP_Utility.handleSymptomClick.bind(WFRP_Utility))
html.on("click", ".condition-chat", WFRP_Utility.handleConditionClick.bind(WFRP_Utility))
html.on("click", ".property-chat", WFRP_Utility.handlePropertyClick.bind(WFRP_Utility))
html.on('mousedown', '.table-click', WFRP_Utility.handleTableClick.bind(WFRP_Utility))
html.on('mousedown', '.pay-link', WFRP_Utility.handlePayClick.bind(WFRP_Utility))
html.on('mousedown', '.credit-link', WFRP_Utility.handleCreditClick.bind(WFRP_Utility))
Expand Down
1 change: 1 addition & 0 deletions modules/system/chat-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ export default class ChatWFRP {

html.on("click", ".symptom-tag", WFRP_Utility.handleSymptomClick.bind(WFRP_Utility))
html.on("click", ".condition-chat", WFRP_Utility.handleConditionClick.bind(WFRP_Utility))
html.on("click", ".property-chat", WFRP_Utility.handlePropertyClick.bind(WFRP_Utility))
html.on('mousedown', '.table-click', WFRP_Utility.handleTableClick.bind(WFRP_Utility))
html.on('mousedown', '.pay-link', WFRP_Utility.handlePayClick.bind(WFRP_Utility))
html.on('mousedown', '.credit-link', WFRP_Utility.handleCreditClick.bind(WFRP_Utility))
Expand Down
12 changes: 12 additions & 0 deletions modules/system/config-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,18 @@ CONFIG.TextEditor.enrichers = CONFIG.TextEditor.enrichers.concat([
return a
}
},
{
pattern : /@Property\[(.+?)](?:{(.+?)})?/gm,
enricher : (match) => {
const a = document.createElement("a");
a.classList.add("property-chat");
a.dataset.cond = match[1];
let id = match[1];
let label = match[2];
a.innerHTML = `<i class="fas fa-wrench"></i>${label ? label : id}`;
return a;
}
},
{
pattern : /@Pay\[(.+?)\](?:{(.+?)})?/gm,
enricher : (match, options) => {
Expand Down
22 changes: 22 additions & 0 deletions modules/system/utility-wfrp4e.js
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,28 @@ export default class WFRP_Utility {
ChatMessage.create(chatData);
}

/**
* Post property description when clicked.
*
* @param {Object} event click event
*/
static handlePropertyClick(event) {
let prop = event.target.text.trim();

// If property rating is present, remove it
if (!isNaN(prop.split(" ").pop()))
prop = prop.split(" ").slice(0, -1).join(" ");

const allProps = game.wfrp4e.utility.allProperties();
const propKey = WFRP_Utility.findKey(prop, allProps, { caseInsensitive: true });
const propName = allProps[propKey];
const description = game.wfrp4e.config.qualityDescriptions[propKey] || game.wfrp4e.config.flawDescriptions[propKey];
const messageContent = `<b>${propName}</b><br>${description}`;

const chatData = WFRP_Utility.chatDataSetup(messageContent, null);
ChatMessage.create(chatData);
}

/**
* Post symptom when clicked
*
Expand Down
9 changes: 6 additions & 3 deletions static/css/wfrp4e.css
Original file line number Diff line number Diff line change
Expand Up @@ -1422,16 +1422,18 @@
margin: 11px 11px 11px 11px;
padding: 5px;
resize: none;
border: none;
border: 3px solid #00000000;
border-radius: 0px;
background: none;
font-family: var(--actor-input-font-family);
font-size: var(--actor-input-font-size);
font-weight: var(--actor-input-font-weight);
color: var(--actor-input-color);
line-height: normal;
border: 3px double #3e000078;
}
#chat-form textarea#chat-message {
border: 3px double #3e000078;
}
#chat-form textarea:focus {
outline: none;
box-shadow: none;
Expand Down Expand Up @@ -14803,6 +14805,7 @@ button.capture-position {

.aoe-template,
.condition-chat,
.property-chat,
.chat-roll,
.table-click,
.travel-click,
Expand Down Expand Up @@ -17696,4 +17699,4 @@ blockquote.foundry-note::before {

li.message.flexcol.whisper:has(div > p.requestmessage) {
display: none;
}
}
2 changes: 1 addition & 1 deletion static/templates/actors/actor-combat.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
{{#select item.currentAmmo.value}}
<option class="ammo-option" value="">{{localize "NoneAmmo"}}</option>
{{#each item.ammoList as |ammo a|}}
<option class="ammo-option" value="{{ammo.id}}"> ({{ammo.quantity.value}}) {{ammo.name}}</option>
<option class="ammo-option" value="{{ammo.id}}"> ({{ammo.quantity.value}}) {{ammo.name}} {{#if ammo.location.name}}{{ammo.location.name}}{{/if}}</option>
{{/each}}
{{/select}}
</select>
Expand Down
2 changes: 1 addition & 1 deletion static/templates/actors/vehicle/vehicle-main.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@
{{#select item.currentAmmo.value}}
<option class="ammo-option" value="0">{{localize "NoneAmmo"}}</option>
{{#each item.ammoList as |ammo a|}}
<option class="ammo-option" value="{{ammo.id}}"> ({{ammo.quantity.value}}) {{ammo.name}}</option>
<option class="ammo-option" value="{{ammo.id}}"> ({{ammo.quantity.value}}) {{ammo.name}} {{#if ammo.location.name}}{{ammo.location.name}}{{/if}}</option>
{{/each}}
{{/select}}
</select>
Expand Down

0 comments on commit 5387bce

Please sign in to comment.