Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
T
Taiko Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
nanahira
Taiko Web
Commits
749e6570
Commit
749e6570
authored
Sep 15, 2018
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add balloon and drumroll notes
parent
1d0fc883
Changes
13
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
1227 additions
and
1225 deletions
+1227
-1225
public/src/css/scoresheet.css
public/src/css/scoresheet.css
+95
-59
public/src/js/assets.js
public/src/js/assets.js
+3
-1
public/src/js/circle.js
public/src/js/circle.js
+79
-93
public/src/js/controller.js
public/src/js/controller.js
+23
-45
public/src/js/game.js
public/src/js/game.js
+358
-446
public/src/js/keyboard.js
public/src/js/keyboard.js
+14
-1
public/src/js/mekadon.js
public/src/js/mekadon.js
+96
-71
public/src/js/p2.js
public/src/js/p2.js
+13
-3
public/src/js/parsesong.js
public/src/js/parsesong.js
+308
-276
public/src/js/scoresheet.js
public/src/js/scoresheet.js
+100
-101
public/src/js/view.js
public/src/js/view.js
+108
-95
public/src/views/scoresheet.html
public/src/views/scoresheet.html
+23
-27
server.py
server.py
+7
-7
No files found.
public/src/css/scoresheet.css
View file @
749e6570
#
scoresheet
{
.
scoresheet
{
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
background
:
#e84019
;
color
:
black
;
color
:
black
;
font-family
:
TnT
;
font-family
:
TnT
;
background
:
url('/assets/img/bg-pattern-2.png')
;
background
:
url("/assets/img/bg-pattern-2.png")
;
position
:
absolute
;
}
}
#scoresheet
h2
{
.scoresheet
h2
{
position
:
absolute
;
position
:
absolute
;
top
:
1%
;
top
:
1%
;
left
:
1%
;
left
:
1%
;
font-size
:
7vmin
;
font-size
:
7vmin
;
margin
:
0
;
margin
:
0
;
color
:
white
;
color
:
white
;
}
}
#
result-window
{
.
result-window
{
width
:
70%
;
width
:
70%
;
margin
:
auto
;
margin
:
auto
;
}
}
#scoresheet
button
{
.scoresheet
button
{
height
:
50%
;
height
:
15%
;
min-width
:
20%
;
width
:
20%
;
position
:
absolute
;
position
:
absolute
;
display
:
inline-block
;
display
:
inline-block
;
cursor
:
pointer
;
cursor
:
pointer
;
...
@@ -38,45 +35,50 @@
...
@@ -38,45 +35,50 @@
border-radius
:
10px
;
border-radius
:
10px
;
outline
:
none
;
outline
:
none
;
top
:
10%
;
top
:
10%
;
white-space
:
nowrap
;
}
}
#
replay
{
.scoresheet
.
replay
{
left
:
1%
;
left
:
1%
;
}
}
#
song-select
{
.scoresheet
.
song-select
{
left
:
23%
;
left
:
23%
;
}
}
#
scoresheet
button
:hover
{
.
scoresheet
button
:hover
{
border-color
:
#fa5d3a
;
border-color
:
#fa5d3a
;
color
:
white
;
color
:
white
;
background
:
#0c6577
;
background
:
#0c6577
;
}
}
#result-bar
{
.scoresheet
.result-bar
{
width
:
100%
;
max-width
:
120vh
;
height
:
40%
;
height
:
71vh
;
position
:
absolute
;
top
:
10%
;
left
:
0
;
border-bottom
:
10px
inset
#b6361d
;
border-top
:
5px
solid
#b23111
;
min-height
:
200px
;
min-height
:
200px
;
display
:
flex
;
flex-direction
:
column
;
justify-content
:
center
;
align-items
:
flex-end
;
position
:
absolute
;
left
:
0
;
right
:
0
;
margin
:
auto
;
}
}
#
score-cont
{
.scoresheet
.
score-cont
{
position
:
absolut
e
;
position
:
relativ
e
;
right
:
1%
;
right
:
1%
;
width
:
60%
;
width
:
60%
;
height
:
80%
;
height
:
80%
;
background
:
rgba
(
255
,
255
,
255
,
0.7
);
background
:
rgba
(
255
,
255
,
255
,
0.7
);
border-radius
:
15px
;
border-radius
:
15px
;
margin
:
10px
;
max-height
:
33vh
;
}
}
#
score-hp-bar-bg
{
.scoresheet
.
score-hp-bar-bg
{
position
:
absolut
e
;
position
:
relativ
e
;
margin-top
:
2%
;
margin-top
:
2%
;
margin-left
:
5%
;
margin-left
:
5%
;
background
:
url("/assets/img/hp-bar-bg.png")
;
background
:
url("/assets/img/hp-bar-bg.png")
;
...
@@ -85,12 +87,12 @@
...
@@ -85,12 +87,12 @@
}
}
#
score-hp-bar-colour
{
.scoresheet
.
score-hp-bar-colour
{
position
:
absolute
;
position
:
absolute
;
padding
:
0
;
padding
:
0
;
}
}
#
score-hp-bar-colour
img
{
.scoresheet
.
score-hp-bar-colour
img
{
position
:
absolute
;
position
:
absolute
;
height
:
100%
;
height
:
100%
;
width
:
100%
;
width
:
100%
;
...
@@ -98,8 +100,8 @@
...
@@ -98,8 +100,8 @@
padding
:
0
;
padding
:
0
;
}
}
#
score-points
{
.scoresheet
.
score-points
{
width
:
30%
;
min-
width
:
30%
;
height
:
18%
;
height
:
18%
;
background
:
black
;
background
:
black
;
border
:
5px
solid
#ae7a26
;
border
:
5px
solid
#ae7a26
;
...
@@ -110,61 +112,95 @@
...
@@ -110,61 +112,95 @@
color
:
white
;
color
:
white
;
font-size
:
5vmin
;
font-size
:
5vmin
;
text-align
:
right
;
text-align
:
right
;
padding-right
:
2%
;
padding
:
.3%
1%
;
white-space
:
nowrap
;
}
}
#
score-details
{
.scoresheet
.
score-details
{
position
:
absolute
;
position
:
absolute
;
right
:
5%
;
right
:
5%
;
width
:
5
0%
;
width
:
7
0%
;
height
:
50%
;
height
:
50%
;
color
:
white
;
color
:
white
;
-webkit-text-stroke-width
:
2px
;
-webkit-text-stroke-color
:
black
;
}
}
#score-details
td
{
.scoresheet
.score-details
th
,
.scoresheet
.score-details
td
{
font-size
:
3vmin
;
font-size
:
3vmin
;
text-align
:
right
;
font-weight
:
normal
;
white-space
:
nowrap
;
}
}
.
floatLeft
{
.
scoresheet
.score-details
td
{
text-align
:
left
!importan
t
;
text-align
:
righ
t
;
}
}
.value
{
.
scoresheet
.
value
{
width
:
25%
;
width
:
25%
;
}
}
#bottom-part
{
.scoresheet
.bottom-part
{
position
:
fixed
;
width
:
100%
;
width
:
100%
;
position
:
absolute
;
height
:
19vh
;
bottom
:
0
;
-webkit-box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
-webkit-box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
-moz-box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
-moz-box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
box-shadow
:
inset
0px
10px
20px
-5px
#ee6d46
;
border-top
:
10px
outset
#b6361d
;
box-sizing
:
border-box
;
}
}
#
score-mark
{
.scoresheet
.
score-mark
{
position
:
absolute
;
position
:
absolute
;
top
:
0
;
bottom
:
0
;
right
:
105%
;
height
:
40%
;
margin
:
auto
;
}
}
.gradient-overlay
{
.
scoresheet
.
gradient-overlay
{
position
:
absolute
;
position
:
absolute
;
width
:
100%
;
width
:
100%
;
height
:
100%
;
height
:
100%
;
background
:
-moz-linear-gradient
(
top
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
/* FF3.6+ */
background
:
linear-gradient
(
to
bottom
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
background
:
-webkit-gradient
(
linear
,
left
top
,
left
bottom
,
color-stop
(
0%
,
rgba
(
0
,
0
,
0
,
0
)),
color-stop
(
62%
,
rgba
(
255
,
165
,
100
,
0.64
)),
color-stop
(
63%
,
rgba
(
255
,
165
,
100
,
0.65
)));
/* Chrome,Safari4+ */
background
:
-webkit-linear-gradient
(
top
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
/* Chrome10+,Safari5.1+ */
background
:
-o-linear-gradient
(
top
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
/* Opera 11.10+ */
background
:
-ms-linear-gradient
(
top
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
/* IE10+ */
background
:
linear-gradient
(
to
bottom
,
rgba
(
0
,
0
,
0
,
0
)
0%
,
rgba
(
255
,
165
,
100
,
0.64
)
62%
,
rgba
(
255
,
165
,
100
,
0.65
)
63%
);
/* W3C */
filter
:
progid
:
DXImageTransform
.
Microsoft
.
gradient
(
startColorstr
=
'#00000000'
,
endColorstr
=
'#a6ffa564'
,
GradientType
=
0
);
/* IE6-9 */
}
}
#
top-part
{
.scoresheet
.
top-part
{
width
:
100%
;
width
:
100%
;
height
:
10
%
;
height
:
10
vh
;
background
:
#e84019
;
background
:
#e84019
;
border-bottom
:
5px
solid
#b23111
;
box-sizing
:
border-box
;
}
.header-great
,
.header-fail
{
color
:
transparent
;
}
.header-great
::after
,
.header-fail
::after
{
content
:
attr
(
alt
);
color
:
transparent
;
-webkit-background-clip
:
text
;
background-clip
:
text
;
position
:
absolute
;
width
:
100%
;
left
:
0
;
}
.header-great
::after
{
background-image
:
linear-gradient
(
0deg
,
#f00
10%
,
#fe0
70%
);
}
.header-fail
::after
{
background-image
:
linear-gradient
(
0deg
,
#00b3df
30%
,
#6a62f9
90%
);
}
.scoresheet
.stroke-sub
{
position
:
relative
;
z-index
:
1
;
}
.scoresheet
.stroke-sub
::before
{
left
:
auto
;
}
}
\ No newline at end of file
public/src/js/assets.js
View file @
749e6570
...
@@ -28,7 +28,8 @@ var assets = {
...
@@ -28,7 +28,8 @@ var assets = {
'
muzu_hard.png
'
,
'
muzu_hard.png
'
,
'
muzu_oni.png
'
,
'
muzu_oni.png
'
,
'
don_anim_normal.png
'
,
'
don_anim_normal.png
'
,
'
don_anim_10combo.png
'
'
don_anim_10combo.png
'
,
'
balloon.png
'
],
],
audioSfx
:
[
audioSfx
:
[
...
@@ -83,6 +84,7 @@ var assets = {
...
@@ -83,6 +84,7 @@ var assets = {
'
note_don.ogg
'
,
'
note_don.ogg
'
,
'
note_ka.ogg
'
,
'
note_ka.ogg
'
,
'
balloon.ogg
'
],
],
audioMusic
:[
audioMusic
:[
...
...
public/src/js/circle.js
View file @
749e6570
function
Circle
(
id
,
ms
,
type
,
text
,
speed
){
class
Circle
{
constructor
(
id
,
ms
,
type
,
text
,
speed
,
endTime
,
requiredHits
){
var
_id
=
id
;
this
.
id
=
id
var
_ms
=
ms
;
this
.
ms
=
ms
var
_type
=
type
;
this
.
type
=
type
var
_played
=
false
;
this
.
text
=
text
var
_pos
=
{
x
:
0
,
y
:
0
};
this
.
speed
=
speed
var
_animating
=
false
;
this
.
endTime
=
endTime
?
endTime
:
ms
+
150
var
_animT
=
0
;
this
.
isPlayed
=
false
var
_score
=
0
;
this
.
animating
=
false
var
_lastFrame
=
ms
+
100
;
this
.
animT
=
0
var
_animationEnded
=
false
;
this
.
score
=
0
this
.
lastFrame
=
ms
+
100
var
played
=
false
;
//if cirlce has been played
this
.
animationEnded
=
false
var
_status
=-
1
;
//check if circle is playable
this
.
status
=
-
1
this
.
timesHit
=
0
// -1 : Not playable
this
.
requiredHits
=
requiredHits
?
requiredHits
:
0
// 0 : Playable, giving 0 points if played at current time (fail)
}
// 50 : Playable, giving 50 points if played at current time (pass)
getMS
(){
// 100 : Playable, giving 100 points if played at current time (good)
return
this
.
ms
}
this
.
getMS
=
function
(){
getEndTime
(){
return
_ms
;
return
this
.
endTime
}
}
getType
(){
this
.
getType
=
function
(){
return
this
.
type
return
_type
;
}
}
getLastFrame
(){
return
this
.
lastFrame
this
.
getLastFrame
=
function
(){
}
return
_lastFrame
;
incFrame
(){
}
this
.
lastFrame
+=
20
}
this
.
incFrame
=
function
(){
animate
(){
_lastFrame
+=
20
;
this
.
animating
=
true
}
}
isAnimated
(){
this
.
animate
=
function
(){
return
this
.
animating
_animating
=
true
;
}
}
getAnimT
(){
return
this
.
animT
this
.
isAnimated
=
function
(){
}
return
_animating
;
incAnimT
(){
}
this
.
animT
+=
0.05
}
this
.
getAnimT
=
function
(){
updateStatus
(
status
){
return
_animT
;
this
.
status
=
status
}
}
getStatus
(){
this
.
incAnimT
=
function
(){
return
this
.
status
_animT
+=
0.05
;
}
}
getPlayed
(){
return
this
.
isPlayed
this
.
updateStatus
=
function
(
status
){
}
_status
=
status
;
isAnimationFinished
(){
}
return
this
.
animationEnded
}
this
.
getStatus
=
function
(){
endAnimation
(){
return
_status
;
this
.
animationEnded
=
true
}
}
played
(
score
){
this
.
getPlayed
=
function
(){
this
.
score
=
score
return
_played
;
this
.
isPlayed
=
true
}
}
hit
(){
this
.
isAnimationFinished
=
function
(){
this
.
timesHit
++
return
_animationEnded
;
}
}
getScore
(){
return
this
.
score
this
.
endAnimation
=
function
(){
}
_animationEnded
=
true
;
getID
(){
}
return
this
.
id
}
this
.
played
=
function
(
score
){
getText
(){
_score
=
score
;
return
this
.
text
_played
=
true
;
}
}
getSpeed
(){
return
this
.
speed
this
.
getScore
=
function
(){
}
return
_score
;
}
this
.
getID
=
function
(){
return
_id
;
}
this
.
getText
=
function
(){
return
text
;
}
this
.
getSpeed
=
function
(){
return
speed
;
}
}
}
\ No newline at end of file
public/src/js/controller.js
View file @
749e6570
...
@@ -57,6 +57,13 @@ class Controller{
...
@@ -57,6 +57,13 @@ class Controller{
this
.
mainLoopRunning
=
true
this
.
mainLoopRunning
=
true
this
.
mainLoop
()
this
.
mainLoop
()
}
}
stopMainLoop
(){
this
.
mainLoopRunning
=
false
this
.
mainAsset
.
stop
()
if
(
this
.
syncWith
){
this
.
syncWith
.
stopMainLoop
()
}
}
mainLoop
(){
mainLoop
(){
if
(
this
.
mainLoopRunning
){
if
(
this
.
mainLoopRunning
){
if
(
this
.
multiplayer
!=
2
){
if
(
this
.
multiplayer
!=
2
){
...
@@ -88,9 +95,6 @@ class Controller{
...
@@ -88,9 +95,6 @@ class Controller{
this
.
keyboard
.
checkMenuKeys
()
this
.
keyboard
.
checkMenuKeys
()
}
}
}
}
getDistanceForCircle
(){
return
this
.
view
.
getDistanceForCircle
()
}
togglePauseMenu
(){
togglePauseMenu
(){
this
.
togglePause
()
this
.
togglePause
()
this
.
view
.
togglePauseMenu
()
this
.
view
.
togglePauseMenu
()
...
@@ -98,43 +102,41 @@ class Controller{
...
@@ -98,43 +102,41 @@ class Controller{
displayResults
(){
displayResults
(){
var
score
=
this
.
getGlobalScore
()
var
score
=
this
.
getGlobalScore
()
var
vp
var
vp
if
(
score
.
fail
==
0
)
{
if
(
score
.
fail
==
0
)
{
vp
=
"
fullcombo
"
vp
=
"
fullcombo
"
this
.
playSoundMeka
(
"
fullcombo
"
,
1.350
)
this
.
playSoundMeka
(
"
fullcombo
"
,
1.350
)
}
else
if
(
score
.
hp
>=
50
)
{
}
else
if
(
score
.
hp
>=
50
)
{
vp
=
"
clear
"
vp
=
"
clear
"
}
else
{
}
else
{
vp
=
"
fail
"
vp
=
"
fail
"
}
}
assets
.
sounds
[
"
game
"
+
vp
].
play
()
assets
.
sounds
[
"
game
"
+
vp
].
play
()
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
mainLoopRunning
=
false
if
(
this
.
mainLoopRunning
){
if
(
this
.
multiplayer
!=
2
){
this
.
stopMainLoop
()
new
Scoresheet
(
this
,
this
.
getGlobalScore
())
if
(
this
.
multiplayer
!=
2
){
new
Scoresheet
(
this
,
this
.
getGlobalScore
(),
this
.
multiplayer
)
}
}
}
},
7000
)
},
7000
)
}
}
displayScore
(
score
,
notPlayed
){
displayScore
(
score
,
notPlayed
){
this
.
view
.
displayScore
(
score
,
notPlayed
)
this
.
view
.
displayScore
(
score
,
notPlayed
)
}
}
fadeOutOver
(){
this
.
game
.
fadeOutOver
()
this
.
displayResults
()
}
getCurrentTimingPoint
(){
return
this
.
game
.
getCurrentTimingPoint
()
}
songSelection
(){
songSelection
(){
$
(
"
#music-bg
"
).
remove
()
$
(
"
#music-bg
"
).
remove
()
this
.
mainLoopRunning
=
false
this
.
stopMainLoop
()
new
SongSelect
()
new
SongSelect
()
}
}
restartSong
(){
restartSong
(){
this
.
mainAsset
.
stop
()
this
.
stopMainLoop
()
this
.
mainLoopRunning
=
false
$
(
"
#screen
"
).
load
(
"
/src/views/game.html
"
,
()
=>
{
$
(
"
#screen
"
).
load
(
"
/src/views/game.html
"
,
()
=>
{
var
taikoGame
=
new
Controller
(
this
.
selectedSong
,
this
.
songData
,
this
.
autoPlayEnabled
)
if
(
this
.
multiplayer
){
taikoGame
.
run
()
new
loadSong
(
this
.
selectedSong
,
false
,
true
)
}
else
{
var
taikoGame
=
new
Controller
(
this
.
selectedSong
,
this
.
songData
,
this
.
autoPlayEnabled
)
taikoGame
.
run
()
}
})
})
}
}
playSoundMeka
(
soundID
,
time
){
playSoundMeka
(
soundID
,
time
){
...
@@ -144,27 +146,12 @@ class Controller{
...
@@ -144,27 +146,12 @@ class Controller{
}
}
assets
.
sounds
[
soundID
+
meka
].
play
(
time
)
assets
.
sounds
[
soundID
+
meka
].
play
(
time
)
}
}
initTiming
(){
this
.
game
.
initTiming
()
}
setHitcircleSpeed
(
speed
){
this
.
view
.
setHitcircleSpeed
(
speed
)
}
getHitcircleSpeed
(){
return
this
.
game
.
getHitcircleSpeed
()
}
toggleMainMusic
(){
this
.
game
.
toggleMainMusic
()
}
togglePause
(){
togglePause
(){
if
(
this
.
syncWith
){
if
(
this
.
syncWith
){
this
.
syncWith
.
game
.
togglePause
()
this
.
syncWith
.
game
.
togglePause
()
}
}
this
.
game
.
togglePause
()
this
.
game
.
togglePause
()
}
}
isPaused
(){
return
this
.
game
.
isPaused
()
}
getKeys
(){
getKeys
(){
return
this
.
keyboard
.
getKeys
()
return
this
.
keyboard
.
getKeys
()
}
}
...
@@ -186,9 +173,6 @@ class Controller{
...
@@ -186,9 +173,6 @@ class Controller{
getCurrentCircle
(){
getCurrentCircle
(){
return
this
.
game
.
getCurrentCircle
()
return
this
.
game
.
getCurrentCircle
()
}
}
updateCurrentCircle
(){
this
.
game
.
updateCurrentCircle
()
}
isWaitingForKeyup
(
key
,
type
){
isWaitingForKeyup
(
key
,
type
){
return
this
.
keyboard
.
isWaitingForKeyup
(
key
,
type
)
return
this
.
keyboard
.
isWaitingForKeyup
(
key
,
type
)
}
}
...
@@ -198,18 +182,12 @@ class Controller{
...
@@ -198,18 +182,12 @@ class Controller{
getKeyTime
(){
getKeyTime
(){
return
this
.
keyboard
.
getKeyTime
()
return
this
.
keyboard
.
getKeyTime
()
}
}
updateCombo
(
score
){
this
.
game
.
updateCombo
(
score
)
}
getCombo
(){
getCombo
(){
return
this
.
game
.
getCombo
()
return
this
.
game
.
getCombo
()
}
}
getGlobalScore
(){
getGlobalScore
(){
return
this
.
game
.
getGlobalScore
()
return
this
.
game
.
getGlobalScore
()
}
}
updateGlobalScore
(
score
){
this
.
game
.
updateGlobalScore
(
score
)
}
autoPlay
(
circle
){
autoPlay
(
circle
){
if
(
this
.
multiplayer
){
if
(
this
.
multiplayer
){
p2
.
play
(
circle
,
this
.
mekadon
)
p2
.
play
(
circle
,
this
.
mekadon
)
...
...
public/src/js/game.js
View file @
749e6570
This diff is collapsed.
Click to expand it.
public/src/js/keyboard.js
View file @
749e6570
...
@@ -91,7 +91,20 @@ function Keyboard(controller){
...
@@ -91,7 +91,20 @@ function Keyboard(controller){
this
.
checkKeySound
=
function
(
keyCode
,
sound
){
this
.
checkKeySound
=
function
(
keyCode
,
sound
){
_this
.
checkKey
(
keyCode
,
"
sound
"
,
function
(){
_this
.
checkKey
(
keyCode
,
"
sound
"
,
function
(){
assets
.
sounds
[
"
note_
"
+
sound
].
play
()
var
circles
=
controller
.
parsedSongData
.
circles
var
circle
=
circles
[
controller
.
game
.
getCurrentCircle
()]
if
(
(
keyCode
==
_kbd
[
"
don_l
"
]
||
keyCode
==
_kbd
[
"
don_r
"
])
&&
circle
&&
!
circle
.
getPlayed
()
&&
circle
.
getStatus
()
!=
-
1
&&
circle
.
getType
()
==
"
balloon
"
&&
circle
.
requiredHits
-
circle
.
timesHit
<=
1
){
assets
.
sounds
[
"
balloon
"
].
play
()
}
else
{
assets
.
sounds
[
"
note_
"
+
sound
].
play
()
}
_keyTime
[
sound
]
=
controller
.
getElapsedTime
().
ms
_keyTime
[
sound
]
=
controller
.
getElapsedTime
().
ms
})
})
}
}
...
...
public/src/js/mekadon.js
View file @
749e6570
class
Mekadon
{
class
Mekadon
{
constructor
(
controller
,
game
){
constructor
(
controller
,
game
){
this
.
controller
=
controller
this
.
controller
=
controller
this
.
game
=
game
this
.
game
=
game
this
.
lr
=
false
this
.
lr
=
false
this
.
keys
=
{}
this
.
keys
=
{}
}
this
.
lastHit
=
-
Infinity
play
(
circle
){
}
if
(
circle
.
getStatus
()
==
450
){
play
(
circle
){
return
this
.
playNow
(
circle
)
var
type
=
circle
.
getType
()
}
if
(
type
==
"
balloon
"
){
}
this
.
playDrumrollAt
(
circle
,
0
,
30
)
playAt
(
circle
,
ms
,
score
){
}
else
if
(
type
==
"
drumroll
"
||
type
==
"
daiDrumroll
"
){
var
currentMs
=
circle
.
getMS
()
-
this
.
controller
.
getElapsedTime
().
ms
this
.
playDrumrollAt
(
circle
,
0
,
60
)
if
(
ms
>
currentMs
-
10
){
}
else
{
return
this
.
playNow
(
circle
,
score
)
this
.
playAt
(
circle
,
0
,
450
)
}
}
}
}
miss
(
circle
){
playAt
(
circle
,
ms
,
score
){
var
currentMs
=
circle
.
getMS
()
-
this
.
controller
.
getElapsedTime
().
ms
var
currentMs
=
circle
.
getMS
()
-
this
.
getMS
()
if
(
0
>
currentMs
-
10
){
if
(
ms
>
currentMs
-
10
){
this
.
controller
.
displayScore
(
0
,
true
)
return
this
.
playNow
(
circle
,
score
)
this
.
game
.
updateCurrentCircle
()
}
this
.
game
.
updateCombo
(
0
)
}
this
.
game
.
updateGlobalScore
(
0
)
playDrumrollAt
(
circle
,
ms
,
pace
){
return
true
if
(
pace
&&
this
.
getMS
()
>=
this
.
lastHit
+
pace
){
}
this
.
playAt
(
circle
,
ms
)
}
}
playNow
(
circle
,
score
){
}
var
kbd
=
this
.
controller
.
getBindings
()
miss
(
circle
){
if
(
circle
.
getType
()
==
"
don
"
){
var
currentMs
=
circle
.
getMS
()
-
this
.
getMS
()
this
.
setKey
(
this
.
lr
?
kbd
[
"
don_l
"
]
:
kbd
[
"
don_r
"
])
if
(
0
>=
currentMs
-
10
){
this
.
lr
=
!
this
.
lr
this
.
controller
.
displayScore
(
0
,
true
)
}
else
if
(
circle
.
getType
()
==
"
daiDon
"
){
this
.
game
.
updateCurrentCircle
()
this
.
setKey
(
kbd
[
"
don_l
"
])
this
.
game
.
updateCombo
(
0
)
this
.
setKey
(
kbd
[
"
don_r
"
])
this
.
game
.
updateGlobalScore
(
0
)
this
.
lr
=
false
return
true
}
else
if
(
circle
.
getType
()
==
"
ka
"
){
}
this
.
setKey
(
this
.
lr
?
kbd
[
"
ka_l
"
]
:
kbd
[
"
ka_r
"
])
}
this
.
lr
=
!
this
.
lr
playNow
(
circle
,
score
){
}
else
if
(
circle
.
getType
()
==
"
daiKa
"
){
var
kbd
=
this
.
controller
.
getBindings
()
this
.
setKey
(
kbd
[
"
ka_l
"
])
var
type
=
circle
.
getType
()
this
.
setKey
(
kbd
[
"
ka_r
"
])
if
(
type
==
"
don
"
||
type
==
"
balloon
"
||
type
==
"
drumroll
"
||
type
==
"
daiDrumroll
"
){
this
.
lr
=
false
this
.
setKey
(
this
.
lr
?
kbd
[
"
don_l
"
]
:
kbd
[
"
don_r
"
])
}
this
.
lr
=
!
this
.
lr
if
(
typeof
score
==
"
undefined
"
){
}
else
if
(
type
==
"
daiDon
"
){
score
=
this
.
game
.
checkScore
(
circle
)
this
.
setKey
(
kbd
[
"
don_l
"
])
}
else
{
this
.
setKey
(
kbd
[
"
don_r
"
])
this
.
controller
.
displayScore
(
score
)
this
.
lr
=
false
this
.
game
.
updateCombo
(
score
)
}
else
if
(
type
==
"
ka
"
){
this
.
game
.
updateGlobalScore
(
score
)
this
.
setKey
(
this
.
lr
?
kbd
[
"
ka_l
"
]
:
kbd
[
"
ka_r
"
])
}
this
.
lr
=
!
this
.
lr
circle
.
updateStatus
(
score
)
}
else
if
(
type
==
"
daiKa
"
){
circle
.
played
(
score
)
this
.
setKey
(
kbd
[
"
ka_l
"
])
this
.
game
.
updateCurrentCircle
()
this
.
setKey
(
kbd
[
"
ka_r
"
])
return
true
this
.
lr
=
false
}
}
setKey
(
keyCode
){
if
(
type
==
"
balloon
"
){
var
self
=
this
if
(
circle
.
requiredHits
==
1
){
if
(
this
.
keys
[
keyCode
]){
assets
.
sounds
[
"
balloon
"
].
play
()
clearTimeout
(
this
.
keys
[
keyCode
])
}
self
.
clearKey
(
keyCode
)
this
.
game
.
checkBalloon
(
circle
)
}
}
else
if
(
type
==
"
drumroll
"
||
type
==
"
daiDrumroll
"
){
this
.
controller
.
setKey
(
keyCode
,
true
)
this
.
game
.
checkDrumroll
(
circle
)
this
.
keys
[
keyCode
]
=
setTimeout
(
function
(){
}
else
{
self
.
clearKey
(
keyCode
)
if
(
typeof
score
==
"
undefined
"
){
},
100
)
score
=
this
.
game
.
checkScore
(
circle
)
}
}
else
{
clearKey
(
keyCode
){
this
.
controller
.
displayScore
(
score
)
this
.
controller
.
setKey
(
keyCode
,
false
)
this
.
game
.
updateCombo
(
score
)
delete
this
.
keys
[
keyCode
]
this
.
game
.
updateGlobalScore
(
score
)
}
this
.
game
.
updateCurrentCircle
()
}
circle
.
updateStatus
(
score
)
circle
.
played
(
score
)
}
this
.
lastHit
=
this
.
getMS
()
return
true
}
getMS
(){
return
this
.
controller
.
getElapsedTime
().
ms
}
setKey
(
keyCode
){
var
self
=
this
if
(
this
.
keys
[
keyCode
]){
clearTimeout
(
this
.
keys
[
keyCode
])
self
.
clearKey
(
keyCode
)
}
this
.
controller
.
setKey
(
keyCode
,
true
)
this
.
keys
[
keyCode
]
=
setTimeout
(
function
(){
self
.
clearKey
(
keyCode
)
},
100
)
}
clearKey
(
keyCode
){
this
.
controller
.
setKey
(
keyCode
,
false
)
delete
this
.
keys
[
keyCode
]
}
}
}
public/src/js/p2.js
View file @
749e6570
...
@@ -5,18 +5,25 @@ class P2Connection{
...
@@ -5,18 +5,25 @@ class P2Connection{
this
.
msgCallbacks
=
{}
this
.
msgCallbacks
=
{}
this
.
closeCallbacks
=
new
Set
()
this
.
closeCallbacks
=
new
Set
()
this
.
openCallbacks
=
new
Set
()
this
.
openCallbacks
=
new
Set
()
this
.
notes
=
[]
this
.
otherConnected
=
false
this
.
otherConnected
=
false
this
.
onmessage
(
"
gamestart
"
,
()
=>
{
this
.
onmessage
(
"
gamestart
"
,
()
=>
{
this
.
otherConnected
=
true
this
.
otherConnected
=
true
this
.
notes
=
[]
this
.
notes
=
[]
this
.
drumrollPace
=
45
this
.
results
=
false
})
})
this
.
onmessage
(
"
gameend
"
,
()
=>
{
this
.
onmessage
(
"
gameend
"
,
()
=>
{
this
.
otherConnected
=
false
this
.
otherConnected
=
false
})
})
this
.
onmessage
(
"
gameresults
"
,
response
=>
{
this
.
results
=
response
})
this
.
onmessage
(
"
note
"
,
response
=>
{
this
.
onmessage
(
"
note
"
,
response
=>
{
this
.
notes
.
push
(
response
)
this
.
notes
.
push
(
response
)
})
})
this
.
onmessage
(
"
drumroll
"
,
response
=>
{
this
.
drumrollPace
=
response
.
pace
})
}
}
open
(){
open
(){
this
.
closed
=
false
this
.
closed
=
false
...
@@ -92,7 +99,7 @@ class P2Connection{
...
@@ -92,7 +99,7 @@ class P2Connection{
this
.
msgCallbacks
[
data
.
type
].
forEach
(
obj
=>
{
this
.
msgCallbacks
[
data
.
type
].
forEach
(
obj
=>
{
obj
.
callback
(
data
.
value
)
obj
.
callback
(
data
.
value
)
if
(
obj
.
once
){
if
(
obj
.
once
){
delete
this
.
msgCallbacks
[
obj
]
this
.
msgCallbacks
[
data
.
type
].
delete
(
obj
)
}
}
})
})
}
}
...
@@ -113,7 +120,10 @@ class P2Connection{
...
@@ -113,7 +120,10 @@ class P2Connection{
}
}
play
(
circle
,
mekadon
){
play
(
circle
,
mekadon
){
if
(
this
.
otherConnected
||
this
.
notes
.
length
>
0
){
if
(
this
.
otherConnected
||
this
.
notes
.
length
>
0
){
if
(
this
.
notes
.
length
==
0
){
var
type
=
circle
.
getType
()
if
(
type
==
"
balloon
"
||
type
==
"
drumroll
"
||
type
==
"
daiDrumroll
"
){
mekadon
.
playDrumrollAt
(
circle
,
0
,
this
.
drumrollPace
)
}
else
if
(
this
.
notes
.
length
==
0
){
mekadon
.
play
(
circle
)
mekadon
.
play
(
circle
)
}
else
{
}
else
{
var
note
=
this
.
notes
[
0
]
var
note
=
this
.
notes
[
0
]
...
...
public/src/js/parsesong.js
View file @
749e6570
This diff is collapsed.
Click to expand it.
public/src/js/scoresheet.js
View file @
749e6570
class
Scoresheet
{
function
Scoresheet
(
controller
,
score
){
constructor
(
controller
,
score
,
multiplayer
){
this
.
controller
=
controller
var
_this
=
this
;
this
.
score
=
score
var
_score
=
score
;
this
.
multiplayer
=
multiplayer
var
_mark
;
$
(
"
#screen
"
).
load
(
"
/src/views/scoresheet.html
"
,
()
=>
{
this
.
run
()
this
.
setResults
=
function
(){
})
if
(
_score
.
fail
==
0
)
{
_mark
=
'
gold
'
;
}
else
if
(
_score
.
hp
>=
50
)
{
_mark
=
'
silver
'
;
};
var
imgW
=
(
_score
.
hp
*
$
(
"
#score-hp-bar-colour
"
).
width
())
/
100
;
$
(
"
#score-hp-bar-colour img
"
).
css
(
"
clip
"
,
"
rect(0,
"
+
imgW
+
"
px,
"
+
$
(
"
#score-hp-bar-colour
"
).
height
()
+
"
px, 0)
"
);
if
(
_mark
==
'
gold
'
)
{
$
(
"
#score-mark
"
).
attr
(
"
src
"
,
'
/assets/img/ranking-X.png
'
);
}
else
if
(
_mark
==
'
silver
'
)
{
$
(
"
#score-mark
"
).
attr
(
"
src
"
,
'
/assets/img/ranking-S.png
'
);
}
else
{
$
(
"
#score-mark
"
).
remove
();
};
$
(
"
#score-points
"
).
html
(
_score
.
points
+
"
点
"
);
$
(
"
#nb-great
"
).
html
(
_score
.
great
);
$
(
"
#nb-good
"
).
html
(
_score
.
good
);
$
(
"
#nb-fail
"
).
html
(
_score
.
fail
);
$
(
"
#max-combo
"
).
html
(
_score
.
maxCombo
);
$
(
'
.result-song
'
).
attr
(
'
alt
'
,
_score
.
song
).
html
(
_score
.
song
);
}
}
setResults
(
score
,
scoreCont
){
this
.
positionning
=
function
(){
this
.
positionning
(
scoreCont
)
var
scoreMark
=
this
.
elem
(
"
score-mark
"
,
scoreCont
)
$
(
"
#score-cont
"
).
css
(
"
top
"
,
$
(
"
#result-bar
"
).
height
()
/
2
-
(
$
(
"
#score-cont
"
).
height
()
/
2
));
var
scoreHpBarColour
=
this
.
elem
(
"
score-hp-bar-colour
"
,
scoreCont
)
var
markSize
=
0.1
*
$
(
"
#score-cont
"
).
width
();
if
(
score
.
fail
==
0
){
var
markX
=
$
(
"
#score-cont
"
).
offset
().
left
-
markSize
-
(
0.5
*
markSize
);
var
mark
=
"
gold
"
var
markY
=
$
(
"
#score-cont
"
).
offset
().
top
;
}
else
if
(
score
.
hp
>=
50
){
var
mark
=
"
silver
"
$
(
"
#score-mark
"
).
width
(
markSize
);
}
$
(
"
#score-mark
"
).
height
(
markSize
);
scoreHpBarColour
.
dataset
.
hp
=
score
.
hp
$
(
"
#score-mark
"
).
css
(
"
left
"
,
markX
);
var
imgW
=
score
.
hp
*
scoreHpBarColour
.
offsetWidth
/
100
$
(
"
#score-mark
"
).
css
(
"
top
"
,
markY
);
var
imgH
=
scoreHpBarColour
.
offsetHeight
scoreHpBarColour
.
getElementsByTagName
(
"
img
"
)[
0
].
style
.
clip
=
"
rect(0,
"
+
imgW
+
"
px,
"
+
imgH
+
"
px, 0)
"
var
scoreBarW
=
0.9
*
$
(
"
#score-cont
"
).
width
();
if
(
mark
==
"
gold
"
){
$
(
"
#score-hp-bar-bg
"
).
width
(
scoreBarW
);
scoreMark
.
src
=
"
/assets/img/ranking-X.png
"
$
(
"
#score-hp-bar-bg
"
).
height
((
51
/
703
)
*
scoreBarW
);
}
else
if
(
mark
==
"
silver
"
){
scoreMark
.
src
=
"
/assets/img/ranking-S.png
"
var
bgW
=
$
(
"
#score-hp-bar-bg
"
).
width
();
}
else
{
var
bgH
=
$
(
"
#score-hp-bar-bg
"
).
height
();
scoreMark
.
parentNode
.
removeChild
(
scoreMark
)
var
bgX
=
$
(
"
#score-hp-bar-bg
"
).
position
().
left
;
}
var
bgY
=
$
(
"
#score-hp-bar-bg
"
).
position
().
top
;
this
.
altText
(
this
.
elem
(
"
score-points
"
,
scoreCont
),
score
.
points
+
"
点
"
)
this
.
altText
(
this
.
elem
(
"
nb-great
"
,
scoreCont
),
score
.
great
)
$
(
"
#score-hp-bar-colour
"
).
css
(
"
left
"
,
bgX
+
(
0.008
*
bgW
));
this
.
altText
(
this
.
elem
(
"
nb-good
"
,
scoreCont
),
score
.
good
)
$
(
"
#score-hp-bar-colour
"
).
css
(
"
top
"
,
bgY
+
(
0.15
*
bgH
));
this
.
altText
(
this
.
elem
(
"
nb-fail
"
,
scoreCont
),
score
.
fail
)
$
(
"
#score-hp-bar-colour
"
).
width
(
bgW
-
(
0.08
*
bgW
));
this
.
altText
(
this
.
elem
(
"
max-combo
"
,
scoreCont
),
score
.
maxCombo
)
$
(
"
#score-hp-bar-colour
"
).
height
(
bgH
-
(
0.25
*
bgH
));
addEventListener
(
"
resize
"
,
()
=>
{
$
(
"
#score-details
"
).
css
(
"
top
"
,
bgY
+
bgH
+
(
bgH
));
this
.
positionning
(
scoreCont
)
})
var
barY
=
$
(
"
#result-bar
"
).
position
().
top
;
var
barH
=
$
(
"
#result-bar
"
).
height
();
var
bottomY
=
barY
+
barH
+
15
;
var
bottomH
=
$
(
window
).
height
()
-
bottomY
;
$
(
"
#bottom-part
"
).
css
(
"
top
"
,
bottomY
);
$
(
"
#bottom-part
"
).
height
(
bottomH
);
}
}
elem
(
className
,
parent
){
this
.
run
=
function
(){
return
parent
.
getElementsByClassName
(
className
)[
0
]
_this
.
positionning
();
}
_this
.
setResults
();
text
(
string
){
return
document
.
createTextNode
(
string
)
$
(
"
#song-select
"
).
click
(
function
(){
}
assets
.
sounds
[
"
don
"
].
play
();
altText
(
element
,
string
){
assets
.
sounds
[
"
bgm_result
"
].
stop
();
element
.
appendChild
(
this
.
text
(
string
))
controller
.
songSelection
();
element
.
setAttribute
(
"
alt
"
,
string
)
});
}
positionning
(
scoreCont
){
$
(
"
#replay
"
).
click
(
function
(){
var
scoreHpBarBg
=
this
.
elem
(
"
score-hp-bar-bg
"
,
scoreCont
)
assets
.
sounds
[
"
don
"
].
play
();
var
scoreHpBarColour
=
this
.
elem
(
"
score-hp-bar-colour
"
,
scoreCont
)
assets
.
sounds
[
"
bgm_result
"
].
stop
();
controller
.
restartSong
();
var
scoreBarW
=
scoreCont
.
offsetWidth
*
0.9
});
var
bgW
=
scoreBarW
var
bgH
=
51
/
703
*
scoreBarW
$
(
window
).
resize
(
_this
.
positionning
);
scoreHpBarBg
.
style
.
width
=
bgW
+
"
px
"
scoreHpBarBg
.
style
.
height
=
bgH
+
"
px
"
var
bgX
=
scoreHpBarBg
.
offsetLeft
var
bgY
=
scoreHpBarBg
.
offsetTop
scoreHpBarColour
.
style
.
left
=
(
bgW
*
0.008
)
+
"
px
"
scoreHpBarColour
.
style
.
top
=
(
bgH
*
0.15
)
+
"
px
"
scoreHpBarColour
.
style
.
width
=
(
bgW
-
bgW
*
0.08
)
+
"
px
"
scoreHpBarColour
.
style
.
height
=
(
bgH
-
bgH
*
0.25
)
+
"
px
"
var
imgW
=
scoreHpBarColour
.
dataset
.
hp
*
scoreHpBarColour
.
offsetWidth
/
100
var
imgH
=
scoreHpBarColour
.
offsetHeight
scoreHpBarColour
.
getElementsByTagName
(
"
img
"
)[
0
].
style
.
clip
=
"
rect(0,
"
+
imgW
+
"
px,
"
+
imgH
+
"
px, 0)
"
}
run
(){
this
.
scoresheet
=
document
.
getElementsByClassName
(
"
scoresheet
"
)[
0
]
var
scoreCont
=
this
.
elem
(
"
score-cont
"
,
this
.
scoresheet
)
var
scoreContHtml
=
scoreCont
.
innerHTML
assets
.
sounds
[
"
results
"
].
play
()
assets
.
sounds
[
"
bgm_result
"
].
playLoop
(
0.1
,
false
,
0
,
0.847
,
17.689
)
this
.
setResults
(
this
.
score
,
scoreCont
)
this
.
altText
(
this
.
elem
(
"
result-song
"
,
this
.
scoresheet
),
this
.
score
.
song
)
this
.
elem
(
"
song-select
"
,
this
.
scoresheet
).
addEventListener
(
"
click
"
,
()
=>
{
assets
.
sounds
[
"
don
"
].
play
()
assets
.
sounds
[
"
bgm_result
"
].
stop
()
this
.
controller
.
songSelection
()
})
this
.
elem
(
"
replay
"
,
this
.
scoresheet
).
addEventListener
(
"
click
"
,
()
=>
{
assets
.
sounds
[
"
don
"
].
play
()
assets
.
sounds
[
"
bgm_result
"
].
stop
()
this
.
controller
.
restartSong
()
})
if
(
this
.
multiplayer
&&
p2
.
results
){
var
scoreCont2
=
document
.
createElement
(
"
div
"
)
scoreCont2
.
classList
.
add
(
"
score-cont
"
)
scoreCont2
.
innerHTML
=
scoreContHtml
scoreCont
.
parentNode
.
appendChild
(
scoreCont2
)
this
.
setResults
(
p2
.
results
,
scoreCont2
)
}
}
}
}
assets
.
sounds
[
"
results
"
].
play
()
assets
.
sounds
[
"
bgm_result
"
].
playLoop
(
0.1
,
false
,
0
,
0.847
,
17.689
)
$
(
"
#screen
"
).
load
(
"
/src/views/scoresheet.html
"
,
_this
.
run
);
}
\ No newline at end of file
public/src/js/view.js
View file @
749e6570
This diff is collapsed.
Click to expand it.
public/src/views/scoresheet.html
View file @
749e6570
<div
id=
'scoresheet'
>
<div
class=
"scoresheet"
>
<div
class=
"top-part"
>
<div
id=
'top-part'
>
<h2
alt=
"成績発表"
class=
"stroke-main result-title"
>
成績発表
</h2>
<h2
alt=
"成績発表"
class=
"stroke-main result-title"
>
成績発表
</h2>
<h3
alt=
""
class=
"stroke-sub result-song"
></h3>
<h3
alt=
""
class=
"stroke-sub result-song"
></h3>
</div>
</div>
<div
class=
"result-bar"
>
<div
id=
'result-bar'
>
<div
class=
"score-cont"
>
<img
class=
"score-mark"
/>
<img
id=
'score-mark'
/>
<div
class=
"score-hp-bar-bg"
>
<div
class=
"score-hp-bar-colour"
>
<div
id=
'score-cont'
>
<img
src=
"/assets/img/hp-bar-colour.png"
/>
<div
id=
'score-hp-bar-bg'
>
<div
id=
'score-hp-bar-colour'
>
<img
src=
"/assets/img/hp-bar-colour.png"
/>
</div>
</div>
</div>
</div>
<div
class=
"score-points"
></div>
<div
id=
'score-points'
></div>
<table
class=
"score-details"
>
<table
id=
'score-details'
>
<tr>
<tr>
<td
class=
'floatLeft'
>
良
</td><td
class=
'value'
id=
'nb-great'
></td>
<th
class=
"header-great stroke-sub"
alt=
"良"
>
良
</th>
<td>
最大コンボ数
</td><td
class=
'value'
id=
'max-combo'
></td>
<td
class=
"value nb-great stroke-sub"
></td>
<td
class=
"stroke-sub"
alt=
"最大コンボ数"
>
最大コンボ数
</td><td
class=
"value max-combo stroke-sub"
></td>
</tr>
</tr>
<tr>
<tr>
<td
class=
'floatLeft'
>
可
</td><td
class=
'value'
id=
'nb-good'
></td>
<th
class=
"header-good stroke-sub"
alt=
"可"
>
可
</th>
<!--<td>連打数</td><td id='nb-rendasu'></td>-->
<td
class=
"value nb-good stroke-sub"
></td>
<!--<td class="stroke-sub" alt="連打数">連打数</td><td class="value nb-rendasu stroke-sub"></td>-->
</tr>
</tr>
<tr>
<tr>
<td
class=
'floatLeft'
>
不可
</td><td
class=
'value'
id=
'nb-fail'
></td>
<th
class=
"header-fail stroke-sub"
alt=
"不可"
>
不可
</th>
<td
class=
"value nb-fail stroke-sub"
></td>
<td></td><td></td>
<td></td><td></td>
</tr>
</tr>
</table>
</table>
</div>
</div>
</div>
</div>
<div
class=
"bottom-part"
>
<div
id=
'bottom-part'
>
<div
class=
"gradient-overlay"
></div>
<div
class=
'gradient-overlay'
></div>
<button
type=
"button"
class=
"song-select"
>
Song select
</button>
<button
type=
'button'
id=
'song-select'
>
Song select
</button>
<button
type=
"button"
class=
"replay"
>
Replay
</button>
<button
type=
'button'
id=
'replay'
>
Replay
</button>
</div>
</div>
</div>
</div>
\ No newline at end of file
server.py
View file @
749e6570
...
@@ -4,9 +4,9 @@ import asyncio
...
@@ -4,9 +4,9 @@ import asyncio
import
websockets
import
websockets
import
json
import
json
users
=
[]
server_status
=
{
server_status
=
{
"waiting"
:
{}
"waiting"
:
{},
"users"
:
[]
}
}
def
msgobj
(
type
,
value
=
None
):
def
msgobj
(
type
,
value
=
None
):
...
@@ -25,7 +25,7 @@ def status_event():
...
@@ -25,7 +25,7 @@ def status_event():
return
msgobj
(
"users"
,
value
)
return
msgobj
(
"users"
,
value
)
async
def
notify_status
():
async
def
notify_status
():
ready_users
=
[
user
for
user
in
users
if
"ws"
in
user
and
user
[
"action"
]
==
"ready"
]
ready_users
=
[
user
for
user
in
server_status
[
"users"
]
if
"ws"
in
user
and
user
[
"action"
]
==
"ready"
]
if
ready_users
:
if
ready_users
:
sent_msg
=
status_event
()
sent_msg
=
status_event
()
await
asyncio
.
wait
([
user
[
"ws"
]
.
send
(
sent_msg
)
for
user
in
ready_users
])
await
asyncio
.
wait
([
user
[
"ws"
]
.
send
(
sent_msg
)
for
user
in
ready_users
])
...
@@ -36,7 +36,7 @@ async def connection(ws, path):
...
@@ -36,7 +36,7 @@ async def connection(ws, path):
"ws"
:
ws
,
"ws"
:
ws
,
"action"
:
"ready"
"action"
:
"ready"
}
}
users
.
append
(
user
)
server_status
[
"users"
]
.
append
(
user
)
try
:
try
:
# Notify user about other users
# Notify user about other users
await
ws
.
send
(
status_event
())
await
ws
.
send
(
status_event
())
...
@@ -126,8 +126,8 @@ async def connection(ws, path):
...
@@ -126,8 +126,8 @@ async def connection(ws, path):
elif
action
==
"playing"
:
elif
action
==
"playing"
:
# Playing with another user
# Playing with another user
if
"other_user"
in
user
and
"ws"
in
user
[
"other_user"
]:
if
"other_user"
in
user
and
"ws"
in
user
[
"other_user"
]:
if
type
==
"note"
:
if
type
==
"note"
or
type
==
"drumroll"
or
type
==
"gameresults"
:
await
user
[
"other_user"
][
"ws"
]
.
send
(
msgobj
(
"note"
,
value
))
await
user
[
"other_user"
][
"ws"
]
.
send
(
msgobj
(
type
,
value
))
if
type
==
"gameend"
:
if
type
==
"gameend"
:
# User wants to disconnect
# User wants to disconnect
user
[
"action"
]
=
"ready"
user
[
"action"
]
=
"ready"
...
@@ -151,7 +151,7 @@ async def connection(ws, path):
...
@@ -151,7 +151,7 @@ async def connection(ws, path):
finally
:
finally
:
# User disconnected
# User disconnected
del
user
[
"ws"
]
del
user
[
"ws"
]
del
users
[
users
.
index
(
user
)]
del
server_status
[
"users"
][
server_status
[
"users"
]
.
index
(
user
)]
if
"other_user"
in
user
and
"ws"
in
user
[
"other_user"
]:
if
"other_user"
in
user
and
"ws"
in
user
[
"other_user"
]:
user
[
"other_user"
][
"action"
]
=
"ready"
user
[
"other_user"
][
"action"
]
=
"ready"
await
asyncio
.
wait
([
await
asyncio
.
wait
([
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment