Commit eeea4bec authored by ganjingcun's avatar ganjingcun

card info api

parent ff6748fe
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
"start": "node ./bin/www" "start": "node ./bin/www"
}, },
"dependencies": { "dependencies": {
"async": "^2.1.5",
"body-parser": "~1.15.2", "body-parser": "~1.15.2",
"cookie-parser": "~1.4.3", "cookie-parser": "~1.4.3",
"debug": "~2.2.0", "debug": "~2.2.0",
...@@ -16,6 +17,7 @@ ...@@ -16,6 +17,7 @@
"pg": "^6.1.0", "pg": "^6.1.0",
"serve-favicon": "~2.3.0", "serve-favicon": "~2.3.0",
"sqlite3": "3.1.8", "sqlite3": "3.1.8",
"superagent": "^3.3.1" "superagent": "^3.3.1",
"underscore": "^1.8.3"
} }
} }
...@@ -302,7 +302,7 @@ router.get('/cardinfo', function (req, res) { ...@@ -302,7 +302,7 @@ router.get('/cardinfo', function (req, res) {
db.serialize(function () { db.serialize(function () {
db.get(`SELECT name , desc FROM texts where id = ${id}`, function (err, row) { db.get(`SELECT name , desc, str1, str2, str3 FROM texts where id = ${id}`, function (err, row) {
if (err) { if (err) {
console.error(err) console.error(err)
...@@ -312,10 +312,14 @@ router.get('/cardinfo', function (req, res) { ...@@ -312,10 +312,14 @@ router.get('/cardinfo', function (req, res) {
return res.status(404).send('card info not found!') return res.status(404).send('card info not found!')
} }
result.id = id
result.name = row.name result.name = row.name
result.desc = row.desc result.desc = row.desc
result.str1 = row.str1
result.str2 = row.str2
result.str3 = row.str3
db.get(`SELECT atk , def FROM datas where id = ${id}`, function (err, row) { db.get(`SELECT * FROM datas where id = ${id}`, function (err, row) {
if (err) { if (err) {
console.error(err) console.error(err)
return res.status(500).send('sqlite error!') return res.status(500).send('sqlite error!')
...@@ -324,8 +328,16 @@ router.get('/cardinfo', function (req, res) { ...@@ -324,8 +328,16 @@ router.get('/cardinfo', function (req, res) {
return res.status(404).send('card info not found!') return res.status(404).send('card info not found!')
} }
result.ot = row.ot
result.alias = row.alias
result.setcode = row.setcode
result.type = row.type
result.atk = row.atk result.atk = row.atk
result.def = row.def result.def = row.def
result.level = row.level
result.race = row.race
result.attribute = row.attribute
result.category = row.category
res.json(result); res.json(result);
}); });
......
var fs = require('fs');
var _ = require('underscore');
var async = require('async');
var filePath = "./locales/zh-CN/strings.conf"
var filePath2 = "./locales/en-US/strings.conf"
async.parallel([
function (callback) {
fs.readFile(filePath, 'utf8', (err, data) => {
if (err) throw err;
var strings = data.split("\n")
.filter((s) => {
return s.startsWith("!")
}).map(s => {
let strs = s.split(" ")
return { [strs[1]]: strs[2] }
}).filter((s) => {
var key = Object.keys(s)[0]
return !isNaN(key) && (key > 1000 && key < 1050)
})
callback(null, strings)
});
},
function (callback) {
fs.readFile(filePath2, 'utf8', (err, data) => {
if (err) throw err;
var strings = data.split("\n")
.filter((s) => {
return s.startsWith("!")
}).map(s => {
let strs = s.split(" ")
return { [strs[1]]: strs[2] }
}).filter((s) => {
var key = Object.keys(s)[0]
return !isNaN(key) && (key > 1000 && key < 1050)
})
callback(null, strings)
});
}],
function (err, results) {
console.log(err)
console.log(JSON.stringify(results))
});
\ No newline at end of file
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