use of com.code.server.constant.response.NoticeReady in project summer by foxsugar.
the class RoomDouDiZhuPlus method getReady.
public int getReady(long userId) {
if (RedisManager.getUserRedisService().getUserMoney(userId) < needsMoney.get(goldRoomType)) {
quitRoom(userId);
return ErrorCode.CANNOT_JOIN_ROOM_NO_MONEY;
}
if (!this.users.contains(userId)) {
return ErrorCode.CANNOT_FIND_THIS_USER;
}
if (isInGame) {
return ErrorCode.CANNOT_FIND_THIS_USER;
}
this.userStatus.put(userId, STATUS_READY);
int readyNum = 0;
for (Map.Entry<Long, Integer> entry : this.userStatus.entrySet()) {
if (entry.getValue() == STATUS_READY) {
readyNum += 1;
}
}
pushScoreChange();
// 通知客户端谁是否准备
Map<String, Integer> userStatus = new HashMap<>();
for (Long i : this.userStatus.keySet()) {
userStatus.put(i + "", this.userStatus.get(i));
}
NoticeReady noticeReady = new NoticeReady();
noticeReady.setUserStatus(userStatus);
MsgSender.sendMsg2Player(new ResponseVo("roomService", "noticeReady", noticeReady), this.users);
// 开始游戏
if (readyNum >= personNumber) {
startGame();
}
MsgSender.sendMsg2Player(new ResponseVo("roomService", "getReady", 0), userId);
return 0;
}
Aggregations