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
2ca638be
Commit
2ca638be
authored
Feb 09, 2017
by
ganjingcun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add battle history
parent
936b6144
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
44 additions
and
8 deletions
+44
-8
routes/api.js
routes/api.js
+36
-0
test.js
test.js
+8
-8
No files found.
routes/api.js
View file @
2ca638be
...
@@ -144,6 +144,24 @@ router.post('/score', function (req, res) {
...
@@ -144,6 +144,24 @@ router.post('/score', function (req, res) {
athletic_all = athletic_all +
${
paramB
.
athletic_all
}
athletic_all = athletic_all +
${
paramB
.
athletic_all
}
where username = '
${
userB
.
username
}
'`
)
where username = '
${
userB
.
username
}
'`
)
queries
.
push
(
`insert into battle_history values (
'
${
userA
.
username
}
',
'
${
userB
.
username
}
',
'
${
userscoreA
}
',
'
${
userscoreB
}
',
'
${
expResult
.
expA
}
',
'
${
expResult
.
expB
}
',
'
${
userA
.
exp
}
',
'
${
userB
.
exp
}
',
'
${
ptResult
.
ptA
}
',
'
${
ptResult
.
ptB
}
',
'
${
userA
.
pt
}
',
'
${
userB
.
pt
}
',
'
${
arena
}
',
'
${
start
}
',
'
${
end
}
'
)`
)
}
else
{
}
else
{
let
expResult
=
utils
.
getExpScore
(
userA
.
exp
,
userB
.
exp
,
userscoreA
,
userscoreB
)
let
expResult
=
utils
.
getExpScore
(
userA
.
exp
,
userB
.
exp
,
userscoreA
,
userscoreB
)
...
@@ -174,6 +192,24 @@ router.post('/score', function (req, res) {
...
@@ -174,6 +192,24 @@ 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 (
'
${
userA
.
username
}
',
'
${
userB
.
username
}
',
'
${
userscoreA
}
',
'
${
userscoreB
}
',
'
${
expResult
.
expA
}
',
'
${
expResult
.
expB
}
',
'
${
userA
.
exp
}
',
'
${
userB
.
exp
}
',
'
${
userA
.
pt
}
',
'
${
userB
.
pt
}
',
'
${
userA
.
pt
}
',
'
${
userB
.
pt
}
',
'
${
arena
}
',
'
${
start
}
',
'
${
end
}
'
)`
)
}
}
queries
.
map
(
function
(
q
)
{
queries
.
map
(
function
(
q
)
{
...
...
test.js
View file @
2ca638be
...
@@ -22,14 +22,14 @@ superagent
...
@@ -22,14 +22,14 @@ superagent
console
.
log
(
res
.
text
)
console
.
log
(
res
.
text
)
})
})
var
Utils
=
require
(
'
./utils/utils
'
)
//
var Utils = require('./utils/utils')
console
.
log
(
"
pt test: ptA 1613 ,ptB 1573 draw =>
"
,
Utils
.
getEloScore
(
1613
,
1573
,
0.5
,
0.5
))
//
console.log("pt test: ptA 1613 ,ptB 1573 draw => ", Utils.getEloScore(1613, 1573, 0.5, 0.5))
console
.
log
(
"
exp test: expA 100 ,expB 50 A win =>
"
,
Utils
.
getExpScore
(
100
,
50
,
2
,
1
))
//
console.log("exp test: expA 100 ,expB 50 A win => ", Utils.getExpScore(100, 50, 2, 1))
console
.
log
(
"
exp test: expA 100 ,expB 50 B win =>
"
,
Utils
.
getExpScore
(
100
,
50
,
1
,
2
))
//
console.log("exp test: expA 100 ,expB 50 B win => ", Utils.getExpScore(100, 50, 1, 2))
console
.
log
(
"
exp test: expA 100 ,expB 50 draw =>
"
,
Utils
.
getExpScore
(
100
,
50
,
2
,
2
))
//
console.log("exp test: expA 100 ,expB 50 draw => ", Utils.getExpScore(100, 50, 2, 2))
console
.
log
(
"
exp test: expA 5 ,expB 5 A win =>
"
,
Utils
.
getExpScore
(
5
,
5
,
2
,
1
))
// console.log("exp test: expA 5 ,expB 5 A win => ", Utils.getExpScore(5, 5, 2, 1))
console
.
log
(
"
exp test: expA 5 ,expB 5 B win =>
"
,
Utils
.
getExpScore
(
5
,
5
,
1
,
2
))
// console.log("exp test: expA 5 ,expB 5 B win => ", Utils.getExpScore(5, 5, 1, 2))
console
.
log
(
"
exp test: expA 5 ,expB 5 draw =>
"
,
Utils
.
getExpScore
(
5
,
5
,
2
,
2
))
// console.log("exp test: expA 5 ,expB 5 draw => ", Utils.getExpScore(5, 5, 2, 2))
\ No newline at end of file
\ No newline at end of file
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