use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method invite.
/**
* 邀请其他玩家
*
* @param msgKey
* @param clubId
* @param roomId
* @param inviteUser
* @return
*/
public int invite(KafkaMsgKey msgKey, String clubId, String roomId, String inviteUser, String roomModel, String name) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
Map<String, Object> result = new HashMap<>();
result.put("clubId", clubId);
result.put("roomId", roomId);
result.put("inviteUser", inviteUser);
result.put("roomModelInfo", getRoomModel(club, roomModel));
result.put("name", name);
msgProducer.send();
sendMsg2Player(new ResponseVo("clubService", "inviteUser", result), Long.valueOf(inviteUser));
sendMsg(msgKey, new ResponseVo("clubService", "invite", "ok"));
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method clubDrawBack.
/**
* 俱乐部房间退钱
*
* @param clubId
* @param clubModelId
*/
public int clubDrawBack(String clubId, String clubModelId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club != null) {
RoomModel roomModel = getRoomModel(club, clubModelId);
if (roomModel != null) {
int money = roomModel.getMoney();
synchronized (club.lock) {
club.setMoney(club.getMoney() + money);
// 统计减去消耗
String today = LocalDate.now().toString();
ClubStatistics clubStatistics = roomModel.getStatisticsMap().get(today);
if (clubStatistics != null) {
clubStatistics.setConsumeNum(clubStatistics.getConsumeNum() - roomModel.getMoney());
}
}
}
}
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method setRoomModel.
/**
* 修改房间模式
*
* @param msgKey
* @param userId
* @param clubId
* @param roomModelId
* @param createCommand
* @param gameType
* @param gameNumber
* @param desc
* @return
*/
public int setRoomModel(KafkaMsgKey msgKey, long userId, String clubId, String roomModelId, String createCommand, String gameType, int gameNumber, String desc) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
// 初始化 房间数据
initRoomData();
StaticDataProto.RoomData roomData = DataManager.data.getRoomDataMap().get(gameType);
if (roomData == null || !roomData.getMoneyMap().containsKey(gameNumber)) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
JsonNode jsonNode = JsonUtil.readTree(createCommand);
String serviceName = jsonNode.path("service").asText();
// 设置创建命令
RoomModel roomModel = getRoomModel(club, roomModelId);
if (roomModel == null) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
createCommand = setRoomModelCommand(createCommand, clubId, roomModel.getId());
roomModel.setCreateCommand(createCommand);
roomModel.setDesc(desc);
roomModel.setTime(System.currentTimeMillis());
roomModel.setMoney(roomData.getMoneyMap().get(gameNumber));
roomModel.setServiceName(serviceName);
sendMsg(msgKey, new ResponseVo("clubService", "setRoomModel", roomModel));
// 实例化房间
initRoomInstance(club);
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method createRoomModel.
/**
* 创建房间model
*
* @param createCommand
* @param userId
* @param clubId
* @param gameType
* @param gameNumber
* @param desc
* @return
*/
public int createRoomModel(KafkaMsgKey msgKey, long userId, String clubId, String createCommand, String gameType, int gameNumber, String desc) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
if (club.getPresident() != userId) {
return ErrorCode.CLUB_NOT_PRESIDENT;
}
if (club.getClubInfo().getRoomModels().size() >= ROOM_LIMIT) {
return ErrorCode.CLUB_NOT_MODEL_LIMIT;
}
// 初始化 房间数据
initRoomData();
StaticDataProto.RoomData roomData = DataManager.data.getRoomDataMap().get(gameType);
if (roomData == null || !roomData.getMoneyMap().containsKey(gameNumber)) {
return ErrorCode.REQUEST_PARAM_ERROR;
}
RoomModel roomModel = new RoomModel();
String id = "" + IdWorker.getDefaultInstance().nextId();
roomModel.setId(id);
JsonNode jsonNode = JsonUtil.readTree(createCommand);
String serviceName = jsonNode.path("service").asText();
// 设置创建命令
createCommand = setRoomModelCommand(createCommand, clubId, id);
roomModel.setCreateCommand(createCommand);
roomModel.setDesc(desc);
roomModel.setTime(System.currentTimeMillis());
roomModel.setMoney(roomData.getMoneyMap().get(gameNumber));
roomModel.setServiceName(serviceName);
club.getClubInfo().getRoomModels().add(roomModel);
sendMsg(msgKey, new ResponseVo("clubService", "createRoomModel", roomModel));
// 实例化房间
initRoomInstance(club);
return 0;
}
use of com.code.server.db.model.Club in project summer by foxsugar.
the class GameClubService method quitClub.
/**
* 退出俱乐部
*
* @param msgKey
* @param userId
* @param clubId
* @return
*/
public int quitClub(KafkaMsgKey msgKey, long userId, String clubId) {
Club club = ClubManager.getInstance().getClubById(clubId);
if (club == null) {
return ErrorCode.CLUB_NO_THIS;
}
// todo
// 删除
clubRemoveMember(club, userId);
sendMsg(msgKey, new ResponseVo("clubService", "quitClub", "ok"));
return 0;
}
Aggregations