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

Add a command to disable sets #180

Merged
merged 3 commits into from
May 4, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions data/mods/gen9ssb/random-teams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1051,6 +1051,9 @@ export class RandomStaffBrosTeams extends RandomTeams {
if (monotype && !debug.length) {
pool = pool.filter(x => this.dex.species.get(ssbSets[x].species).types.includes(monotype));
}
if (global.Config?.disabledssbsets?.length) {
pool = pool.filter(x => !global.Config.disabledssbsets.includes(this.dex.toID(x)));
}
const typePool: {[k: string]: number} = {};
let depth = 0;
while (pool.length && team.length < this.maxTeamSize) {
Expand Down
34 changes: 34 additions & 0 deletions server/chat-plugins/randombattles/ssb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,17 @@ function SSBSets(target: string) {
return buf;
}


export const disabledSets = Chat.oldPlugins.ssb?.disabledSets || [];

function enforceDisabledSets() {
for (const process of Rooms.PM.processes) {
process.getProcess().send(`EVAL\n\nConfig.disabledssbsets = ${JSON.stringify(disabledSets)}`);
}
}

enforceDisabledSets();

export const commands: Chat.ChatCommands = {
ssb(target, room, user) {
if (!this.runBroadcast()) return;
Expand All @@ -387,4 +398,27 @@ export const commands: Chat.ChatCommands = {
ssbhelp: [
`/ssb [staff member] - Displays a staff member's Super Staff Bros. set and custom features.`,
],
enablessbset: 'disablessbset',
disablessbset(target, room, user, connection, cmd) {
this.checkCan('rangeban');
target = toID(target);
if (!Object.keys(ssbSets).map(toID).includes(target as ID)) {
throw new Chat.ErrorMessage(`${target} has no SSB set.`);
}
const disableIdx = disabledSets.indexOf(target);
if (cmd.startsWith('enable')) {
if (disableIdx < 0) {
throw new Chat.ErrorMessage(`${target}'s set is not disabled.`);
}
disabledSets.splice(disableIdx, 1);
this.privateGlobalModAction(`${user.name} enabled ${target}'s SSB set.`);
} else {
if (disableIdx > -1) {
throw new Chat.ErrorMessage(`That set is already disabled.`);
}
disabledSets.push(target);
this.privateGlobalModAction(`${user.name} disabled the SSB set for ${target}`);
}
enforceDisabledSets();
},
};
Loading