fix bugs
This commit is contained in:
parent
b80881719f
commit
b6f0503c9e
|
@ -90,10 +90,10 @@ class DoudizhuGameBoard extends React.Component {
|
||||||
const [rankClass, suitClass, rankText, suitText] = translateCardData(card);
|
const [rankClass, suitClass, rankText, suitText] = translateCardData(card);
|
||||||
return (
|
return (
|
||||||
<li key={`handCard-${card}`}>
|
<li key={`handCard-${card}`}>
|
||||||
<a className={`card ${rankClass} ${suitClass}`} href="javascript:void(0);">
|
<label className={`card ${rankClass} ${suitClass}`}>
|
||||||
<span className="rank">{rankText}</span>
|
<span className="rank">{rankText}</span>
|
||||||
<span className="suit">{suitText}</span>
|
<span className="suit">{suitText}</span>
|
||||||
</a>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
@ -107,10 +107,10 @@ class DoudizhuGameBoard extends React.Component {
|
||||||
const [rankClass, suitClass, rankText, suitText] = translateCardData(card);
|
const [rankClass, suitClass, rankText, suitText] = translateCardData(card);
|
||||||
return (
|
return (
|
||||||
<li key={`handCard-${card}`}>
|
<li key={`handCard-${card}`}>
|
||||||
<a className={`card ${rankClass} ${suitClass}`} href="javascript:void(0);">
|
<label className={`card ${rankClass} ${suitClass}`}>
|
||||||
<span className="rank">{rankText}</span>
|
<span className="rank">{rankText}</span>
|
||||||
<span className="suit">{suitText}</span>
|
<span className="suit">{suitText}</span>
|
||||||
</a>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
|
|
|
@ -1,14 +1,14 @@
|
||||||
|
import Button from '@material-ui/core/Button';
|
||||||
|
import Dialog from '@material-ui/core/Dialog';
|
||||||
|
import DialogActions from '@material-ui/core/DialogActions';
|
||||||
|
import DialogContent from '@material-ui/core/DialogContent';
|
||||||
|
import DialogContentText from '@material-ui/core/DialogContentText';
|
||||||
|
import DialogTitle from '@material-ui/core/DialogTitle';
|
||||||
import Paper from '@material-ui/core/Paper';
|
import Paper from '@material-ui/core/Paper';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { Layout, Message } from 'element-react';
|
import { Layout, Message } from 'element-react';
|
||||||
import qs from 'query-string';
|
import qs from 'query-string';
|
||||||
import React, { useEffect, useState } from 'react';
|
import React, { useEffect, useState } from 'react';
|
||||||
import DialogTitle from "@material-ui/core/DialogTitle";
|
|
||||||
import DialogContent from "@material-ui/core/DialogContent";
|
|
||||||
import DialogContentText from "@material-ui/core/DialogContentText";
|
|
||||||
import DialogActions from "@material-ui/core/DialogActions";
|
|
||||||
import Dialog from "@material-ui/core/Dialog";
|
|
||||||
import Button from '@material-ui/core/Button';
|
|
||||||
import { DoudizhuGameBoard } from '../../components/GameBoard';
|
import { DoudizhuGameBoard } from '../../components/GameBoard';
|
||||||
import {
|
import {
|
||||||
card2SuiteAndRank,
|
card2SuiteAndRank,
|
||||||
|
@ -204,18 +204,20 @@ function PvEDoudizhuDemoView() {
|
||||||
setToggleFade('');
|
setToggleFade('');
|
||||||
}, 200);
|
}, 200);
|
||||||
|
|
||||||
|
if (gameStateTimeout) {
|
||||||
|
clearTimeout(gameStateTimeout);
|
||||||
|
}
|
||||||
|
|
||||||
if (newHand.length === 0) {
|
if (newHand.length === 0) {
|
||||||
const winner = playerInfo[newGameState.currentPlayer];
|
const winner = playerInfo[gameState.currentPlayer];
|
||||||
setGameStatus('over');
|
setGameStatus('over');
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
gameEndDialogText = winner.role + ' wins!';
|
gameEndDialogText = winner.role + ' wins!';
|
||||||
setIsGameEndDialogOpen(true);
|
setIsGameEndDialogOpen(true);
|
||||||
}, 300);
|
}, 300);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gameStateTimeout) {
|
|
||||||
clearTimeout(gameStateTimeout);
|
|
||||||
}
|
|
||||||
setConsiderationTime(initConsiderationTime);
|
setConsiderationTime(initConsiderationTime);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -275,7 +277,7 @@ function PvEDoudizhuDemoView() {
|
||||||
|
|
||||||
if (data.status !== 0) {
|
if (data.status !== 0) {
|
||||||
if (data.status === -1) {
|
if (data.status === -1) {
|
||||||
// check if no legal action can be made
|
// check if no legal action or only one legal action can be made
|
||||||
const player_hand_cards = cardArr2DouzeroFormat(
|
const player_hand_cards = cardArr2DouzeroFormat(
|
||||||
gameState.hands[gameState.currentPlayer].slice().reverse(),
|
gameState.hands[gameState.currentPlayer].slice().reverse(),
|
||||||
);
|
);
|
||||||
|
@ -295,6 +297,8 @@ function PvEDoudizhuDemoView() {
|
||||||
};
|
};
|
||||||
const apiRes = await axios.post(`${douzeroDemoUrl}/legal`, qs.stringify(requestBody));
|
const apiRes = await axios.post(`${douzeroDemoUrl}/legal`, qs.stringify(requestBody));
|
||||||
if (apiRes.data.legal_action === '') proceedNextTurn([]);
|
if (apiRes.data.legal_action === '') proceedNextTurn([]);
|
||||||
|
else if (apiRes.data.legal_action.split(',').length === 1)
|
||||||
|
proceedNextTurn(apiRes.data.legal_action.split(''));
|
||||||
else {
|
else {
|
||||||
Message({
|
Message({
|
||||||
message: 'Error receiving prediction result, please try refresh the page',
|
message: 'Error receiving prediction result, please try refresh the page',
|
||||||
|
@ -359,7 +363,7 @@ function PvEDoudizhuDemoView() {
|
||||||
const handleCloseGameEndDialog = () => {
|
const handleCloseGameEndDialog = () => {
|
||||||
setIsGameEndDialogOpen(false);
|
setIsGameEndDialogOpen(false);
|
||||||
// todo: proceed next game option
|
// todo: proceed next game option
|
||||||
}
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
gameStateTimer();
|
gameStateTimer();
|
||||||
|
@ -435,11 +439,11 @@ function PvEDoudizhuDemoView() {
|
||||||
aria-labelledby="alert-dialog-title"
|
aria-labelledby="alert-dialog-title"
|
||||||
aria-describedby="alert-dialog-description"
|
aria-describedby="alert-dialog-description"
|
||||||
>
|
>
|
||||||
<DialogTitle id="alert-dialog-title" style={{"width": "200px"}}>{"Game Ends!"}</DialogTitle>
|
<DialogTitle id="alert-dialog-title" style={{ width: '200px' }}>
|
||||||
|
{'Game Ends!'}
|
||||||
|
</DialogTitle>
|
||||||
<DialogContent>
|
<DialogContent>
|
||||||
<DialogContentText id="alert-dialog-description">
|
<DialogContentText id="alert-dialog-description">{gameEndDialogText}</DialogContentText>
|
||||||
{gameEndDialogText}
|
|
||||||
</DialogContentText>
|
|
||||||
</DialogContent>
|
</DialogContent>
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={handleCloseGameEndDialog} color="primary" autoFocus>
|
<Button onClick={handleCloseGameEndDialog} color="primary" autoFocus>
|
||||||
|
|
Loading…
Reference in New Issue