added game logic

This commit is contained in:
Peter Hudec 2023-12-17 12:17:08 +01:00
parent 89b029df9a
commit a80f2f841c

View File

@ -27,16 +27,16 @@
<div v-show="isGameStarted" v-for="r in rounds">
Tief:
<span v-for="pos in r.tief">{{ pos }}</span>
<span class="border border-primary rounded-circle" v-for="pos in r.tief">{{ pos }}</span>
Police:
<span v-for="pos in r.police">{{ pos }}</span>
<span class="border border-primary rounded-circle" v-for="pos in r.police">{{ pos }}</span>
Transport:
<span>{{ r.transport }}</span>
</div>
<div v-show="isGameStarted">
<form v-on:submit.prevent="gameRound" name="form_move">
Tief:
<span v-for="pos in round.tief">{{ pos }}</span>
<span class="border border-primary rounded-circle" v-for="pos in round.tief">{{ pos }}</span>
Police:
<input v-for="(police, index) in round.police" v-model="round.police[index]" type="number" min="1" max="199" required name="police">
Transport:
@ -86,9 +86,25 @@
'police': this.round.police.slice(),
})
// clear values
let tief = new Array()
for (vertex in this.round.tief) {
let tief_pos = this.round.tief[vertex]
// iterate edges
for (edge in this.graph[tief_pos].siblings) {
let sibbling = this.graph[tief_pos].siblings[edge]
if (this.round.police.includes(sibbling.vertex)) {
console.log("skip vertex, police there")
} else if (sibbling.edge == this.round.transport) {
tief.push(sibbling.vertex)
} else if (this.round.transport == 'hidden') {
tief.push(sibbling.vertex)
}
}
}
this.round.police = new Array(this.police_players).fill(0);
this.round.transport = null
this.round.tief.push(4)
this.round.tief = new Set(tief)
},
listPossibleTransports(round) {
let values = []