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 {
// 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)))
return;
@ -199,20 +212,25 @@ export class BingoGoal {
export class BingoGroup {
name: string;
@Exclude({
toPlainOnly: true
})
@Type(() => BingoGroup)
parent?: BingoGroup;
// @Exclude({
// toPlainOnly: true
// })
// @Type(() => BingoGroup)
#parent?: BingoGroup;
constructor(name: string, parent?: BingoGroup | undefined) {
this.name = name;
this.parent = parent;
this.#parent = parent;
}
@Exclude()
get parent(): BingoGroup | undefined {
return this.#parent;
}
@Expose()
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.',
'Very long text here haha lmao'
);
const group1 = new BingoGroup('1');
const group2 = new BingoGroup('2', group1);
const group3 = new BingoGroup('3', group2);
// group1.parent = group2;
// group2.parent = group1;
game.addGroup(group1);
game.addGroup(group2);
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 jsonifiedInstance = instanceToPlain(game, {
enableCircularCheck: true
});
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 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');
// const group1 = new BingoGroup('1');
// const group2 = new BingoGroup('2', group1);
// const group3 = new BingoGroup('3', group2);
game.addGoal(easy);
game.addGoal(normal);
game.addGoal(hard);
// game.addGroup(group1);
// game.addGroup(group2);
// 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);
// game.groups[0].name = 'not 1';