mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13:39 +02:00
Added initiator handling
This commit is contained in:
parent
cd6cd1c952
commit
86f3da8ac7
7 changed files with 66 additions and 8 deletions
|
|
@ -17,6 +17,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
id: member.id,
|
||||
selected: false
|
||||
}));
|
||||
this.intiator = null;
|
||||
|
||||
this.tabGroups.application = Object.keys(party.system.tagTeam.members).length
|
||||
? 'tagTeamRoll'
|
||||
|
|
@ -81,8 +82,16 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
const partContext = await super._preparePartContext(partId, context, options);
|
||||
switch (partId) {
|
||||
case 'initialization':
|
||||
partContext.tagTeamFields = this.party.system.schema.fields.tagTeam.fields;
|
||||
partContext.memberSelection = this.partyMembers;
|
||||
partContext.allSelected = partContext.memberSelection.filter(x => x.selected).length >= 2;
|
||||
const selectedMembers = partContext.memberSelection.filter(x => x.selected);
|
||||
|
||||
partContext.allSelected = selectedMembers.length === 2;
|
||||
partContext.canStartTagTeam = partContext.allSelected && this.initiator;
|
||||
partContext.initiator = this.initiator;
|
||||
partContext.initiatorOptions = selectedMembers.map(x => ({ value: x.id, label: x.name }));
|
||||
partContext.initiatorDisabled = !selectedMembers.length;
|
||||
|
||||
break;
|
||||
case 'tagTeamRoll':
|
||||
partContext.fields = this.party.system.schema.fields.tagTeam.fields;
|
||||
|
|
@ -152,14 +161,17 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
}
|
||||
|
||||
static async updateData(_event, _, formData) {
|
||||
const form = foundry.utils.expandObject(formData.object);
|
||||
await this.party.update(form);
|
||||
const { initiator, ...partyData } = foundry.utils.expandObject(formData.object);
|
||||
this.initiator = initiator;
|
||||
await this.party.update(partyData);
|
||||
this.render(true);
|
||||
}
|
||||
|
||||
//#region Initialization
|
||||
static #toggleSelectMember(_, button) {
|
||||
const member = this.partyMembers.find(x => x.id === button.dataset.id);
|
||||
if (member.selected && this.initiator?.memberId === member.id) this.initiator = null;
|
||||
|
||||
member.selected = !member.selected;
|
||||
this.render();
|
||||
}
|
||||
|
|
@ -168,6 +180,7 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
await this.party.update({
|
||||
'system.==tagTeam': new game.system.api.data.TagTeamData({
|
||||
...this.party.system.tagTeam.toObject(),
|
||||
initiator: this.initiator,
|
||||
members: this.partyMembers.reduce((acc, member) => {
|
||||
if (member.selected)
|
||||
acc[member.id] = {
|
||||
|
|
@ -461,7 +474,10 @@ export default class TagTeamDialog extends HandlebarsApplicationMixin(Applicatio
|
|||
|
||||
static async #cancelRoll() {
|
||||
await this.party.update({
|
||||
'system.tagTeam.==members': {}
|
||||
'system.==tagTeam': {
|
||||
initiator: null,
|
||||
members: {}
|
||||
}
|
||||
});
|
||||
this.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,6 +118,7 @@ export default class Party extends DHBaseActorSheet {
|
|||
secrets: this.document.isOwner,
|
||||
relativeTo: this.document
|
||||
});
|
||||
context.tagTeamActive = Boolean(this.document.system.tagTeam.initiator);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -3,6 +3,13 @@ export default class TagTeamData extends foundry.abstract.DataModel {
|
|||
const fields = foundry.data.fields;
|
||||
|
||||
return {
|
||||
initiator: new fields.SchemaField(
|
||||
{
|
||||
memberId: new fields.StringField({ required: true, label: 'Initiating Character' }),
|
||||
cost: new fields.NumberField({ integer: true, initial: 3, label: 'Initiation Cost' })
|
||||
},
|
||||
{ nullable: true, initial: null }
|
||||
),
|
||||
members: new fields.TypedObjectField(new fields.EmbeddedDataField(MemberData))
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,9 @@
|
|||
.daggerheart.dialog.dh-style.views.tag-team-dialog {
|
||||
.initialization-container {
|
||||
h2 {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.members-container {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr 1fr 1fr;
|
||||
|
|
@ -20,6 +24,17 @@
|
|||
}
|
||||
}
|
||||
|
||||
.intiator-container {
|
||||
margin-top: 8px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 8px;
|
||||
|
||||
&.inactive {
|
||||
opacity: 0.4;
|
||||
}
|
||||
}
|
||||
|
||||
footer {
|
||||
margin-top: 8px;
|
||||
display: flex;
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@
|
|||
font-size: 12px;
|
||||
}
|
||||
}
|
||||
|
||||
.active-action {
|
||||
animation: glow 0.75s infinite alternate;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,14 +2,29 @@
|
|||
<h2>{{localize "Select the two participants"}}</h2>
|
||||
<div class="members-container">
|
||||
{{#each memberSelection as |member|}}
|
||||
<a class="member-container {{#unless member.selected}}inactive {{#if ../allselected}}locked{{/if}}{{/unless}}" data-action="toggleSelectMember" data-id="{{member.id}}">
|
||||
<a
|
||||
class="member-container {{#unless member.selected}}inactive {{#if ../allselected}}locked{{/if}}{{/unless}}"
|
||||
data-action="toggleSelectMember" data-id="{{member.id}}" {{#if (and (not member.selected) ../allSelected)}}disabled{{/if}}
|
||||
>
|
||||
<span class="member-name">{{member.name}}</span>
|
||||
<img src="{{member.img}}" />
|
||||
</a>
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
</div>
|
||||
|
||||
<div class="intiator-container {{#if initiatorDisabled}}inactive{{/if}}">
|
||||
<div class="form-group">
|
||||
<label>{{localize "Initiating Character"}}</label>
|
||||
<div class="form-fields">
|
||||
<select name="initiator.memberId" {{#if initiatorDisabled}}disabled{{/if}}>
|
||||
{{selectOptions initiatorOptions selected=initiator.memberId blank="" }}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
{{formGroup tagTeamFields.initiator.fields.cost name="initiator.cost" value=initiator.cost disabled=initiatorDisabled localize=true }}
|
||||
</div>
|
||||
|
||||
<footer>
|
||||
<button type="button" data-action="startTagTeamRoll" {{#unless allSelected}}disabled{{/unless}}>{{localize "Start Tag Team Roll"}} <i class="fa-solid fa-arrow-right-long"></i></button>
|
||||
<button type="button" data-action="startTagTeamRoll" {{#unless canStartTagTeam}}disabled{{/unless}}>{{localize "Start Tag Team Roll"}} <i class="fa-solid fa-arrow-right-long"></i></button>
|
||||
</footer>
|
||||
</section>
|
||||
|
|
@ -5,7 +5,7 @@
|
|||
>
|
||||
|
||||
<div class="actions-section">
|
||||
<button data-action="tagTeamRoll">
|
||||
<button data-action="tagTeamRoll" class="{{#if tagTeamActive}}active-action{{/if}}">
|
||||
<i class="fa-solid fa-user-group"></i>
|
||||
<span>Tag Team Roll</span>
|
||||
</button>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue