Skip to content

Commit

Permalink
Prevent inputs out of game
Browse files Browse the repository at this point in the history
  • Loading branch information
alopezo committed Feb 8, 2024
1 parent 9170568 commit c90b5b4
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 34 deletions.
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,6 @@
<style>html,body{height:100%}body{margin:0;font-family:Roboto,Helvetica Neue,sans-serif}</style><link rel="stylesheet" href="styles.25b54d3c54f3517b.css" media="print" onload="this.media='all'"><noscript><link rel="stylesheet" href="styles.25b54d3c54f3517b.css"></noscript></head>
<body class="mat-typography">
<app-root></app-root>
<script src="runtime.c2d2548033d65b02.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.4bdcf6bb37ae3747.js" type="module"></script>
<script src="runtime.c2d2548033d65b02.js" type="module"></script><script src="polyfills.75186c7b7fc1d123.js" type="module"></script><script src="scripts.a1e2309b4257c7b3.js" defer></script><script src="main.615e54262452c7e0.js" type="module"></script>

</body></html>

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion src/app/game/service/snoguess.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export class SnoguessService {
);
let fsn = this.extractFSN(fullConcept);
this.fsn = fsn? fsn : '';
console.log(fsn)
let scg = this.extractScg(fullConcept);
this.scg = scg? scg : '';
let focusConcepts = this.extractFocusConcepts(scg? scg : '');
Expand Down
4 changes: 2 additions & 2 deletions src/app/game/snoguess-main/snoguess-main.component.css
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@

.lost {
color: #F44336; /* Red color for "Lost" */
text-shadow: black 2px 2px 2px;
text-shadow: rgb(255, 255, 255) 2px 2px 2px;
}

/* Optional: Style the button if needed */
.overlay button {
.overlay button {
font-size: 1.5rem;
padding: 10px 20px;
}
Expand Down
9 changes: 5 additions & 4 deletions src/app/game/snoguess-main/snoguess-main.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ <h2>Guess the SNOMED Term</h2>
Score: {{ gameState.score }} &nbsp;&nbsp;&nbsp;&nbsp; Life:
</span>
<span *ngFor="let hp of [].constructor(gameState.hitPoints); let i = index">
<mat-icon [@heartAnimation]="gameState.hitPoints > i ? 'filled' : 'empty'">favorite</mat-icon>
<mat-icon>favorite</mat-icon>
</span>
<span *ngFor="let hp of [].constructor(gameState.maxHitPoints - gameState.hitPoints); let i = index">
<mat-icon [@heartAnimation]="'empty'">favorite_border</mat-icon>
<mat-icon>favorite_border</mat-icon>
</span>
</div>

Expand Down Expand Up @@ -53,7 +53,7 @@ <h2>Guess the SNOMED Term</h2>

<br>
<div class="guess-field">
<button mat-flat-button color="accent" (click)="revealHint()" (keydown.enter)="$event.preventDefault()" [disabled]="gameState.state !== 'playing' || !gameState.hintsAvailable">Reveal Hint</button>
<button mat-flat-button color="accent" (click)="revealHint()" (keydown.enter)="$event.preventDefault()" [disabled]="gameState.state !== 'playing' || !gameState.hintsAvailable || gameState.hitPoints <= 1">Reveal Hint</button>
<button mat-flat-button color="accent" (click)="initialize()" (keydown.enter)="$event.preventDefault()" [disabled]="gameState.state !== 'playing'">Reset</button>
</div>
<div class="note">
Expand Down Expand Up @@ -134,7 +134,8 @@ <h2>Hints</h2>
<div class="drop" style="--i:50"></div>
</div>
<div class="message lost">You have lost!</div>
<div class="reveal lost">{{ gameState.term }}</div>
<div class="reveal lost"> The term was: </div>
<div class="reveal lost"> {{ gameState.term }}</div>
<div class="reveal lost">Final Score: {{ gameState.score }}</div>
<button mat-flat-button color="warn" (click)="initialize()">Try Again</button>
</div>
Expand Down
31 changes: 6 additions & 25 deletions src/app/game/snoguess-main/snoguess-main.component.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Component, OnInit, ViewChild } from "@angular/core";
import { Observable } from "rxjs";
import { Observable, firstValueFrom } from "rxjs";
import { Game, SnoguessService } from "../service/snoguess.service";
import { trigger, state, style, transition, animate, keyframes } from "@angular/animations";
import { KeyboardComponent } from "../keyboard/keyboard.component";
Expand All @@ -9,28 +9,6 @@ import { KeyboardComponent } from "../keyboard/keyboard.component";
templateUrl: './snoguess-main.component.html',
styleUrls: ['./snoguess-main.component.css', './fireworks.scss', './rain.scss'],
animations: [
trigger('heartAnimation', [
state('filled', style({
opacity: 1,
})),
state('empty', style({
opacity: 0.5,
})),
transition('filled => empty', [
animate('0.5s', keyframes([
style({transform: 'scale(1)', opacity: 1, offset: 0}),
style({transform: 'scale(1.5)', opacity: 0.7, offset: 0.5}),
style({transform: 'scale(1)', opacity: 0.5, offset: 1.0}),
]))
]),
transition('empty => filled', [
animate('0.5s', keyframes([
style({transform: 'scale(1)', opacity: 0.5, offset: 0}),
style({transform: 'scale(1.5)', opacity: 0.7, offset: 0.5}),
style({transform: 'scale(1)', opacity: 1, offset: 1.0}),
]))
]),
]),
trigger('shake', [
transition('normal => shake', animate(200, keyframes([
style({transform: 'translateX(0)'}),
Expand Down Expand Up @@ -86,8 +64,11 @@ export class SnoguessMainComponent implements OnInit {
this.snoguessMainService.getRandomConcept(true);
}

guessLetter(letter: string): void {
this.snoguessMainService.guessLetter(letter);
async guessLetter(letter: string) {
let game = await firstValueFrom(this.game);
if (game?.state === 'playing') {
this.snoguessMainService.guessLetter(letter);
}
}

guessTerm(term: string): void {
Expand Down

0 comments on commit c90b5b4

Please sign in to comment.