Skip to content

Commit

Permalink
Fixes #264
Browse files Browse the repository at this point in the history
With a watchout, a json duplication may not be the best way to do this with typescript as it assumes this object is a data model.
  • Loading branch information
MarkDawson104 committed Sep 22, 2024
1 parent 840e162 commit 7be77c4
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/renderer/components/battle/BotParticipant.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<div class="flex-row flex-center">
<Icon :icon="robot" :height="16" />
</div>
<div>{{ bot.name }}</div>
<div>{{ bot.name }} - {{ botNameAffix }}</div>
</TeamParticipant>
<LuaOptionsModal
:id="`configure-bot-${bot.name}`"
Expand Down Expand Up @@ -43,6 +43,10 @@ const actions: MenuItem[] = [
label: "Configure",
command: configureBot,
},
{
label: "Duplicate",
command: duplicateBot,
},
{
label: "Kick",
command: kickBot,
Expand All @@ -59,6 +63,13 @@ function kickBot() {
props.battle.removeBot(props.bot);
}
// Duplicates this bot and its settings and gives it a new player id.
function duplicateBot() {
let duplicatedBot = JSON.parse(JSON.stringify(props.bot));
duplicatedBot.playerId = props.battle.contenders.value.length;
props.battle.addBot(duplicatedBot);
}
async function configureBot() {
const engineVersion = api.content.engine.installedVersions.find((version) => version.id === props.battle.battleOptions.engineVersion);
const ai = engineVersion?.ais.find((ai) => ai.name === props.bot.name);
Expand Down

0 comments on commit 7be77c4

Please sign in to comment.