diff --git a/frontend/projects/ui/src/app/app/snek/snek.directive.ts b/frontend/projects/ui/src/app/app/snek/snek.directive.ts index 1f1defe5d..a60185c5c 100644 --- a/frontend/projects/ui/src/app/app/snek/snek.directive.ts +++ b/frontend/projects/ui/src/app/app/snek/snek.directive.ts @@ -6,17 +6,10 @@ import { SnakePage } from '../../modals/snake/snake.page' import { PatchDbService } from '../../services/patch-db/patch-db.service' import { ApiService } from '../../services/api/embassy-api.service' -const SNEK = ['s', 'n', 'e', 'k'] - @Directive({ selector: 'img[appSnek]', }) export class SnekDirective { - private readonly code = new Map([ - ...SNEK.map<[string, boolean]>(char => [char, false]), - ['unlocked', false], - ]) - constructor( private readonly modalCtrl: ModalController, private readonly loadingCtrl: LoadingController, @@ -25,30 +18,8 @@ export class SnekDirective { private readonly patch: PatchDbService, ) {} - @HostListener('document:keyup', ['$event.key']) - onKeyUp(key: string) { - this.code.set(key, false) - } - - @HostListener('document:keypress', ['$event']) - async onKeyPress({ repeat, key }: KeyboardEvent) { - if (repeat || this.code.get('unlocked')) return - - this.code.set(key, true) - - if (SNEK.every(char => this.code.get(char))) { - await this.openSnek() - } - } - @HostListener('click') async onClick() { - await this.openSnek() - } - - private async openSnek() { - this.code.set('unlocked', true) - const modal = await this.modalCtrl.create({ component: SnakePage, cssClass: 'snake-modal', @@ -56,8 +27,6 @@ export class SnekDirective { }) modal.onDidDismiss().then(async ({ data }) => { - this.code.set('unlocked', false) - const highScore = this.patch.getData().ui.gaming?.snake?.['high-score'] || 0