use of com.code.server.constant.game.RoomRecord in project summer by foxsugar.
the class RoomGoldPaijiu method genRoomRecord.
/**
* 生成房间战绩
*/
@Override
public void genRoomRecord() {
RoomRecord roomRecord = new RoomRecord();
roomRecord.setRoomId(this.roomId);
roomRecord.setId(this.getUuid());
roomRecord.setType(this.roomType);
roomRecord.setTime(System.currentTimeMillis());
roomRecord.setClubId(this.getClubId());
roomRecord.setClubRoomModel(this.getClubRoomModel());
for (Long l : userScoresForGold.keySet()) {
UserRecord userRecord = new UserRecord();
userRecord.setScore(userScoresForGold.get(l));
userRecord.setUserId(l);
UserBean userBean = RedisManager.getUserRedisService().getUserBean(l);
if (userBean != null) {
userRecord.setName(userBean.getUsername());
}
roomRecord.getRecords().add(userRecord);
}
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_ROOM_RECORD);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, roomRecord);
}
use of com.code.server.constant.game.RoomRecord in project summer by foxsugar.
the class CenterMsgService method genRecord.
private static void genRecord(String msg) {
RoomRecord roomRecord = JsonUtil.readValue(msg, RoomRecord.class);
List<com.code.server.constant.game.UserRecord> lists = roomRecord.getRecords();
for (com.code.server.constant.game.UserRecord userRecord : lists) {
UserRecord addRecord = userRecordService.getUserRecordByUserId(userRecord.getUserId());
if (addRecord != null) {
userRecordService.addRecord(userRecord.getUserId(), roomRecord);
} else {
Record record = new Record();
record.addRoomRecord(roomRecord);
UserRecord newRecord = new UserRecord();
newRecord.setId(userRecord.getUserId());
newRecord.setRecord(record);
userRecordService.save(newRecord);
}
}
}
use of com.code.server.constant.game.RoomRecord in project summer by foxsugar.
the class ClubRecordService method addRecord.
public void addRecord(String clubId, RoomRecord roomRecord) {
ClubRecord clubRecord = clubRecordDao.getClubRecordById(clubId);
if (clubRecord == null) {
clubRecord = new ClubRecord();
clubRecord.setId(clubId);
}
List<RoomRecord> rc = clubRecord.getRecords();
// 有删除的战绩
if (rc == null) {
rc = new ArrayList<>();
// gameRecordService.decGameRecordCount(roomUid);
} else {
rc.add(roomRecord);
}
// 过长 删除第一个
if (rc.size() >= 20) {
rc.remove(0);
}
clubRecordDao.save(clubRecord);
// return userRecordDao.save(userRecords);
}
use of com.code.server.constant.game.RoomRecord in project summer by foxsugar.
the class UserRecordService method addRecord.
/**
* 添加一条战绩 超过指定条数后删除第一条
* @param userid
* @param roomRecord
* @return
*/
public UserRecord addRecord(long userid, RoomRecord roomRecord) {
UserRecord userRecords = userRecordDao.findOne(userid);
RoomRecord rc = userRecords.getRecord().addRoomRecord(roomRecord);
// 有删除的战绩
if (rc != null) {
long roomUid = rc.getId();
gameRecordService.decGameRecordCount(roomUid);
}
return userRecordDao.save(userRecords);
}
use of com.code.server.constant.game.RoomRecord in project summer by foxsugar.
the class CenterMsgService method genRoomRecord.
private static void genRoomRecord(String msg) {
RoomRecord roomRecord = JsonUtil.readValue(msg, RoomRecord.class);
List<com.code.server.constant.game.UserRecord> lists = roomRecord.getRecords();
for (com.code.server.constant.game.UserRecord userRecord : lists) {
UserRecord addRecord = userRecordService.getUserRecordByUserId(userRecord.getUserId());
if (addRecord != null) {
userRecordService.addRecord(userRecord.getUserId(), roomRecord);
} else {
Record record = new Record();
record.addRoomRecord(roomRecord);
UserRecord newRecord = new UserRecord();
newRecord.setId(userRecord.getUserId());
newRecord.setRecord(record);
userRecordService.save(newRecord);
}
}
// 俱乐部战绩
String clubId = roomRecord.getClubId();
if (clubId != null && !"".equals(clubId)) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club != null) {
String roomModel = roomRecord.getClubRoomModel();
RoomModel rm = GameClubService.getRoomModel(club, roomModel);
roomRecord.setName(rm.getDesc());
}
clubRecordService.addRecord(clubId, roomRecord);
}
}
Aggregations