use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class Game method genRecord.
protected void genRecord(Map<Long, Double> scores, Room room, long id) {
Map<String, Object> data = new HashMap<>();
data.put("count", scores.size());
data.put("room_uuid", room.getUuid());
data.put("replay_id", id);
GameRecord gameRecord = new GameRecord();
gameRecord.setCurGameNumber(room.getCurGameNumber());
scores.forEach((key, value) -> {
UserRecord userRecord = new UserRecord();
userRecord.setScore(value);
userRecord.setUserId(key);
userRecord.setRoomId(room.getRoomId());
UserBean userBean = RedisManager.getUserRedisService().getUserBean(key);
if (userBean != null) {
userRecord.setName(userBean.getUsername());
}
gameRecord.getRecords().add(userRecord);
});
data.put("record", JsonUtil.toJson(gameRecord));
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_GAME_RECORD);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, data);
}
use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class RoomCow method noticeJoinRoom.
@Override
public void noticeJoinRoom(long userId) {
List<UserVo> usersList = new ArrayList<>();
UserOfRoom userOfRoom = new UserOfRoom();
int readyNumber = 0;
for (UserBean userBean : RedisManager.getUserRedisService().getUserBeans(users)) {
userOfRoom.getUserList().add(userBean.toVo());
}
userOfRoom.setInRoomNumber(users.size());
userOfRoom.setReadyNumber(readyNumber);
Map<Long, Double> scoresMap = new HashMap<>();
if ("30".equals(getGameType())) {
for (Long l : users) {
scoresMap.put(l, 1000.0);
}
} else {
for (Long l : users) {
scoresMap.put(l, 0.0);
}
}
userOfRoom.setUserScores(scoresMap);
userOfRoom.setCanStartUserId(users.get(0));
MsgSender.sendMsg2Player(new ResponseVo("roomService", "joinRoom", this.toVo(userId)), userId);
MsgSender.sendMsg2Player(new ResponseVo("roomService", "roomNotice", userOfRoom), this.getUsers());
}
Aggregations