Skip to content

Commit 368e79e

Browse files
committed
disable cache to build
1 parent e0ba39a commit 368e79e

File tree

15 files changed

+151
-75
lines changed

15 files changed

+151
-75
lines changed
Lines changed: 49 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,56 @@
1-
import { Command } from '@colyseus/command'
2-
import { Player } from '../rooms/schema/entities/PlayerState'
3-
import { CountryRoom } from '../rooms/CountryRoom'
4-
import { Client } from 'colyseus'
5-
import { ScoreBoard } from '../rooms/schema/entities/ScoreBoardState'
6-
import { ConnectOptions } from '../constants/clients'
1+
import {Command} from '@colyseus/command'
2+
import {Player} from '../rooms/schema/entities/PlayerState'
3+
import {CountryRoom} from '../rooms/CountryRoom'
4+
import {Client} from 'colyseus'
5+
import {ScoreBoard} from '../rooms/schema/entities/ScoreBoardState'
6+
import {ConnectOptions} from '../constants/clients'
7+
import {randomUUID} from "crypto";
78

89
export class OnJoinCommand extends Command<
9-
CountryRoom,
10-
{
11-
client: Client
12-
options: ConnectOptions
13-
}
14-
> {
15-
execute({ client, options }) {
16-
if (
17-
!this.state.creatorId ||
18-
!this.state.players.get(this.state.creatorId)
19-
) {
20-
this.state.creatorId = client.sessionId
10+
CountryRoom,
11+
{
12+
client: Client
13+
options: ConnectOptions
2114
}
15+
> {
16+
execute({client, options}) {
17+
if (
18+
!this.state.creatorId ||
19+
!this.state.players.get(this.state.creatorId) ||
20+
!this.state.players.get(this.state.creatorId).connected
21+
) {
22+
this.state.creatorId = client.sessionId
23+
}
2224

23-
const player = new Player()
24-
player.username = options.username
25-
player.sessionId = client.sessionId
26-
player.connected = true
27-
player.pin = parseInt(options.pin) || 1
28-
this.state.players.set(client.sessionId, player)
25+
// check if player already has a valid session
26+
let isExistingUser = false;
27+
this.state.players.forEach((player) => {
28+
if (player.sessionId === client.sessionId){
29+
isExistingUser = true;
30+
}
31+
})
2932

30-
const scoreboard = new ScoreBoard()
31-
scoreboard.sessionId = client.sessionId
32-
scoreboard.points = 0
33-
if (this.state.scoreboard.has(client.sessionId)) {
34-
scoreboard.points = this.state.scoreboard.get(client.sessionId).points
35-
}
33+
if (isExistingUser){
34+
return;
35+
}
36+
37+
console.log(client.sessionId, '/', options.username, ' has joined');
3638

37-
this.state.scoreboard.set(client.sessionId, scoreboard)
38-
}
39+
const player = new Player()
40+
player.username = options.username
41+
player.sessionId = client.sessionId
42+
player.key = randomUUID();
43+
player.connected = true
44+
player.pin = parseInt(options.pin) || 1
45+
this.state.players.set(client.sessionId, player)
46+
47+
const scoreboard = new ScoreBoard()
48+
scoreboard.sessionId = client.sessionId
49+
scoreboard.points = 0
50+
if (this.state.scoreboard.has(client.sessionId)) {
51+
scoreboard.points = this.state.scoreboard.get(client.sessionId).points
52+
}
53+
54+
this.state.scoreboard.set(client.sessionId, scoreboard)
55+
}
3956
}

packages/api/src/commands/OnLeaveCommand.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,27 @@ export class OnLeaveCommand extends Command<
2020
this.state.players.get(client.sessionId).connected = false
2121

2222
try {
23+
if (consented){
24+
throw new Error("consented");
25+
}
26+
2327
await this.room.allowReconnection(client, ALLOW_RECONNECTION_FOR_SECONDS)
28+
console.log(client.sessionId, ' has returned');
2429
this.state.players.get(client.sessionId).connected = true
2530
} catch (e) {
31+
console.log(client.sessionId, ' has left');
32+
2633
this.state.players.delete(client.sessionId)
34+
if (
35+
this.state.creatorId && client.sessionId
36+
) {
37+
console.log("Was room owner, changing room owner to next user");
38+
this.state.players.forEach((p) => {
39+
if (this.state.creatorId == client.sessionId){
40+
this.state.creatorId = p.sessionId;
41+
}
42+
})
43+
}
2744
}
2845
}
2946
}

packages/api/src/commands/OnScoreboardCommand.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export class OnScoreboardCommand extends Command<CountryRoom, {}> {
3434
)
3535
this.room.dispatcher.dispatch(new OnPrepareRoundCommand())
3636
},
37-
this.state.room === 'speedrun' ? 4000 : 12000
37+
this.state.room === 'speedrun' ? 4000 : 10000
3838
)
3939
}
4040
}

packages/api/src/rooms/schema/entities/PlayerState.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ export class Player extends Schema {
44
@type('string') username: string
55
@type('string') sessionId: string
66
@type('number') pin: number
7+
@type('string') key: string;
78
@type('boolean') connected: boolean
89
}

packages/web/assets/globals.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@
33
--animate-delay: 0.3s;
44
}
55

