Skip to content

Commit 9e30291

Browse files
mia-pi-gitKrisXV
andauthored
Add a command to disable sets (#180)
Co-authored-by: Kris Johnson <[email protected]>
1 parent 1c558af commit 9e30291

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

data/mods/gen9ssb/random-teams.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1051,6 +1051,9 @@ export class RandomStaffBrosTeams extends RandomTeams {
10511051
if (monotype && !debug.length) {
10521052
pool = pool.filter(x => this.dex.species.get(ssbSets[x].species).types.includes(monotype));
10531053
}
1054+
if (global.Config?.disabledssbsets?.length) {
1055+
pool = pool.filter(x => !global.Config.disabledssbsets.includes(this.dex.toID(x)));
1056+
}
10541057
const typePool: {[k: string]: number} = {};
10551058
let depth = 0;
10561059
while (pool.length && team.length < this.maxTeamSize) {

server/chat-plugins/randombattles/ssb.ts

+34
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,17 @@ function SSBSets(target: string) {
374374
return buf;
375375
}
376376

377+
378+
export const disabledSets = Chat.oldPlugins.ssb?.disabledSets || [];
379+
380+
function enforceDisabledSets() {
381+
for (const process of Rooms.PM.processes) {
382+
process.getProcess().send(`EVAL\n\nConfig.disabledssbsets = ${JSON.stringify(disabledSets)}`);
383+
}
384+
}
385+
386+
enforceDisabledSets();
387+
377388
export const commands: Chat.ChatCommands = {
378389
ssb(target, room, user) {
379390
if (!this.runBroadcast()) return;
@@ -387,4 +398,27 @@ export const commands: Chat.ChatCommands = {
387398
ssbhelp: [
388399
`/ssb [staff member] - Displays a staff member's Super Staff Bros. set and custom features.`,
389400
],
401+
enablessbset: 'disablessbset',
402+
disablessbset(target, room, user, connection, cmd) {
403+
this.checkCan('rangeban');
404+
target = toID(target);
405+
if (!Object.keys(ssbSets).map(toID).includes(target as ID)) {
406+
throw new Chat.ErrorMessage(`${target} has no SSB set.`);
407+
}
408+
const disableIdx = disabledSets.indexOf(target);
409+
if (cmd.startsWith('enable')) {
410+
if (disableIdx < 0) {
411+
throw new Chat.ErrorMessage(`${target}'s set is not disabled.`);
412+
}
413+
disabledSets.splice(disableIdx, 1);
414+
this.privateGlobalModAction(`${user.name} enabled ${target}'s SSB set.`);
415+
} else {
416+
if (disableIdx > -1) {
417+
throw new Chat.ErrorMessage(`That set is already disabled.`);
418+
}
419+
disabledSets.push(target);
420+
this.privateGlobalModAction(`${user.name} disabled the SSB set for ${target}`);
421+
}
422+
enforceDisabledSets();
423+
},
390424
};

0 commit comments

Comments
 (0)