Skip to content

Commit 62531cd

Browse files
authored
Merge pull request Detailing-the-Realm#91 from Detailing-the-Realm/develop
Merge v9 compatibility to master
2 parents 1645a82 + 95fbb82 commit 62531cd

File tree

15 files changed

+83
-41
lines changed

15 files changed

+83
-41
lines changed

css/svnsea2e.css

+1
Original file line numberDiff line numberDiff line change
@@ -609,6 +609,7 @@ input[type=range]::-webkit-slider-thumb {
609609
}
610610

611611
.svnsea2e .tabs .item {
612+
flex: 1;
612613
font-weight: bold;
613614
text-transform: uppercase;
614615
border-top: 2px solid #091B27;

lang/de.json

+1
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@
119119
"SVNSEA2E.GISLES": "Glamourinseln",
120120
"SVNSEA2E.Newadvantage": "Neuer Vorteil",
121121
"SVNSEA2E.Newbackground": "Neuer Hintergrund",
122+
"SVNSEA2E.Newduelstyle": "Neuer Duellstile",
122123
"SVNSEA2E.Newsorcery": "Neue Zauberkraft",
123124
"SVNSEA2E.Newshipadventure": "Neues Schiffsabenteuer",
124125
"SVNSEA2E.Newshipbackground": "Neuer Schiffshintergrund",

lang/en.json

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"SVNSEA2E.GISLES": "Glamour Isles",
121121
"SVNSEA2E.Newadvantage": "New Advantage",
122122
"SVNSEA2E.Newbackground": "New Background",
123+
"SVNSEA2E.Newduelstyle": "New Duel Style",
123124
"SVNSEA2E.Newsorcery": "New Sorcery",
124125
"SVNSEA2E.Newshipadventure": "New Ship Adventure",
125126
"SVNSEA2E.Newshipbackground": "New Ship Background",

lang/es.json

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
"SVNSEA2E.GISLES": "Islas del Glamaour",
121121
"SVNSEA2E.Newadvantage": "Nueva ventaja",
122122
"SVNSEA2E.Newbackground": "Nuevo trasfondo",
123+
"SVNSEA2E.Newduelstyle": "Nuevo estilo de esgrima",
123124
"SVNSEA2E.Newsorcery": "Nueva hechicería",
124125
"SVNSEA2E.Newshipadventure": "Nueva aventura de barco",
125126
"SVNSEA2E.Newshipbackground": "Nuevo trasfondo de barco",

lang/fr.json

+1
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@
117117
"SVNSEA2E.GISLES": "Îles du Glamour",
118118
"SVNSEA2E.Newadvantage": "Nouvel Avantage",
119119
"SVNSEA2E.Newbackground": "Nouvel Historique",
120+
"SVNSEA2E.Newduelstyle": "Nouvel Style de Duel",
120121
"SVNSEA2E.Newmonsterquality": "Nouvelle Qualité de Monstre",
121122
"SVNSEA2E.Newsorcery": "Nouvelle Sorcellerie",
122123
"SVNSEA2E.Newshipadventure": "Nouveau Navire d'Aventure",

module/actor/sheets/base.js

+37-21
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,16 @@ export default class ActorSheetSS2e extends ActorSheet {
140140
.find('.minus-1-initiative')
141141
.on('click', this._onMinusInitiative.bind(this));
142142

143+
//Create Inventory Item
143144
html.find('.item-create').on('click', this._onItemCreate.bind(this));
144145

145146
// Update Inventory Item
146-
html.find('.item-edit').on('click', (ev) => {
147-
const li = $(ev.currentTarget).parents('.item');
148-
const item = this.actor.getOwnedItem(li.data('itemId'));
149-
item.sheet.render(true);
150-
});
147+
html.find('.item-edit').on('click', this._onItemEdit.bind(this));
151148

152149
// Delete Inventory Item
153150
html.find('.item-delete').on('click', this._onItemDelete.bind(this));
154151

152+
//Expand item summary
155153
html
156154
.find('.item h4.item-name')
157155
.on('click', (event) => this._onItemSummary(event));
@@ -351,8 +349,9 @@ export default class ActorSheetSS2e extends ActorSheet {
351349
/* -------------------------------------------- */
352350

353351
/**
354-
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset
355-
* @param {Event} event The originating click event
352+
* Handle creating a new Owned Item for the actor using initial data defined in the HTML dataset.
353+
* @param {Event} event The originating click event.
354+
* @returns {Promise<Item5e[]>} The newly created item.
356355
* @private
357356
*/
358357
_onItemCreate(event) {
@@ -365,14 +364,30 @@ export default class ActorSheetSS2e extends ActorSheet {
365364
name: game.i18n.localize(`SVNSEA2E.New${type}`),
366365
img: `systems/svnsea2e/icons/${type}.jpg`,
367366
type: type,
368-
data: duplicate(header.dataset),
367+
data: foundry.utils.deepClone(header.dataset),
369368
};
370369
// Remove the type from the dataset since it's in the itemData.type prop.
371370
delete itemData.data.type;
372371

373372
// Finally, create the item!
374-
return this.actor.createOwnedItem(itemData);
373+
return this.actor.createEmbeddedDocuments('Item', [itemData]);
374+
}
375+
376+
/* -------------------------------------------- */
377+
378+
/**
379+
* Handle editing an existing Owned Item for the Actor.
380+
* @param {Event} event The originating click event.
381+
* @returns {ItemSheet5e} The rendered item sheet.
382+
* @private
383+
*/
384+
_onItemEdit(event) {
385+
event.preventDefault();
386+
const li = event.currentTarget.closest('.item');
387+
const item = this.actor.items.get(li.dataset.itemId);
388+
return item.sheet.render(true);
375389
}
390+
376391
/* -------------------------------------------- */
377392

378393
/**
@@ -383,13 +398,14 @@ export default class ActorSheetSS2e extends ActorSheet {
383398
async _onItemDelete(event) {
384399
event.preventDefault();
385400
const li = event.currentTarget.closest('.item');
386-
const itemid = li.dataset.itemId;
401+
const item = this.actor.items.get(li.dataset.itemId);
387402

388-
const item = this.actor.getOwnedItem(itemid);
389-
if (item && item.data.type === 'background')
390-
await this._processBackgroundDelete(item.data.data);
403+
if (item) {
404+
if (item.data.type === 'background')
405+
await this._processBackgroundDelete(item.data.data);
391406

392-
await this.actor.deleteOwnedItem(itemid);
407+
return item.delete();
408+
}
393409
}
394410

395411
/* -------------------------------------------- */
@@ -400,8 +416,8 @@ export default class ActorSheetSS2e extends ActorSheet {
400416
*/
401417
async _onItemSummary(event) {
402418
event.preventDefault();
403-
const li = $(event.currentTarget).parents('.item');
404-
const item = this.actor.getOwnedItem(li.data('item-id'));
419+
const li = $(event.currentTarget).closest('.item');
420+
const item = this.actor.items.get(li.data('itemId'));
405421
const chatData = item.getChatData({ secrets: this.actor.owner });
406422

407423
// Toggle summary
@@ -620,9 +636,9 @@ export default class ActorSheetSS2e extends ActorSheet {
620636

621637
for (let a = 0; a < bkgData.advantages.length; a++) {
622638
// need to grab the advantage first from world then compendium
623-
let advantage = game.items.entities.find(
624-
(entry) => entry.data.name === bkgData.advantages[a],
625-
);
639+
let advantage = game.items
640+
.values()
641+
.find((entry) => entry.data.name === bkgData.advantages[a]);
626642
if (!advantage) {
627643
// now we see if it is in a compendium
628644
for (var p = 0; p < packAdvs.length; p++) {
@@ -1137,12 +1153,12 @@ export default class ActorSheetSS2e extends ActorSheet {
11371153
const rollMode = game.settings.get('core', 'rollMode');
11381154
// Basic chat message
11391155
const chatData = {
1140-
user: game.user._id,
1156+
user: game.user.id,
11411157
type: CONST.CHAT_MESSAGE_TYPES.OTHER,
11421158
content: html,
11431159
image: actor.img,
11441160
speaker: {
1145-
actor: actor._id,
1161+
actor: actor.id,
11461162
token: actor.token,
11471163
alias: actor.name,
11481164
},

module/actor/sheets/villain.js

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
getAdvantageItems,
44
getArtifactItems,
55
getHubrisItems,
6+
getMonsterQualityItems,
67
getSchemeItems,
78
getSorceryItems,
89
getVirtueItems,
@@ -43,5 +44,6 @@ export class ActorSheetSS2eVillain extends ActorSheetSS2e {
4344
sheetData.schemes = getSchemeItems(baseData);
4445
sheetData.virtues = getVirtueItems(baseData);
4546
sheetData.hubriss = getHubrisItems(baseData);
47+
sheetData.monsterqualities = getMonsterQualityItems(baseData);
4648
}
4749
}

module/combat.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ export function updateInitiative(actorId, raise) {
88
}
99

1010
activeCombat.forEach((combat) => {
11-
const actors = combat.combatants.filter((c) => c._actor._id === actorId);
11+
const actors = combat.combatants.filter((c) => c.actor.id === actorId);
1212

1313
if (actors.length === 0) {
1414
ui.notifications.error(`This actor does not participate in this combat.`);
1515
return;
1616
}
1717

1818
combat.combatants
19-
.filter((c) => c._actor._id === actorId)
19+
.filter((c) => c.actor.id === actorId)
2020
.map((c) => {
2121
c.update({ initiative: parseFloat(nRaise) });
2222
});

module/item/sheets/base.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export class ItemSheetSS2e extends ItemSheet {
138138

139139
async _getAllAdvantages() {
140140
const advantages = [];
141-
const items = game.items.directory.entities;
141+
const items = game.items.directory.documents;
142142
for (let i = 0; i < items.length; i++) {
143143
if (items[i].type === 'advantage') {
144144
advantages.push(items[i].name);

module/migration.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export const migrateWorld = async function () {
1010
},
1111
);
1212
// Migrate World Actors
13-
for (const a of game.actors.entities) {
13+
for (const a of game.actors.values()) {
1414
try {
1515
const updateData = migrateActorData(a.data);
1616
if (!isObjectEmpty(updateData)) {
@@ -25,7 +25,7 @@ export const migrateWorld = async function () {
2525
}
2626

2727
// Migrate World Items
28-
for (const i of game.items.entities) {
28+
for (const i of game.items.values()) {
2929
try {
3030
const updateData = migrateItemData(i.data);
3131
if (!isObjectEmpty(updateData)) {
@@ -172,7 +172,7 @@ export const migrateActorData = function (actor) {
172172
actor.type === 'hero' ||
173173
actor.type === 'villain'
174174
) {
175-
if (data.arcana) {
175+
if (actor.data.arcana) {
176176
migrateVirtue(actor);
177177
migrateHubris(actor);
178178
actor.document.update({ data: { arcana: null } });
@@ -216,7 +216,7 @@ export const migrateSceneData = function (scene) {
216216

217217
export const migrateVirtue = function (actor) {
218218
const virtue = actor.data.arcana.virtue;
219-
if (virtue.name != null) {
219+
if (virtue.name) {
220220
const itemData = {
221221
name: virtue.name,
222222
img: `systems/svnsea2e/icons/virtue.jpg`,
@@ -225,13 +225,13 @@ export const migrateVirtue = function (actor) {
225225
description: virtue.description,
226226
},
227227
};
228-
actor.document.createOwnedItem(itemData);
228+
actor.document.createEmbeddedDocuments('Item', [itemData]);
229229
}
230230
};
231231

232232
export const migrateHubris = function (actor) {
233233
const hubris = actor.data.arcana.hubris;
234-
if (hubris.name != null) {
234+
if (hubris.name) {
235235
const itemData = {
236236
name: hubris.name,
237237
img: `systems/svnsea2e/icons/hubris.jpg`,
@@ -240,6 +240,6 @@ export const migrateHubris = function (actor) {
240240
description: hubris.description,
241241
},
242242
};
243-
actor.document.createOwnedItem(itemData);
243+
actor.document.createEmbeddedDocuments('Item', [itemData]);
244244
}
245245
};

module/svnsea2e.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,8 @@ Hooks.once('init', async function () {
5858
CONFIG.SVNSEA2E.natTypes.gisles = 'SVNSEA2E.RegionGlamourIsles';
5959

6060
// Define custom Entity classes
61-
CONFIG.Actor.entityClass = SvnSea2EActor;
62-
CONFIG.Item.entityClass = SvnSea2EItem;
61+
CONFIG.Actor.documentClass = SvnSea2EActor;
62+
CONFIG.Item.documentClass = SvnSea2EItem;
6363

6464
// Register System Settings
6565
registerSystemSettings();
@@ -301,11 +301,10 @@ Hooks.on('preCreateItem', function (document, options, userId) {
301301
/**
302302
* Set the default image for an actor type instead of the mystery man
303303
**/
304-
Hooks.on('preCreateActor', function (entity, options, userId) {
305-
entity.img = 'systems/svnsea2e/icons/' + entity.type + '.jpg';
306-
if (entity.name == '') {
307-
entity.name = 'New ' + entity.type[0].toUpperCase() + entity.type.slice(1);
308-
}
304+
Hooks.on('preCreateActor', function (document, entity, options, userId) {
305+
document.data.update({
306+
img: 'systems/svnsea2e/icons/' + document.data.type + '.jpg',
307+
});
309308
});
310309

311310
async function getAllPackAdvantages() {

scss/components/_tabs.scss

+1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
}
99

1010
.item {
11+
flex: 1;
1112
font-weight: bold;
1213
text-transform: uppercase;
1314
border-top: $brd-s-md-dk;

templates/actors/parts/actor-advantages.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ <h3 class="item-name flexrow">{{localize 'SVNSEA2E.Advantage'}}</h3>
1111
{{#each advantages as |item id|}}
1212
<li class="item flexrow advantage" data-item-id="{{item._id}}">
1313
<div class="item-image"><img src="{{item.img}}" title="{{item.name}}" /></div>
14-
<h4 class="item-name">{{item.name}}</h4>
14+
<h4 class="item-name">{{item.name}}{{#if item.data.knack}}<span title="{{localize 'SVNSEA2E.Knack'}}"><i class="fas fa-award"></i></span>{{/if}}{{#if item.data.innate}}<span title="{{localize 'SVNSEA2E.Innate'}}"><i class="fas fa-male"></i></span>{{/if}}</h4>
1515
<div class="item-controls">
1616
<a class="item-control item-edit" title="{{item.editlabel}}"><i class="fas fa-edit"></i></a>
1717
<a class="item-control item-delete" title="{{item.deletelabel}}"><i class="fas fa-trash"></i></a>

templates/actors/villain.html

+19
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ <h4 class="item-name">{{item.name}}</h4>
6161
</li>
6262
{{/each}}
6363

64+
<li class="flexrow item-header">
65+
<h3 class="item-name flexrow">{{localize "SVNSEA2E.MonsterQualities"}}</h3>
66+
<div class="item-controls">
67+
<a class="item-control item-create" title="{{localize 'SVNSEA2E.AddMonsterQuality'}}" data-type="monsterquality" {{#each section.dataset as |v k|}}data-{{k}}="{{v}}" {{/each}}>
68+
<i class="fas fa-plus"></i> {{localize "SVNSEA2E.Add"}}
69+
</a>
70+
</div>
71+
</li>
72+
{{#each monsterqualities as |item id|}}
73+
<li class="item flexrow" data-item-id="{{item._id}}">
74+
<div class="item-image"><img src="{{item.img}}" title="{{item.name}}" /></div>
75+
<h4 class="item-name">{{item.name}}</h4>
76+
<div class="item-controls">
77+
<a class="item-control item-edit" title="{{item.editlabel}}"><i class="fas fa-edit"></i></a>
78+
<a class="item-control item-delete" title="{{item.deletelabel}}"><i class="fas fa-trash"></i></a>
79+
</div>
80+
</li>
81+
{{/each}}
82+
6483
<li class="flexrow item-header">
6584
<h3 class="item-name flexrow">{{localize "SVNSEA2E.Schemes"}}</h3>
6685
<div class="item-controls">

templates/chats/roll-card.html

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<div class="chat-card skill-roll dice-roll" data-actor-id="{{ actor._id }}">
1+
<div class="chat-card skill-roll dice-roll" data-actor-id="{{ actor.id }}">
22
<div class="dice-result">
33
<h4 class="dice-total">{{ raises }} {{ raisetxt }}</h4>
44
<div class="dice-tooltip">
@@ -36,7 +36,7 @@ <h6>{{ rCombos }}</h6>
3636
</section>
3737
</div>
3838
<div>
39-
<button class="initiative-tracker-add" data-raise="{{ raises }}" data-actor="{{ actor._id }}">
39+
<button class="initiative-tracker-add" data-raise="{{ raises }}" data-actor="{{ actor.id }}">
4040
{{ localize "SVNSEA2E.AddToInitiativeTracker" }}
4141
</button>
4242
</div>

0 commit comments

Comments
 (0)