use of com.code.server.kafka.MsgProducer in project summer by foxsugar.
the class GameDouDiZhuGold method genRecord.
protected void genRecord() {
room.setRoomType("3");
long id = IdWorker.getDefaultInstance().nextId();
genRecord(playerCardInfos.values().stream().collect(Collectors.toMap(PlayerCardInfoDouDiZhu::getUserId, PlayerCardInfoDouDiZhu::getScore)), room, id);
// 回放
replay.setId(id);
replay.setCount(playerCardInfos.size());
replay.setRoom_uuid(this.room.getUuid());
replay.setRoomInfo(this.room.toVo(0));
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_REPLAY);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, replay);
}
use of com.code.server.kafka.MsgProducer in project summer by foxsugar.
the class GameDouDiZhuPlus method genRecord.
protected void genRecord() {
room.setRoomType("3");
long id = IdWorker.getDefaultInstance().nextId();
genRecord(playerCardInfos.values().stream().collect(Collectors.toMap(PlayerCardInfoDouDiZhu::getUserId, PlayerCardInfoDouDiZhu::getScore)), room, id);
// 回放
replay.setId(id);
replay.setCount(playerCardInfos.size());
replay.setRoom_uuid(this.room.getUuid());
replay.setRoomInfo(this.room.toVo(0));
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_REPLAY);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, replay);
}
use of com.code.server.kafka.MsgProducer in project summer by foxsugar.
the class GameGuessCar method sendResult.
// =====================================
// ==============结束操作================
// =====================================
/**
* 发送战绩
*/
protected void sendResult() {
double tempS = bankerCardInfos.getScore();
// 算分
for (PlayerCardInfoGuessCar playerCardInfo : playerCardInfos.values()) {
if (RED == this.color) {
playerCardInfo.setFinalScore(playerCardInfo.getFinalScore() + playerCardInfo.getRedScore() * 0.95 - playerCardInfo.getGreenScore());
bankerCardInfos.setScore(bankerCardInfos.getScore() + playerCardInfo.getGreenScore() - playerCardInfo.getRedScore());
RedisManager.getUserRedisService().addUserMoney(playerCardInfo.getUserId(), (playerCardInfo.getRedScore() * 0.95 - playerCardInfo.getGreenScore()));
// RedisManager.getUserRedisService().addUserMoney(bankerCardInfos.getUserId(),(playerCardInfo.getGreenScore()-playerCardInfo.getRedScore()));
this.room.bankerScore += (playerCardInfo.getGreenScore() - playerCardInfo.getRedScore());
} else {
playerCardInfo.setFinalScore(playerCardInfo.getFinalScore() + playerCardInfo.getGreenScore() * 0.95 - playerCardInfo.getRedScore());
bankerCardInfos.setScore(bankerCardInfos.getScore() + playerCardInfo.getRedScore() - playerCardInfo.getGreenScore());
RedisManager.getUserRedisService().addUserMoney(playerCardInfo.getUserId(), (playerCardInfo.getGreenScore() * 0.95 - playerCardInfo.getRedScore()));
// RedisManager.getUserRedisService().addUserMoney(bankerCardInfos.getUserId(),(playerCardInfo.getRedScore()-playerCardInfo.getGreenScore()));
this.room.bankerScore += (playerCardInfo.getRedScore() - playerCardInfo.getGreenScore());
}
}
// 普通玩家
if (playerCardInfos != null && playerCardInfos.size() > 0) {
for (Long l : playerCardInfos.keySet()) {
Map<String, Object> result = new HashMap<>();
result.put("color", this.color);
result.put("finalScore", playerCardInfos.get(l).getFinalScore());
double add = 0;
if (RED == this.color) {
// 设置赢了多少
result.put("score", playerCardInfos.get(l).getRedScore() * 2 * 0.975 - playerCardInfos.get(l).getGreenScore());
add = playerCardInfos.get(l).getRedScore();
} else {
result.put("score", playerCardInfos.get(l).getGreenScore() * 2 * 0.975 - playerCardInfos.get(l).getRedScore());
add = playerCardInfos.get(l).getGreenScore();
}
Map<String, Object> addGold = new HashMap<>();
addGold.put("userId", l);
addGold.put("gold", add / 100);
KafkaMsgKey kafkaMsgKey = new KafkaMsgKey().setMsgId(KAFKA_MSG_ID_GUESS_ADD_GOLD);
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
msgProducer.send(IKafaTopic.CENTER_TOPIC, kafkaMsgKey, addGold);
ResponseVo vo = new ResponseVo("gameGuessService", "gameResult", result);
MsgSender.sendMsg2Player(vo, l);
}
}
/*RedisManager.getUserRedisService().setUserMoney(bankerCardInfos.getUserId(),RedisManager.getUserRedisService().getUserMoney(bankerCardInfos.getUserId()) + (bankerCardInfos.getScore()-tempS));*/
// 庄家
Map<String, Object> result = new HashMap<>();
// this.room.bankerScore = bankerCardInfos.getScore();
result.put("score", bankerCardInfos.getScore() - tempS);
result.put("bankerScore", bankerCardInfos.getScore());
result.put("color", this.color);
ResponseVo vo = new ResponseVo("gameGuessService", "gameBankerResult", result);
ResponseVo voBanker = new ResponseVo("gameGuessService", "gameResult", result);
// MsgSender.sendMsg2Player(vo, bankerCardInfos.getUserId());
MsgSender.sendMsg2Player(voBanker, bankerCardInfos.getUserId());
MsgSender.sendMsg2Player(vo, this.room.getUsers());
// 改变状态
this.room.state = RoomGuessCar.STATE_GUESS;
MsgSender.sendMsg2Player("gameGuessService", "stateChange", this.room.state, this.room.getUsers());
if (this.room.bankerScore <= 50) {
MsgSender.sendMsg2Player("gameGuessService", "gameOver", "gameOver", this.room.getUsers());
this.room.quitRoom(this.room.getBankerId());
}
}
use of com.code.server.kafka.MsgProducer 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.kafka.MsgProducer in project summer by foxsugar.
the class Room method clubDrawBack.
private void clubDrawBack() {
MsgProducer msgProducer = SpringUtil.getBean(MsgProducer.class);
KafkaMsgKey kafkaKey = new KafkaMsgKey();
kafkaKey.setUserId(0);
Map<String, Object> msg = new HashMap<>();
msg.put("clubId", this.clubId);
msg.put("clubModelId", this.clubRoomModel);
ResponseVo responseVo = new ResponseVo("clubService", "clubDrawBack", msg);
msgProducer.send("clubService", kafkaKey, responseVo);
}
Aggregations