Working on refactor
This commit is contained in:
parent
bf8d99d92e
commit
2486f57e2b
4 changed files with 275 additions and 251 deletions
32
scripts/functions.ts
Normal file
32
scripts/functions.ts
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
import { races, channels } from "./commands";
|
||||
|
||||
export let encounterInProgress: boolean = false;
|
||||
|
||||
export function encounter(): void {
|
||||
if (encounterInProgress == false) { // randomInt(1,20) === 20 &&
|
||||
console.log("Starting Encounter");
|
||||
encounterInProgress = true;
|
||||
channels.encounter.send("An encounter is beginning!");
|
||||
|
||||
channels.encounter.send(`\`■■■ ■■■ ■■■ ■■■\`\n\`■■■ ■■■ ■■■ ■■■\`\n\`■■■ ■■■ ■■■ ■■■\``)
|
||||
console.log("Encounter finished");
|
||||
encounterInProgress = false;
|
||||
}
|
||||
}
|
||||
|
||||
export function randomInt(low: number, high: number): number {
|
||||
return Math.floor(Math.random() * (high - low + 1) + low)
|
||||
}
|
||||
|
||||
export function raceText(race: string): string {
|
||||
if (race === races[2]) return capitalize(race);
|
||||
else if (race === races[0] || race === races[1]) return `${capitalize(race)} Squirrel`;
|
||||
else {
|
||||
console.log(`Error ${race} is not a valid race`);
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
export function capitalize(toCaps: string): string {
|
||||
return toCaps.charAt(0).toUpperCase() + toCaps.slice(1).toLowerCase();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue