1
1
<template >
2
2
<div class =" w-full" >
3
- <div class =" flex items-center justify-center h-full" v-if =" !isMatchRunning" >
3
+ <div class =" flex items-center justify-center h-128" style =" height : 50% " v-if =" starting" >
4
+ <Loading />
5
+ </div >
6
+ <div class =" flex items-center justify-center h-full" v-else-if =" !isMatchRunning" >
4
7
<button class =" button" @click =" startTestGame()" >
5
8
{{ $t("laboratory.start-test-game") }}
6
9
</button >
@@ -19,10 +22,12 @@ import currUser from '../lib/User';
19
22
import Game from ' ../game/Game.vue' ;
20
23
import RoomConnection from ' ../lib/RoomConnection' ;
21
24
import StopStatsModal , { StopStatsInterface } from ' ./StopStatsModal.vue' ;
25
+ import Loading from ' ./Loading.vue' ;
22
26
23
27
@Component ({
24
28
components: {
25
29
Game ,
30
+ Loading ,
26
31
StopStatsModal ,
27
32
},
28
33
props: {
@@ -33,6 +38,7 @@ import StopStatsModal, { StopStatsInterface } from './StopStatsModal.vue';
33
38
const isMatchRunning = ref (false );
34
39
const roomConn = new RoomConnection (currUserId as string );
35
40
const stopStats = ref <StopStatsInterface | null >();
41
+ const starting = ref (false );
36
42
37
43
const handleMessage = (type : WsMessageType , payload : any ) => {
38
44
switch (type ) {
@@ -62,6 +68,8 @@ import StopStatsModal, { StopStatsInterface } from './StopStatsModal.vue';
62
68
};
63
69
}),
64
70
};
71
+ } else {
72
+ starting .value = false ;
65
73
}
66
74
break ;
67
75
}
@@ -76,26 +84,29 @@ import StopStatsModal, { StopStatsInterface } from './StopStatsModal.vue';
76
84
onUnmounted (() => roomConn .disconnect ());
77
85
78
86
const startTestGame = async () => {
87
+ starting .value = true ;
88
+
79
89
await props .onStart ();
80
90
if (! roomConn .ws ) {
81
91
await roomConn .connect ();
82
- await new Promise ((resolve ) => setTimeout (resolve , 50 ));
92
+ await new Promise ((resolve ) => setTimeout (resolve , 300 ));
83
93
}
84
94
await roomConn .send (WsMessageType .GAME_JOIN );
85
- await new Promise ((resolve ) => setTimeout (resolve , 50 ));
95
+ await new Promise ((resolve ) => setTimeout (resolve , 300 ));
86
96
await roomConn .send (WsMessageType .GAME_ACCEPT );
87
97
};
88
98
89
99
return {
90
100
currUserId ,
91
101
isMatchRunning ,
92
102
roomConn ,
103
+ starting ,
93
104
startTestGame ,
94
105
stopStats ,
95
106
};
96
107
},
97
108
})
98
- export default class SinglePlayer extends Vue {}
109
+ export default class SinglePlayer extends Vue { }
99
110
</script >
100
111
101
112
<style lang="postcss">
0 commit comments