added game logic
This commit is contained in:
parent
89b029df9a
commit
a80f2f841c
24
game.html
24
game.html
@ -27,16 +27,16 @@
|
|||||||
|
|
||||||
<div v-show="isGameStarted" v-for="r in rounds">
|
<div v-show="isGameStarted" v-for="r in rounds">
|
||||||
Tief:
|
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:
|
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:
|
Transport:
|
||||||
<span>{{ r.transport }}</span>
|
<span>{{ r.transport }}</span>
|
||||||
</div>
|
</div>
|
||||||
<div v-show="isGameStarted">
|
<div v-show="isGameStarted">
|
||||||
<form v-on:submit.prevent="gameRound" name="form_move">
|
<form v-on:submit.prevent="gameRound" name="form_move">
|
||||||
Tief:
|
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:
|
Police:
|
||||||
<input v-for="(police, index) in round.police" v-model="round.police[index]" type="number" min="1" max="199" required name="police">
|
<input v-for="(police, index) in round.police" v-model="round.police[index]" type="number" min="1" max="199" required name="police">
|
||||||
Transport:
|
Transport:
|
||||||
@ -86,9 +86,25 @@
|
|||||||
'police': this.round.police.slice(),
|
'police': this.round.police.slice(),
|
||||||
})
|
})
|
||||||
// clear values
|
// 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.police = new Array(this.police_players).fill(0);
|
||||||
this.round.transport = null
|
this.round.transport = null
|
||||||
this.round.tief.push(4)
|
this.round.tief = new Set(tief)
|
||||||
},
|
},
|
||||||
listPossibleTransports(round) {
|
listPossibleTransports(round) {
|
||||||
let values = []
|
let values = []
|
||||||
|
Loading…
x
Reference in New Issue
Block a user