use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class GameClubService method createClub.
/**
* 创建俱乐部
*
* @param msgKey
* @param userId
* @param clubName
* @param wx
* @param area
* @param desc
* @return
*/
public int createClub(KafkaMsgKey msgKey, long userId, String clubName, String wx, String area, String desc) {
// 钱是否够
double money = RedisManager.getUserRedisService().getUserMoney(userId);
if (money < getCreateMoney()) {
return ErrorCode.CLUB_CANNOT_MONEY;
}
// 多于5个俱乐部 不可以创建
int num = ClubManager.getInstance().getUserClubNum(userId);
if (num >= JOIN_LIMIT) {
return ErrorCode.CLUB_CANNOT_NUM;
}
// 人减钱
RedisManager.getUserRedisService().addUserMoney(userId, -getCreateMoney());
Club club = new Club();
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
// id
club.setId(ClubManager.getInstance().getClubId());
club.setPresident(userId);
club.setName(clubName);
club.setPresidentName(userBean.getUsername());
club.setPresidentWx(wx);
club.setArea(area);
club.setMoney(getCreateMoney());
club.setClubDesc(desc);
clubAddMember(club, userBean);
clubService.getClubDao().save(club);
ClubManager.getInstance().getClubMap().put(club.getId(), club);
ResponseVo vo = new ResponseVo("clubService", "createClub", club);
sendMsg(msgKey, vo);
return 0;
}
use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class RoomInfo 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());
resultObj.setScores(this.userScores.get(eachUser.getId()) + "");
resultObj.setUserId(eachUser.getId());
resultObj.setTime(time);
if (this.getHuNum().containsKey(eachUser.getId())) {
resultObj.setHuNum(this.getHuNum().get(eachUser.getId()));
}
if (this.getLianZhuangNum().containsKey(eachUser.getId())) {
resultObj.setLianZhuangNum(this.getLianZhuangNum().get(eachUser.getId()));
}
if (this.getDianPaoNum().containsKey(eachUser.getId())) {
resultObj.setDianPaoNum((this.getDianPaoNum().get(eachUser.getId())));
}
if (this.getMoBaoNum().containsKey(eachUser.getId())) {
resultObj.setMoBaoNum(this.getMoBaoNum().get(eachUser.getId()));
}
userOfResultList.add(resultObj);
// 删除映射关系
// RedisManager.getUserRedisService().removeRoom(eachUser.getId());
}
return userOfResultList;
}
use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class ReconnService method reconnection.
public static int reconnection(String roomId, long userId) {
AllMessage allMessage = new AllMessage();
allMessage.setExist(false);
RoomInfo roomInfo = (RoomInfo) RoomManager.getRoom(roomId);
if (roomInfo != null) {
allMessage.setExist(true);
List<UserVo> userList = new ArrayList<>();
allMessage.setRoom(getRoomInfo(roomInfo));
allMessage.setBanker(roomInfo.getBankerId());
allMessage.setCurGameNumber(roomInfo.getCurGameNumber());
allMessage.setUserScores(roomInfo.getUserScores());
allMessage.setUserStatus(roomInfo.getUserStatus());
// 圈数
allMessage.setCircleNum(roomInfo.getCurCircle());
allMessage.getLaZhuang().putAll(roomInfo.getLaZhuang());
allMessage.getLaZhuangStatus().putAll(roomInfo.getLaZhuangStatus());
for (UserBean userBean : RedisManager.getUserRedisService().getUserBeans(roomInfo.getUsers())) {
userList.add(userBean.toVo());
}
// 在线状态
for (long uid : roomInfo.getUsers()) {
allMessage.getOfflineStatus().put(uid, RedisManager.getUserRedisService().getGateId(uid) != null);
}
GameInfo gameInfo = (GameInfo) roomInfo.getGame();
roomInfo.getReady(userId);
if (gameInfo != null) {
ReconnectResp reconnect = new ReconnectResp(gameInfo, userId);
allMessage.setGameId(gameInfo.getGameId());
allMessage.setCardNumber(gameInfo.getRemainCards().size());
allMessage.setReconnectResp(reconnect);
}
allMessage.setUsers(userList);
if (roomInfo.getTimerNode() != null) {
long time = roomInfo.getTimerNode().getStart() + roomInfo.getTimerNode().getInterval() - System.currentTimeMillis();
allMessage.setRemainTime(time);
}
}
ResponseVo vo = new ResponseVo("reconnService", "reconnection", allMessage);
MsgSender.sendMsg2Player(vo, userId);
return 0;
}
use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class RoomHitGoldFlower 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.getBaoziNum().containsKey(eachUser.getId())) {
resultObj.setBaoziNum(this.getBaoziNum().get(eachUser.getId()));
}
if (this.getTonghuashunNum().containsKey(eachUser.getId())) {
resultObj.setTonghuashunNum(this.getTonghuashunNum().get(eachUser.getId()));
}
if (this.getTonghuaNum().containsKey(eachUser.getId())) {
resultObj.setTonghuaNum(this.getTonghuaNum().get(eachUser.getId()));
}
if (this.getShunziNum().containsKey(eachUser.getId())) {
resultObj.setShunziNum(this.getShunziNum().get(eachUser.getId()));
}
if (this.getDuiziNum().containsKey(eachUser.getId())) {
resultObj.setDuiziNum(this.getDuiziNum().get(eachUser.getId()));
}
if (this.getSanpaiNum().containsKey(eachUser.getId())) {
resultObj.setSanpaiNum(this.getSanpaiNum().get(eachUser.getId()));
}
userOfResultList.add(resultObj);
}
return userOfResultList;
}
use of com.code.server.constant.game.UserBean in project summer by foxsugar.
the class RedisApplication method test.
public void test() {
UserBean userBean = new UserBean();
userBean.setGold(1);
HashOperations<String, String, UserBean> user_money = redisTemplate.opsForHash();
user_money.put("testString", "1", userBean);
Map<String, Object> params = new HashMap<>();
}
Aggregations