Commit 1384e162 authored by ganjingcun's avatar ganjingcun

asd

parent 5c83e06e
...@@ -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) {
......
...@@ -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({
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment