mirror of
https://github.com/Start9Labs/start-os.git
synced 2026-03-26 02:11:53 +00:00
chore(snek): remove keyboard activation
This commit is contained in:
@@ -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<string, boolean>([
|
||||
...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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user