use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class RoomCow method getUserOfResult.
public List<UserOfResult> getUserOfResult() {
ArrayList<UserOfResult> userOfResultList = new ArrayList<>();
long time = System.currentTimeMillis();
for (UserBean eachUser : RedisManager.getUserRedisService().getUserBeans(this.users)) {
UserOfResult resultObj = new UserOfResult();
resultObj.setUsername(eachUser.getUsername());
resultObj.setImage(eachUser.getImage());
if ("30".equals(getGameType())) {
resultObj.setScores(this.userScores.get(eachUser.getId()) - 1000.0 + "");
} else {
resultObj.setScores(this.userScores.get(eachUser.getId()) + "");
}
resultObj.setUserId(eachUser.getId());
resultObj.setTime(time);
resultObj.setRoomStatistics(roomStatisticsMap.get(eachUser.getId()));
// 设置牌型次数
if (this.getAllWinNum().containsKey(eachUser.getId())) {
resultObj.setAllWinNum(this.getAllWinNum().get(eachUser.getId()));
}
if (this.getAllLoseNum().containsKey(eachUser.getId())) {
resultObj.setAllLoseNum(this.getAllLoseNum().get(eachUser.getId()));
}
if (this.getCowCowNum().containsKey(eachUser.getId())) {
resultObj.setCowCowNum(this.getCowCowNum().get(eachUser.getId()));
}
if (this.getNullCowNum().containsKey(eachUser.getId())) {
resultObj.setNullCowNum(this.getNullCowNum().get(eachUser.getId()));
}
if (this.getWinNum().containsKey(eachUser.getId())) {
resultObj.setWinNum(this.getWinNum().get(eachUser.getId()));
}
userOfResultList.add(resultObj);
}
return userOfResultList;
}
use of com.code.server.constant.game.UserBean 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.game.UserBean in project summer by foxsugar.
the class RoomHitGoldFlower 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());
}
use of com.code.server.constant.game.UserBean 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.UserBean in project summer by foxsugar.
the class UserRedisService method addUserGold.
@Override
public double addUserGold(long userId, double gold) {
HashOperations<String, String, Double> user_money = redisTemplate.opsForHash();
// 把修改后的值放入userBean里
double m = user_money.increment(USER_GOLD, "" + userId, gold);
UserBean userBean = getUserBean(userId);
if (userBean != null) {
userBean.setGold(m);
updateUserBean(userId, userBean);
}
return m;
}
Aggregations