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
29fb7845
Commit
29fb7845
authored
Mar 16, 2020
by
LoveEevee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add session crowns
parent
47b769c8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
165 additions
and
38 deletions
+165
-38
public/src/js/p2.js
public/src/js/p2.js
+34
-0
public/src/js/scorestorage.js
public/src/js/scorestorage.js
+65
-3
public/src/js/songselect.js
public/src/js/songselect.js
+60
-35
server.py
server.py
+6
-0
No files found.
public/src/js/p2.js
View file @
29fb7845
...
...
@@ -116,6 +116,7 @@ class P2Connection{
this
.
kaAmount
=
0
this
.
results
=
false
this
.
branch
=
"
normal
"
scoreStorage
.
clearP2
()
break
case
"
gameend
"
:
this
.
otherConnected
=
false
...
...
@@ -130,6 +131,7 @@ class P2Connection{
this
.
hashLock
=
false
}
this
.
name
=
null
scoreStorage
.
clearP2
()
break
case
"
gameresults
"
:
this
.
results
=
{}
...
...
@@ -157,6 +159,7 @@ class P2Connection{
this
.
clearMessage
(
"
users
"
)
this
.
otherConnected
=
true
this
.
session
=
true
scoreStorage
.
clearP2
()
if
(
"
player
"
in
response
.
value
){
this
.
player
=
response
.
value
.
player
===
2
?
2
:
1
}
...
...
@@ -164,6 +167,37 @@ class P2Connection{
case
"
name
"
:
this
.
name
=
response
.
value
?
response
.
value
.
toString
()
:
response
.
value
break
case
"
getcrowns
"
:
if
(
response
.
value
){
var
output
=
{}
for
(
var
i
in
response
.
value
){
if
(
response
.
value
[
i
]){
var
score
=
scoreStorage
.
get
(
response
.
value
[
i
],
false
,
true
)
if
(
score
){
var
crowns
=
{}
for
(
var
diff
in
score
){
if
(
diff
!==
"
title
"
){
crowns
[
diff
]
=
{
crown
:
score
[
diff
].
crown
}
}
}
}
else
{
var
crowns
=
null
}
output
[
response
.
value
[
i
]]
=
crowns
}
}
p2
.
send
(
"
crowns
"
,
output
)
}
break
case
"
crowns
"
:
if
(
response
.
value
){
for
(
var
i
in
response
.
value
){
scoreStorage
.
addP2
(
i
,
false
,
response
.
value
[
i
],
true
)
}
}
break
}
}
onhashchange
(){
...
...
public/src/js/scorestorage.js
View file @
29fb7845
class
ScoreStorage
{
constructor
(){
this
.
scores
=
{}
this
.
scoresP2
=
{}
this
.
requestP2
=
new
Set
()
this
.
requestedP2
=
new
Set
()
this
.
songTitles
=
{}
this
.
difficulty
=
[
"
oni
"
,
"
ura
"
,
"
hard
"
,
"
normal
"
,
"
easy
"
]
this
.
scoreKeys
=
[
"
points
"
,
"
good
"
,
"
ok
"
,
"
bad
"
,
"
maxCombo
"
,
"
drumroll
"
]
...
...
@@ -151,15 +154,40 @@ class ScoreStorage{
}
}
}
getP2
(
song
,
difficulty
,
isHash
){
if
(
!
song
){
return
this
.
scoresP2
}
else
{
var
hash
=
isHash
?
song
:
this
.
titleHash
(
song
)
if
(
!
(
hash
in
this
.
scoresP2
)
&&
!
this
.
requestP2
.
has
(
hash
)
&&
!
this
.
requestedP2
.
has
(
hash
)){
this
.
requestP2
.
add
(
hash
)
this
.
requestedP2
.
add
(
hash
)
}
if
(
difficulty
){
if
(
hash
in
this
.
scoresP2
){
return
this
.
scoresP2
[
hash
][
difficulty
]
}
}
else
{
return
this
.
scoresP2
[
hash
]
}
}
}
add
(
song
,
difficulty
,
scoreObject
,
isHash
,
setTitle
,
saveFailed
){
var
hash
=
isHash
?
song
:
this
.
titleHash
(
song
)
if
(
!
(
hash
in
this
.
scores
)){
this
.
scores
[
hash
]
=
{}
}
if
(
setTitle
){
this
.
scores
[
hash
].
title
=
setTitle
if
(
difficulty
){
if
(
setTitle
){
this
.
scores
[
hash
].
title
=
setTitle
}
this
.
scores
[
hash
][
difficulty
]
=
scoreObject
}
else
{
this
.
scores
[
hash
]
=
scoreObject
if
(
setTitle
){
this
.
scores
[
hash
].
title
=
setTitle
}
}
this
.
scores
[
hash
][
difficulty
]
=
scoreObject
this
.
writeString
(
hash
)
this
.
write
()
if
(
saveFailed
){
...
...
@@ -186,6 +214,23 @@ class ScoreStorage{
}).
catch
(()
=>
this
.
add
(
song
,
difficulty
,
scoreObject
,
isHash
,
setTitle
,
true
))
}
}
addP2
(
song
,
difficulty
,
scoreObject
,
isHash
,
setTitle
){
var
hash
=
isHash
?
song
:
this
.
titleHash
(
song
)
if
(
!
(
hash
in
this
.
scores
)){
this
.
scoresP2
[
hash
]
=
{}
}
if
(
difficulty
){
if
(
setTitle
){
this
.
scoresP2
[
hash
].
title
=
setTitle
}
this
.
scoresP2
[
hash
][
difficulty
]
=
scoreObject
}
else
{
this
.
scoresP2
[
hash
]
=
scoreObject
if
(
setTitle
){
this
.
scoresP2
[
hash
].
title
=
setTitle
}
}
}
template
(){
var
template
=
{
crown
:
""
}
for
(
var
i
in
this
.
scoreKeys
){
...
...
@@ -257,4 +302,21 @@ class ScoreStorage{
return
Promise
.
resolve
()
}
}
eventLoop
(){
if
(
p2
.
session
&&
this
.
requestP2
.
size
){
var
req
=
[]
this
.
requestP2
.
forEach
(
hash
=>
{
req
.
push
(
hash
)
})
this
.
requestP2
.
clear
()
if
(
req
.
length
){
p2
.
send
(
"
getcrowns
"
,
req
)
}
}
}
clearP2
(){
this
.
scoresP2
=
{}
this
.
requestP2
.
clear
()
this
.
requestedP2
.
clear
()
}
}
public/src/js/songselect.js
View file @
29fb7845
...
...
@@ -1495,20 +1495,33 @@ class SongSelect{
}
var
drawDifficulty
=
(
ctx
,
i
,
currentUra
)
=>
{
if
(
currentSong
.
courses
[
this
.
difficultyId
[
i
]]
||
currentUra
){
var
score
=
scoreStorage
.
get
(
currentSong
.
hash
,
false
,
true
)
var
crownDiff
=
currentUra
?
"
ura
"
:
this
.
difficultyId
[
i
]
var
crownType
=
""
if
(
score
&&
score
[
crownDiff
]){
crownType
=
score
[
crownDiff
].
crown
var
players
=
p2
.
session
?
2
:
1
var
score
=
[
scoreStorage
.
get
(
currentSong
.
hash
,
false
,
true
)]
if
(
p2
.
session
){
score
[
p2
.
player
===
1
?
"
push
"
:
"
unshift
"
](
scoreStorage
.
getP2
(
currentSong
.
hash
,
false
,
true
))
}
var
reversed
=
false
for
(
var
a
=
players
;
a
--
;){
var
crownType
=
""
var
p
=
reversed
?
-
(
a
-
1
)
:
a
if
(
score
[
p
]
&&
score
[
p
][
crownDiff
]){
crownType
=
score
[
p
][
crownDiff
].
crown
}
if
(
!
reversed
&&
players
===
2
&&
p
===
1
&&
crownType
){
reversed
=
true
a
++
}
else
{
this
.
draw
.
crown
({
ctx
:
ctx
,
type
:
crownType
,
x
:
(
songSel
?
x
+
33
+
i
*
60
:
x
+
402
+
i
*
100
)
+
(
players
===
2
?
p
===
0
?
-
13
:
13
:
0
),
y
:
songSel
?
y
+
75
:
y
+
30
,
scale
:
0.25
,
ratio
:
this
.
ratio
/
this
.
pixelRatio
})
}
}
this
.
draw
.
crown
({
ctx
:
ctx
,
type
:
crownType
,
x
:
songSel
?
x
+
33
+
i
*
60
:
x
+
402
+
i
*
100
,
y
:
songSel
?
y
+
75
:
y
+
30
,
scale
:
0.25
,
ratio
:
this
.
ratio
/
this
.
pixelRatio
})
if
(
songSel
){
var
_x
=
x
+
33
+
i
*
60
var
_y
=
y
+
120
...
...
@@ -2269,6 +2282,11 @@ class SongSelect{
ctx
.
restore
()
}
if
(
p2
.
session
&&
(
!
this
.
lastScoreMS
||
ms
>
this
.
lastScoreMS
+
1000
)){
this
.
lastScoreMS
=
ms
scoreStorage
.
eventLoop
()
}
}
drawClosedSong
(
config
){
...
...
@@ -2327,31 +2345,38 @@ class SongSelect{
drawSongCrown
(
config
){
if
(
!
config
.
song
.
action
&&
config
.
song
.
hash
){
var
ctx
=
config
.
ctx
var
score
=
scoreStorage
.
get
(
config
.
song
.
hash
,
false
,
true
)
var
players
=
p2
.
session
?
2
:
1
var
score
=
[
scoreStorage
.
get
(
config
.
song
.
hash
,
false
,
true
)]
var
scoreDrawn
=
[]
if
(
p2
.
session
){
score
[
p2
.
player
===
1
?
"
push
"
:
"
unshift
"
](
scoreStorage
.
getP2
(
config
.
song
.
hash
,
false
,
true
))
}
for
(
var
i
=
this
.
difficultyId
.
length
;
i
--
;){
var
diff
=
this
.
difficultyId
[
i
]
if
(
!
score
){
break
}
if
(
config
.
song
.
courses
[
this
.
difficultyId
[
i
]]
&&
score
[
diff
]
&&
score
[
diff
].
crown
){
this
.
draw
.
crown
({
ctx
:
ctx
,
type
:
score
[
diff
].
crown
,
x
:
config
.
x
+
this
.
songAsset
.
width
/
2
,
y
:
config
.
y
-
13
,
scale
:
0.3
,
ratio
:
this
.
ratio
/
this
.
pixelRatio
})
this
.
draw
.
diffIcon
({
ctx
:
ctx
,
diff
:
i
,
x
:
config
.
x
+
this
.
songAsset
.
width
/
2
+
8
,
y
:
config
.
y
-
8
,
scale
:
diff
===
"
hard
"
||
diff
===
"
normal
"
?
0.45
:
0.5
,
border
:
6.5
,
small
:
true
})
break
for
(
var
p
=
players
;
p
--
;){
if
(
!
score
[
p
]
||
scoreDrawn
[
p
]){
continue
}
if
(
config
.
song
.
courses
[
this
.
difficultyId
[
i
]]
&&
score
[
p
][
diff
]
&&
score
[
p
][
diff
].
crown
){
this
.
draw
.
crown
({
ctx
:
ctx
,
type
:
score
[
p
][
diff
].
crown
,
x
:
(
config
.
x
+
this
.
songAsset
.
width
/
2
)
+
(
players
===
2
?
p
===
0
?
-
13
:
13
:
0
),
y
:
config
.
y
-
13
,
scale
:
0.3
,
ratio
:
this
.
ratio
/
this
.
pixelRatio
})
this
.
draw
.
diffIcon
({
ctx
:
ctx
,
diff
:
i
,
x
:
(
config
.
x
+
this
.
songAsset
.
width
/
2
+
8
)
+
(
players
===
2
?
p
===
0
?
-
13
:
13
:
0
),
y
:
config
.
y
-
8
,
scale
:
diff
===
"
hard
"
||
diff
===
"
normal
"
?
0.45
:
0.5
,
border
:
6.5
,
small
:
true
})
scoreDrawn
[
p
]
=
true
}
}
}
}
...
...
server.py
View file @
29fb7845
...
...
@@ -283,6 +283,12 @@ async def connection(ws, path):
ws
.
send
(
sent_msg
),
user
[
"other_user"
][
"ws"
]
.
send
(
sent_msg
)
])
elif
type
==
"crowns"
or
type
==
"getcrowns"
:
if
user
[
"other_user"
][
"action"
]
==
"songsel"
:
sent_msg
=
msgobj
(
type
,
value
)
await
asyncio
.
wait
([
user
[
"other_user"
][
"ws"
]
.
send
(
sent_msg
)
])
elif
type
==
"join"
:
# Start game
if
value
==
None
:
...
...
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