diff --git a/server/index.js b/server/index.js index 9a234be..bf22240 100644 --- a/server/index.js +++ b/server/index.js @@ -1,4 +1,5 @@ const express = require("express"); +const router = require("express").Router(); const cors = require("cors"); const fs = require("fs"); @@ -15,7 +16,7 @@ const server = app.listen(port, () => { const socket = require("socket.io"); const io = socket(server); -let testDoudizhuData = null; +let testDoudizhuData = null, testLeducHoldemData = null; io.on("connection", socket => { console.log("successfully connected to rlcard showdown frontend"); @@ -55,12 +56,30 @@ io.on("connection", socket => { }) }); +router.get('/replay/leduc_holdem/:id', (req, res)=>{ + res.json(testLeducHoldemData); +}); + +router.get('/replay/doudizhu/:id', (req, res)=>{ + res.json(testDoudizhuData); +}); + +app.use(router); + function getGameHistory(){ fs.readFile("./sample_data/sample_doudizhu.json", (err, data) => { if (err) throw err; testDoudizhuData = JSON.parse(data); console.log(testDoudizhuData); }); + + fs.readFile("./sample_data/sample_leduc_holdem.json", (err, data) => { + if (err) throw err; + testLeducHoldemData = JSON.parse(data); + console.log(testLeducHoldemData); + }); } -getGameHistory(); \ No newline at end of file +getGameHistory(); + +module.exports = router; \ No newline at end of file diff --git a/server/sample_data/sample_leduc_holdem.json b/server/sample_data/sample_leduc_holdem.json new file mode 100644 index 0000000..515b1b0 --- /dev/null +++ b/server/sample_data/sample_leduc_holdem.json @@ -0,0 +1,55 @@ +{ + "initHands": [ + "HJ", + "HK" + ], + "playerInfo": [ + { + "id": 0, + "index": 0 + }, + { + "id": 1, + "index": 1 + } + ], + "moveHistory": [ + [ + { + "playerIdx": 0, + "move": "Check" + }, + { + "playerIdx": 1, + "move": "Raise" + }, + { + "playerIdx": 0, + "move": "Call" + }, + { + "playerIdx": 1, + "move": "Check" + } + ], + "SJ", + [ + { + "playerIdx": 0, + "move": "Raise" + }, + { + "playerIdx": 1, + "move": "Call" + }, + { + "playerIdx": 0, + "move": "Raise" + }, + { + "playerIdx": 1, + "move": "Call" + } + ] + ] +} \ No newline at end of file diff --git a/src/components/GameBoard/LeducHoldemGameBoard.js b/src/components/GameBoard/LeducHoldemGameBoard.js index a5f5281..d0db72e 100644 --- a/src/components/GameBoard/LeducHoldemGameBoard.js +++ b/src/components/GameBoard/LeducHoldemGameBoard.js @@ -8,7 +8,19 @@ class LeducHoldemGameBoard extends React.Component { render() { return ( -
Leduc Holdem GameBoard Placeholder
+
+
+
+ played card area +
+
+
+ {`Player Id ${bottomId}\n${this.props.playerInfo.length > 0 ? this.props.playerInfo[bottomIdx].role : ""}`} +
+ {bottomIdx >= 0 ?
{this.computeSingleLineHand(this.props.hands[bottomIdx])}
:
Waiting...
} +
+
+
); } } diff --git a/src/view/LeducHoldemGameView.js b/src/view/LeducHoldemGameView.js index ff43454..dbcc98b 100644 --- a/src/view/LeducHoldemGameView.js +++ b/src/view/LeducHoldemGameView.js @@ -1,6 +1,6 @@ import React from 'react'; import '../assets/gameview.scss'; -import { LeducHoldemGameBoard } from '../components/GameBoard'; +import {DoudizhuGameBoard, LeducHoldemGameBoard} from '../components/GameBoard'; import {removeCards, doubleRaf} from "../utils"; import { Button, Layout, Slider as elSlider } from 'element-react'; @@ -13,7 +13,18 @@ class LeducHoldemGameView extends React.Component { render(){ return ( -
Leduc Holdem Placeholder
+
+ this.runNewTurn(prevTurn)} + /> +
); } }