🆕:Command File Changed ❌:All commands
Currently only Create command works
This commit is contained in:
parent
2486f57e2b
commit
f83a4231f1
7 changed files with 226 additions and 227 deletions
|
|
@ -1,31 +1,57 @@
|
|||
import { races, channels } from "./commands";
|
||||
import { squirrel } from "../scripts/enums";
|
||||
import { fs } from "../main";
|
||||
|
||||
export let encounterInProgress: boolean = false;
|
||||
const races: Array<string> = ["tree", "ground", "chipmunk"];
|
||||
const classes: Array<string> = ["rogue", "berserker", "knight", "ranger", "priest"];
|
||||
const lastNames: Array<string> = ["Nutcrack", "Nutmeg", "Seedsower", "McScuiri", "Rodentia", "Arbora", "Patagi"];
|
||||
// const COLOR: string = "#E81B47";
|
||||
|
||||
export function encounter(): void {
|
||||
if (encounterInProgress == false) { // randomInt(1,20) === 20 &&
|
||||
console.log("Starting Encounter");
|
||||
encounterInProgress = true;
|
||||
channels.encounter.send("An encounter is beginning!");
|
||||
export function newSquirrel(name: string, race: string, classtype: string): squirrel {
|
||||
let raceNum: number = -1;
|
||||
let classNum: number = -1;
|
||||
|
||||
channels.encounter.send(`\`■■■ ■■■ ■■■ ■■■\`\n\`■■■ ■■■ ■■■ ■■■\`\n\`■■■ ■■■ ■■■ ■■■\``)
|
||||
console.log("Encounter finished");
|
||||
encounterInProgress = false;
|
||||
}
|
||||
if (races.includes(race.toLowerCase()))
|
||||
raceNum = races.indexOf(race.toLowerCase());
|
||||
|
||||
if (classes.includes(classtype.toLowerCase()))
|
||||
classNum = classes.indexOf(classtype.toLowerCase());
|
||||
|
||||
return {
|
||||
"name": `${capitalize(name)} ${lastNames[randomInt(0, lastNames.length - 1)]}`,
|
||||
"race": raceNum,
|
||||
"class": classNum,
|
||||
"weapon": {
|
||||
"weaponName": "",
|
||||
"attackStat": 0,
|
||||
"defenseStat": 0,
|
||||
"secondStat": 0
|
||||
},
|
||||
"level": 1,
|
||||
"nuts": 0,
|
||||
"staminaMax": 0,
|
||||
"stamina": 0,
|
||||
"dm": false,
|
||||
"dm_points": 0
|
||||
};
|
||||
}
|
||||
|
||||
export function updateSquirrelFile(playerId: string, squirrel: squirrel): void {
|
||||
let playerFile: string = `./data/playerdata/${playerId}.json`;
|
||||
fs.writeFileSync(playerFile, JSON.stringify(squirrel));
|
||||
}
|
||||
|
||||
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 raceText(race: number): string {
|
||||
// if (race === 2) return capitalize(races[race]);
|
||||
// else if (race === 0 || race === 1) return `${capitalize(races[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