police fix
This commit is contained in:
parent
5abd24b102
commit
89b029df9a
32
game.html
32
game.html
@ -15,13 +15,11 @@
|
||||
<form v-on:submit.prevent="gameStart" name="form_start">
|
||||
<p>
|
||||
Number of players
|
||||
<input name="police_players" type="number" min="3" max="6" required
|
||||
placeholder="how many players do we have ?" v-model="police_players">
|
||||
<input name="police_players" type="number" min="3" max="6" required v-model="police_players">
|
||||
</p>
|
||||
<p>
|
||||
Position of the tief
|
||||
<input name="tief_posistion" type="number" min="1" max="199" required placeholder="tief position"
|
||||
v-model="tief_position_start">
|
||||
<input name="tief_posistion" type="number" min="1" max="199" required v-model="tief_start">
|
||||
</p>
|
||||
<button type="submit" v-bind:disabled="isGameStarted == true">Start the hunting</button>
|
||||
</form>
|
||||
@ -40,7 +38,7 @@
|
||||
Tief:
|
||||
<span v-for="pos in round.tief">{{ pos }}</span>
|
||||
Police:
|
||||
<input v-for="pos in police_players" 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:
|
||||
<select v-model="round.transport" name="transport" required>
|
||||
<option disabled value="">Please select one</option>
|
||||
@ -59,7 +57,7 @@
|
||||
data() {
|
||||
return {
|
||||
police_players: 3,
|
||||
tief_position_start: null,
|
||||
tief_start: 0,
|
||||
rounds: [],
|
||||
round: {
|
||||
tief: null,
|
||||
@ -69,28 +67,26 @@
|
||||
graph: null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
gameStart(e) {
|
||||
axios.get("data/graph.json")
|
||||
mounted() {
|
||||
axios.get("data/graph.json")
|
||||
.then(response => { this.graph = response.data })
|
||||
.catch(err => console.log("Axios err: ", err))
|
||||
this.round.tief = [this.tief_position_start];
|
||||
this.round.police = new Array(this.police_players);
|
||||
},
|
||||
methods: {
|
||||
gameStart(e) {
|
||||
console.log(this.tief_start)
|
||||
this.round.police = new Array(this.police_players).fill(0);
|
||||
this.round.transport = null;
|
||||
this.round.tief = [this.tief_start];
|
||||
},
|
||||
gameRound(e) {
|
||||
let police = new Array(this.police_players)
|
||||
for (i in e.target.elements.police) {
|
||||
police.push(e.target.elements.police[i].value)
|
||||
e.target.elements.police[i].value = null
|
||||
}
|
||||
this.rounds.push({
|
||||
'tief': this.round.tief.slice(),
|
||||
'transport': this.round.transport,
|
||||
'police': police
|
||||
'police': this.round.police.slice(),
|
||||
})
|
||||
// clear values
|
||||
this.round.police = null
|
||||
this.round.police = new Array(this.police_players).fill(0);
|
||||
this.round.transport = null
|
||||
this.round.tief.push(4)
|
||||
},
|
||||
|
Loading…
x
Reference in New Issue
Block a user