fix: aligner le JS avec l'API Foundry v14
- effects.mjs: remove e._getSourceName() (removed in v14, now a getter) - fight.mjs: convert VermineCombatTracker from AppV1 (get template/getData) to AppV2 PARTS + _prepareContext/_prepareTurnContext - fight.mjs: VermineCombat.rollInitiative v14 options-object signature - hooks.mjs: renderPause -> renderGamePause; getSceneControlButtons now uses controls.tokens and tools record (v14 names/structure) - roll.mjs: ChatMessage.create uses rolls array (v14 removed 'roll' key) - item.mjs: getRollData returns system when no actor (v14 expects object) - vermine2047.mjs: correct unregisterSheet API for ActorSheetV2 - base-item-sheet.mjs: call super._onRender
This commit is contained in:
+63
-14
@@ -184,10 +184,9 @@ export class VermineCombat extends Combat {
|
||||
// encounter check
|
||||
}
|
||||
|
||||
async rollInitiative(ids, formula = undefined, messageOptions = {}) {
|
||||
async rollInitiative(ids, {formula=null, updateTurn=true, messageMode, messageOptions={}}={}) {
|
||||
// roll initiative
|
||||
return super.rollInitiative(ids, formula, messageOptions)
|
||||
|
||||
return super.rollInitiative(ids, {formula, updateTurn, messageMode, messageOptions});
|
||||
}
|
||||
|
||||
nextRound() {
|
||||
@@ -224,19 +223,69 @@ export class VermineCombat extends Combat {
|
||||
|
||||
export class VermineCombatTracker extends foundry.applications.sidebar.tabs.CombatTracker {
|
||||
|
||||
get template() {
|
||||
return "systems/vermine2047/templates/combat-tracker.hbs";
|
||||
/** @override */
|
||||
static PARTS = {
|
||||
main: {
|
||||
template: "systems/vermine2047/templates/combat-tracker.hbs",
|
||||
root: true
|
||||
}
|
||||
};
|
||||
|
||||
/** @override */
|
||||
async _prepareContext(options) {
|
||||
const context = await super._prepareContext(options);
|
||||
context.user = game.user;
|
||||
|
||||
const combat = this.viewed;
|
||||
const hasCombat = combat !== null;
|
||||
const combats = this.combats;
|
||||
const currentIdx = combats.indexOf(combat);
|
||||
const isPlayerTurn = combat?.combatant?.players?.includes(game.user);
|
||||
const canControl = combat?.turn && combat.turn.between(1, combat.turns.length - 2)
|
||||
? combat.canUserModify(game.user, "update", { turn: 0 })
|
||||
: combat?.canUserModify(game.user, "update", { round: 0 });
|
||||
|
||||
Object.assign(context, {
|
||||
combat,
|
||||
hasCombat,
|
||||
combatCount: combats.length,
|
||||
currentIndex: currentIdx + 1,
|
||||
previousId: combats[currentIdx - 1]?.id,
|
||||
nextId: combats[currentIdx + 1]?.id,
|
||||
round: combat?.round,
|
||||
control: isPlayerTurn && canControl,
|
||||
linked: combat?.scene !== null,
|
||||
cssClass: combats.length > 7 ? "cycle" : combats.length ? "tabbed" : "",
|
||||
cssId: "combat",
|
||||
tabName: "combat",
|
||||
labels: {
|
||||
scope: game.i18n.localize(`COMBAT.${combat?.scene ? "Linked" : "Unlinked"}`)
|
||||
},
|
||||
turns: []
|
||||
});
|
||||
|
||||
if ( combat ) {
|
||||
for ( const [i, combatant] of combat.turns.entries() ) {
|
||||
if ( !combatant.visible ) continue;
|
||||
context.turns.push(await this._prepareTurnContext(combat, combatant, i));
|
||||
}
|
||||
}
|
||||
return context;
|
||||
}
|
||||
|
||||
async getData(options) {
|
||||
const context = await super.getData(options);
|
||||
|
||||
if (!context.hasCombat) {
|
||||
return context;
|
||||
}
|
||||
|
||||
|
||||
return context;
|
||||
/** @override */
|
||||
async _prepareTurnContext(combat, combatant, index) {
|
||||
const turn = await super._prepareTurnContext(combat, combatant, index);
|
||||
const actor = combatant.actor;
|
||||
turn.attitude = combatant.getFlag("world", "attitude") || "active";
|
||||
turn.isPlayer = actor?.hasPlayerOwner ?? false;
|
||||
turn.isNpc = !!actor && !actor.hasPlayerOwner;
|
||||
turn.owner = combatant.isOwner;
|
||||
turn.defeated = combatant.isDefeated;
|
||||
turn.hasRolled = combatant.initiative !== null;
|
||||
turn.hasResource = combatant.resource !== null && combatant.resource !== undefined;
|
||||
turn.effects = (turn.effects?.icons ?? []).map(e => e.img);
|
||||
return turn;
|
||||
}
|
||||
|
||||
_onRender(context, options) {
|
||||
|
||||
Reference in New Issue
Block a user