use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method cludGameStart.
/**
* 俱乐部游戏开始
*
* @param clubId
* @param clubModelId
* @return
*/
public int cludGameStart(String clubId, String clubModelId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club != null) {
synchronized (club.lock) {
// 删除一个房间
club.getClubInfo().getRoomInstance().remove(clubModelId);
// 统计
RoomModel roomModel = getRoomModel(club, clubModelId);
if (roomModel != null) {
String today = LocalDate.now().toString();
ClubStatistics clubStatistics = roomModel.getStatisticsMap().get(today);
if (clubStatistics == null) {
clubStatistics = new ClubStatistics();
}
clubStatistics.setOpenNum(clubStatistics.getOpenNum() + 1);
clubStatistics.setConsumeNum(clubStatistics.getConsumeNum() + roomModel.getMoney());
roomModel.getStatisticsMap().put(today, clubStatistics);
// 删除七天前的
roomModel.getStatisticsMap().remove(LocalDate.now().minusDays(7).toString());
}
}
initRoomInstance(club);
}
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method getClubInfo.
/**
* 获得俱乐部信息
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int getClubInfo(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
// 刷新房间
initRoomInstance(club);
boolean isPresident = club.getPresident() == userId;
ClubVo clubVo = getClubVo_simple(club);
clubVo.getRoomModels().addAll(club.getClubInfo().getRoomModels());
// 玩家在线情况
clubVo.getMember().addAll(club.getClubInfo().getMember().values());
clubVo.getMember().forEach(clubMember -> {
String gateId = RedisManager.getUserRedisService().getGateId(clubMember.getUserId());
boolean online = gateId != null;
clubMember.setOnline(online);
});
club.getClubInfo().getRoomInstance().values().forEach(roomInstance -> {
if (roomInstance.getRoomId() != null) {
clubVo.getRoomInstance().add(getRoomInstanceVo(roomInstance));
}
});
// 房间情况
if (isPresident) {
clubVo.getApplyList().addAll(club.getClubInfo().getApplyList());
}
// todo 初始化数据
// todo 更改玩家真实信息
UserBean userBean = RedisManager.getUserRedisService().getUserBean(userId);
if (isPresident) {
club.setPresidentName(userBean.getUsername());
}
ClubMember clubMember = club.getClubInfo().getMember().get("" + userId);
clubMember.setName(userBean.getUsername());
clubMember.setImage(userBean.getImage());
// 发送结果
sendMsg(msgKey, new ResponseVo("clubService", "getClubInfo", clubVo));
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method charge.
/**
* 充值
*
* @param msgKey
* @param userId
* @param clubId
* @param money
* @return
*/
public int charge(KafkaMsgKey msgKey, long userId, String clubId, int money) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
if (money <= 0) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
if (RedisManager.getUserRedisService().getUserMoney(userId) < money) {
return ErrorCode.NOT_HAVE_MORE_MONEY;
}
// 加钱
club.setMoney(club.getMoney() + money);
RedisManager.getUserRedisService().addUserMoney(userId, -money);
sendMsg(msgKey, new ResponseVo("clubService", "charge", "ok"));
// 记录
ClubCharge clubCharge = new ClubCharge();
clubCharge.setClubId(clubId);
clubCharge.setNum(money);
clubCharge.setNowMoney(club.getMoney());
clubCharge.setChargeTime(LocalDateTime.now().toString());
clubChargeService.getClubChargeDao().save(clubCharge);
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method kickUser.
public int kickUser(KafkaMsgKey msgKey, long userId, String clubId, long kickUser) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
clubRemoveMember(club, kickUser);
sendMsg(msgKey, new ResponseVo("clubService", "kickUser", "ok"));
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method getClubRecord.
/**
* 获得俱乐部战绩
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int getClubRecord(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
ClubRecord clubRecord = clubRecordService.getClubRecordDao().getClubRecordById(clubId);
sendMsg(msgKey, new ResponseVo("clubService", "getClubRecord", clubRecord));
return 0;
}
Aggregations