删除跑得快冗余代码
parent
45ea77d98d
commit
cb55f75624
|
|
@ -1,105 +1,10 @@
|
||||||
package robot.mj;
|
package robot.mj;
|
||||||
|
|
||||||
public class Config {
|
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 String CREATE_ROOM_ROBOT = "create_room_for_robot";
|
||||||
|
public static final String INIT_CONNECTION = "init_connection";
|
||||||
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";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 加入房间 - robot_mgr to robot_mj_cs 的内部协议号
|
* 加入房间 - robot_mgr to robot_mj_cs 的内部协议号
|
||||||
|
|
@ -111,16 +16,6 @@ public class Config {
|
||||||
*/
|
*/
|
||||||
public static final String GAME_READY = "2003";
|
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 的协议号
|
* 发送准备 - robot_mj_cs to game_mj_cs 的协议号
|
||||||
*/
|
*/
|
||||||
|
|
@ -130,11 +25,4 @@ public class Config {
|
||||||
* 加入房间 - robot_mgr to game_mj_cs 的内部协议号
|
* 加入房间 - robot_mgr to game_mj_cs 的内部协议号
|
||||||
*/
|
*/
|
||||||
public static final String JOIN_ROOM_CS = "1002";
|
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";
|
|
||||||
}
|
}
|
||||||
|
|
@ -364,7 +364,7 @@ public class EXGameController extends GameController {
|
||||||
RobotUser robotUserCopy = new RobotUser();
|
RobotUser robotUserCopy = new RobotUser();
|
||||||
robotUserCopy.setRobotId(robotId);
|
robotUserCopy.setRobotId(robotId);
|
||||||
robotUserCopy.setPassword("123456");
|
robotUserCopy.setPassword("123456");
|
||||||
robotUserCopy.setGameHost("127.0.0.1");
|
robotUserCopy.setGameHost("8.134.76.43");
|
||||||
robotUserCopy.setGamePort("6841");
|
robotUserCopy.setGamePort("6841");
|
||||||
robotUserCopy.setRobotGroupid("330800");
|
robotUserCopy.setRobotGroupid("330800");
|
||||||
robotUserCopy.setRobotPid("66");
|
robotUserCopy.setRobotPid("66");
|
||||||
|
|
|
||||||
|
|
@ -29,8 +29,6 @@ public class EXMainServer extends MainServer{
|
||||||
private static final Logger log = LoggerFactory.getLogger(EXMainServer.class);
|
private static final Logger log = LoggerFactory.getLogger(EXMainServer.class);
|
||||||
|
|
||||||
private static final RobotConnectionManager robotConnectionManager = new RobotConnectionManager();
|
private static final RobotConnectionManager robotConnectionManager = new RobotConnectionManager();
|
||||||
private static final EXGameController exGameController = new EXGameController();
|
|
||||||
private volatile boolean connectionCheckRunning = true;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
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<String, RobotUser> 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、干活
|
//5、干活
|
||||||
log.info("跑得快机器人服务器已启动");
|
log.info("跑得快机器人服务器已启动");
|
||||||
log.info("服务器将监听端口 {} 用于接收robot_mgr管理协议", gameSetting.port);
|
log.info("服务器将监听端口 {} 用于接收robot_mgr管理协议", gameSetting.port);
|
||||||
|
|
@ -132,7 +89,7 @@ public class EXMainServer extends MainServer{
|
||||||
}
|
}
|
||||||
}, "paodekuai-Thread");
|
}, "paodekuai-Thread");
|
||||||
|
|
||||||
eventThread.setDaemon(true); // 设置为守护线程
|
eventThread.setDaemon(true); //设置为守护线程
|
||||||
eventThread.start();
|
eventThread.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -157,8 +114,6 @@ public class EXMainServer extends MainServer{
|
||||||
public void onStop() {
|
public void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
|
||||||
// 停止连接检查线程
|
|
||||||
connectionCheckRunning = false;
|
|
||||||
log.info("跑得快机器人服务器已停止");
|
log.info("跑得快机器人服务器已停止");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,15 +1,7 @@
|
||||||
package robot.mj;
|
package robot.mj;
|
||||||
|
|
||||||
import com.robot.Util;
|
|
||||||
import com.robot.data.Player;
|
import com.robot.data.Player;
|
||||||
import com.robot.data.Room;
|
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.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -7,29 +7,12 @@ import java.util.Map;
|
||||||
|
|
||||||
public class EXRoom extends Room {
|
public class EXRoom extends Room {
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
||||||
super(roomid, redis_room_map);
|
super(roomid, redis_room_map);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void checkAction() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void roomResult() {
|
protected void roomResult() {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ public class RobotConnectionManager {
|
||||||
private static final Map<String, HuNanPaoDeKuai> huNanPaoDeKuaiInstances = new ConcurrentHashMap<>();
|
private static final Map<String, HuNanPaoDeKuai> huNanPaoDeKuaiInstances = new ConcurrentHashMap<>();
|
||||||
private final EXGameController exGameController;
|
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;
|
private final int port=6841;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -144,7 +144,7 @@ public class RoomCreator {
|
||||||
roomInfo.setRoomId(roomKey);
|
roomInfo.setRoomId(roomKey);
|
||||||
roomInfo.setGroupId(groupId);
|
roomInfo.setGroupId(groupId);
|
||||||
roomInfo.setWanfaId(wanfaId);
|
roomInfo.setWanfaId(wanfaId);
|
||||||
roomInfo.setServerIp("127.0.0.1");
|
roomInfo.setServerIp("8.134.76.43");
|
||||||
roomInfo.setServerPort(getGamePortForWanfa(wanfaId));
|
roomInfo.setServerPort(getGamePortForWanfa(wanfaId));
|
||||||
|
|
||||||
log.info("成功创建机器人房间: {}, 群组: {}, 玩法: {}", roomKey, groupId, wanfaId);
|
log.info("成功创建机器人房间: {}, 群组: {}, 玩法: {}", roomKey, groupId, wanfaId);
|
||||||
|
|
|
||||||
|
|
@ -21,13 +21,6 @@ import com.taurus.web.Controller;
|
||||||
import com.taurus.web.WebException;
|
import com.taurus.web.WebException;
|
||||||
import redis.clients.jedis.Jedis;
|
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.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
@ -36,70 +29,6 @@ import java.util.Set;
|
||||||
public class AccountBusiness extends Controller {
|
public class AccountBusiness extends Controller {
|
||||||
private static Logger logger = Logger.getLogger(AccountBusiness.class);
|
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) {
|
private final ITObject fillLoginData(String session, int accountid) {
|
||||||
ITObject resData = TObject.newInstance();
|
ITObject resData = TObject.newInstance();
|
||||||
ITObject userData = TObject.newInstance();
|
ITObject userData = TObject.newInstance();
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,6 @@ import taurus.client.MessageResponse;
|
||||||
import taurus.client.TaurusClient;
|
import taurus.client.TaurusClient;
|
||||||
import taurus.util.CardObj;
|
import taurus.util.CardObj;
|
||||||
import taurus.util.CardUtil;
|
import taurus.util.CardUtil;
|
||||||
import taurus.util.test;
|
|
||||||
import taurus.util.test_smart;
|
import taurus.util.test_smart;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -203,19 +202,6 @@ public class HuNanPaoDeKuai {
|
||||||
System.out.println("updateHandCard同步手牌add:"+ paoDekuaiCardInhand);
|
System.out.println("updateHandCard同步手牌add:"+ paoDekuaiCardInhand);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateOutCard(List<Integer> 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){
|
public void ready(TaurusClient client){
|
||||||
try {
|
try {
|
||||||
// 添加1秒延迟
|
// 添加1秒延迟
|
||||||
|
|
|
||||||
|
|
@ -10,22 +10,6 @@ import java.util.Map;
|
||||||
|
|
||||||
public class CardUtil {
|
public class CardUtil {
|
||||||
|
|
||||||
//用于找比指定牌大的最小单牌
|
|
||||||
public static CardObj findMinBiggerSingleCard(List<CardObj> 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<CardObj> cardList) {
|
public static CardObj findMinSingleCard(List<CardObj> cardList) {
|
||||||
|
|
@ -76,14 +60,6 @@ public class CardUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final ITArray maJiangToTArray(List<Integer> list) {
|
|
||||||
ITArray result = new TArray();
|
|
||||||
for (Integer integer : list) {
|
|
||||||
result.addInt(integer);
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final CardObj getCard(int eventCard, List<CardObj> cardList) {
|
public static final CardObj getCard(int eventCard, List<CardObj> cardList) {
|
||||||
for (CardObj card : cardList) {
|
for (CardObj card : cardList) {
|
||||||
if (card.cardMod == eventCard) {
|
if (card.cardMod == eventCard) {
|
||||||
|
|
@ -93,209 +69,6 @@ public class CardUtil {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final CardObj getCard1(int eventCard, List<CardObj> 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<CardObj> 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<CardObj> 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<CardObj> 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<CardObj> 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<CardObj> 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<CardObj> 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<CardObj> 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
|
* TArray to list
|
||||||
*
|
*
|
||||||
|
|
@ -329,37 +102,6 @@ public class CardUtil {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 获取每张牌的数量MAP
|
|
||||||
*
|
|
||||||
* @param cardList
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public static final void getCardNumMap(Map<Integer, Integer> result, List<CardObj> 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<Integer, Integer> result, List<CardObj> 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
|
* 获取每张牌的数量MAP
|
||||||
*
|
*
|
||||||
|
|
@ -392,18 +134,4 @@ public class CardUtil {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static public void removeCard1(List<Integer> 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++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue