diff --git a/src/controller/client/TransferController.java b/src/controller/client/TransferController.java index 181cddb..9e1ad6a 100644 --- a/src/controller/client/TransferController.java +++ b/src/controller/client/TransferController.java @@ -113,6 +113,7 @@ static void fromServerTransmitter(Transmitter transmitter) { } private static void battleHandler(Transmitter transmitter) { + System.out.println("battleHandler"); if (transmitter.battleEnum == BattleEnum.START_GAME) { SelectGameScene.startGame(transmitter.match, transmitter.numberOfMap, transmitter.imPlayer0); diff --git a/src/controller/server/RequestEnumController.java b/src/controller/server/RequestEnumController.java index 2b0b71b..df690b8 100644 --- a/src/controller/server/RequestEnumController.java +++ b/src/controller/server/RequestEnumController.java @@ -254,6 +254,7 @@ else if (!allAccount.passwordMatcher(clientTransmitter.name, clientTransmitter.p socketClass.opponent = opponentSocketClass; if (opponentSocketClass != null) { waiterHashMap.put(opponentSocketClass, socketClass); + waiterHashMap.put(socketClass, opponentSocketClass); opponentSocketClass.changeTransmitter(); Transmitter personTransmitter = opponentSocketClass.getTransmitter(); personTransmitter.transmitterId = 0; @@ -276,7 +277,6 @@ else if (!allAccount.passwordMatcher(clientTransmitter.name, clientTransmitter.p SocketClass waiter = waiterHashMap.get(socketClass); waiter.changeTransmitter(); socketClass.changeTransmitter(); - socketClass.opponent = waiter; Game game = new Game(); game.checkPlayerDeck(waiter.getAccount(), 1); game.checkPlayerDeck(socketClass.getAccount(), 2); @@ -391,10 +391,15 @@ private static void battleCheck(Transmitter clientTransmitter, SocketClass socke break; } transfer(socketClass); - if (transmitter.errorType == null && socketClass.opponent != null) { - System.out.println("i sent!"); - socketClass.opponent.setTransmitter(clientTransmitter); - transfer(socketClass.opponent); + if (transmitter.errorType == null) { + SocketClass opponent = waiterHashMap.get(socketClass); + System.out.println("i sent to " + opponent.getAccount().getUserName() + "!"); + opponent.changeTransmitter(); + opponent.getTransmitter().requestEnum = clientTransmitter.requestEnum; + opponent.getTransmitter().name = clientTransmitter.name; + opponent.getTransmitter().srcPosition = clientTransmitter.srcPosition; + opponent.getTransmitter().desPosition = clientTransmitter.desPosition; + transfer(opponent); } }