From 9144683de37f4262ead04030f46a466d0db84ea0 Mon Sep 17 00:00:00 2001 From: djmil Date: Wed, 27 Sep 2023 11:35:49 +0200 Subject: [PATCH] rename Piece to Stone --- .../cordaclient/CordaClient.java | 4 +- .../cordaclient/dao/GameState.java | 4 +- .../dao/{Piece.java => Stone.java} | 8 +-- .../flow/arguments/ReqGameProposalCreate.java | 4 +- .../gameproposal/GameProposalController.java | 4 +- .../cordaclient/GameBoardTests.java | 20 +++--- .../cordaclient/GameProposalTests.java | 4 +- .../cordaclient/GameStateTests.java | 4 +- .../cordaclient/RankingTests.java | 4 +- .../contracts/GameBoardContract.java | 71 +++++++++---------- .../cordacheckers/states/GameBoardState.java | 18 ++--- .../djmil/cordacheckers/states/GameState.java | 6 +- .../states/{Piece.java => Stone.java} | 11 ++- .../gameproposal/CreateFlow.java | 10 +-- .../djmil/cordacheckers/gamestate/View.java | 6 +- 15 files changed, 89 insertions(+), 89 deletions(-) rename backend/src/main/java/djmil/cordacheckers/cordaclient/dao/{Piece.java => Stone.java} (89%) rename corda/contracts/src/main/java/djmil/cordacheckers/states/{Piece.java => Stone.java} (73%) diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java index 2bc9eee..245d7a7 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/CordaClient.java @@ -18,7 +18,7 @@ import com.fasterxml.jackson.databind.ObjectMapper; import djmil.cordacheckers.cordaclient.dao.GameState; import djmil.cordacheckers.cordaclient.dao.HoldingIdentity; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.cordaclient.dao.Rank; import djmil.cordacheckers.cordaclient.dao.VirtualNode; import djmil.cordacheckers.cordaclient.dao.VirtualNodeList; @@ -95,7 +95,7 @@ public class CordaClient { .getResponce(requestBody); } - public GameState gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Piece.Color acquierColor, + public GameState gameProposalCreate(HoldingIdentity issuer, HoldingIdentity acquier, Stone.Color acquierColor, String message ) { final RequestBody requestBody = new RequestBody( diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/GameState.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/GameState.java index 6271a03..a68ae73 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/GameState.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/GameState.java @@ -7,9 +7,9 @@ import java.util.UUID; public record GameState( Status status, String opponentName, - Piece.Color opponentColor, + Stone.Color opponentColor, - Map board, + Map board, Integer moveNumber, List previousMove, diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Piece.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Stone.java similarity index 89% rename from backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Piece.java rename to backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Stone.java index c283f0f..68e55d4 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Piece.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/Stone.java @@ -1,6 +1,6 @@ package djmil.cordacheckers.cordaclient.dao; -public class Piece { +public class Stone { public enum Type { MAN, @@ -19,12 +19,12 @@ public class Piece { Color color; Type type; - public Piece() { + public Stone() { this.color = null; this.type = null; } - public Piece(Color color, Type type) { + public Stone(Color color, Type type) { this.color = color; this.type = type; } @@ -50,7 +50,7 @@ public class Piece { return false; if (getClass() != obj.getClass()) return false; - Piece other = (Piece) obj; + Stone other = (Stone) obj; if (color != other.color) return false; if (type != other.type) diff --git a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/ReqGameProposalCreate.java b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/ReqGameProposalCreate.java index ff76911..358619f 100644 --- a/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/ReqGameProposalCreate.java +++ b/backend/src/main/java/djmil/cordacheckers/cordaclient/dao/flow/arguments/ReqGameProposalCreate.java @@ -1,10 +1,10 @@ package djmil.cordacheckers.cordaclient.dao.flow.arguments; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; public record ReqGameProposalCreate( String opponentName, - Piece.Color opponentColor, + Stone.Color opponentColor, String message ) { diff --git a/backend/src/main/java/djmil/cordacheckers/gameproposal/GameProposalController.java b/backend/src/main/java/djmil/cordacheckers/gameproposal/GameProposalController.java index bdf4b25..7f387b7 100644 --- a/backend/src/main/java/djmil/cordacheckers/gameproposal/GameProposalController.java +++ b/backend/src/main/java/djmil/cordacheckers/gameproposal/GameProposalController.java @@ -19,7 +19,7 @@ import com.fasterxml.jackson.databind.JsonMappingException; import djmil.cordacheckers.cordaclient.CordaClient; import djmil.cordacheckers.cordaclient.dao.GameState; import djmil.cordacheckers.cordaclient.dao.HoldingIdentity; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.cordaclient.dao.flow.arguments.ReqGameProposalCreate; import djmil.cordacheckers.user.HoldingIdentityResolver; import djmil.cordacheckers.user.User; @@ -59,7 +59,7 @@ public class GameProposalController { final HoldingIdentity gpSender = sender.getHoldingIdentity(); // TODO: throw execption with custom type final HoldingIdentity gpReceiver = holdingIdentityResolver.getByUsername(gpRequest.opponentName()); - final Piece.Color gpReceiverColor = gpRequest.opponentColor(); + final Stone.Color gpReceiverColor = gpRequest.opponentColor(); // TODO handle expectionns here GameState gameStateView = cordaClient.gameProposalCreate( diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java index 741a008..86d79ab 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameBoardTests.java @@ -12,7 +12,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameState; import djmil.cordacheckers.cordaclient.dao.GameState.Status; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.user.HoldingIdentityResolver; @SpringBootTest @@ -26,10 +26,10 @@ public class GameBoardTests { final String whitePlayerName = "alice"; final String blackPlayerName = "bob"; - final static Piece WHITE_MAN = new Piece(Piece.Color.WHITE, Piece.Type.MAN); - final static Piece WHITE_KING = new Piece(Piece.Color.WHITE, Piece.Type.KING); - final static Piece BLACK_MAN = new Piece(Piece.Color.BLACK, Piece.Type.MAN); - final static Piece BLACK_KING = new Piece(Piece.Color.BLACK, Piece.Type.KING); + final static Stone WHITE_MAN = new Stone(Stone.Color.WHITE, Stone.Type.MAN); + final static Stone WHITE_KING = new Stone(Stone.Color.WHITE, Stone.Type.KING); + final static Stone BLACK_MAN = new Stone(Stone.Color.BLACK, Stone.Type.MAN); + final static Stone BLACK_KING = new Stone(Stone.Color.BLACK, Stone.Type.KING); @Test void testSurrender() { @@ -38,14 +38,14 @@ public class GameBoardTests { final String message = "GameBoard SURRENDER test"; final GameState game = cordaClient.gameProposalCreate( - hiWhite, hiBlack, Piece.Color.BLACK, message); + hiWhite, hiBlack, Stone.Color.BLACK, message); System.out.println("Game UUID " +game.uuid()); final GameState acceptedGameBlackView = cordaClient.gameProposalAccept( hiBlack, game.uuid()); - assertThat(acceptedGameBlackView.opponentColor()).isEqualByComparingTo(Piece.Color.WHITE); + assertThat(acceptedGameBlackView.opponentColor()).isEqualByComparingTo(Stone.Color.WHITE); assertThat(acceptedGameBlackView.status()).isEqualByComparingTo(Status.GAME_BOARD_WAIT_FOR_OPPONENT); assertThatThrownBy(() -> { // Black can not surrender, since it is opponent's turn @@ -57,14 +57,14 @@ public class GameBoardTests { hiWhite, game.uuid()); assertThat(surrendererGameView.opponentName()).isEqualToIgnoringCase(blackPlayerName); - assertThat(surrendererGameView.opponentColor()).isEqualByComparingTo(Piece.Color.BLACK); + assertThat(surrendererGameView.opponentColor()).isEqualByComparingTo(Stone.Color.BLACK); assertThat(surrendererGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_LOOSE); final GameState winnerGameView = cordaClient.gameStateGet( hiBlack, game.uuid()); assertThat(winnerGameView.opponentName()).isEqualToIgnoringCase(whitePlayerName); - assertThat(winnerGameView.opponentColor()).isEqualByComparingTo(Piece.Color.WHITE); + assertThat(winnerGameView.opponentColor()).isEqualByComparingTo(Stone.Color.WHITE); assertThat(winnerGameView.status()).isEqualByComparingTo(Status.GAME_RESULT_YOU_WON); } @@ -75,7 +75,7 @@ public class GameBoardTests { final String message = "GameBoard MOVE test"; final GameState game = cordaClient.gameProposalCreate( - hiWhite, hiBlack, Piece.Color.BLACK, message); + hiWhite, hiBlack, Stone.Color.BLACK, message); System.out.println("Game UUID " +game.uuid()); final var m0 = cordaClient.gameProposalAccept(hiBlack, game.uuid()); diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java index e8de3f3..3a59a0b 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameProposalTests.java @@ -10,7 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameState; import djmil.cordacheckers.cordaclient.dao.GameState.Status; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.user.HoldingIdentityResolver; @SpringBootTest @@ -23,7 +23,7 @@ public class GameProposalTests { final String issuer = "alice"; final String acquier = "bob"; - final Piece.Color acquierColor = Piece.Color.WHITE; + final Stone.Color acquierColor = Stone.Color.WHITE; @Test void testCreate() { diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java index d466705..d410307 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/GameStateTests.java @@ -8,7 +8,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameState; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.user.HoldingIdentityResolver; @SpringBootTest @@ -21,7 +21,7 @@ public class GameStateTests { final String issuer = "alice"; final String acquier = "bob"; - final Piece.Color acquierColor = Piece.Color.WHITE; + final Stone.Color acquierColor = Stone.Color.WHITE; @Test void testList() { diff --git a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java index 249473c..ef3c087 100644 --- a/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java +++ b/backend/src/test/java/djmil/cordacheckers/cordaclient/RankingTests.java @@ -9,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import djmil.cordacheckers.cordaclient.dao.GameState; -import djmil.cordacheckers.cordaclient.dao.Piece; +import djmil.cordacheckers.cordaclient.dao.Stone; import djmil.cordacheckers.cordaclient.dao.Rank; import djmil.cordacheckers.user.HoldingIdentityResolver; @@ -32,7 +32,7 @@ public class RankingTests { final var hiLooser = holdingIdentityResolver.getByUsername("Bob"); final GameState game = cordaClient.gameProposalCreate( - hiWinner, hiLooser, Piece.Color.WHITE, "GameBoard GLOBAL_RANKING test"); + hiWinner, hiLooser, Stone.Color.WHITE, "GameBoard GLOBAL_RANKING test"); cordaClient.gameProposalAccept(hiLooser, game.uuid()); cordaClient.gameBoardSurrender(hiLooser, game.uuid()); diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameBoardContract.java b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameBoardContract.java index b9fe620..407aca3 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameBoardContract.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/contracts/GameBoardContract.java @@ -10,17 +10,17 @@ import java.util.Map; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import djmil.cordacheckers.states.Piece; -import djmil.cordacheckers.states.Piece.Color; +import djmil.cordacheckers.states.Stone; +import djmil.cordacheckers.states.Stone.Color; import net.corda.v5.ledger.utxo.transaction.UtxoLedgerTransaction; public class GameBoardContract implements net.corda.v5.ledger.utxo.Contract { public static class MoveResult { - final public Map board; - final public Piece.Color moveColor; + final public Map board; + final public Stone.Color moveColor; - public MoveResult(Map board, Color moveColor) { + public MoveResult(Map board, Color moveColor) { this.board = board; this.moveColor = moveColor; } @@ -59,11 +59,11 @@ public class GameBoardContract implements net.corda.v5.ledger.utxo.Contract { } } - public static MoveResult applyMove(List move, Map board, Piece.Color moveColor) { + public static MoveResult applyMove(List move, Map board, Stone.Color moveColor) { final int mFrom = move.get(0); final int mTo = move.get(1); - final Piece piece = board.get(mFrom); + final Stone piece = board.get(mFrom); if (piece == null) throw new MoveResult.Exception("An empty starting tile"); @@ -73,45 +73,40 @@ public class GameBoardContract implements net.corda.v5.ledger.utxo.Contract { if (board.get(mTo) != null) throw new MoveResult.Exception("An occupied finishing tile"); - final Map newBoard = new LinkedHashMap(board); + final Map newBoard = new LinkedHashMap(board); newBoard.remove(mFrom); newBoard.put(mTo, piece); return new GameBoardContract.MoveResult(newBoard, moveColor.opposite()); } - final static Piece WHITE_MAN = new Piece(Piece.Color.WHITE, Piece.Type.MAN); - final static Piece WHITE_KING = new Piece(Piece.Color.WHITE, Piece.Type.KING); - final static Piece BLACK_MAN = new Piece(Piece.Color.BLACK, Piece.Type.MAN); - final static Piece BLACK_KING = new Piece(Piece.Color.BLACK, Piece.Type.KING); - - public final static Map initialBoard = Map.ofEntries( + public final static Map initialBoard = Map.ofEntries( // Inspired by Checkers notation rules: https://www.bobnewell.net/nucleus/checkers.php - Map.entry( 1, BLACK_MAN), - Map.entry( 2, BLACK_MAN), - Map.entry( 3, BLACK_MAN), - Map.entry( 4, BLACK_MAN), - Map.entry( 5, BLACK_MAN), - Map.entry( 6, BLACK_MAN), - Map.entry( 7, BLACK_MAN), - Map.entry( 8, BLACK_MAN), - Map.entry( 9, BLACK_MAN), - Map.entry(10, BLACK_MAN), - Map.entry(11, BLACK_MAN), - Map.entry(12, BLACK_MAN), + Map.entry( 1, Stone.BLACK_MAN), + Map.entry( 2, Stone.BLACK_MAN), + Map.entry( 3, Stone.BLACK_MAN), + Map.entry( 4, Stone.BLACK_MAN), + Map.entry( 5, Stone.BLACK_MAN), + Map.entry( 6, Stone.BLACK_MAN), + Map.entry( 7, Stone.BLACK_MAN), + Map.entry( 8, Stone.BLACK_MAN), + Map.entry( 9, Stone.BLACK_MAN), + Map.entry(10, Stone.BLACK_MAN), + Map.entry(11, Stone.BLACK_MAN), + Map.entry(12, Stone.BLACK_MAN), - Map.entry(21, WHITE_MAN), - Map.entry(22, WHITE_MAN), - Map.entry(23, WHITE_MAN), - Map.entry(24, WHITE_MAN), - Map.entry(25, WHITE_MAN), - Map.entry(26, WHITE_MAN), - Map.entry(27, WHITE_MAN), - Map.entry(28, WHITE_MAN), - Map.entry(29, WHITE_MAN), - Map.entry(30, WHITE_MAN), - Map.entry(31, WHITE_MAN), - Map.entry(32, WHITE_MAN) + Map.entry(21, Stone.WHITE_MAN), + Map.entry(22, Stone.WHITE_MAN), + Map.entry(23, Stone.WHITE_MAN), + Map.entry(24, Stone.WHITE_MAN), + Map.entry(25, Stone.WHITE_MAN), + Map.entry(26, Stone.WHITE_MAN), + Map.entry(27, Stone.WHITE_MAN), + Map.entry(28, Stone.WHITE_MAN), + Map.entry(29, Stone.WHITE_MAN), + Map.entry(30, Stone.WHITE_MAN), + Map.entry(31, Stone.WHITE_MAN), + Map.entry(32, Stone.WHITE_MAN) ); diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/states/GameBoardState.java b/corda/contracts/src/main/java/djmil/cordacheckers/states/GameBoardState.java index c8a8d0f..6f5f28c 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/states/GameBoardState.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/states/GameBoardState.java @@ -8,23 +8,23 @@ import java.util.UUID; import djmil.cordacheckers.contracts.GameBoardContract; import djmil.cordacheckers.contracts.GameBoardContract.MoveResult; -import djmil.cordacheckers.states.Piece.Color; +import djmil.cordacheckers.states.Stone.Color; import net.corda.v5.base.annotations.ConstructorForDeserialization; import net.corda.v5.base.types.MemberX500Name; import net.corda.v5.ledger.utxo.BelongsToContract; @BelongsToContract(GameBoardContract.class) public class GameBoardState extends GameState { - private final Piece.Color moveColor; + private final Stone.Color moveColor; private final Integer moveNumber; - private final Map board; + private final Map board; public GameBoardState(GameProposalState gameProposalState) { super(gameProposalState.whitePlayer, gameProposalState.blackPlayer, gameProposalState.gameUuid, gameProposalState.message, gameProposalState.participants); - this.board = new LinkedHashMap(GameBoardContract.initialBoard); - this.moveColor = Piece.Color.WHITE; + this.board = new LinkedHashMap(GameBoardContract.initialBoard); + this.moveColor = Stone.Color.WHITE; this.moveNumber = 0; } @@ -43,7 +43,7 @@ public class GameBoardState extends GameState { @ConstructorForDeserialization public GameBoardState(MemberX500Name whitePlayer, MemberX500Name blackPlayer, - Color moveColor, Integer moveNumber, Map board, String message, + Color moveColor, Integer moveNumber, Map board, String message, UUID gameUuid, List participants) { super(whitePlayer, blackPlayer, gameUuid, message, participants); @@ -52,7 +52,7 @@ public class GameBoardState extends GameState { this.board = board; } - public Piece.Color getMoveColor() { + public Stone.Color getMoveColor() { return moveColor; } @@ -61,10 +61,10 @@ public class GameBoardState extends GameState { } public MemberX500Name getActivePlayerName() { - return moveColor == Piece.Color.WHITE ? whitePlayer : blackPlayer; + return moveColor == Stone.Color.WHITE ? whitePlayer : blackPlayer; } - public Map getBoard() { + public Map getBoard() { return board; } diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/states/GameState.java b/corda/contracts/src/main/java/djmil/cordacheckers/states/GameState.java index 987e534..8b93508 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/states/GameState.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/states/GameState.java @@ -67,11 +67,11 @@ public abstract class GameState implements ContractState { throw new NotInvolved(playerName, this.getClass(), gameUuid); } - public Piece.Color getOpponentColor(MemberX500Name playerName) throws NotInvolved { + public Stone.Color getOpponentColor(MemberX500Name playerName) throws NotInvolved { if (playerName.compareTo(whitePlayer) == 0) - return Piece.Color.BLACK; + return Stone.Color.BLACK; if (playerName.compareTo(blackPlayer) == 0) - return Piece.Color.WHITE; + return Stone.Color.WHITE; throw new NotInvolved(playerName, this.getClass(), gameUuid); } diff --git a/corda/contracts/src/main/java/djmil/cordacheckers/states/Piece.java b/corda/contracts/src/main/java/djmil/cordacheckers/states/Stone.java similarity index 73% rename from corda/contracts/src/main/java/djmil/cordacheckers/states/Piece.java rename to corda/contracts/src/main/java/djmil/cordacheckers/states/Stone.java index c3e6def..2e2c93a 100644 --- a/corda/contracts/src/main/java/djmil/cordacheckers/states/Piece.java +++ b/corda/contracts/src/main/java/djmil/cordacheckers/states/Stone.java @@ -4,7 +4,7 @@ import net.corda.v5.base.annotations.ConstructorForDeserialization; import net.corda.v5.base.annotations.CordaSerializable; @CordaSerializable -public class Piece { +public class Stone { @CordaSerializable public enum Type { @@ -31,8 +31,13 @@ public class Piece { private final Color color; private final Type type; + public final static Stone WHITE_MAN = new Stone(Stone.Color.WHITE, Stone.Type.MAN); + public final static Stone WHITE_KING = new Stone(Stone.Color.WHITE, Stone.Type.KING); + public final static Stone BLACK_MAN = new Stone(Stone.Color.BLACK, Stone.Type.MAN); + public final static Stone BLACK_KING = new Stone(Stone.Color.BLACK, Stone.Type.KING); + @ConstructorForDeserialization - public Piece(Color color, Type type) { + public Stone(Color color, Type type) { this.color = color; this.type = type; } @@ -53,7 +58,7 @@ public class Piece { return false; if (getClass() != obj.getClass()) return false; - Piece other = (Piece) obj; + Stone other = (Stone) obj; if (color != other.color) return false; if (type != other.type) diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java b/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java index 39382ed..4199280 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gameproposal/CreateFlow.java @@ -16,7 +16,7 @@ import djmil.cordacheckers.gamestate.FlowResponce; import djmil.cordacheckers.gamestate.View; import djmil.cordacheckers.gamestate.ViewBuilder; import djmil.cordacheckers.states.GameProposalState; -import djmil.cordacheckers.states.Piece; +import djmil.cordacheckers.states.Stone; import net.corda.v5.application.flows.ClientRequestBody; import net.corda.v5.application.flows.ClientStartableFlow; import net.corda.v5.application.flows.CordaInject; @@ -88,10 +88,10 @@ public class CreateFlow implements ClientStartableFlow{ private GameProposalState buildGameProposalStateFrom(ClientRequestBody requestBody) { final CreateFlowArgs args = requestBody.getRequestBodyAs(jsonMarshallingService, CreateFlowArgs.class); - final Piece.Color opponentColor = Piece.Color.valueOf(args.opponentColor); + final Stone.Color opponentColor = Stone.Color.valueOf(args.opponentColor); if (opponentColor == null) { throw new RuntimeException("Allowed values for opponentColor are: " - + Piece.Color.WHITE.name() +", " + Piece.Color.BLACK.name() + + Stone.Color.WHITE.name() +", " + Stone.Color.BLACK.name() + ". Actual value was: " + args.opponentColor); } @@ -101,8 +101,8 @@ public class CreateFlow implements ClientStartableFlow{ "MemberLookup can't find opponentName specified in flow arguments: " + args.opponentName ); - final MemberInfo whitePlayerInfo = opponentColor == Piece.Color.WHITE ? opponentInfo : myInfo; - final MemberInfo blackPlayerInfo = opponentColor == Piece.Color.BLACK ? opponentInfo : myInfo; + final MemberInfo whitePlayerInfo = opponentColor == Stone.Color.WHITE ? opponentInfo : myInfo; + final MemberInfo blackPlayerInfo = opponentColor == Stone.Color.BLACK ? opponentInfo : myInfo; return new GameProposalState( whitePlayerInfo.getName(), diff --git a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/View.java b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/View.java index 4e0f126..84d1234 100644 --- a/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/View.java +++ b/corda/workflows/src/main/java/djmil/cordacheckers/gamestate/View.java @@ -7,7 +7,7 @@ import java.util.UUID; import djmil.cordacheckers.states.GameBoardState; import djmil.cordacheckers.states.GameProposalState; import djmil.cordacheckers.states.GameResultState; -import djmil.cordacheckers.states.Piece; +import djmil.cordacheckers.states.Stone; import net.corda.v5.base.types.MemberX500Name; // GameBoard from the player's point of view @@ -27,9 +27,9 @@ public class View { public final Status status; public final String opponentName; - public final Piece.Color opponentColor; + public final Stone.Color opponentColor; - public final Map board; + public final Map board; public final Integer moveNumber; public final List previousMove;