mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-22 02:19:54 +02:00
Changed to use ResourceUpdateMap in TagTeamDialog
This commit is contained in:
parent
25a64b1332
commit
5299beed8b
1 changed files with 17 additions and 12 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { ResourceUpdateMap } from '../../data/action/baseAction.mjs';
|
||||||
import { MemberData } from '../../data/tagTeamData.mjs';
|
import { MemberData } from '../../data/tagTeamData.mjs';
|
||||||
import { getCritDamageBonus, shouldUseHopeFearAutomation } from '../../helpers/utils.mjs';
|
import { getCritDamageBonus, shouldUseHopeFearAutomation } from '../../helpers/utils.mjs';
|
||||||
import { emitGMUpdate, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
|
import { emitGMUpdate, GMUpdateEvent, RefreshType, socketEvent } from '../../systemRegistration/socket.mjs';
|
||||||
|
|
@ -767,11 +768,13 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
|
|
||||||
/* Handle resource updates from the finished TagTeamRoll */
|
/* Handle resource updates from the finished TagTeamRoll */
|
||||||
const tagTeamData = this.party.system.tagTeam;
|
const tagTeamData = this.party.system.tagTeam;
|
||||||
const fearUpdate = { key: 'fear', value: null, enabled: true };
|
const fearResourceMap = new ResourceUpdateMap(mainActor);
|
||||||
|
|
||||||
if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) {
|
if (shouldUseHopeFearAutomation({ gmAsPlayer: true })) {
|
||||||
for (let memberId in tagTeamData.members) {
|
for (const memberId in tagTeamData.members) {
|
||||||
const resourceUpdates = [];
|
const actor = game.actors.get(memberId);
|
||||||
|
const resourceMap = new ResourceUpdateMap(actor);
|
||||||
|
|
||||||
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
|
const rollGivesHope = finalRoll.isCritical || finalRoll.withHope;
|
||||||
if (memberId === tagTeamData.initiator.memberId) {
|
if (memberId === tagTeamData.initiator.memberId) {
|
||||||
const value = tagTeamData.initiator.cost
|
const value = tagTeamData.initiator.cost
|
||||||
|
|
@ -779,16 +782,20 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
? 1 - tagTeamData.initiator.cost
|
? 1 - tagTeamData.initiator.cost
|
||||||
: -tagTeamData.initiator.cost
|
: -tagTeamData.initiator.cost
|
||||||
: 1;
|
: 1;
|
||||||
resourceUpdates.push({ key: 'hope', value: value, enabled: true });
|
resourceMap.addResources([{ key: 'hope', value: value, enabled: true }]);
|
||||||
} else if (rollGivesHope) {
|
} else if (rollGivesHope) {
|
||||||
resourceUpdates.push({ key: 'hope', value: 1, enabled: true });
|
resourceMap.addResources([{ key: 'hope', value: 1, enabled: true }]);
|
||||||
}
|
}
|
||||||
if (finalRoll.isCritical) resourceUpdates.push({ key: 'stress', value: -1, enabled: true });
|
if (finalRoll.isCritical) resourceMap.addResources([{ key: 'stress', value: -1, enabled: true }]);
|
||||||
if (finalRoll.withFear) {
|
if (finalRoll.withFear) {
|
||||||
fearUpdate.value = fearUpdate.value === null ? 1 : fearUpdate.value + 1;
|
fearResourceMap.addResources([{
|
||||||
|
key: 'fear',
|
||||||
|
value: 1,
|
||||||
|
enabled: true
|
||||||
|
}]);
|
||||||
}
|
}
|
||||||
|
|
||||||
game.actors.get(memberId).modifyResource(resourceUpdates);
|
resourceMap.updateResources();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Even with Hope/Fear automation off, the hope cost of performing the TagTeamRoll can still optionally be subtracted */
|
/* Even with Hope/Fear automation off, the hope cost of performing the TagTeamRoll can still optionally be subtracted */
|
||||||
|
|
@ -797,10 +804,8 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
||||||
initiatingActor.modifyResource([{ key: 'hope', value: -tagTeamData.initiator.cost, enabled: true }]);
|
initiatingActor.modifyResource([{ key: 'hope', value: -tagTeamData.initiator.cost, enabled: true }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fearUpdate.value) {
|
fearResourceMap.updateResources();
|
||||||
mainActor.modifyResource([fearUpdate]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Fin */
|
/* Fin */
|
||||||
this.cancelRoll({ confirm: false });
|
this.cancelRoll({ confirm: false });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue