Skip to content

Commit

Permalink
Add Duplicate Combatant command
Browse files Browse the repository at this point in the history
  • Loading branch information
cynicaloptimist committed Jul 25, 2024
1 parent c8ae505 commit 29c2d8c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
7 changes: 7 additions & 0 deletions client/Commands/BuildCombatantCommandList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,5 +126,12 @@ export const BuildCombatantCommandList: (
actionBinding: c.SelectPrevious,
fontAwesomeIcon: "arrow-up",
defaultShowOnActionBar: false
}),
new Command({
id: "duplicate-combatant",
description: "Duplicate Combatant",
actionBinding: c.Duplicate,
fontAwesomeIcon: "clone",
defaultShowOnActionBar: false
})
];
22 changes: 22 additions & 0 deletions client/Commands/CombatantCommander.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -507,4 +507,26 @@ export class CombatantCommander {
});
this.tracker.PromptQueue.Add(prompt);
};

public Duplicate = () => {
if (!this.HasSelected()) {
return;
}

const selectedCombatants = this.SelectedCombatants();
selectedCombatants.forEach(c => {
if (c.Combatant.PersistentCharacterId) {
return;
}

this.tracker.Encounter.AddCombatantFromState({
...c.Combatant.GetState(),
Id: probablyUniqueString()
});
});

this.tracker.EventLog.AddEvent(
`${selectedCombatants.map(c => c.Name()).join(", ")} duplicated.`
);
};
}
3 changes: 2 additions & 1 deletion client/Commands/DefaultKeybindings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ export const DefaultKeybindings: { [commandId: string]: string } = {
"move-down": "alt+j",
"move-up": "alt+k",
"select-next": "j",
"select-previous": "k"
"select-previous": "k",
"duplicate-combatant": "alt+d"
};

0 comments on commit 29c2d8c

Please sign in to comment.