2020-01-13 06:01:31 +08:00
|
|
|
const express = require("express");
|
2020-01-30 13:35:56 +08:00
|
|
|
const router = require("express").Router();
|
2020-01-13 06:01:31 +08:00
|
|
|
const cors = require("cors");
|
2020-01-13 15:55:10 +08:00
|
|
|
const fs = require("fs");
|
2020-01-13 06:01:31 +08:00
|
|
|
|
|
|
|
const app = express();
|
|
|
|
const port = process.env.PORT || 10080;
|
|
|
|
|
|
|
|
app.use(cors());
|
|
|
|
app.use(express.json());
|
|
|
|
|
2020-02-07 14:51:26 +08:00
|
|
|
app.listen(port, () => {
|
2020-01-13 06:01:31 +08:00
|
|
|
console.log(`Server is running on port: ${port}`);
|
2020-01-13 15:55:10 +08:00
|
|
|
});
|
2020-01-13 06:01:31 +08:00
|
|
|
|
2020-01-30 13:35:56 +08:00
|
|
|
let testDoudizhuData = null, testLeducHoldemData = null;
|
2020-01-13 15:55:10 +08:00
|
|
|
|
2020-01-30 13:35:56 +08:00
|
|
|
router.get('/replay/leduc_holdem/:id', (req, res)=>{
|
|
|
|
res.json(testLeducHoldemData);
|
|
|
|
});
|
|
|
|
|
|
|
|
router.get('/replay/doudizhu/:id', (req, res)=>{
|
|
|
|
res.json(testDoudizhuData);
|
|
|
|
});
|
|
|
|
|
|
|
|
app.use(router);
|
|
|
|
|
2020-01-13 15:55:10 +08:00
|
|
|
function getGameHistory(){
|
|
|
|
fs.readFile("./sample_data/sample_doudizhu.json", (err, data) => {
|
|
|
|
if (err) throw err;
|
|
|
|
testDoudizhuData = JSON.parse(data);
|
|
|
|
console.log(testDoudizhuData);
|
|
|
|
});
|
2020-01-30 13:35:56 +08:00
|
|
|
|
2020-02-12 05:21:55 +08:00
|
|
|
fs.readFile("./sample_data/sample_leduc_holdem.json", (err, data) => {
|
2020-01-30 13:35:56 +08:00
|
|
|
if (err) throw err;
|
|
|
|
testLeducHoldemData = JSON.parse(data);
|
|
|
|
console.log(testLeducHoldemData);
|
2020-02-01 09:43:49 +08:00
|
|
|
});
|
2020-01-13 15:55:10 +08:00
|
|
|
}
|
|
|
|
|
2020-01-30 13:35:56 +08:00
|
|
|
getGameHistory();
|
|
|
|
|
|
|
|
module.exports = router;
|