X-Git-Url: https://git.auder.net/?a=blobdiff_plain;f=variants%2FDice%2Fclass.js;h=53836eb5f1c418323f7bf19fa821d63237c5dbf7;hb=939e06bf9febef0a7935c7f6a58c5e28dee4dedc;hp=02e4f6d2a9fc2597a42d338bd286bd812cb2e4f9;hpb=7fbcb53de45ba7b7aed99d6087928779713810b1;p=xogo.git
diff --git a/variants/Dice/class.js b/variants/Dice/class.js
index 02e4f6d..53836eb 100644
--- a/variants/Dice/class.js
+++ b/variants/Dice/class.js
@@ -54,20 +54,39 @@ export default class DiceRules extends ChessRules {
this.afterPlay = (move_s, newTurn, ops) => {
// Movestack contains only one move:
move_s[0].toplay = this.getRandomPiece(this.turn);
- super.displayMessage(
- this.message, "To play: " + move_s[0].toplay.toUpperCase());
+ this.toplay = move_s[0].toplay;
+ this.displayMessage(move_s[0].toplay,
+ C.GetOppTurn(move_s[0].appear[0].c));
o.afterPlay(move_s, newTurn, ops);
};
}
+ displayMessage(piece, color) {
+ if (color == 'b') {
+ const blackPieceToCode = {
+ 'k': 'l',
+ 'p': 'o',
+ 'n': 'm',
+ 'b': 'v',
+ 'q': 'w',
+ 'r': 't'
+ };
+ piece = blackPieceToCode[piece];
+ }
+ super.displayMessage(this.message,
+ 'to play: ' +
+ '' + piece + ''
+ );
+ }
+
setOtherVariables(fenParsed) {
super.setOtherVariables(fenParsed);
this.toplay = fenParsed.toplay;
this.message = document.createElement("div");
C.AddClass_es(this.message, "piece-text");
- this.message.innerHTML = "To play: " + this.toplay.toUpperCase();
let container = document.getElementById(this.containerId);
container.appendChild(this.message);
+ this.displayMessage(this.toplay, fenParsed.turn);
}
getRandomPiece(color) {
@@ -102,8 +121,7 @@ export default class DiceRules extends ChessRules {
playReceivedMove(moves, callback) {
this.toplay = moves[0].toplay; //only one move
- super.displayMessage(
- this.message, "To play: " + this.toplay.toUpperCase());
+ this.displayMessage(this.toplay, C.GetOppTurn(moves[0].appear[0].c));
super.playReceivedMove(moves, callback);
}