Skip to content

Commit

Permalink
feat: Add text to table
Browse files Browse the repository at this point in the history
  • Loading branch information
CaedenPH committed Aug 22, 2024
1 parent 38d65ab commit 3ebfa2d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 14 deletions.
2 changes: 0 additions & 2 deletions src/routes/game.ts
Original file line number Diff line number Diff line change
Expand Up @@ -527,9 +527,7 @@ export class CogSpeedGame {
*/
public async start(time: number | null = null) {
this.ui?.setupGame(this);
this.stop(0);
this.startTime = time === null ? performance.now() : time;
return;

this.maxTestTimeout = setTimeout(this.stop.bind(this), this.config.timeouts.max_test_duration);
this.nextRound();
Expand Down
4 changes: 0 additions & 4 deletions src/routes/results.ts
Original file line number Diff line number Diff line change
Expand Up @@ -277,10 +277,6 @@ export class ProcessResultsPage {
normalizedLocation,
};

data.sleepData.fatigueLevel = 2;
data.cognitiveProcessingIndex = 20;
data.blockingRoundDuration = 3000;

// Add table to top of page
const resultsTableContainer = this.ui.createResultsTable(data.sleepData.fatigueLevel, data.cognitiveProcessingIndex, data.blockingRoundDuration, this.app.screen.height * 0.15);

Expand Down
26 changes: 18 additions & 8 deletions src/ui/handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,18 +162,17 @@ export class CogSpeedGraphicsHandler {

// Blocking Round Duration Mapping
const _blockingRoundDurationMap = {
1800: 0xF4B4B4, // >1800 ms
1690: 0xff644e, // 1690-1789 ms
1525: 0xFFB05C, // 1525-1668 ms
1800: 0x7CE8FF, // >1800 ms
1690: 0xA7EA63, // 1690-1789 ms
1525: 0xC1F46A, // 1525-1668 ms
1250: 0xFFEE67, // 1250-1514 ms
975: 0xC1F46A, // 975-1239 ms
810: 0xA7EA63, // 810-964 ms
700: 0x7CE8FF // 700-799 ms
975: 0xFFB05C, // 975-1239 ms
810: 0xff644e, // 810-964 ms
700: 0xF4B4B4 // 700-799 ms
};

const container = new Container();


const screenWidth = this.app.screen.width;
const screenHeight = this.app.screen.height;

Expand All @@ -191,6 +190,9 @@ export class CogSpeedGraphicsHandler {
const headerTextSPF = new Text("S-PF Score", {fill: 0x00000, fontSize: 14})
headerTextSPF.position.set(screenWidth * 0.135, yPos + 8);

const valueTextSPF = new Text(spfScore, {fill: 0x00000, fontSize: 18})
valueTextSPF.position.set(screenWidth * 0.135 + 30, yPos + 50);

const valueBoxSPF = new Graphics();
let colour = _spfScoreMap[spfScore];
valueBoxSPF.beginFill(colour);
Expand All @@ -207,6 +209,9 @@ export class CogSpeedGraphicsHandler {
const headerTextCPI = new Text("CogSpeed Score", {fill: 0x00000, fontSize: 14})
headerTextCPI.position.set(screenWidth * 0.105 + width, yPos + 8);

const valueTextCPI = new Text(cpiScore.toString(), {fill: 0x00000, fontSize: 18})
valueTextCPI.position.set(screenWidth * 0.105 + width + 30, yPos + 50);

const valueBoxCPI = new Graphics();
colour = this._getMapValue(_cogspeedScoreMap, cpiScore);
valueBoxCPI.beginFill(colour);
Expand All @@ -222,6 +227,9 @@ export class CogSpeedGraphicsHandler {
const headerTextBRD = new Text("BRD", {fill: 0x00000, fontSize: 14})
headerTextBRD.position.set(screenWidth * 0.12 + width * 2, yPos + 8);

const valueTextBRD = new Text(blockingRoundDuration.toString(), {fill: 0x00000, fontSize: 18});
valueTextBRD.position.set(screenWidth * 0.12 + width * 2 + 30, yPos + 50);

const valueBoxBRD = new Graphics();
colour = this._getMapValue(_blockingRoundDurationMap, blockingRoundDuration);
valueBoxBRD.beginFill(colour);
Expand All @@ -240,7 +248,9 @@ export class CogSpeedGraphicsHandler {
container.addChild(headerTextCPI);
container.addChild(headerTextBRD);


container.addChild(valueTextSPF);
container.addChild(valueTextCPI);
container.addChild(valueTextBRD);

return container;
}
Expand Down

0 comments on commit 3ebfa2d

Please sign in to comment.