mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
Initial commit
This commit is contained in:
commit
aa4021d1a2
163 changed files with 26530 additions and 0 deletions
41
module/documents/combat.mjs
Normal file
41
module/documents/combat.mjs
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
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;
|
||||
|
||||
return aVal - bVal;
|
||||
}
|
||||
|
||||
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