diff --git a/landlords-common/src/main/java/org/nico/ratel/landlords/robot/RobotDecisionMakers.java b/landlords-common/src/main/java/org/nico/ratel/landlords/robot/RobotDecisionMakers.java new file mode 100644 index 0000000..e9dce34 --- /dev/null +++ b/landlords-common/src/main/java/org/nico/ratel/landlords/robot/RobotDecisionMakers.java @@ -0,0 +1,25 @@ +package org.nico.ratel.landlords.robot; + +import java.util.List; + +import org.nico.ratel.landlords.entity.Poker; +import org.nico.ratel.landlords.entity.PokerSell; + +/** + * How does the machine decide on a better strategy to win the game + * + * @author nico + */ +public class RobotDecisionMakers { + + public static List howToPlayPokers(PokerSell lastPokerSell, List myPokers){ + + return null; + } + + public static boolean howToChooseLandlord(List leftPokers, List rightPokers, List landlordPokers, List myPokers) { + + return true; + } + +} diff --git a/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_LANDLORD_ELECT.java b/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_LANDLORD_ELECT.java index e195e08..e337d6b 100644 --- a/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_LANDLORD_ELECT.java +++ b/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_LANDLORD_ELECT.java @@ -3,8 +3,11 @@ package org.nico.ratel.landlords.server.robot; import java.util.Map; import org.nico.ratel.landlords.entity.ClientSide; +import org.nico.ratel.landlords.entity.Room; import org.nico.ratel.landlords.enums.ServerEventCode; import org.nico.ratel.landlords.helper.MapHelper; +import org.nico.ratel.landlords.robot.RobotDecisionMakers; +import org.nico.ratel.landlords.server.ServerContains; import org.nico.ratel.landlords.server.event.ServerEventListener; public class RobotEventListener_CODE_GAME_LANDLORD_ELECT implements RobotEventListener{ @@ -12,11 +15,13 @@ public class RobotEventListener_CODE_GAME_LANDLORD_ELECT implements RobotEventLi @Override public void call(ClientSide robot, String data) { + Room room = ServerContains.ROOM_MAP.get(robot.getRoomId()); + Map map = MapHelper.parser(data); int turnClientId = (int) map.get("nextClientId"); if(turnClientId == robot.getId()) { - ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, "TRUE"); + ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, String.valueOf(RobotDecisionMakers.howToChooseLandlord(robot.getPre().getPokers(), robot.getNext().getPokers(), room.getLandlordPokers(), robot.getPokers()))); } } diff --git a/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_POKER_PLAY.java b/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_POKER_PLAY.java index 4e903c0..6572b73 100644 --- a/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_POKER_PLAY.java +++ b/landlords-server/src/main/java/org/nico/ratel/landlords/server/robot/RobotEventListener_CODE_GAME_POKER_PLAY.java @@ -1,24 +1,21 @@ package org.nico.ratel.landlords.server.robot; -import java.util.Map; - import org.nico.ratel.landlords.entity.ClientSide; -import org.nico.ratel.landlords.enums.ServerEventCode; -import org.nico.ratel.landlords.helper.MapHelper; -import org.nico.ratel.landlords.server.event.ServerEventListener; +import org.nico.ratel.landlords.entity.PokerSell; +import org.nico.ratel.landlords.entity.Room; +import org.nico.ratel.landlords.server.ServerContains; public class RobotEventListener_CODE_GAME_POKER_PLAY implements RobotEventListener{ @Override public void call(ClientSide robot, String data) { + Room room = ServerContains.ROOM_MAP.get(robot.getRoomId()); - Map map = MapHelper.parser(data); - int turnClientId = (int) map.get("nextClientId"); - - if(turnClientId == robot.getId()) { - ServerEventListener.get(ServerEventCode.CODE_GAME_LANDLORD_ELECT).call(robot, "TRUE"); + if(room.getLastSellClient() == robot.getId()) { + + }else { + PokerSell lastPokerShell = room.getLastPokerShell(); } - } }