diff --git a/client/Commands/BuildCombatantCommandList.ts b/client/Commands/BuildCombatantCommandList.ts index 7552ff65..1cdc674f 100644 --- a/client/Commands/BuildCombatantCommandList.ts +++ b/client/Commands/BuildCombatantCommandList.ts @@ -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 }) ]; diff --git a/client/Commands/CombatantCommander.tsx b/client/Commands/CombatantCommander.tsx index 477caf9d..1d80bdec 100644 --- a/client/Commands/CombatantCommander.tsx +++ b/client/Commands/CombatantCommander.tsx @@ -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.` + ); + }; } diff --git a/client/Commands/DefaultKeybindings.ts b/client/Commands/DefaultKeybindings.ts index 9c90c0e5..18b64839 100644 --- a/client/Commands/DefaultKeybindings.ts +++ b/client/Commands/DefaultKeybindings.ts @@ -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" };