More todo stuff and such

This commit is contained in:
Lordmau5 2023-11-14 23:25:10 +01:00
parent 883098fd32
commit 42344db22f

View File

@ -56,6 +56,19 @@ export class BingoGame {
} }
addGroup(group: BingoGroup): void { addGroup(group: BingoGroup): void {
// TODO: Right now we can do circular groups.
// 1.parent = 2, 2.parent = 1
// This will loop the objects infinitely.
// Make sure that going through the tree we don't have this problem.
//
// Option B:
// Trash idea of groups-in-groups (parent system)
// Just have groups and be done with them.
//
// Option C:
// Bring back categories so we have categories + groups.
// _____________________________________________________
if (this.groups.some(_group => stringCompare(_group.name, group.name))) if (this.groups.some(_group => stringCompare(_group.name, group.name)))
return; return;
@ -199,20 +212,25 @@ export class BingoGoal {
export class BingoGroup { export class BingoGroup {
name: string; name: string;
@Exclude({ // @Exclude({
toPlainOnly: true // toPlainOnly: true
}) // })
@Type(() => BingoGroup) // @Type(() => BingoGroup)
parent?: BingoGroup; #parent?: BingoGroup;
constructor(name: string, parent?: BingoGroup | undefined) { constructor(name: string, parent?: BingoGroup | undefined) {
this.name = name; this.name = name;
this.parent = parent; this.#parent = parent;
}
@Exclude()
get parent(): BingoGroup | undefined {
return this.#parent;
} }
@Expose() @Expose()
get parent_id(): string | undefined { get parent_id(): string | undefined {
return this.parent?.name; return this.#parent?.name;
} }
} }
@ -224,26 +242,41 @@ function test(): void {
'The funny game we used for all bingos.', 'The funny game we used for all bingos.',
'Very long text here haha lmao' 'Very long text here haha lmao'
); );
const group1 = new BingoGroup('1'); const group1 = new BingoGroup('1');
const group2 = new BingoGroup('2', group1); const group2 = new BingoGroup('2', group1);
const group3 = new BingoGroup('3', group2); // group1.parent = group2;
// group2.parent = group1;
game.addGroup(group1); game.addGroup(group1);
game.addGroup(group2); game.addGroup(group2);
game.addGroup(group3);
const battle_group = new BingoGroup('Battle'); const jsonifiedInstance = instanceToPlain(game, {
const defeat_enemies = new BingoGroup('Defeat enemies on the street', battle_group); enableCircularCheck: true
game.addGroup(battle_group); });
game.addGroup(defeat_enemies); const fixed = JSON.parse(JSON.stringify(jsonifiedInstance));
console.log(JSON.stringify([ fixed ]));
const easy = new BingoGoal('Defeat 50 enemies on the street', group1).addTag('Easy'); // const group1 = new BingoGroup('1');
const normal = new BingoGoal('Defeat 150 enemies on the street', group2).addTag('Normal'); // const group2 = new BingoGroup('2', group1);
const hard = new BingoGoal('Defeat 300 enemies on the street', group3).addTag('Hard'); // const group3 = new BingoGroup('3', group2);
game.addGoal(easy); // game.addGroup(group1);
game.addGoal(normal); // game.addGroup(group2);
game.addGoal(hard); // game.addGroup(group3);
// const battle_group = new BingoGroup('Battle');
// const defeat_enemies = new BingoGroup('Defeat enemies on the street', battle_group);
// game.addGroup(battle_group);
// game.addGroup(defeat_enemies);
// const easy = new BingoGoal('Defeat 50 enemies on the street', group1).addTag('Easy');
// const normal = new BingoGoal('Defeat 150 enemies on the street', group2).addTag('Normal');
// const hard = new BingoGoal('Defeat 300 enemies on the street', group3).addTag('Hard');
// game.addGoal(easy);
// game.addGoal(normal);
// game.addGoal(hard);
// console.log(game.goals[0].group); // console.log(game.goals[0].group);
// game.groups[0].name = 'not 1'; // game.groups[0].name = 'not 1';