-
Notifications
You must be signed in to change notification settings - Fork 74
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
127 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Note this is a site Percival role that assists the Mods with site moderation. | ||
// It is not the Percival role in Avalon gameplay. | ||
|
||
// all in lower case | ||
export const percivalsArray: string[] = []; | ||
|
||
export function isPercival(username: string): boolean { | ||
return percivalsArray.includes(username.toLowerCase()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Command, Commands } from '../types'; | ||
import { p } from './p'; | ||
import { mdc } from '../mod/mdc'; | ||
|
||
// Percival commands are intended to be a strict subset of mod commands. | ||
|
||
export function convertModCommandToPercivalCommand( | ||
modCommand: Command, | ||
): Command { | ||
const modPrefix = 'm'; | ||
const percivalPrefix = 'p'; | ||
|
||
// Throw error if invalid command is passed | ||
if (!modCommand.command.startsWith(modPrefix)) { | ||
throw new Error(`Incorrect command prefix. Expected to start with: "${modPrefix}" Got: "${modCommand.command}"`); | ||
} | ||
|
||
if (!modCommand.help.startsWith(`/${modPrefix}`)) { | ||
throw new Error( | ||
`Incorrect command help prefix. Expected to start with: "/${modPrefix}" Got: "${modCommand.help}"`, | ||
); | ||
} | ||
|
||
return { | ||
command: modCommand.command.replace( | ||
modPrefix, | ||
percivalPrefix, | ||
), | ||
help: modCommand.help.replace(modPrefix, percivalPrefix), | ||
run: modCommand.run, | ||
}; | ||
} | ||
|
||
const pdc = convertModCommandToPercivalCommand(mdc); | ||
|
||
export const percivalCommands: Commands = { | ||
[p.command]: p, | ||
[pdc.command]: pdc, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { Command } from '../types'; | ||
import { SocketUser } from '../../types'; | ||
import { percivalCommands } from './index'; | ||
|
||
export const p: Command = { | ||
command: 'p', | ||
help: '/p: show percival commands.', | ||
run: async (args: string[], socket: SocketUser) => { | ||
const dataToSend = []; | ||
|
||
for (const key in percivalCommands) { | ||
if (percivalCommands.hasOwnProperty(key)) { | ||
const commandKey = key as keyof typeof percivalCommands; | ||
dataToSend.push({ | ||
message: percivalCommands[commandKey].help, | ||
classStr: 'server-text', | ||
}); | ||
} | ||
} | ||
|
||
socket.emit('messageCommandReturnStr', dataToSend); | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters