diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/Config.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/Config.java index e283639..eb4b586 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/Config.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/Config.java @@ -1,105 +1,10 @@ package robot.mj; public class Config { - public static final int FENGDING_SCORE = 28; - public static final int XIPAI_SCORE = 10; - - public static final int ANCHOU_SCORE = 10; - - public static final String ROOM_CONFIG_ZIMO = "zimo"; - public static final String ROOM_CONFIG_ZHUANGXIAN = "zhuangxian"; - public static final String ROOM_CONFIG_NIAO = "niao"; - public static final String ROOM_CONFIG_NIAO_TYPE = "niao_type"; - public static final String ROOM_CONFIG_PIAO_NIAO = "piao_niao"; //0:不嫖 1:自由票 2:固定票 - public static final String ROOM_CONFIG_PIAO_NIAO_AUTO = "auto_piao"; //piao fen - public static final String ROOM_CONFIG_PIAO_NIAO_OPT = "piao_niao_opt"; //piao fen - public static final String ROOM_CONFIG_ZT_LIULIUSHUN = "zhongtuliuliushun"; - public static final String ROOM_CONFIG_ZT_DASIXI = "zhongtusixi"; - public static final String ROOM_CONFIG_QS_JIEJIEGAO = "jiejiegao"; - public static final String ROOM_CONFIG_QS_SANTONG = "santong"; - public static final String ROOM_CONFIG_QS_YIZHIHUA = "yizhihua"; - public static final String ROOM_CONFIG_QUEYIMEN = "queyimen"; - public static final String ROOM_CONFIG_FENGDING = "fengding"; - public static final String ROOM_CONFIG_FENGDING_SCORE = "fengding_score"; - public static final String ROOM_CONFIG_XIPAI = "xi_pai"; - public static final String ROOM_CONFIG_XIPAI_SCORE = "xi_pai_score"; - - public static final String ROOM_CONFIG_ANCHOU_SCORE = "an_chou_score"; - - public static final String ROOM_CONFIG_DIFEN_SCORE = "difen_score"; - public static final String ROOM_CONFIG_NIAOFEN_SCORE = "niaofen_score"; - public static final String ROOM_CONFIG_NIAOFEN_OPT = "niaofen_opt"; //0中鸟加分,//1中鸟加倍 - public static final String ROOM_CONFIG_KAI_GONG = "kai_gong"; //0:开杠2张,1:开杠四张 - public static final int NIAO_TYPE_ADD = 0; - - public static final int NIAO_TYPE_DOUBLE = 1; - - public static final int NIAO_TYPE_CS2NIAO = 2; - - - public static final String ROOM_CONFIG_QS_JTYN = "two_pair"; - - public static final String ROOM_CONFIG_NO_JIANG = "no_jiang"; - - public static final String ROOM_CONFIG_NATIVE_HU = "native_hu"; - - - public static final String ROOM_CONFIG_FOUR_WIN = "four_win"; - - public static final String SETTLE_XIAO_DIAN_PAO = "xiao_dian_pao"; - public static final String SETTLE_XIAO_JIE_PAO = "xiao_jie_pao"; - public static final String SETTLE_XIAO_ZIMO = "xiao_zimo"; - public static final String SETTLE_DA_DIAN_PAO = "da_dian_pao"; - public static final String SETTLE_DA_JIE_PAO = "da_jie_pao"; - public static final String SETTLE_DA_ZIMO = "da_zimo"; - - - public static final String GAME_EVT_PLAYER_DEAL = "811"; - - public static final String GAME_DIS_CARD = "611"; - - public static final String GAME_EVT_DISCARD = "812"; - - public static final String GAME_EVT_DISCARD_TIP = "813"; - - public static final String GAME_EVT_FZTIPS = "814"; - - public static final String GAME_ACTION = "612"; - - public static final String GAME_EVT_ACTION = "815"; - - public static final String GAME_EVT_HU = "816"; - - public static final String GAME_EVT_RESULT1 = "817"; - - public static final String GAME_EVT_RESULT2 = "818"; - - public static final String GAME_EVT_DRAW = "819"; - - public static final String GAME_EVT_CHANGE_ACTIVE_PLAYER = "820"; - - public static final String GAME_EVT_NIAO = "821"; - - public static final String GAME_EVT_QSTIP = "822"; - - public static final String GAME_EVT_QSWIN = "823"; - - public static final String GAME_EVT_OPENKONG = "824"; - - public static final String GAME_EVT_HAIDITIP = "825"; - - public static final String GAME_EVT_PIAONIAO_TIP = "833"; - - public static final String GAME_EVT_PIAONIAO = "834"; - - public static final String GAME_EVT_TING_TIP = "835"; - - public static final String GAME_EVT_TING = "836"; - - public static final String CREATE_ROOM_ROBOT = "create_room_for_robot"; - public static final String INIT_CONNECTION = "init_connection"; + public static final String CREATE_ROOM_ROBOT = "create_room_for_robot"; + public static final String INIT_CONNECTION = "init_connection"; /** * 加入房间 - robot_mgr to robot_mj_cs 的内部协议号 @@ -111,16 +16,6 @@ public class Config { */ public static final String GAME_READY = "2003"; - /** - * 退出房间 - robot_mgr to robot_mj_cs 的内部协议号 - */ - public static final String EXIT_ROOM = "2005"; - - /** - * 手动重连 - robot_mgr to robot_mj_cs 的内部协议号 - */ - public static final String RECONNECT = "2006"; - /** * 发送准备 - robot_mj_cs to game_mj_cs 的协议号 */ @@ -130,11 +25,4 @@ public class Config { * 加入房间 - robot_mgr to game_mj_cs 的内部协议号 */ public static final String JOIN_ROOM_CS = "1002"; - - public static final String GAME_EVT_PIAO = "2032"; - - /** - * 退出房间 - robot_mgr to game_mj_cs 的内部协议号 - */ - public static final String EXIT_ROOM_CS = "1005"; } \ No newline at end of file diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXGameController.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXGameController.java index 7d5c91f..8fb3187 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXGameController.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXGameController.java @@ -364,7 +364,7 @@ public class EXGameController extends GameController { RobotUser robotUserCopy = new RobotUser(); robotUserCopy.setRobotId(robotId); robotUserCopy.setPassword("123456"); - robotUserCopy.setGameHost("127.0.0.1"); + robotUserCopy.setGameHost("8.134.76.43"); robotUserCopy.setGamePort("6841"); robotUserCopy.setRobotGroupid("330800"); robotUserCopy.setRobotPid("66"); diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXMainServer.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXMainServer.java index 090e1c8..6774a31 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXMainServer.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXMainServer.java @@ -29,8 +29,6 @@ public class EXMainServer extends MainServer{ private static final Logger log = LoggerFactory.getLogger(EXMainServer.class); private static final RobotConnectionManager robotConnectionManager = new RobotConnectionManager(); - private static final EXGameController exGameController = new EXGameController(); - private volatile boolean connectionCheckRunning = true; @Override public void onStart() { @@ -68,47 +66,6 @@ public class EXMainServer extends MainServer{ } } -// TPServer.me().getTimerPool().scheduleAtFixedRate(new Runnable() { -// @Override -// public void run() { -// -// for(Map.Entry entry : robotRoomMapping.entrySet()) { -// RobotUser robotUser = entry.getValue(); -// //1、登录 -// //判断是否登录 -// if(!robotUser.isLogin){ -// robotConnectionManager.login(robotUser); -// } -// /*//2、链接 -// //判断是否链接 -// System.out.println("robotUser.isconnect"+robotUser.getIsconnect()); -// if(!robotUser.getIsconnect()){ -// robotConnectionManager.connectGame(robotUser); -// }else{ -// robotConnectionManager.renconnect(robotUser); -// } -// -// -// //4、加入房间 -// if(robotUser.getStatus()==0){ -// //没状态时候进入加入房间 -// ITObject params = new TObject(); -// params.putString("connecId", robotUser.getRoomId()+"_"+robotUser.getRobotId()); -// params.putString("roomId", robotUser.getRoomId()); -// params.putString("groupId", robotUser.getRobotGroupid()); -// params.putString("session", "{user}:"+robotUser.getRobotId()); -// exGameController.joinRoom(null, params, robotUser.getClient().getId()); -// } -// System.out.println("robotUser.getIntoRoomTime()"+robotUser.getIntoRoomTime()); -// System.out.println("robGetTiem"+robotConnectionManager.getTime()); -// if(robotUser.getIntoRoomTime()+6<=robotConnectionManager.getTime()){ -// //5、退出房间 -// robotConnectionManager.outoRoom(robotUser); -// }*/ -// -// } -// } -// }, 0, 5 ,TimeUnit.SECONDS); //5、干活 log.info("跑得快机器人服务器已启动"); log.info("服务器将监听端口 {} 用于接收robot_mgr管理协议", gameSetting.port); @@ -132,7 +89,7 @@ public class EXMainServer extends MainServer{ } }, "paodekuai-Thread"); - eventThread.setDaemon(true); // 设置为守护线程 + eventThread.setDaemon(true); //设置为守护线程 eventThread.start(); } @@ -157,8 +114,6 @@ public class EXMainServer extends MainServer{ public void onStop() { super.onStop(); - // 停止连接检查线程 - connectionCheckRunning = false; log.info("跑得快机器人服务器已停止"); } } \ No newline at end of file diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXPlayer.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXPlayer.java index 54b8039..009e6a6 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXPlayer.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXPlayer.java @@ -1,15 +1,7 @@ package robot.mj; -import com.robot.Util; import com.robot.data.Player; import com.robot.data.Room; -import com.robot.data.Score; -import com.taurus.core.entity.ITArray; -import com.taurus.core.entity.ITObject; -import com.taurus.core.entity.TArray; -import com.taurus.core.entity.TObject; - -import java.util.*; /** * diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXRoom.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXRoom.java index 84ea302..5043ec3 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXRoom.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/EXRoom.java @@ -7,29 +7,12 @@ import java.util.Map; public class EXRoom extends Room { - // - - - public EXRoom(String roomid, Map redis_room_map) { super(roomid, redis_room_map); } - - - - public void checkAction() { - - } - - - - - - - @Override protected void roomResult() { diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RobotConnectionManager.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RobotConnectionManager.java index 5a42905..8d87ab7 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RobotConnectionManager.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RobotConnectionManager.java @@ -33,7 +33,7 @@ public class RobotConnectionManager { private static final Map huNanPaoDeKuaiInstances = new ConcurrentHashMap<>(); private final EXGameController exGameController; - private final String host="127.0.0.1"; + private final String host="8.134.76.43"; private final int port=6841; diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RoomCreator.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RoomCreator.java index c3f0ecc..dba2fc0 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RoomCreator.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/RoomCreator.java @@ -144,7 +144,7 @@ public class RoomCreator { roomInfo.setRoomId(roomKey); roomInfo.setGroupId(groupId); roomInfo.setWanfaId(wanfaId); - roomInfo.setServerIp("127.0.0.1"); + roomInfo.setServerIp("8.134.76.43"); roomInfo.setServerPort(getGamePortForWanfa(wanfaId)); log.info("成功创建机器人房间: {}, 群组: {}, 玩法: {}", roomKey, groupId, wanfaId); diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/business/AccountBusiness.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/business/AccountBusiness.java index bdf1bfa..4beff88 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/business/AccountBusiness.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/business/AccountBusiness.java @@ -21,13 +21,6 @@ import com.taurus.web.Controller; import com.taurus.web.WebException; import redis.clients.jedis.Jedis; -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.security.MessageDigest; -import java.security.NoSuchAlgorithmException; import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; @@ -36,70 +29,6 @@ import java.util.Set; public class AccountBusiness extends Controller { private static Logger logger = Logger.getLogger(AccountBusiness.class); - public static String request(String httpUrl, String httpArg) { - BufferedReader reader = null; - String result = null; - StringBuffer sbf = new StringBuffer(); - httpUrl = httpUrl + "?" + httpArg; - - try { - URL url = new URL(httpUrl); - HttpURLConnection connection = (HttpURLConnection) url.openConnection(); - connection.setRequestMethod("GET"); - connection.connect(); - InputStream is = connection.getInputStream(); - reader = new BufferedReader(new InputStreamReader(is, "UTF-8")); - String strRead = reader.readLine(); - if (strRead != null) { - sbf.append(strRead); - while ((strRead = reader.readLine()) != null) { - sbf.append("\n"); - sbf.append(strRead); - } - } - reader.close(); - result = sbf.toString(); - } catch (Exception e) { - e.printStackTrace(); - } - return result; - } - - public static String md5(String plainText) { - StringBuffer buf = null; - try { - MessageDigest md = MessageDigest.getInstance("MD5"); - md.update(plainText.getBytes()); - byte b[] = md.digest(); - int i; - buf = new StringBuffer(""); - for (int offset = 0; offset < b.length; offset++) { - i = b[offset]; - if (i < 0) - i += 256; - if (i < 16) - buf.append("0"); - buf.append(Integer.toHexString(i)); - } - } catch (NoSuchAlgorithmException e) { - e.printStackTrace(); - } - return buf.toString(); - } - - public static String encodeUrlString(String str, String charset) { - String strret = null; - if (str == null) - return str; - try { - strret = java.net.URLEncoder.encode(str, charset); - } catch (Exception e) { - e.printStackTrace(); - return null; - } - return strret; - } - private final ITObject fillLoginData(String session, int accountid) { ITObject resData = TObject.newInstance(); ITObject userData = TObject.newInstance(); diff --git a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/handler/HuNanPaoDeKuai.java b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/handler/HuNanPaoDeKuai.java index d59f1bb..6f30477 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/robot/mj/handler/HuNanPaoDeKuai.java +++ b/robots/puke/robot_pk_pdk/src/main/java/robot/mj/handler/HuNanPaoDeKuai.java @@ -12,7 +12,6 @@ import taurus.client.MessageResponse; import taurus.client.TaurusClient; import taurus.util.CardObj; import taurus.util.CardUtil; -import taurus.util.test; import taurus.util.test_smart; import java.util.*; @@ -203,19 +202,6 @@ public class HuNanPaoDeKuai { System.out.println("updateHandCard同步手牌add:"+ paoDekuaiCardInhand); } - public void updateOutCard(List outCard) { - System.out.println("updateOutCard - 出牌记录:" + outCard); - - ITArray cardArray = CardUtil.maJiangToTArray(outCard); - - ITObject newCardList = TObject.newInstance(); - newCardList.putTArray("card_list", cardArray); - card_list = newCardList; - - System.out.println("updateOutCard - 已更新card_list:" + card_list); - } - - public void ready(TaurusClient client){ try { // 添加1秒延迟 diff --git a/robots/puke/robot_pk_pdk/src/main/java/taurus/util/CardUtil.java b/robots/puke/robot_pk_pdk/src/main/java/taurus/util/CardUtil.java index 52a4018..8606198 100644 --- a/robots/puke/robot_pk_pdk/src/main/java/taurus/util/CardUtil.java +++ b/robots/puke/robot_pk_pdk/src/main/java/taurus/util/CardUtil.java @@ -10,22 +10,6 @@ import java.util.Map; public class CardUtil { - //用于找比指定牌大的最小单牌 - public static CardObj findMinBiggerSingleCard(List cardList, int minCard) { - if (cardList == null || cardList.isEmpty() || minCard <= 0) { - return null; - } - CardObj result = null; - int minBiggerValue = Integer.MAX_VALUE; - for (CardObj card : cardList) { - int cardMod = card.getCardMod(); - if (cardMod > minCard && cardMod < minBiggerValue) { - minBiggerValue = cardMod; - result = card; - } - } - return result; - } // 补充:找最小单牌(如未实现) public static CardObj findMinSingleCard(List cardList) { @@ -76,14 +60,6 @@ public class CardUtil { return result; } - public static final ITArray maJiangToTArray(List list) { - ITArray result = new TArray(); - for (Integer integer : list) { - result.addInt(integer); - } - return result; - } - public static final CardObj getCard(int eventCard, List cardList) { for (CardObj card : cardList) { if (card.cardMod == eventCard) { @@ -93,209 +69,6 @@ public class CardUtil { return null; } - public static final CardObj getCard1(int eventCard, List cardList) { - for (CardObj card : cardList) { - if (card.card == eventCard) { - return card; - } - } - return null; - } - - /** - * 检测牌数量 - * - * @param eventCard - * @param cardList - * @param num - * @return - */ - public static final boolean checkCard(int eventCard, List cardList, int num) { - int result = 0; - for (CardObj card : cardList) { - if (card.cardMod == eventCard) { - result++; - if (result == num) - return true; - } - } - return false; - } - - public static final boolean checkGoodCard(int eventCard, List cardList, int num) { - int result = 0; - for (CardObj card : cardList) { - if (card.cardMod == eventCard) { - result++; - if (result >= num) - return true; - } - } - return false; - } - - public static final boolean checkShunZi(int eventCard, List cardList) { - int result = 0; - if (checkGoodCard(eventCard + 1, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 2, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 3, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 4, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 5, cardList, 1)) { - result++; - } - } - } - } - } - if (checkGoodCard(eventCard - 1, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 2, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 3, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 4, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 5, cardList, 1)) { - result++; - } - } - } - } - } - - if (result >= 4) { - return true; - } - return false; - } - - public static final boolean checkSevenShunzi(int eventCard, List cardList) { - int result = 0; - if (checkGoodCard(eventCard + 1, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 2, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 3, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 4, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 5, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 6, cardList, 1)) { - result++; - if (checkGoodCard(eventCard + 7, cardList, 1)) { - result++; - } - } - } - } - } - } - } - if (checkGoodCard(eventCard - 1, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 2, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 3, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 4, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 5, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 6, cardList, 1)) { - result++; - if (checkGoodCard(eventCard - 7, cardList, 1)) { - result++; - } - } - } - } - } - } - } - - if (result >= 6) { - return true; - } - return false; - } - - public static final boolean checkFenJi(int eventCard, List cardList) { - int result = 0; - if (checkGoodCard(eventCard, cardList, 2)) { - result++; - if (checkGoodCard(eventCard + 1, cardList, 3)) { - result++; - } - if (checkGoodCard(eventCard - 1, cardList, 3)) { - result++; - } - } - - if (result >= 2) { - return true; - } - return false; - } - - public static final boolean checkFourDui(int eventCard, List cardList) { - int result = 0; - if (checkGoodCard(eventCard, cardList, 1)) { - result++; - } - - if (checkGoodCard(eventCard + 1, cardList, 2)) { - result++; - if (checkGoodCard(eventCard + 2, cardList, 2)) { - result++; - if (checkGoodCard(eventCard + 3, cardList, 2)) { - result++; - if (checkGoodCard(eventCard + 4, cardList, 2)) { - result++; - } - } - } - } - if (checkGoodCard(eventCard - 1, cardList, 2)) { - result++; - if (checkGoodCard(eventCard - 2, cardList, 2)) { - result++; - if (checkGoodCard(eventCard - 3, cardList, 2)) { - result++; - if (checkGoodCard(eventCard - 4, cardList, 2)) { - result++; - } - } - } - } - - if (result >= 4) { - return true; - } - return false; - } - - public static final boolean checkQPai(int eventCard, List cardList) { - int result = 0; - if (eventCard >= 12) { - result++; - for (CardObj card : cardList) { - if (card.cardMod >= 12) { - result++; - } - } - } - - if (result >= 5) { - return true; - } - return false; - } - /** * TArray to list * @@ -329,37 +102,6 @@ public class CardUtil { return result; } - /** - * 获取每张牌的数量MAP - * - * @param cardList - * @return - */ - public static final void getCardNumMap(Map result, List cardList) { - result.clear(); - for (CardObj card : cardList) { - if (!result.containsKey(card.cardMod)) { - result.put(card.cardMod, 1); - } else { - int num = result.get(card.cardMod); - result.put(card.cardMod, (num + 1)); - } - } - } - - public static final void getCardNumMap(Map result, List cardList, CardObj tempCard) { - result.clear(); - result.put(tempCard.cardMod, 1); - for (CardObj card : cardList) { - if (!result.containsKey(card.cardMod)) { - result.put(card.cardMod, 1); - } else { - int num = result.get(card.cardMod); - result.put(card.cardMod, (num + 1)); - } - } - } - /** * 获取每张牌的数量MAP * @@ -392,18 +134,4 @@ public class CardUtil { } } - static public void removeCard1(List cardList, int card, int count) { - int curCount = 0; - for (int i = 0; i < cardList.size(); i++) { - if (count == curCount) { - return; - } - if (cardList.get(i) == card) { - - cardList.remove(i); - i--; - curCount++; - } - } - } }