diff --git a/src/locales/en/translation.json b/src/locales/en/translation.json
index 2b0f37b..a9d1094 100644
--- a/src/locales/en/translation.json
+++ b/src/locales/en/translation.json
@@ -8,6 +8,7 @@
"doudizhu": {
"ai_hand_faceup": "AI Hand Face-Up",
+ "ai_prediction": "AI Prediction",
"play_as_landlord": "Play As Landlord",
"play_as_peasant": "Play As Peasant",
"landlord_up": "Landlord Up",
diff --git a/src/locales/zh/translation.json b/src/locales/zh/translation.json
index 5f5d542..a32ba82 100644
--- a/src/locales/zh/translation.json
+++ b/src/locales/zh/translation.json
@@ -8,6 +8,7 @@
"doudizhu": {
"ai_hand_faceup": "显示AI手牌",
+ "ai_prediction": "显示AI预测",
"play_as_landlord": "扮演地主",
"play_as_peasant": "扮演农民",
"landlord_up": "地主上家",
diff --git a/src/view/PvEView/PvEDoudizhuDemoView.js b/src/view/PvEView/PvEDoudizhuDemoView.js
index 9435f8c..28d3dd1 100644
--- a/src/view/PvEView/PvEDoudizhuDemoView.js
+++ b/src/view/PvEView/PvEDoudizhuDemoView.js
@@ -356,7 +356,7 @@ function PvEDoudizhuDemoView() {
}
};
- const requestApiPlay = async () => {
+ const requestApiPlay = async (eval_only) => {
// gather information for api request
const player_position = playerInfo[gameState.currentPlayer].douzeroPlayerPosition;
const player_hand_cards = cardArr2DouzeroFormat(gameState.hands[gameState.currentPlayer].slice().reverse());
@@ -444,13 +444,17 @@ function PvEDoudizhuDemoView() {
};
const apiRes = await axios.post(`${douzeroDemoUrl}/legal`, qs.stringify(requestBody));
if (apiRes.data.legal_action === '') {
- proceedNextTurn([]);
+ if(!eval_only) {
+ proceedNextTurn([]);
+ }
setPredictionRes({
prediction: [['', t('doudizhu.only_choice')]],
hands: gameState.hands[gameState.currentPlayer].slice(),
});
} else if (apiRes.data.legal_action.split(',').length === 1) {
- proceedNextTurn(apiRes.data.legal_action.split(''));
+ if(!eval_only) {
+ proceedNextTurn(apiRes.data.legal_action.split(''));
+ }
setPredictionRes({
prediction: [[apiRes.data.legal_action, t('doudizhu.only_choice')]],
hands: gameState.hands[gameState.currentPlayer].slice(),
@@ -493,7 +497,9 @@ function PvEDoudizhuDemoView() {
}
}
}
- proceedNextTurn(bestAction.split(''));
+ if(!eval_only) {
+ proceedNextTurn(bestAction.split(''));
+ }
}
} catch (err) {
Message({
@@ -715,7 +721,9 @@ function PvEDoudizhuDemoView() {
if (gameState.currentPlayer !== null && syncGameStatus === 'playing') {
// if current player is not user, request for API player
if (gameState.currentPlayer !== mainPlayerId) {
- requestApiPlay();
+ requestApiPlay(false);
+ } else if (!hidePredictionArea) {
+ requestApiPlay(true);
} else {
setPredictionRes({ prediction: [], hands: [] });
}
@@ -1056,10 +1064,18 @@ function PvEDoudizhuDemoView() {
style={{ textAlign: 'center', height: '100%', display: 'inline-block' }}
className="switch-control"
control={
-
+
}
label={t('doudizhu.ai_hand_faceup')}
/>
+
+ }
+ label={t('doudizhu.ai_prediction')}
+ />