6+
* {
7+
overscroll-behavior: none;
8+
}
9+
610
body {
11+
712
touch-action: pan-x pan-y;
813
}
914

packages/web/components/dialog.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Dialog extends Vue {
4242
}
4343
4444
.dialog {
45-
@apply absolute left-1/2 w-20 z-10 p-5 rounded shadow-2xl lg:mt-20;
45+
@apply absolute left-1/2 w-20 z-10 p-2 md:p-5 rounded shadow-2xl lg:mt-20;
4646
@apply flex content-center justify-center text-gray-700 flex-col;
4747
font-family: 'Luckiest Guy';
4848
top: 20px;

packages/web/components/dialogs/multiplayer-score-board-dialog.vue

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<Dialog classes="bg-white dark:bg-gray-800" class="scoreboard-dialog">
2+
<Dialog classes="bg-white dark:bg-gray-800 " class="scoreboard-dialog">
33
<div class="flex mb-10 justify-between items-center">
44
<div class="flex items-center pin-title mb-0">
55
<Flag
@@ -14,7 +14,7 @@
1414
"
1515
/>
1616
<div style="">
17-
<span class="text-2xl flex-col sm:flex-row dark:text-gray-100">
17+
<span class="text-xl md:text-2xl flex-col sm:flex-row dark:text-gray-100">
1818
<span class="" v-if="room.country.translations[$i18n.locale]">{{
1919
room.country.translations[$i18n.locale].country
2020
}}</span>
@@ -28,7 +28,7 @@
2828
}}
2929
</span>
3030
</span>
31-
<div class="text-gray-500 dark:text-gray-300">
31+
<div class="text-sm md:text-base text-gray-500 dark:text-gray-300">
3232
👥 {{ formatNumber(room.country.population, 1) }}
3333
{{ $t('t.citizen') }} &mdash; 📍
3434
{{ $t(`subregion.${room.country.subregion}`) }}
@@ -48,12 +48,13 @@
4848
<template v-else>
4949
<div v-if="showScore">
5050
<div
51-
:class="`flex items-center justify-between pin mp-pin align-middle mb-1 border-dashed border-b-2 border-gray-300 py-3 px-1`"
51+
:class="`flex items-center justify-between pin mp-pin align-middle mb-1 border-dashed border-b-2 border-gray-300 py-1 md:py-3 px-1`"
5252
v-for="player in sortedPlayers"
5353
>
5454
<div class="flex items-center">
55-
<Pin :id="player.pin" width="32" style="min-width: 32px"/>
55+
<Pin :id="player.pin" width="32" style="min-width: 32px; position: relative; left: -8px"/>
5656
<h4 :class="`pr-3 dark:text-gray-300`">{{ player.username }}</h4>
57+
5758
</div>
5859
<h4 class="dark:text-gray-300 flex">
5960
<h4
@@ -83,10 +84,22 @@
8384
"
8485
>
8586
<div class="flex items-center">
86-
<Pin :id="vote.player.pin" width="32" style="min-width: 32px"/>
87+
88+
<Pin :id="vote.player.pin" width="32" style="min-width: 32px; position: relative; left: -8px" />
8789
<h4 class="dark:text-gray-300">{{ vote.player.username }}</h4>
90+
<span class="pl-3 flex md:hidden text-gray-600 dark:text-gray-300">(<ICountUp
91+
class="flex md:hidden"
92+
v-if="
93+
(!vote.country || vote.country.id !== room.country.id) &&
94+
vote.distance > 0 &&
95+
animateLine
96+
"
97+
:endVal="vote.distance"
98+
:options="countupOptions"
99+
/>)
100+
</span>
88101
</div>
89-
<div class="w-full max-w-[40vw] md:max-w-full">
102+
<div class="w-full hidden md:flex md:max-w-full">
90103
<div
91104
:class="[
92105
'sm:flex',
@@ -322,4 +335,13 @@ h2 {
322335
min-width: 64px !important;
323336
min-height: 46px !important;
324337
}
338+
339+
@media (max-width: 768px){
340+
.scoreboard-dialog .flag img {
341+
width: 42px !important;
342+
min-width: 42px !important;
343+
height: 32px !important;
344+
min-height: 32px !important;
345+
}
346+
}
325347
</style>

packages/web/components/game/GameMap.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,6 @@ export default class GameMap extends Vue {
159159
}
160160
161161
getMidpointLatLng(coords) {
162-
console.log(coords, this.room)
163162
if (!this.room) {
164163
return []
165164
}

packages/web/components/lobby-players.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
<li
55
class="flex items-center justify-between"
66
v-for="player in room.players"
7+
:key="player.key"
78
>
89
<div class="flex items-center">
910
<Pin :id="player.pin" width="48" style="min-width: 48px" />

packages/web/components/open-room-settings-view.vue

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ export default class OpengameSettingsView extends Vue {
5555
name: 'countries',
5656
image: require('~/assets/gamemodes/countries.svg?raw'),
5757
},
58+
{
59+
name: 'party',
60+
image: require('~/assets/gamemodes/party.svg?raw'),
61+
},
5862
{
5963
name: 'capitals',
6064
image: require('~/assets/gamemodes/capitals.svg?raw'),

0 commit comments

Comments
 (0)