删除红中麻将冗余代码
parent
d3c6f363af
commit
45ea77d98d
|
|
@ -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 的协议号
|
||||
*/
|
||||
|
|
@ -131,8 +26,4 @@ public class Config {
|
|||
*/
|
||||
public static final String JOIN_ROOM_CS = "1002";
|
||||
|
||||
/**
|
||||
* 退出房间 - robot_mgr to game_mj_cs 的内部协议号
|
||||
*/
|
||||
public static final String EXIT_ROOM_CS = "1005";
|
||||
}
|
||||
|
|
@ -6,18 +6,12 @@ import com.robot.GameController;
|
|||
import com.robot.MainServer;
|
||||
import com.robot.data.Player;
|
||||
import com.robot.data.Room;
|
||||
import com.taurus.core.entity.ITObject;
|
||||
import com.taurus.core.entity.TObject;
|
||||
import com.taurus.core.plugin.redis.Redis;
|
||||
import com.taurus.permanent.TPServer;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import robot.mj.info.RobotUser;
|
||||
import taurus.client.NetManager;
|
||||
import taurus.client.TaurusClient;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static robot.mj.EXGameController.robotRoomMapping;
|
||||
|
||||
|
|
@ -29,8 +23,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 +60,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、干活
|
||||
log.info("红中麻将机器人服务器已启动");
|
||||
log.info("服务器将监听端口 {} 用于接收robot_mgr管理协议", gameSetting.port);
|
||||
|
|
@ -157,8 +108,6 @@ public class EXMainServer extends MainServer{
|
|||
public void onStop() {
|
||||
super.onStop();
|
||||
|
||||
// 停止连接检查线程
|
||||
connectionCheckRunning = false;
|
||||
log.info("红中麻将机器人服务器已停止");
|
||||
}
|
||||
}
|
||||
|
|
@ -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.*;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -17,8 +9,6 @@ import java.util.*;
|
|||
*/
|
||||
public class EXPlayer extends Player {
|
||||
|
||||
|
||||
|
||||
public EXPlayer(int playerid, Room table, String session_id) {
|
||||
super(playerid, table, session_id);
|
||||
System.out.println("new robot ");
|
||||
|
|
|
|||
|
|
@ -7,29 +7,12 @@ import java.util.Map;
|
|||
|
||||
public class EXRoom extends Room {
|
||||
|
||||
//
|
||||
|
||||
|
||||
|
||||
public EXRoom(String roomid, Map<String, String> redis_room_map) {
|
||||
super(roomid, redis_room_map);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public void checkAction() {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
protected void roomResult() {
|
||||
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -18,7 +18,6 @@ import java.util.*;
|
|||
|
||||
public class HuNanHongZhong {
|
||||
|
||||
|
||||
public static int hongZhongCard = 0;
|
||||
|
||||
//红中麻将手牌
|
||||
|
|
@ -27,7 +26,6 @@ public class HuNanHongZhong {
|
|||
//红中麻将出过的牌
|
||||
private final List<Integer> hongZhongchuguopai = new ArrayList<>();
|
||||
|
||||
|
||||
// 玩家座位号
|
||||
public static int seat = 0;
|
||||
|
||||
|
|
@ -38,14 +36,12 @@ public class HuNanHongZhong {
|
|||
public static String session = "";
|
||||
// 访问令牌
|
||||
public static String token = "";
|
||||
//红中麻将算法
|
||||
// private static HongZhongSuanFa hongZhongSuanFa = new HongZhongSuanFa();
|
||||
|
||||
private static HongZhongSuanFaTest hongZhongSuanFaTest = new HongZhongSuanFaTest();
|
||||
|
||||
private static final Gson gson = new Gson();
|
||||
|
||||
// 公共的getter和setter方法
|
||||
//公共的getter和setter方法
|
||||
public List<Integer> getHongZhongCardInhand() {
|
||||
return hongZhongCardInhand;
|
||||
}
|
||||
|
|
@ -246,8 +242,6 @@ public class HuNanHongZhong {
|
|||
|
||||
// 直接调用hongZhongSuanFaTest中的shouldPong方法,它已经包含了所有需要的规则
|
||||
return hongZhongSuanFaTest.shouldPong(proposedCard, hongZhongCardInhand);
|
||||
|
||||
// return hongZhongSuanFaTest.shouldPong(proposedCard, Arrays.asList(305,304,303,207,207,204,204,208,208,201,201,412,412));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -264,7 +258,6 @@ public class HuNanHongZhong {
|
|||
if (param == null) {
|
||||
return null;
|
||||
}
|
||||
// {bank_seat=1, laiziCard=0, laiziCard2=0, laiziCard2Before=0, jing=0, laiziCardBefore=0, card_list=[101, 103, 104, 201, 204, 207, 208, 209, 307, 309, 501, 502, 503]}
|
||||
ITArray cardList = param.getTArray("card_list");
|
||||
for (int i = 0; i < cardList.size(); i++) {
|
||||
hongZhongCardInhand.add(cardList.getInt(i));
|
||||
|
|
@ -375,7 +368,6 @@ public class HuNanHongZhong {
|
|||
/**
|
||||
* 出牌方法
|
||||
*/
|
||||
// public String outCard(TaurusClient client, List< Integer> list) {
|
||||
public String outCard(TaurusClient client) {
|
||||
// 调用分离分析方法,将刻子、顺子、红中单独拎出后分析剩余牌
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -3,47 +3,10 @@ package taurus.util;
|
|||
import com.taurus.core.entity.ITArray;
|
||||
import com.taurus.core.entity.TArray;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CardUtil {
|
||||
|
||||
/**
|
||||
* 从手牌中找出最大的单牌
|
||||
*
|
||||
* @param handCards 手牌列表
|
||||
* @return 最大的单牌,如果没有单牌则返回null
|
||||
*/
|
||||
public static CardObj findMaxSingleCard(List<CardObj> handCards) {
|
||||
if (handCards == null || handCards.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
handCards.sort((c1, c2) -> c2.cardMod - c1.cardMod);
|
||||
return handCards.get(0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* list to TArray
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static final ITArray toTArray(List<CardObj> list) {
|
||||
ITArray result = new TArray();
|
||||
for (CardObj card : list) {
|
||||
result.addInt(card.card);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final ITArray toTArray1(CardObj list) {
|
||||
ITArray result = new TArray();
|
||||
result.addInt(list.card);
|
||||
return result;
|
||||
}
|
||||
|
||||
public static final ITArray maJiangToTArray(List<Integer> list) {
|
||||
ITArray result = new TArray();
|
||||
|
|
@ -53,326 +16,5 @@ public class CardUtil {
|
|||
return result;
|
||||
}
|
||||
|
||||
public static final CardObj getCard(int eventCard, List<CardObj> cardList) {
|
||||
for (CardObj card : cardList) {
|
||||
if (card.cardMod == eventCard) {
|
||||
return card;
|
||||
}
|
||||
}
|
||||
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
|
||||
*
|
||||
* @param list
|
||||
* @return
|
||||
*/
|
||||
public static final List<CardObj> toList(ITArray list) {
|
||||
List<CardObj> tem = new ArrayList<CardObj>();
|
||||
for (int i = 0; i < list.size(); ++i) {
|
||||
tem.add(new CardObj(list.getInt(i)));
|
||||
}
|
||||
return tem;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取每张牌的数量MAP
|
||||
*
|
||||
* @param cardList
|
||||
* @return
|
||||
*/
|
||||
public static final Map<Integer, Integer> getCardNumMap(List<CardObj> cardList) {
|
||||
Map<Integer, Integer> result = new HashMap<Integer, Integer>();
|
||||
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));
|
||||
}
|
||||
}
|
||||
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
|
||||
*
|
||||
* @param cardList
|
||||
* @return
|
||||
*/
|
||||
public static final Map<Integer, List<CardObj>> getCardListMap(List<CardObj> cardList) {
|
||||
Map<Integer, List<CardObj>> result = new HashMap<Integer, List<CardObj>>();
|
||||
for (CardObj card : cardList) {
|
||||
if (!result.containsKey(card.cardMod)) {
|
||||
List<CardObj> list = new ArrayList<CardObj>();
|
||||
list.add(card);
|
||||
result.put(card.cardMod, list);
|
||||
} else {
|
||||
List<CardObj> list = result.get(card.cardMod);
|
||||
list.add(card);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static public void removeCard(List<CardObj> cardList, List<CardObj> cards) {
|
||||
for (int i = 0; i < cards.size(); i++) {
|
||||
for (int j = 0; j < cardList.size(); j++) {
|
||||
if (cardList.get(j).card == cards.get(i).card) {
|
||||
cardList.remove(j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue