Skip to content

Commit

Permalink
Add a command to disable sets (#180)
Browse files Browse the repository at this point in the history
Co-authored-by: Kris Johnson <[email protected]>
  • Loading branch information
mia-pi-git and KrisXV authored May 4, 2024
1 parent 1c558af commit 9e30291
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
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();
},
};

0 comments on commit 9e30291

Please sign in to comment.