修改 1.31
parent
cb0703d8b3
commit
dbcb834b6f
|
|
@ -141,7 +141,7 @@ public class HuNanChangSha {
|
|||
String pid = jedis222.hget("{robortInfo}:" + player, "pid");
|
||||
String getStart = "g{" + circleId + "}:play:" + pid;
|
||||
if (!pid.equals("0")) {
|
||||
jedis222.hset(getStart, String.valueOf(player), "2");
|
||||
// jedis222.hset(getStart, String.valueOf(player), "2");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
package taurus.newRobot;
|
||||
|
||||
import com.taurus.core.plugin.redis.Redis;
|
||||
import com.taurus.core.util.Logger;
|
||||
import redis.clients.jedis.*;
|
||||
|
||||
import java.util.*;
|
||||
|
|
@ -10,6 +11,12 @@ import taurus.client.TaurusClient;
|
|||
public class AddRoomRobot {
|
||||
|
||||
|
||||
private final static Logger log;
|
||||
|
||||
static {
|
||||
log = Logger.getLogger(AddRoomRobot.class);
|
||||
}
|
||||
|
||||
|
||||
public void addRoom() {
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
|
|
@ -28,18 +35,42 @@ public class AddRoomRobot {
|
|||
String playId = pid.substring(pid.indexOf("play:") + 5);
|
||||
String playKey = "g{" + groupId + "}:play:" + playId;
|
||||
|
||||
String leftover_robot = "0";
|
||||
if (jedis11.hget(playKey, "leftover_robot") != null) {
|
||||
leftover_robot = jedis11.hget(playKey, "leftover_robot");
|
||||
if (Integer.parseInt(leftover_robot) > 0) {
|
||||
String shangxian_robot = "0";
|
||||
if (jedis11.hget(playKey, "shangxian_robot") != null) {
|
||||
shangxian_robot = jedis11.hget(playKey, "shangxian_robot");
|
||||
if (Integer.parseInt(shangxian_robot) > 0) {
|
||||
|
||||
|
||||
|
||||
//分配完机器之后去看有没有初始化“leftover_robot”字段
|
||||
if (jedis11.hget(playKey, "leftover_robot") == null){
|
||||
jedis11.hset(playKey, "leftover_robot", shangxian_robot);
|
||||
}
|
||||
|
||||
|
||||
Map<String, String> stringStringMap = jedis2.hgetAll(playKey);
|
||||
log.info("靠靠靠靠靠靠靠靠靠靠靠靠靠靠靠靠靠靠靠" + stringStringMap);
|
||||
//循环stringStringMap
|
||||
boolean b = areAllValuesZero(stringStringMap);
|
||||
log.info("iiiiiiiiiiiiiiiiiiiiiiiiiiiiii" + b);
|
||||
if (b){
|
||||
jedis11.hset(playKey, "leftover_robot", shangxian_robot);
|
||||
}
|
||||
|
||||
//给圈子玩法分配机器人,创建到redis
|
||||
addPlayRobot(groupId, playId, leftover_robot);
|
||||
addPlayRobot(groupId, playId, shangxian_robot);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
System.out.println("bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb");
|
||||
//机器人主动找真人
|
||||
joinzhenrenRoom();
|
||||
|
|
@ -97,6 +128,20 @@ public class AddRoomRobot {
|
|||
}
|
||||
}
|
||||
|
||||
// 判断玩家状态是不是都为0
|
||||
public static boolean areAllValuesZero(Map<String, String> map) {
|
||||
if (map == null || map.isEmpty()) {
|
||||
return false; // 或者 true,根据业务需求
|
||||
}
|
||||
|
||||
for (String value : map.values()) {
|
||||
if (!"0".equals(value)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//统计 玩法里 等待中的次数
|
||||
// 方法1:返回 Map<圈子ID, Map<玩法ID, 房间需求>>
|
||||
|
|
@ -214,14 +259,14 @@ public class AddRoomRobot {
|
|||
|
||||
|
||||
//给圈子玩法分配机器人,创建到redis
|
||||
public void addPlayRobot(String groupId, String playId, String leftover_robot) {
|
||||
public void addPlayRobot(String groupId, String playId, String shangxian_robot) {
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
// 为这个玩法创建机器人配置
|
||||
String robotPlayKey = "g{" + groupId + "}:play:" + playId;
|
||||
boolean exists = jedis2.exists(robotPlayKey);
|
||||
if (!exists) {
|
||||
// 计算需要配置的机器人数量
|
||||
int num = Integer.parseInt(leftover_robot) * 2;
|
||||
int num = Integer.parseInt(shangxian_robot) * 2;
|
||||
|
||||
// 获取所有可用的机器人
|
||||
List<String> availableRobots1 = getAvailableRobots();
|
||||
|
|
|
|||
|
|
@ -7,6 +7,7 @@ import com.taurus.core.events.Event;
|
|||
import com.taurus.core.events.IEventListener;
|
||||
import com.taurus.core.plugin.redis.Redis;
|
||||
import com.taurus.core.util.ICallback;
|
||||
import com.taurus.core.util.Logger;
|
||||
import com.taurus.core.util.StringUtil;
|
||||
import hunan.HuNanChangSha;
|
||||
import redis.clients.jedis.Jedis;
|
||||
|
|
@ -26,6 +27,12 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class jiqiren {
|
||||
|
||||
private final static Logger log;
|
||||
|
||||
static {
|
||||
log = Logger.getLogger(jiqiren.class);
|
||||
}
|
||||
|
||||
public String wanfaId = "";
|
||||
// 会话标识
|
||||
private String session = "";
|
||||
|
|
@ -38,6 +45,10 @@ public class jiqiren {
|
|||
|
||||
private Map<String, Object> mapclient = new HashMap<>();
|
||||
|
||||
|
||||
//使用数量
|
||||
public static Map<Integer, Integer> count2 = new HashMap<Integer, Integer>();
|
||||
|
||||
public TaurusClient getClient() {
|
||||
return client;
|
||||
}
|
||||
|
|
@ -48,7 +59,7 @@ public class jiqiren {
|
|||
|
||||
//进入真人房间
|
||||
public void tcp_jiqirenzhenren(String id) {
|
||||
Jedis jedis0 = Redis.use().getJedis();
|
||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
|
||||
|
|
@ -71,7 +82,7 @@ public class jiqiren {
|
|||
//机器人主动找真人
|
||||
if (players1 != null && !players1.equals("[]")) {
|
||||
List<String> availableRobots1 = getAvailableRobots1();
|
||||
|
||||
log.info("所有机器人------"+availableRobots1);
|
||||
String players = jedis0.hget(roomKey, "players");
|
||||
players = players.substring(1, players.length() - 1);
|
||||
|
||||
|
|
@ -86,9 +97,11 @@ public class jiqiren {
|
|||
if (!availableRobots1.contains(playeid) && Integer.parseInt(leftover_robot) > 0) {
|
||||
Map<String, String> stringStringMap = jedis2.hgetAll(playKey);
|
||||
List<String> zeroValueKeys = getKeysWithValueZero(stringStringMap);
|
||||
System.out.println("值为0的机器人ID: " + zeroValueKeys);
|
||||
log.info("值为0的机器人ID------"+zeroValueKeys);
|
||||
|
||||
String randomKeyFromList = getRandomKeyFromList(zeroValueKeys);
|
||||
System.out.println("随机给的用户id----" + randomKeyFromList);
|
||||
log.info("随机给的用户id------"+randomKeyFromList);
|
||||
|
||||
|
||||
|
||||
wanfaId = jedis0.hget(roomKey, "game");
|
||||
|
|
@ -98,7 +111,7 @@ public class jiqiren {
|
|||
}
|
||||
|
||||
if ("10".equalsIgnoreCase(wanfaId)) {
|
||||
client = new TaurusClient("8.138.242.190:6311", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
client = new TaurusClient("8.138.242.190:6311", randomKeyFromList, TaurusClient.ConnectionProtocol.Tcp);
|
||||
//TaurusClient client1=getClient();
|
||||
client.connect();
|
||||
mapclient.put(randomKeyFromList, client);
|
||||
|
|
@ -150,19 +163,36 @@ public class jiqiren {
|
|||
|
||||
try {
|
||||
ITObject roomInfos = GroupRoomBusiness.joinRoom(Integer.parseInt(group), roomKey1, session, null);
|
||||
log.info("房间数据数据时数据1213234453543545------"+roomInfos);
|
||||
|
||||
String roomIds = roomInfos.getString("room_id");
|
||||
|
||||
jedis2.hset(playKey, randomKeyFromList, "1");
|
||||
String robortInfoKey = "{robortInfo}:" + randomKeyFromList;
|
||||
jedis2.hset(robortInfoKey, "circleId", group);
|
||||
jedis2.hset(robortInfoKey, "pid", gpid);
|
||||
jedis2.hset(robortInfoKey, "room_id", roomIds);
|
||||
|
||||
log.info("进入真人-- 用户id ----"+ randomKeyFromList);
|
||||
log.info("进入真人-- group ----"+ jedis2.hget(robortInfoKey, "circleId"));
|
||||
log.info("进入真人-- gpid ----"+ jedis2.hget(robortInfoKey, "pid"));
|
||||
log.info("进入真人-- room_id ----"+ jedis2.hget(robortInfoKey, "room_id"));
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
joinRoom(Integer.parseInt(randomKeyFromList)); //进入房间
|
||||
|
||||
|
||||
jedis2.hset(playKey, randomKeyFromList, "1");
|
||||
String robortInfoKey = "{robortInfo}:" + randomKeyFromList;
|
||||
jedis2.hset(robortInfoKey, "circleId", group);
|
||||
jedis2.hset(robortInfoKey, "pid", gpid);
|
||||
jedis2.hset(robortInfoKey, "room_id", roomId);
|
||||
ready(); //准备
|
||||
|
||||
ready(); //准备
|
||||
count2.put(Integer.valueOf(gpid), count2.getOrDefault(Integer.parseInt(gpid), 0) + 1);
|
||||
jedis11.hincrBy(playKey, "leftover_robot", -1);
|
||||
lianjiejiqiren lianjiejiqiren = new lianjiejiqiren();
|
||||
lianjiejiqiren.token = token;
|
||||
|
|
@ -182,7 +212,7 @@ public class jiqiren {
|
|||
|
||||
//进入中括号的房间
|
||||
public void tcp_jiqirezhongkouhao(String id) {
|
||||
Jedis jedis0 = Redis.use().getJedis();
|
||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
String roomKey = "";
|
||||
|
|
@ -220,7 +250,7 @@ public class jiqiren {
|
|||
// client = new TaurusClient("8.138.242.190:6421", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
}
|
||||
if ("10".equalsIgnoreCase(wanfaId)) {
|
||||
client = new TaurusClient("8.138.242.190:6311", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
client = new TaurusClient("8.138.242.190:6311", randomKeyFromList, TaurusClient.ConnectionProtocol.Tcp);
|
||||
client.connect();
|
||||
mapclient.put(randomKeyFromList, client);
|
||||
}
|
||||
|
|
@ -271,19 +301,30 @@ public class jiqiren {
|
|||
|
||||
try {
|
||||
ITObject roomInfos = GroupRoomBusiness.joinRoom(Integer.parseInt(group), roomKey1, session, null);
|
||||
String roomIds = roomInfos.getString("room_id");
|
||||
|
||||
jedis2.hset(playKey, randomKeyFromList, "1");
|
||||
String robortInfoKey = "{robortInfo}:" + randomKeyFromList;
|
||||
jedis2.hset(robortInfoKey, "circleId", group);
|
||||
jedis2.hset(robortInfoKey, "pid", gpid);
|
||||
jedis2.hset(robortInfoKey, "room_id", roomIds);
|
||||
|
||||
|
||||
log.info("中括号-- 用户id ----"+ randomKeyFromList);
|
||||
log.info("中括号-- group ----"+ jedis2.hget(robortInfoKey, "circleId"));
|
||||
log.info("中括号-- gpid ----"+ jedis2.hget(robortInfoKey, "pid"));
|
||||
log.info("中括号-- room_id ----"+ jedis2.hget(robortInfoKey, "room_id"));
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
joinRoom(Integer.parseInt(randomKeyFromList)); //进入房间
|
||||
|
||||
|
||||
jedis2.hset(playKey, randomKeyFromList, "1");
|
||||
String robortInfoKey = "{robortInfo}:" + randomKeyFromList;
|
||||
jedis2.hset(robortInfoKey, "circleId", group);
|
||||
jedis2.hset(robortInfoKey, "pid", gpid);
|
||||
jedis2.hset(robortInfoKey, "room_id", roomId);
|
||||
ready(); //准备
|
||||
|
||||
ready(); //准备
|
||||
count2.put(Integer.valueOf(gpid), count2.getOrDefault(Integer.parseInt(gpid), 0) + 1);
|
||||
jedis11.hincrBy(playKey, "leftover_robot", -1);
|
||||
lianjiejiqiren lianjiejiqiren = new lianjiejiqiren();
|
||||
lianjiejiqiren.token = token;
|
||||
|
|
@ -309,7 +350,7 @@ public class jiqiren {
|
|||
public void createRoomsForCircle(String circleId, Map<String, Integer> playRoomMap) {
|
||||
Jedis jedis2 = Redis.use("group1_db2").getJedis();
|
||||
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
||||
Jedis jedis0 = Redis.use().getJedis();
|
||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||
// 按玩法ID排序处理
|
||||
List<Map.Entry<String, Integer>> sortedPlays = playRoomMap.entrySet().stream()
|
||||
.sorted(Map.Entry.comparingByKey())
|
||||
|
|
@ -394,7 +435,7 @@ public class jiqiren {
|
|||
String roomKey = String.valueOf(room);
|
||||
System.out.println("roomkey--------" + roomKey);
|
||||
|
||||
client = null;
|
||||
// client = null;
|
||||
|
||||
System.out.println("wanfaId" + wanfaId);
|
||||
|
||||
|
|
@ -404,7 +445,7 @@ public class jiqiren {
|
|||
}
|
||||
|
||||
if ("10".equalsIgnoreCase(wanfaId)) {
|
||||
client = new TaurusClient("8.138.242.190:6311", "game", TaurusClient.ConnectionProtocol.Tcp);
|
||||
client = new TaurusClient("8.138.242.190:6311", randomKeyFromList, TaurusClient.ConnectionProtocol.Tcp);
|
||||
// client.setSession(session);
|
||||
client.connect();
|
||||
mapclient.put(randomKeyFromList, client);
|
||||
|
|
@ -428,8 +469,16 @@ public class jiqiren {
|
|||
joinRoom(Integer.parseInt(randomKeyFromList)); //进入房间
|
||||
|
||||
|
||||
log.info("创建-- 用户id ----"+ randomKeyFromList);
|
||||
log.info("创建-- group ----"+ jedis2.hget(robort, "circleId"));
|
||||
log.info("创建-- gpid ----"+ jedis2.hget(robort, "pid"));
|
||||
log.info("创建-- room_id ----"+ jedis2.hget(robort, "room_id"));
|
||||
|
||||
String playKey1 = "g{" + circleId + "}:play:" + playId;
|
||||
|
||||
count2.put(Integer.valueOf(playId), count2.getOrDefault(Integer.parseInt(playId), 0) + 1);
|
||||
|
||||
// count.put(key, count.getOrDefault(key, 0) + 1);
|
||||
jedis11.hincrBy(playKey1, "leftover_robot", -1);
|
||||
|
||||
lianjiejiqiren lianjiejiqiren = new lianjiejiqiren();
|
||||
|
|
@ -438,12 +487,6 @@ public class jiqiren {
|
|||
lianjiejiqiren.lianjie(client, wanfaId, mapclient);
|
||||
ready(); //准备
|
||||
|
||||
if (room != null) {
|
||||
roomsForPlay.add(room);
|
||||
System.out.println(" 第 " + i + " 个房间创建成功");
|
||||
} else {
|
||||
System.out.println(" 第 " + i + " 个房间创建失败");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,8 +8,10 @@ import com.taurus.core.events.Event;
|
|||
import com.taurus.core.events.IEventListener;
|
||||
import com.taurus.core.plugin.redis.Redis;
|
||||
import com.taurus.core.util.ICallback;
|
||||
import com.taurus.core.util.Logger;
|
||||
import com.taurus.core.util.StringUtil;
|
||||
import hunan.HuNanChangSha;
|
||||
import hunan.JiQiRens;
|
||||
import redis.clients.jedis.Jedis;
|
||||
import taurus.client.Message;
|
||||
import taurus.client.MessageResponse;
|
||||
|
|
@ -25,6 +27,12 @@ import java.util.Map;
|
|||
|
||||
public class lianjiejiqiren {
|
||||
|
||||
private final static Logger log;
|
||||
|
||||
static {
|
||||
log = Logger.getLogger(lianjiejiqiren.class);
|
||||
}
|
||||
|
||||
// 会话标识
|
||||
public String session = "";
|
||||
// 访问令牌
|
||||
|
|
@ -448,19 +456,20 @@ public class lianjiejiqiren {
|
|||
// System.out.println("初始化手牌" + session);
|
||||
Jedis jedis222 = Redis.use("group1_db2").getJedis();
|
||||
for (Map.Entry<String, Object> entry : mapclient.entrySet()) {
|
||||
System.out.println("mapclient++++++++++++++++++++++++++++++++"+mapclient);
|
||||
System.out.println("client++++++++++++++++++++++++++++++++++"+client);
|
||||
log.info("mapclient++++++++++++++++++++++++++++++++"+mapclient);
|
||||
log.info("client++++++++++++++++++++++++++++++++++"+client);
|
||||
TaurusClient taurusClient = (TaurusClient) entry.getValue();
|
||||
if (client.getId() == taurusClient.getId()) {
|
||||
if (client.equals(taurusClient)) {
|
||||
String key = entry.getKey();
|
||||
System.out.println("key+++++++++++++++++++++++++++++++++++" + key);
|
||||
log.info("key+++++++++++++++++++++++++++++++++++" + key);
|
||||
if (jedis222.hget("{robortInfo}:" + key, "circleId") != null && jedis222.hget("{robortInfo}:" + key, "pid") != null) {
|
||||
String circleId = jedis222.hget("{robortInfo}:" + key, "circleId");
|
||||
System.out.println("circleId +++++++++++++++++++++++++"+circleId);
|
||||
log.info("circleId +++++++++++++++++++++++++"+circleId);
|
||||
String pid = jedis222.hget("{robortInfo}:" + key, "pid");
|
||||
System.out.println("pid +++++++++++++++++++++++++"+pid);
|
||||
log.info("pid +++++++++++++++++++++++++"+pid);
|
||||
String getStart = "g{" + circleId + "}:play:" + pid;
|
||||
if (!pid.equals("0")){
|
||||
log.info("getStart +++++++++++++++++++++++++"+getStart);
|
||||
jedis222.hset(getStart, key, "2");
|
||||
}
|
||||
}
|
||||
|
|
@ -468,7 +477,7 @@ public class lianjiejiqiren {
|
|||
}
|
||||
jedis222.close();
|
||||
huNanChangSha.cardInHead(command, message, client);
|
||||
System.out.println("client " + client);
|
||||
log.info("client " + client);
|
||||
} else if ("812".equalsIgnoreCase(command)) {//出牌广播
|
||||
//{"opzicards":[{"opzicards":[],"playerId":101555}],"opmingcards":[{"opmingcards":[],"playerId":101555}],"outcard_map":[{"outcards":[209,205],"playerId":101555},{"outcards":[],"playerId":112233}],"card":205,"opchicards":[{"opchicards":[105,103],"playerId":101555}],"oppengcards":[{"oppengcards":[],"playerId":101555}],"seat":1}
|
||||
ITArray outcard_map = param.getTArray("outcard_map");
|
||||
|
|
@ -566,7 +575,7 @@ public class lianjiejiqiren {
|
|||
} else if ("819".equalsIgnoreCase(command)) {
|
||||
for (Map.Entry<String, Object> entry : mapclient.entrySet()) {
|
||||
TaurusClient taurusClient = (TaurusClient) entry.getValue();
|
||||
if (client == taurusClient) {
|
||||
if (client.equals(taurusClient)) {
|
||||
//摸牌
|
||||
huNanChangSha.getCard(command, message, taurusClient,mapclient);
|
||||
}
|
||||
|
|
@ -593,8 +602,8 @@ public class lianjiejiqiren {
|
|||
});
|
||||
|
||||
}else if ("2009".equalsIgnoreCase(command)) {
|
||||
|
||||
|
||||
log.info("斤斤计较急急急急急急急急急====="+param);
|
||||
// sleepTime(3000);
|
||||
|
||||
//db0
|
||||
Jedis jedis22 = Redis.use().getJedis();
|
||||
|
|
@ -602,31 +611,50 @@ public class lianjiejiqiren {
|
|||
Jedis jedis33 = Redis.use("group1_db2").getJedis();
|
||||
|
||||
Jedis jedis = Redis.use("group1_db0").getJedis();
|
||||
Integer aid = param.getInt("aid");
|
||||
String aid = client.getGameID();
|
||||
|
||||
String getKey = "{robortInfo}:" + aid;
|
||||
|
||||
|
||||
System.out.println("param ++++++++++++++++ " + param);
|
||||
log.info("连接的id---------------:"+aid);
|
||||
|
||||
|
||||
// System.out.println("param ++++++++++++++++ " + param);
|
||||
|
||||
ITObject params = TObject.newInstance();
|
||||
|
||||
String[] playerIds2 = null;
|
||||
|
||||
if (jedis33.hget(getKey, "pid") != null) {
|
||||
|
||||
|
||||
|
||||
String circleId1 = jedis33.hget(getKey, "circleId");
|
||||
String pid = jedis33.hget(getKey, "pid");
|
||||
System.out.println("comds2:2002");
|
||||
|
||||
String key = "g{" + circleId1 + "}:play:" + pid;
|
||||
if (jedis33.hget(getKey, "room_id") != null) {
|
||||
String roomid = jedis33.hget(getKey, "room_id");
|
||||
|
||||
String roomKey = "room:" + roomid;
|
||||
System.out.println("comds3:2002");
|
||||
Integer start = param.getInt("start");
|
||||
log.info("获取数据的key----------------"+ key);
|
||||
if (start == 1){
|
||||
log.info("进入修好状态12345------------"+aid);
|
||||
jedis33.hset(key, aid, "2");
|
||||
log.info("进入修好状态ttttttttttttttt------------"+jedis33.hget(key, aid));
|
||||
}
|
||||
|
||||
if (jedis22.hget(roomKey, "players") != null) {
|
||||
String players = jedis22.hget(roomKey, "players");
|
||||
if (!players.equals("[]")) {
|
||||
players = players.substring(1, players.length() - 1);
|
||||
playerIds2 = players.split(",");
|
||||
// log.info("用户的长度-------"+playerIds2.length);
|
||||
// if (playerIds2.length ==2){
|
||||
// jedis33.hset(key, String.valueOf(aid), "2");
|
||||
// }
|
||||
|
||||
|
||||
if (playerIds2.length == 1) {
|
||||
if (!pid.equals("0")) {
|
||||
System.out.println("comds4:2002");
|
||||
|
|
@ -636,24 +664,68 @@ public class lianjiejiqiren {
|
|||
jedis20.close();
|
||||
System.out.println("mapclient--------------" + mapclient);
|
||||
|
||||
String room_id = jedis33.hget(getKey, "room_id");
|
||||
//
|
||||
|
||||
for (Map.Entry<String, Object> entry : mapclient.entrySet()) {
|
||||
String key1 = entry.getKey();
|
||||
if (Integer.parseInt(key1) == aid) {
|
||||
//
|
||||
log.info("client-----key1----"+ client);
|
||||
log.info("entry.getValue()--------连接"+entry.getValue());
|
||||
if (client.equals(entry.getValue())) {
|
||||
|
||||
log.info("2009状态start---------"+start);
|
||||
|
||||
// 获取指定field的值
|
||||
String value = jedis33.hget(key, String.valueOf(aid));
|
||||
String value = jedis33.hget(key, aid);
|
||||
log.info("2009-----value----"+ value);
|
||||
|
||||
if (!value.equals("2")) {
|
||||
sleepTime(4000);
|
||||
jedis33.hset(getKey, "circleId", "0");
|
||||
jedis33.hset(getKey, "pid", "0");
|
||||
jedis33.hset(getKey, "room_id", "0");
|
||||
//退出修改机器人状态
|
||||
System.out.println("comds5:2002");
|
||||
jedis33.hset(key, String.valueOf(aid), "0");
|
||||
TaurusClient taurusClient = (TaurusClient) entry.getValue();
|
||||
taurusClient.send("1005", params, response -> {
|
||||
});
|
||||
|
||||
// log.info("jiqiren.count333333333333333333333333-------------"+jiqiren.count2);
|
||||
|
||||
|
||||
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
|
||||
Integer currentValue = jiqiren.count2.get(Integer.parseInt(pid));
|
||||
if (currentValue > 0) {
|
||||
jiqiren.count2.put(Integer.parseInt(pid), currentValue - 1);
|
||||
}
|
||||
}
|
||||
System.out.println("jiqiren.count2000000000000-------------"+jiqiren.count2);
|
||||
|
||||
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
|
||||
Integer value1 = jiqiren.count2.get(Integer.parseInt(pid));
|
||||
|
||||
// 如果找到了对应的 pid
|
||||
Jedis jedis12 = Redis.use("group1_db11").getJedis();
|
||||
|
||||
String shangxianRobot = jedis12.hget(key, "shangxian_robot");
|
||||
String leftoverRobot = jedis12.hget(key, "leftover_robot");
|
||||
|
||||
if (shangxianRobot != null && leftoverRobot != null) {
|
||||
if (value1 == 0) {
|
||||
System.out.println("key leftover_robot " + key);
|
||||
jedis12.hset(key, "leftover_robot", shangxianRobot);
|
||||
}
|
||||
}
|
||||
jedis12.close();
|
||||
}
|
||||
|
||||
sleepTime(5000);
|
||||
String valueq = jedis33.hget(key, aid);
|
||||
log.info("redis----状态状态111223243546----"+ valueq);
|
||||
if (!valueq.equals("2")){
|
||||
|
||||
TaurusClient taurusClient = (TaurusClient) entry.getValue();
|
||||
taurusClient.send("1005", params, response -> {
|
||||
log.info("退出状态---------"+response);
|
||||
|
||||
jedis33.hset(getKey, "circleId", "0");
|
||||
jedis33.hset(getKey, "pid", "0");
|
||||
jedis33.hset(getKey, "room_id", "0");
|
||||
//退出修改机器人状态
|
||||
jedis33.hset(key,aid, "0");
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -669,7 +741,9 @@ public class lianjiejiqiren {
|
|||
jedis22.close();
|
||||
jedis.close();
|
||||
}
|
||||
} else if ("817".equalsIgnoreCase(command)) {//结算
|
||||
} else if ("2001".equalsIgnoreCase(command)){
|
||||
log.info("2001-------状态状态------"+param);
|
||||
}else if ("817".equalsIgnoreCase(command)) {//结算
|
||||
huNanChangSha.getChangShaCardInhand().clear();
|
||||
huNanChangSha.getChuGuoCardInhand().clear();
|
||||
huNanChangSha.getpongGroup().clear();
|
||||
|
|
@ -691,7 +765,7 @@ public class lianjiejiqiren {
|
|||
for (Map.Entry<String, Object> entry : mapclient.entrySet()) {
|
||||
|
||||
TaurusClient taurusClient = (TaurusClient) entry.getValue();
|
||||
if (client == taurusClient) {
|
||||
if (client.equals(taurusClient)) {
|
||||
String key = entry.getKey();
|
||||
if (jedis21.hget("{robortInfo}:" + key, "circleId") != null && jedis21.hget("{robortInfo}:" + key, "pid") != null) {
|
||||
String circleId = jedis21.hget("{robortInfo}:" + key, "circleId");
|
||||
|
|
@ -699,11 +773,40 @@ public class lianjiejiqiren {
|
|||
String getStart = "g{" + circleId + "}:play:" + pid;
|
||||
jedis21.hset(getStart, key, "0");
|
||||
|
||||
System.out.println("jiqiren.count2886746435243211-------------"+jiqiren.count2);
|
||||
|
||||
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
|
||||
Integer currentValue = jiqiren.count2.get(Integer.parseInt(pid));
|
||||
if (currentValue > 0) {
|
||||
jiqiren.count2.put(Integer.parseInt(pid), currentValue - 1);
|
||||
}
|
||||
}
|
||||
|
||||
jedis11s.hincrBy(getStart, "leftover_robot", 1);
|
||||
|
||||
jedis21.hset("{robortInfo}:" + key, "circleId", "0");
|
||||
jedis21.hset("{robortInfo}:" + key, "pid", "0");
|
||||
jedis21.hset("{robortInfo}:" + key, "room_id", "0");
|
||||
|
||||
System.out.println("jiqiren.count2-------------"+jiqiren.count2);
|
||||
|
||||
if (jiqiren.count2 != null && jiqiren.count2.containsKey(Integer.parseInt(pid))) {
|
||||
Integer value = jiqiren.count2.get(Integer.parseInt(pid));
|
||||
|
||||
// 如果找到了对应的 pid
|
||||
Jedis jedis12 = Redis.use("group1_db11").getJedis();
|
||||
|
||||
String shangxianRobot = jedis12.hget(key, "shangxian_robot");
|
||||
String leftoverRobot = jedis12.hget(key, "leftover_robot");
|
||||
|
||||
if (shangxianRobot != null && leftoverRobot != null) {
|
||||
if (value == 0) {
|
||||
jedis12.hset(key, "leftover_robot", shangxianRobot);
|
||||
}
|
||||
}
|
||||
jedis12.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue