Search in sources :

Example 1 with RoomRecord

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);
}
Also used : UserRecord(com.code.server.constant.game.UserRecord) UserBean(com.code.server.constant.game.UserBean) MsgProducer(com.code.server.kafka.MsgProducer) KafkaMsgKey(com.code.server.constant.kafka.KafkaMsgKey) RoomRecord(com.code.server.constant.game.RoomRecord)

Example 2 with 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);
        }
    }
}
Also used : RoomRecord(com.code.server.constant.game.RoomRecord) Record(com.code.server.constant.game.Record) RoomRecord(com.code.server.constant.game.RoomRecord)

Example 3 with RoomRecord

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);
}
Also used : ClubRecord(com.code.server.db.model.ClubRecord) RoomRecord(com.code.server.constant.game.RoomRecord)

Example 4 with RoomRecord

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);
}
Also used : UserRecord(com.code.server.db.model.UserRecord) RoomRecord(com.code.server.constant.game.RoomRecord)

Example 5 with RoomRecord

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);
    }
}
Also used : RoomRecord(com.code.server.constant.game.RoomRecord) RoomRecord(com.code.server.constant.game.RoomRecord) Record(com.code.server.constant.game.Record) RoomModel(com.code.server.constant.club.RoomModel)

Aggregations

RoomRecord (com.code.server.constant.game.RoomRecord)5 Record (com.code.server.constant.game.Record)2 RoomModel (com.code.server.constant.club.RoomModel)1 UserBean (com.code.server.constant.game.UserBean)1 UserRecord (com.code.server.constant.game.UserRecord)1 KafkaMsgKey (com.code.server.constant.kafka.KafkaMsgKey)1 ClubRecord (com.code.server.db.model.ClubRecord)1 UserRecord (com.code.server.db.model.UserRecord)1 MsgProducer (com.code.server.kafka.MsgProducer)1