Skip to content

Commit dc36c68

Browse files
authored
Merge pull request #123 from GeoGuess/feature/106-coutdown
feature: countdown #106
2 parents 736d08c + b31ba32 commit dc36c68

8 files changed

Lines changed: 259 additions & 76 deletions

File tree

.github/workflows/ci.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ jobs:
8989
wait-on: 'http://localhost:8080'
9090
record: true
9191
parallel: true
92-
config_file: cypress.json
9392
group: ${{matrix.browsers}}
9493
tag: ${{ github.event_name }}
9594
browser: ${{matrix.browsers}}

src/components/Maps.vue

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ export default {
191191
'country',
192192
'timeAttack',
193193
'nbRound',
194+
'countdown',
194195
],
195196
components: {
196197
DialogSummary,
@@ -216,6 +217,7 @@ export default {
216217
size: 2,
217218
pinActive: false,
218219
printMapFull: false,
220+
countdownStarted: false,
219221
game: {
220222
multiplayer: !!this.roomName,
221223
date: new Date(),
@@ -362,6 +364,7 @@ export default {
362364
this.isGuessButtonClicked = false;
363365
this.isSelected = false;
364366
this.isNextButtonVisible = false;
367+
this.countdownStarted = false;
365368
366369
if (this.$viewport.width < 450) {
367370
// Hide the map if the player is on mobile
@@ -396,9 +399,10 @@ export default {
396399
this.room.on('value', (snapshot) => {
397400
// Check if the room is already removed
398401
if (snapshot.hasChild('active')) {
399-
// Allow players to move on to the next round when every players guess locations
400402
if (
403+
// If Time Attack and 1st true guess finish round
401404
(this.timeAttack &&
405+
this.countdown === 0 &&
402406
snapshot.child('guess').numChildren() >= 1 &&
403407
snapshot
404408
.child('guess')
@@ -407,6 +411,7 @@ export default {
407411
guess.child('country').val() ===
408412
this.country
409413
)) ||
414+
// Allow players to move on to the next round when every players guess locations
410415
snapshot.child('guess').numChildren() ===
411416
snapshot.child('size').val()
412417
) {
@@ -540,6 +545,17 @@ export default {
540545
) {
541546
this.isNextStreetViewReady = true;
542547
}
548+
549+
if (
550+
!this.countdownStarted &&
551+
!this.printMapFull &&
552+
this.countdown > 0 &&
553+
snapshot.child('guess').numChildren() >= 1
554+
) {
555+
this.$parent.initTimer(this.countdown, true);
556+
557+
this.countdownStarted = true;
558+
}
543559
}
544560
});
545561
}

src/components/dialogroom/DialogRoom.vue

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ export default {
8181
zoomControl: true,
8282
moveControl: true,
8383
panControl: true,
84+
countdown: 0,
8485
};
8586
},
8687
computed: {
@@ -237,7 +238,8 @@ export default {
237238
timeAttack,
238239
zoomControl,
239240
moveControl,
240-
panControl
241+
panControl,
242+
countdown
241243
) {
242244
this.timeLimitation = timeLimitation;
243245
this.roomSize = roomSize;
@@ -246,6 +248,7 @@ export default {
246248
this.zoomControl = zoomControl;
247249
this.moveControl = moveControl;
248250
this.panControl = panControl;
251+
this.countdown = countdown;
249252
if (this.singlePlayer) {
250253
this.$router.push({
251254
name: 'street-view',
@@ -272,6 +275,7 @@ export default {
272275
zoomControl,
273276
moveControl,
274277
panControl,
278+
countdown,
275279
},
276280
(error) => {
277281
if (!error) {
@@ -311,6 +315,7 @@ export default {
311315
zoomControl: this.zoomControl,
312316
moveControl: this.moveControl,
313317
panControl: this.panControl,
318+
countdown: this.countdown,
314319
};
315320
this.startGameMultiplayer(playerName, gameParams);
316321
} else {
@@ -333,6 +338,9 @@ export default {
333338
panControl: snapshot
334339
.child('panControl')
335340
.val(),
341+
countdown: snapshot
342+
.child('countdown')
343+
.val(),
336344
};
337345
this.startGameMultiplayer(
338346
playerName,

src/components/dialogroom/card/CardRoomSettings.vue

Lines changed: 74 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -57,50 +57,81 @@
5757
<TimePicker v-model="timeLimitation" />
5858
</v-row>
5959

60-
<v-row align="center" class="card_settings__allow_btns">
61-
<v-checkbox
62-
v-model="zoomControl"
63-
:label="$t('CardRoomSettings.allowZoom')"
64-
hide-details
65-
>
66-
</v-checkbox>
67-
<v-checkbox
68-
v-model="moveControl"
69-
:label="$t('CardRoomSettings.allowMove')"
70-
hide-details
71-
>
72-
</v-checkbox>
73-
<v-checkbox
74-
v-model="panControl"
75-
:label="$t('CardRoomSettings.allowPan')"
76-
hide-details
77-
>
78-
</v-checkbox>
79-
</v-row>
8060
<v-row
81-
v-if="this.mode === gameMode.COUNTRY && !singlePlayer"
8261
align="center"
62+
class="card_settings__allow_btns d-flex justify-space-around flex-row"
8363
>
84-
<v-checkbox
85-
v-model="timeAttack"
86-
:label="$t('CardRoomSettings.timeAttackLabel')"
87-
>
88-
</v-checkbox>
89-
<v-tooltip
90-
top
91-
max-width="350"
92-
class="tooltip-timeattack"
93-
>
94-
<template v-slot:activator="{ on, attrs }">
95-
<v-btn icon v-bind="attrs" v-on="on">
96-
<v-icon> mdi-information</v-icon>
97-
</v-btn>
98-
</template>
99-
<span>{{
100-
$t('CardRoomSettings.timeattackInfos')
101-
}}</span>
102-
</v-tooltip>
64+
<div>
65+
<v-checkbox
66+
v-model="zoomControl"
67+
:label="$t('CardRoomSettings.allowZoom')"
68+
hide-details
69+
>
70+
</v-checkbox>
71+
<v-checkbox
72+
v-model="moveControl"
73+
:label="$t('CardRoomSettings.allowMove')"
74+
hide-details
75+
>
76+
</v-checkbox>
77+
<v-checkbox
78+
v-model="panControl"
79+
:label="$t('CardRoomSettings.allowPan')"
80+
hide-details
81+
>
82+
</v-checkbox>
83+
</div>
84+
<div>
85+
<v-text-field
86+
v-if="!singlePlayer"
87+
v-model="countdown"
88+
hide-details
89+
label="CountDown (seconds)"
90+
type="number"
91+
></v-text-field>
92+
<div
93+
v-if="
94+
this.mode === gameMode.COUNTRY &&
95+
!singlePlayer
96+
"
97+
>
98+
<v-checkbox v-model="timeAttack" hide-details>
99+
<template #label>
100+
{{
101+
$t(
102+
'CardRoomSettings.timeAttackLabel'
103+
)
104+
}}
105+
<v-tooltip
106+
top
107+
max-width="350"
108+
class="tooltip-timeattack"
109+
>
110+
<template
111+
v-slot:activator="{ on, attrs }"
112+
>
113+
<v-btn
114+
icon
115+
v-bind="attrs"
116+
v-on="on"
117+
>
118+
<v-icon>
119+
mdi-information</v-icon
120+
>
121+
</v-btn>
122+
</template>
123+
<span>{{
124+
$t(
125+
'CardRoomSettings.timeattackInfos'
126+
)
127+
}}</span>
128+
</v-tooltip>
129+
</template>
130+
</v-checkbox>
131+
</div>
132+
</div>
103133
</v-row>
134+
<v-row align="center"> </v-row>
104135
</v-col>
105136
<v-col
106137
v-bind:class="{
@@ -165,6 +196,7 @@ export default {
165196
zoomControl: true,
166197
moveControl: true,
167198
panControl: true,
199+
countdown: 0,
168200
};
169201
},
170202
computed: {
@@ -212,7 +244,8 @@ export default {
212244
this.timeAttack,
213245
this.zoomControl,
214246
this.moveControl,
215-
this.panControl
247+
this.panControl,
248+
+this.countdown
216249
);
217250
}
218251
},

src/lang/locale/en.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@
3333
"redirectToHomePage":"Redirect to Home Page...",
3434
"exitGame":"You are forced to exit the game. Redirect to home page after 5 seconds...",
3535
"waitForOtherPlayersToFinish":"Waiting for other players to finish the game...",
36-
"confirmExit": "Are you sure to leave the current game? This will abort the game!"
36+
"confirmExit": "Are you sure to leave the current game? This will abort the game!",
37+
"countdownAlert": "Countdown started : {count} seconde remaining | Countdown started : {count} secondes remaining"
3738
},
3839
"Maps":{
3940
"makeGuess":"MAKE GUESS",

0 commit comments

Comments
 (0)