验证是否打过
parent
4de59b6d59
commit
32dfab453c
|
|
@ -43,10 +43,6 @@ public class GroupRoomController extends Controller {
|
||||||
throw new WebException(ErrorCode.GROUP_MEMBER_BAN);
|
throw new WebException(ErrorCode.GROUP_MEMBER_BAN);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//检查玩家今天是否已经与机器人对打过
|
|
||||||
isPlayerRobotToday(acc.id);
|
|
||||||
|
|
||||||
ITObject resData = GroupRoomService.matchRoom(groupId, pid, session, platform, is_null);
|
ITObject resData = GroupRoomService.matchRoom(groupId, pid, session, platform, is_null);
|
||||||
this.sendResponse(0, resData);
|
this.sendResponse(0, resData);
|
||||||
}
|
}
|
||||||
|
|
@ -90,25 +86,4 @@ public class GroupRoomController extends Controller {
|
||||||
this.sendResponse(0, obj);
|
this.sendResponse(0, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 检查玩家今天是否已经与机器人对打过
|
|
||||||
* @param playerId 玩家ID
|
|
||||||
*/
|
|
||||||
private void isPlayerRobotToday(int playerId) {
|
|
||||||
Jedis jedis = Redis.use("group1_db3").getJedis();
|
|
||||||
try {
|
|
||||||
String redisKey = "player_user:" + playerId;
|
|
||||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
|
||||||
String matchedDate = jedis.get(redisKey);
|
|
||||||
|
|
||||||
if (matchedDate != null && matchedDate.equals(today)) {
|
|
||||||
logger.info("玩家{" + playerId + "}当天已与机器人对打");
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
logger.error("检查玩家对打记录时发生异常", e);
|
|
||||||
} finally {
|
|
||||||
jedis.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,8 @@ import java.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.charset.StandardCharsets;
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.util.ArrayList;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.concurrent.CompletableFuture;
|
import java.util.concurrent.CompletableFuture;
|
||||||
|
|
||||||
import com.data.bean.AccountBean;
|
import com.data.bean.AccountBean;
|
||||||
|
|
@ -1086,6 +1082,10 @@ public class GroupRoomService {
|
||||||
resData = publicJoinRoom(groupId, session, key, platform);
|
resData = publicJoinRoom(groupId, session, key, platform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//检查玩家今天是否已经与机器人对打过
|
||||||
|
if (!isPlayerRobotToday(acc.id)) {
|
||||||
|
log.info("matchRoom() ==> 玩家今天和机器人对打过了isPlayerRobotToday = " + isPlayerRobotToday(acc.id));
|
||||||
//匹配
|
//匹配
|
||||||
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
Jedis jedis11 = Redis.use("group1_db11").getJedis();
|
||||||
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
Jedis jedis0 = Redis.use("group1_db0").getJedis();
|
||||||
|
|
@ -1138,10 +1138,33 @@ public class GroupRoomService {
|
||||||
jedis11.close();
|
jedis11.close();
|
||||||
jedis0.close();
|
jedis0.close();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
return resData;
|
return resData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查玩家今天是否已经与机器人对打过
|
||||||
|
* @param playerId 玩家ID
|
||||||
|
*/
|
||||||
|
private static boolean isPlayerRobotToday(int playerId) {
|
||||||
|
Jedis jedis = Redis.use("group1_db3").getJedis();
|
||||||
|
try {
|
||||||
|
String redisKey = "player_user:" + playerId;
|
||||||
|
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||||
|
String matchedDate = jedis.get(redisKey);
|
||||||
|
|
||||||
|
if (matchedDate != null && matchedDate.equals(today)) {
|
||||||
|
log.info("玩家{" + playerId + "}当天已与机器人对打");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
log.error("检查玩家对打记录时发生异常", e);
|
||||||
|
} finally {
|
||||||
|
jedis.close();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* //发起机器人请求(HTTP 同步方式,替代原 TCP 异步多线程方式)
|
* //发起机器人请求(HTTP 同步方式,替代原 TCP 异步多线程方式)
|
||||||
*
|
*
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue