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