Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes #264 #268

Merged
merged 5 commits into from
Sep 29, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/renderer/components/battle/BotParticipant.vue
Original file line number Diff line number Diff line change
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));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

structuredClone should be cleaner in what you are trying to do here vs pasing object via JSON serialization. It also should be better for typing.

Also change let to const.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Adjustments made in a877be / 959a9fc, alongside a fix for options not being set by some sort of Id.

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
Loading