From 76c5c4a353e0cba20a830bbb00938ee54b31da01 Mon Sep 17 00:00:00 2001 From: nico Date: Wed, 14 Nov 2018 21:04:45 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=9C=BA=E5=99=A8=E5=86=B3?= =?UTF-8?q?=E7=AD=96=E7=B1=BB=EF=BC=8C=E4=BD=9C=E4=B8=BA=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E5=87=BA=E7=89=8C=E7=9A=84=E5=86=B3=E7=AD=96=E8=80=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../landlords/robot/RobotDecisionMakers.java | 25 +++++++++++++++++++ ...ventListener_CODE_GAME_LANDLORD_ELECT.java | 7 +++++- ...botEventListener_CODE_GAME_POKER_PLAY.java | 19 ++++++-------- 3 files changed, 39 insertions(+), 12 deletions(-) create mode 100644 landlords-common/src/main/java/org/nico/ratel/landlords/robot/RobotDecisionMakers.java 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(); } - } }