mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-11 19:25:21 +01:00
Combat and CombatTracker (#108)
* Added Combat and CombatTracker * Some cleneaup * Fixing and cleaning up * Added categories for combatants * Style improvements * Layout change
This commit is contained in:
parent
32730b3aac
commit
aa8fe6a7a1
23 changed files with 730 additions and 684 deletions
|
|
@ -1,44 +1,19 @@
|
|||
import { GMUpdateEvent, socketEvent } from '../helpers/socket.mjs';
|
||||
|
||||
export default class DhpCombat extends Combat {
|
||||
_sortCombatants(a, b) {
|
||||
if (a.isNPC !== b.isNPC) {
|
||||
const aVal = a.isNPC ? 0 : 1;
|
||||
const bVal = b.isNPC ? 0 : 1;
|
||||
async startCombat() {
|
||||
this._playCombatSound('startEncounter');
|
||||
const updateData = { round: 1, turn: null };
|
||||
Hooks.callAll('combatStart', this, updateData);
|
||||
await this.update(updateData);
|
||||
return this;
|
||||
}
|
||||
|
||||
return aVal - bVal;
|
||||
_sortCombatants(a, b) {
|
||||
const aNPC = Number(a.isNPC);
|
||||
const bNPC = Number(b.isNPC);
|
||||
if (aNPC !== bNPC) {
|
||||
return aNPC - bNPC;
|
||||
}
|
||||
|
||||
return a.name.localeCompare(b.name);
|
||||
}
|
||||
|
||||
async useActionToken(combatantId) {
|
||||
const automateActionPoints = await game.settings.get(
|
||||
SYSTEM.id,
|
||||
SYSTEM.SETTINGS.gameSettings.Automation.ActionPoints
|
||||
);
|
||||
|
||||
if (game.user.isGM) {
|
||||
if (this.system.actions < 1) return;
|
||||
|
||||
const update = automateActionPoints
|
||||
? { 'system.activeCombatant': combatantId, 'system.actions': Math.max(this.system.actions - 1, 0) }
|
||||
: { 'system.activeCombatant': combatantId };
|
||||
|
||||
await this.update(update);
|
||||
} else {
|
||||
const update = automateActionPoints
|
||||
? { 'system.activeCombatant': combatantId, 'system.actions': this.system.actions + 1 }
|
||||
: { 'system.activeCombatant': combatantId };
|
||||
|
||||
await game.socket.emit(`system.${SYSTEM.id}`, {
|
||||
action: socketEvent.GMUpdate,
|
||||
data: {
|
||||
action: GMUpdateEvent.UpdateDocument,
|
||||
uuid: this.uuid,
|
||||
update: update
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue