Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
ygopro-arena-api
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
MyCard
ygopro-arena-api
Commits
1384e162
Commit
1384e162
authored
Jun 19, 2017
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
asd
parent
5c83e06e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
15 additions
and
6 deletions
+15
-6
routes/api.js
routes/api.js
+13
-4
test.js
test.js
+2
-2
No files found.
routes/api.js
View file @
1384e162
...
@@ -146,14 +146,17 @@ router.post('/score', function (req, res) {
...
@@ -146,14 +146,17 @@ router.post('/score', function (req, res) {
entertain_draw
:
0
,
entertain_draw
:
0
,
entertain_all
:
1
,
entertain_all
:
1
,
}
}
var
winner
=
"
none
"
var
firstWin
=
false
// athletic = 竞技 entertain = 娱乐
// athletic = 竞技 entertain = 娱乐
if
(
arena
===
'
athletic
'
)
{
if
(
arena
===
'
athletic
'
)
{
// select count(*) from battle_history where (usernameA = '爱吉' OR usernameB = '爱吉') and start_time > date '2017-02-09'
// select count(*) from battle_history where (usernameA = '爱吉' OR usernameB = '爱吉') and start_time > date '2017-02-09'
// 日首胜 每日0点开始计算 日首胜的话是额外增加固定4DP
// 日首胜 每日0点开始计算 日首胜的话是额外增加固定4DP
var
firstWin
=
false
var
winner
=
"
xxxxx
"
var
today
=
moment
().
format
(
'
YYYY-MM-DD
'
)
var
today
=
moment
().
format
(
'
YYYY-MM-DD
'
)
// 真实得分 S(胜=1分,和=0.5分,负=0分)
// 真实得分 S(胜=1分,和=0.5分,负=0分)
...
@@ -233,7 +236,7 @@ router.post('/score', function (req, res) {
...
@@ -233,7 +236,7 @@ router.post('/score', function (req, res) {
'
${
start
}
',
'
${
start
}
',
'
${
end
}
',
'
${
end
}
',
'
${
winner
}
',
'
${
winner
}
',
'
${
firstWin
}
'
,
'
${
firstWin
}
'
)`
)
)`
)
queries
.
map
(
function
(
q
)
{
queries
.
map
(
function
(
q
)
{
...
@@ -253,10 +256,12 @@ router.post('/score', function (req, res) {
...
@@ -253,10 +256,12 @@ router.post('/score', function (req, res) {
if
(
userscoreA
>
userscoreB
)
{
if
(
userscoreA
>
userscoreB
)
{
paramA
[
'
entertain_win
'
]
=
1
paramA
[
'
entertain_win
'
]
=
1
paramB
[
'
entertain_lose
'
]
=
1
paramB
[
'
entertain_lose
'
]
=
1
winner
=
usernameA
}
}
if
(
userscoreA
<
userscoreB
)
{
if
(
userscoreA
<
userscoreB
)
{
paramA
[
'
entertain_lose
'
]
=
1
paramA
[
'
entertain_lose
'
]
=
1
paramB
[
'
entertain_win
'
]
=
1
paramB
[
'
entertain_win
'
]
=
1
winner
=
usernameB
}
}
if
(
userscoreA
===
userscoreB
)
{
if
(
userscoreA
===
userscoreB
)
{
paramA
[
'
entertain_draw
'
]
=
1
paramA
[
'
entertain_draw
'
]
=
1
...
@@ -277,6 +282,8 @@ router.post('/score', function (req, res) {
...
@@ -277,6 +282,8 @@ router.post('/score', function (req, res) {
entertain_all = entertain_all +
${
paramB
.
entertain_all
}
entertain_all = entertain_all +
${
paramB
.
entertain_all
}
where username = '
${
userB
.
username
}
'`
)
where username = '
${
userB
.
username
}
'`
)
queries
.
push
(
`insert into battle_history values (
queries
.
push
(
`insert into battle_history values (
'
${
userA
.
username
}
',
'
${
userA
.
username
}
',
'
${
userB
.
username
}
',
'
${
userB
.
username
}
',
...
@@ -292,7 +299,9 @@ router.post('/score', function (req, res) {
...
@@ -292,7 +299,9 @@ router.post('/score', function (req, res) {
'
${
userB
.
pt
}
',
'
${
userB
.
pt
}
',
'
${
arena
}
',
'
${
arena
}
',
'
${
start
}
',
'
${
start
}
',
'
${
end
}
'
'
${
end
}
',
'
${
winner
}
',
'
${
firstWin
}
'
)`
)
)`
)
queries
.
map
(
function
(
q
)
{
queries
.
map
(
function
(
q
)
{
...
...
test.js
View file @
1384e162
...
@@ -5,8 +5,8 @@ var superagent = require('superagent')
...
@@ -5,8 +5,8 @@ var superagent = require('superagent')
var
mement
=
require
(
'
moment
'
)
var
mement
=
require
(
'
moment
'
)
var
url
=
'
https://mycard.moe/ygopro/api/score
'
//
var url = 'https://mycard.moe/ygopro/api/score'
//
var url = 'http://localhost:3000/api/score'
var
url
=
'
http://localhost:3000/api/score
'
superagent
superagent
.
post
(
url
)
.
post
(
url
)
.
send
({
.
send
({
...
...
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