探索血量更新

back_recharge
xuexinpeng 2021-12-28 18:25:41 +08:00
parent eab1eb0b89
commit 5e811fb9aa
1 changed files with 17 additions and 13 deletions

View File

@ -44,7 +44,22 @@ public class ExplorerMapLogic {
public static ExplorerMapLogic getInstance() {
return ExplorerMapLogic.Instance.instance;
}
public static void sendIndication(int uid, ExplorerInfo explorerInfo, int teamId){
ISession sess = OnlineUserManager.sessionMap.get(uid);
if (sess != null) {
List<CommonProto.CommKeyVal> dropKeyValList = new ArrayList<>();
for (Map.Entry<Integer, Integer> keyVal : explorerInfo.getDropMap().entrySet()) {
dropKeyValList.add(CommonProto.CommKeyVal.newBuilder().setKey(keyVal.getKey()).setVal(keyVal.getValue()).build());
}
CommonProto.ExplorerMapInfo mapInfo = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(teamId).setMapId(explorerInfo.getMapId()).setHp(explorerInfo.getPlayerHp()).
setExploreTime(explorerInfo.getSendEndTime()).addAllDropReward(dropKeyValList).build();
PlayerInfoProto.ExplorerMapIndicationResponse.Builder indication = PlayerInfoProto.ExplorerMapIndicationResponse.newBuilder();
indication.setExploreInfo(mapInfo);
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
}
}
//单场战斗
public static void singleBattle(User user, ExplorerInfo explorerInfo, int teamId, int time) throws Exception {
if (explorerInfo == null) {
@ -78,6 +93,7 @@ public class ExplorerMapLogic {
if (reducePlayer > reduceMonster) {
//怪物赢了 保留血量 下次打
LOGGER.info("怪物赢了:");
sendIndication(user.getId(),explorerInfo,teamId);
} else {
LOGGER.info("玩家赢了:");
Map<Integer, Integer> dropMap = explorerInfo.getDropMap();
@ -93,19 +109,7 @@ public class ExplorerMapLogic {
}
}
explorerInfo.setDropMap(dropMap);
ISession sess = OnlineUserManager.sessionMap.get(user.getId());
if (sess != null) {
List<CommonProto.CommKeyVal> dropKeyValList = new ArrayList<>();
for (Map.Entry<Integer, Integer> keyVal : explorerInfo.getDropMap().entrySet()) {
dropKeyValList.add(CommonProto.CommKeyVal.newBuilder().setKey(keyVal.getKey()).setVal(keyVal.getValue()).build());
}
CommonProto.ExplorerMapInfo mapInfo = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(teamId).setMapId(explorerInfo.getMapId()).setHp(explorerInfo.getPlayerHp()).
setExploreTime(explorerInfo.getSendEndTime()).addAllDropReward(dropKeyValList).build();
PlayerInfoProto.ExplorerMapIndicationResponse.Builder indication = PlayerInfoProto.ExplorerMapIndicationResponse.newBuilder();
indication.setExploreInfo(mapInfo);
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
}
sendIndication(user.getId(),explorerInfo,teamId);
}
//玩家死亡 设置重生时间
if (explorerInfo.getPlayerHp() == 0) {