Introduce LocalGame logic and integrate with LocalMode rendering.

This commit is contained in:
2026-02-19 21:05:33 +01:00
committed by Jonas
parent 13fdf97f5a
commit 7395b6d3bf
8 changed files with 63 additions and 20 deletions
+13 -14
View File
@@ -1,25 +1,24 @@
<script setup lang="ts">
import Field from '@/components/game/Field.vue'
import { ref } from 'vue'
import type { FieldSize } from '@/scripts/interfaces/FieldSize.ts'
import LocalGame from '@/scripts/logic/localMode/LocalGame.ts'
let gameField = [
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 0, 0],
[0, 0, 0, 0, 0, 2, 1],
[1, 0, 1, 0, 0, 1, 1],
[1, 0, 2, 0, 1, 2, 2],
[1, 1, 2, 1, 2, 1, 2],
]
const gameFieldSize: FieldSize = {
x: 7,
y: 6,
}
let currentSelection = ref(null)
setInterval(() => {
console.log(currentSelection.value)
}, 1000)
const game = ref(new LocalGame(gameFieldSize))
const currentSelection = ref(null)
</script>
<template>
<Field :game-state="gameField" v-model:current-selection-index="currentSelection" ></Field>
<Field
v-model:current-selection-index="currentSelection"
:gameState="game.field"
@clickOnGameField="game.place(currentSelection)"
></Field>
</template>
<style scoped></style>