Skip to content

Commit

Permalink
Feature/#188 state mode (#194)
Browse files Browse the repository at this point in the history
* feat(#188): init AreaPicker

* feat: init France Région Mode

* feat: add mode continent

* feat: filter area mode

* Home Card

* refacto: init store settting

* feat: HomeCard Area

* fix: lint

* feat: JSON areas modes

* fixs

* fix: analytics ignore if not activated

* askip ça marche

* add: time attack

* fix: home sliders

* fixs: timeAtack Countdown ,...

* test

* fix: tests

* fix: warning deep

* fix: ci

* add: tests

* fix: url room openDIalog

* fix: lock

* feat: add tests

* feat: history Area

* fix: lint

* Delete TODO
  • Loading branch information
BilelJegham authored Jun 30, 2021
1 parent d69f381 commit fe17ff3
Show file tree
Hide file tree
Showing 64 changed files with 2,434 additions and 4,094 deletions.
9 changes: 6 additions & 3 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@ module.exports = {
es6: true,
},
extends: [
'eslint:recommended',
...(process.env.NODE_ENV === 'production'
? ['eslint:recommended']
: []),
'plugin:vue/essential',
],
globals: {
Expand All @@ -20,9 +22,10 @@ module.exports = {
},
plugins: ['vue', 'prettier'],
rules: {
'no-console': 'warn',
'no-console': process.env.NODE_ENV === 'production' ? 'error' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'error' : 'off',
semi: ['error', 'always'],
"vue/html-indent": ['warn', 4]
'vue/html-indent': ['warn', 4],
},
overrides: [
{
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ jobs:
run: npm ci

- name: Linter
run: npm run lint -- --no-fix
run: NODE_ENV=production npm run lint -- --no-fix

- name: Run unit tests
run: npm run test:unit
Expand Down
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module.exports = {
collectCoverage: true,
collectCoverageFrom: [
'src/**/*.{js,vue}',
'src/utils.js',
'src/utils/*',
'!**/node_modules/**',
'!src/plugins/*',
'!src/lang/*',
Expand Down
3,610 changes: 866 additions & 2,744 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"@vue/test-utils": "^1.1.2",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.2.2",
"cypress": "^7.2.0",
"cypress": "^7.6.0",
"eslint": "^5.16.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-cypress": "^2.11.2",
Expand Down
2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<meta name="msapplication-TileColor" content="#ffffff">
<meta name="msapplication-TileImage" content="<%= BASE_URL %>img/icons/ms-icon-144x144.png">
<title>GeoGuess</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@4.9.95/css/materialdesignicons.min.css">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@5.9.55/css/materialdesignicons.min.css">
<link href="https://fonts.googleapis.com/css2?family=Roboto&display=swap" rel="stylesheet">
<style>
html{
Expand Down
6 changes: 5 additions & 1 deletion src/components/HeaderGame.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@
</div>
<div v-if="isDistanceVisible">
<span class="main-text">{{
$t('HeaderGame.kmaway', { value: new Intl.NumberFormat($i18n.locale).format(distance / 1000) })
$t('HeaderGame.kmaway', {
value: new Intl.NumberFormat($i18n.locale).format(
distance / 1000
),
})
}}</span>
</div>
<div class="round-points-container">
Expand Down
48 changes: 25 additions & 23 deletions src/components/Maps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,15 @@
:bbox="bbox"
@setSeletedPos="setSeletedPos"
/>
<MapCountries
v-if="this.mode === 'country'"
<MapAreas
v-if="this.mode !== 'classic'"
id="map"
ref="map"
:country="country"
:area="area"
:areasGeoJsonUrl="areasGeoJsonUrl"
:pathKey="pathKey"
:bbox="bbox"
:showFlag="this.mode === 'country'"
@setSeletedPos="setSeletedPos"
/>
<textarea class="container-map_notepad" v-show="isNotepadVisible" spellcheck="false" v-if="!printMapFull" ref="refNotepad"/>
Expand Down Expand Up @@ -180,16 +183,17 @@ import 'firebase/database';
import DialogSummary from '@/components/DialogSummary';
import DetailsMap from '@/components/game/DetailsMap';
import Map from '@/components/map/Map';
import MapCountries from '@/components/map/MapCountries';
import MapAreas from '@/components/map/MapAreas';
import { GAME_MODE } from '../constants';
import { getScore, getSelectedPos } from '../utils';
import { getSelectedPos } from '../utils';
import { getScore } from '../utils/game/score';
export default {
components: {
DialogSummary,
DetailsMap,
Map,
MapCountries,
MapAreas,
},
props: [
'randomLatLng',
Expand All @@ -205,11 +209,13 @@ export default {
'difficulty',
'bbox',
'mode',
'country',
'area',
'timeAttack',
'nbRound',
'countdown',
'scoreMode',
'areasGeoJsonUrl',
'pathKey',
],
data() {
return {
Expand Down Expand Up @@ -274,8 +280,7 @@ export default {
.child('guess')
.forEach(
(guess) =>
guess.child('country').val() ===
this.country
guess.child('area').val() === this.area
)) ||
// Allow players to move on to the next round when every players guess locations
snapshot.child('guess').numChildren() ===
Expand Down Expand Up @@ -304,20 +309,15 @@ export default {
lng: lng,
});
} else {
posGuess = childSnapshot.child('country').val();
posGuess = childSnapshot.child('area').val();
}
const playerName = snapshot
.child('playerName')
.child(childSnapshot.key)
.val();
const roundValues = snapshot
.child(
'round' +
this.round +
'/player' +
j
)
.child('round' + this.round + '/player' + j)
.exportVal();
const { points, distance } = roundValues;
Expand Down Expand Up @@ -352,7 +352,7 @@ export default {
this.game.rounds.push({
position: {
...this.randomLatLng.toJSON(),
country: this.country,
area: this.area,
},
players,
});
Expand Down Expand Up @@ -462,8 +462,8 @@ export default {
false,
this.setSeletedPos
);
this.$refs.map.fitBounds();
this.printMapFull = true;
this.$refs.map.fitBounds();
if (this.round >= this.nbRound) {
this.isSummaryButtonVisible = true;
} else {
Expand Down Expand Up @@ -495,8 +495,10 @@ export default {
},
calculateDistance() {
const timePassed = new Date() - this.startTime;
if (this.mode === GAME_MODE.COUNTRY) {
this.point = +(this.country === this.selectedPos);
if (
[GAME_MODE.COUNTRY, GAME_MODE.CUSTOM_AREA].includes(this.mode)
) {
this.point = +(this.area === this.selectedPos);
this.distance = null;
} else {
this.distance = Math.floor(
Expand Down Expand Up @@ -526,7 +528,7 @@ export default {
} else {
this.game.rounds.push({
guess: this.selectedPos,
country: this.country,
area: this.area,
position: this.randomLatLng,
distance: this.distance,
points: this.point,
Expand Down Expand Up @@ -625,8 +627,8 @@ export default {
&.container-map--full {
transition: none;
opacity: 1;
--active-width: 65vw;
--inactive-width: 65vw;
--active-width: 85vw;
--inactive-width: 85vw;
position: relative;
margin: auto;
.container-map_controls {
Expand Down
Loading

0 comments on commit fe17ff3

Please sign in to comment.