3838 :disabled =" size < 2"
3939 @click =" size--"
4040 >
41- <v-icon dark >
42- mdi-arrow-bottom-left
43- </v-icon >
41+ <v-icon dark > mdi-arrow-bottom-left </v-icon >
4442 </v-btn >
4543
4644 <v-btn
5048 :disabled =" size > 3"
5149 @click =" size++"
5250 >
53- <v-icon dark >
54- mdi-arrow-top-right
55- </v-icon >
51+ <v-icon dark > mdi-arrow-top-right </v-icon >
5652 </v-btn >
5753
58- <v-btn
59- id =" btnPin"
60- fab
61- x-small
62- @click =" pinActive = !pinActive"
63- >
64- <v-icon dark >
65- mdi-pin{{ pinActive ? '-off' : '' }}
66- </v-icon >
54+ <v-btn id =" btnPin" fab x-small @click =" pinActive = !pinActive" >
55+ <v-icon dark > mdi-pin{{ pinActive ? '-off' : '' }} </v-icon >
6756 </v-btn >
6857 </div >
6958 </div >
7968 color =" red"
8069 @click =" hideMap"
8170 >
82- <v-icon color =" white" >
83- mdi-close
84- </v-icon >
71+ <v-icon color =" white" > mdi-close </v-icon >
8572 </v-btn >
8673 <Map
8774 v-if =" this.mode === 'classic'"
@@ -184,7 +171,7 @@ import DetailsMap from '@/components/game/DetailsMap';
184171import Map from ' @/components/map/Map' ;
185172import MapCountries from ' @/components/map/MapCountries' ;
186173import { GAME_MODE } from ' ../constants' ;
187- import { getSelectedPos } from ' ../utils' ;
174+ import { getScore , getSelectedPos } from ' ../utils' ;
188175
189176export default {
190177 components: {
@@ -211,6 +198,7 @@ export default {
211198 ' timeAttack' ,
212199 ' nbRound' ,
213200 ' countdown' ,
201+ ' scoreMode' ,
214202 ],
215203 data () {
216204 return {
@@ -236,6 +224,7 @@ export default {
236224 date: new Date (),
237225 rounds: [],
238226 },
227+ startTime: null ,
239228 };
240229 },
241230 computed: {
@@ -257,6 +246,7 @@ export default {
257246 this .game .difficulty = this .difficulty ;
258247 this .game .mode = this .mode ;
259248 this .game .timeAttack = this .timeAttack ;
249+ this .game .playerName = this .playerName ;
260250
261251 if (this .roomName ) {
262252 this .room = firebase .database ().ref (this .roomName );
@@ -317,11 +307,12 @@ export default {
317307 j
318308 )
319309 .exportVal ();
310+
320311 const { points , distance } = roundValues;
312+
321313 players[playerName] = {
314+ ... roundValues,
322315 guess: posGuess,
323- distance,
324- points,
325316 };
326317 this .$refs .map .drawPolyline (
327318 posGuess,
@@ -483,30 +474,24 @@ export default {
483474 this .$emit (' resetLocation' );
484475 },
485476 calculateDistance () {
477+ const timePassed = new Date () - this .startTime ;
486478 if (this .mode === GAME_MODE .COUNTRY ) {
487479 this .point = + (this .country === this .selectedPos );
488- this .$emit ( ' calculateDistance ' , null , this . point ) ;
480+ this .distance = null ;
489481 } else {
490482 this .distance = Math .floor (
491483 google .maps .geometry .spherical .computeDistanceBetween (
492484 this .randomLatLng ,
493485 this .selectedPos
494486 )
495487 );
496- if (this .distance < 50 ) {
497- this .point = 5000 ;
498- } else {
499- this .point = Math .round (
500- 5000 *
501- Math .exp (- (this .distance / 1000 / this .difficulty ))
502- );
503-
504- if (this .point > 5000 ) {
505- this .point = 5000 ;
506- } else if (this .point < 0 ) {
507- this .point = 0 ;
508- }
509- }
488+
489+ this .point = getScore (
490+ this .distance ,
491+ this .difficulty ,
492+ timePassed,
493+ this .scoreMode
494+ );
510495 }
511496 // Save the distance into firebase
512497 if (this .room ) {
@@ -516,6 +501,7 @@ export default {
516501 ... getSelectedPos (this .selectedPos , this .mode ),
517502 distance: this .distance ,
518503 points: this .point ,
504+ timePassed,
519505 });
520506 } else {
521507 this .game .rounds .push ({
@@ -524,13 +510,15 @@ export default {
524510 position: this .randomLatLng ,
525511 distance: this .distance ,
526512 points: this .point ,
513+ timePassed,
527514 });
528515 }
529516
530517 this .$emit (' calculateDistance' , this .distance , this .point );
531518 },
532519 startNextRound () {
533520 this .$refs .map .startNextRound ();
521+ this .startTime = new Date ();
534522 },
535523 goToNextRound (isPlayAgain = false ) {
536524 if (isPlayAgain) {
0 commit comments