use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameDouDiZhuPlus method pushScoreChange.
public void pushScoreChange() {
Map<Long, Double> userMoneys = new HashMap<>();
for (Long l : users) {
userMoneys.put(l, RedisManager.getUserRedisService().getUserMoney(l));
}
MsgSender.sendMsg2Player(new ResponseVo("gameService", "scoreChange", userMoneys), this.getUsers());
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class GameDouDiZhuPlus method startGame.
public void startGame(List<Long> users, Room room) {
RoomDouDiZhuPlus roomDouDiZhuPlus = (RoomDouDiZhuPlus) room;
this.users.forEach(userId -> {
RedisManager.getUserRedisService().addUserMoney(userId, -roomDouDiZhuPlus.getUsesMoney().get(room.getGoldRoomType()));
});
Map<Long, Double> userScores = new HashMap<>();
for (Long l : room.getUsers()) {
userScores.put(l, 0.0);
}
room.setUserScores(userScores);
this.room = room;
init(users, room.getBankerId());
updateLastOperateTime();
// 通知其他人游戏已经开始
MsgSender.sendMsg2Player(new ResponseVo("gameService", "gameBegin", "ok"), this.getUsers());
RoomManager.getRobotRoom().add(room);
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class RoomDouDiZhu method dissolutionRoom.
// @Override
// protected Game getGameInstance() {
// switch (gameType) {
// case GAMETYPE_LINFEN:
// return new GameDouDiZhuLinFen();
// case GAMETYPE_QIANAN:
// return new GameDouDiZhuQianAn();
// case GAMETYPE_LONGQI:
// return new GameDouDiZhu();
// case GAMETYPE_LONGQI_LINFEN:
// return new GameDouDiZhuLinFenLongQi();
// case GAMETYPE_LONGQI_LINFEN_NO_QIANG:
// return new GameDouDiZhuLinFenNoQiang();
//
// case GAMETYPE_LONGQI_NO_QIANG:
// return new GameDouDiZhuNoQiang();
// default:
// return new GameDouDiZhu();
// }
//
// }
public void dissolutionRoom() {
if (RoomManager.getRoom(this.roomId) == null) {
return;
}
RoomManager.removeRoom(this.roomId);
// 结果类
List<UserOfResult> userOfResultList = getUserOfResult();
// 代开房 并且游戏未开始
if (!isCreaterJoin && !this.isInGame && this.curGameNumber == 1) {
drawBack();
GameTimer.removeNode(this.prepareRoomTimerNode);
}
if ((this.isInGame || !isCreaterJoin) && this.curGameNumber == 1) {
drawBack();
}
this.isInGame = false;
// 存储返回
GameOfResult gameOfResult = new GameOfResult();
gameOfResult.setUserList(userOfResultList);
gameOfResult.setEndTime(LocalDateTime.now().toString());
MsgSender.sendMsg2Player(new ResponseVo("gameService", "askNoticeDissolutionResult", gameOfResult), users);
// 战绩
genRoomRecord();
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class RoomDouDiZhuGold method quitRoom.
@Override
public int quitRoom(long userId) {
if (!this.users.contains(userId)) {
return ErrorCode.CANNOT_QUIT_ROOM_NOT_EXIST;
}
if (isInGame) {
return ErrorCode.CANNOT_QUIT_ROOM_IS_IN_GAME;
}
// 删除玩家房间映射关系
roomRemoveUser(userId);
boolean isInFullRoom = false;
if (this.users.size() == personNumber) {
isInFullRoom = true;
}
if (isInFullRoom) {
RoomManager.removeRoom(this);
}
// 删除
if (this.users.size() == 0) {
RoomManager.removeRoomFromMap(this);
}
Notice n = new Notice();
n.setMessage("quit room success!");
ResponseVo result = new ResponseVo("roomService", "quitRoom", n);
MsgSender.sendMsg2Player(result, userId);
UserOfRoom userOfRoom = new UserOfRoom();
List<Long> noticeList = this.getUsers();
int inRoomNumber = this.getUsers().size();
int readyNumber = 0;
for (int i : this.getUserStatus().values()) {
if (i == STATUS_READY) {
readyNumber++;
}
}
for (UserBean userBean : RedisManager.getUserRedisService().getUserBeans(users)) {
userOfRoom.getUserList().add(userBean.toVo());
}
userOfRoom.setInRoomNumber(inRoomNumber);
userOfRoom.setReadyNumber(readyNumber);
ResponseVo noticeResult = new ResponseVo("roomService", "roomNotice", userOfRoom);
MsgSender.sendMsg2Player(noticeResult, noticeList);
return 0;
}
use of com.code.server.constant.response.ResponseVo in project summer by foxsugar.
the class RoomDouDiZhuGold method joinGoldRoom.
/*public static String getRoomIdStr() {
return System.currentTimeMillis()+"" + random.nextInt(999999);
}*/
// 金币场加入房间
public static int joinGoldRoom(long userId, Double goldRoomType, String roomType, String gameType) throws DataNotFoundException {
if (RedisManager.getUserRedisService().getRoomId(userId) != null) {
return ErrorCode.CANNOT_CREATE_ROOM_USER_HAS_IN_ROOM;
}
if (RedisManager.getUserRedisService().getUserMoney(userId) < needMoney.get(goldRoomType)) {
return ErrorCode.CANNOT_JOIN_ROOM_NO_MONEY;
}
Room nullRoom = RoomManager.getNullRoom(goldRoomType);
if (nullRoom == null) {
switch(roomType) {
case "2":
nullRoom = new RoomDouDiZhuGold();
break;
case "3":
nullRoom = new RoomDouDiZhuPlus();
break;
default:
nullRoom = new RoomDouDiZhuPlus();
break;
}
nullRoom.setPersonNumber(PERSONNUM);
nullRoom.setRoomId(getRoomIdStr(genRoomId()));
nullRoom.setCreateUser(userId);
nullRoom.setGoldRoomType(goldRoomType);
nullRoom.setGameType(GAMETYPE_LONGQI);
nullRoom.setRoomType(roomType);
nullRoom.setAA(true);
nullRoom.setCreaterJoin(true);
nullRoom.init(1, -1);
nullRoom.setCreateType(1);
}
nullRoom.joinRoom(userId, true);
/*ArrayList<Long> userslist = new ArrayList<>();
userslist.add(userId);
HashMap<Long, Integer> userStatusMap = new HashMap<>();
userStatusMap.put(userId, 0);
HashMap<Long, Double> userScoresMap = new HashMap<>();
userScoresMap.put(userId, 0D);
HashMap<Long, RoomStatistics> roomStatisticsMap = new HashMap<>();
roomStatisticsMap.put(userId, new RoomStatistics(userId));
room.setUsers(userslist);
room.setUserStatus(userStatusMap);
room.setUserScores(userScoresMap);
room.setRoomStatisticsMap(roomStatisticsMap);*/
// room.getReady(userId);//准备
// list.add(room);
ServerConfig serverConfig = SpringUtil.getBean(ServerConfig.class);
RoomManager.addRoom(nullRoom.getRoomId(), "" + serverConfig.getServerId(), nullRoom);
IdWorker idWorker = new IdWorker(serverConfig.getServerId(), 0);
nullRoom.setUuid(idWorker.nextId());
MsgSender.sendMsg2Player(new ResponseVo("pokerRoomService", "joinGoldRoom", nullRoom.toVo(userId)), userId);
return 0;
}
Aggregations