back_recharge
parent
705e81c629
commit
eab1eb0b89
|
@ -214,7 +214,6 @@ public class CoreService implements RPCRequestIFace.Iface {
|
|||
public boolean sendCrossLingmaiHongdian(int uid){
|
||||
ISession sess = OnlineUserManager.sessionMap.get(uid);
|
||||
if (sess != null) {
|
||||
LOGGER.info("灵脉秘境红点logloglogggggggggggggg");
|
||||
ArenaInfoProto.CrossLingmaiIndicationResponse.Builder indication = ArenaInfoProto.CrossLingmaiIndicationResponse.newBuilder();
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.CrossLingmaiIndicationResponse_VALUE, indication.build(), true);
|
||||
}
|
||||
|
|
|
@ -15,29 +15,29 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExplorerMapInfoHandler extends BaseHandler<PlayerInfoProto.ExplorerMapInfoRequest> {
|
||||
public class ExplorerMapInfoHandler extends BaseHandler<PlayerInfoProto.ExplorerMapInfoRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.ExplorerMapInfoRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapInfoRequest proto) throws Exception{
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapInfoRequest proto) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.ExplorerMapInfoResponse.Builder builder = PlayerInfoProto.ExplorerMapInfoResponse.newBuilder();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
for(int i = TeamEnum.EXPLORE_TEAM_ONE.getTeamId();i<=TeamEnum.EXPLORE_TEAM_FIVE.getTeamId();i++){
|
||||
PlayerInfoProto.ExplorerMapInfoResponse.Builder builder = PlayerInfoProto.ExplorerMapInfoResponse.newBuilder();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
for (int i = TeamEnum.EXPLORE_TEAM_ONE.getTeamId(); i <= TeamEnum.EXPLORE_TEAM_FIVE.getTeamId(); i++) {
|
||||
CommonProto.ExplorerMapInfo record;
|
||||
List<CommonProto.CommKeyVal> dropKeyValList = new ArrayList<>();
|
||||
if(!explorer.containsKey(i)){
|
||||
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).build();
|
||||
}else{
|
||||
for(Map.Entry<Integer,Integer> keyVal:explorer.get(i).getDropMap().entrySet() ){
|
||||
dropKeyValList.add( CommonProto.CommKeyVal.newBuilder().setKey(keyVal.getKey()).setVal(keyVal.getValue()).build());
|
||||
if (!explorer.containsKey(i)) {
|
||||
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).build();
|
||||
} else {
|
||||
for (Map.Entry<Integer, Integer> keyVal : explorer.get(i).getDropMap().entrySet()) {
|
||||
dropKeyValList.add(CommonProto.CommKeyVal.newBuilder().setKey(keyVal.getKey()).setVal(keyVal.getValue()).build());
|
||||
}
|
||||
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).setMapId(explorer.get(i).getMapId()).setHp(explorer.get(i).getPlayerHp()).
|
||||
setExploreTime(explorer.get(i).getSendEndTime()).addAllDropReward(dropKeyValList).build();
|
||||
|
|
|
@ -14,7 +14,6 @@ import rpc.protocols.CommonProto;
|
|||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.ExplorerMapPlayerInfoRequest> {
|
||||
|
@ -23,8 +22,9 @@ public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.ExplorerMapPlayerInfoRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapPlayerInfoRequest proto) throws Exception{
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapPlayerInfoRequest proto) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
|
@ -37,13 +37,13 @@ public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
String key;
|
||||
if (crossGroup == -1) {
|
||||
key = Integer.toString(mapId);
|
||||
}else{
|
||||
} else {
|
||||
//跨服分组
|
||||
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
|
||||
key = Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
|
||||
}
|
||||
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
|
||||
Set<String> set = redisUtil.sGet(RedisKey.EXPLORER_MAP_PLAYER+RedisKey.Delimiter_colon + key);
|
||||
for(String uidStr:set){
|
||||
Set<String> set = redisUtil.sGet(RedisKey.EXPLORER_MAP_PLAYER + RedisKey.Delimiter_colon + key);
|
||||
for (String uidStr : set) {
|
||||
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(Integer.parseInt(uidStr));
|
||||
String serverName = CrossServiceLogic.simplifyServerName(csPlayer.getServerId());
|
||||
CommonProto.ArenaPersonInfo playerInfo = CommonProto.ArenaPersonInfo.newBuilder()
|
||||
|
@ -51,7 +51,7 @@ public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
.setLevel(csPlayer.getLevel())
|
||||
.setName(csPlayer.getName())
|
||||
.setServername(serverName)
|
||||
.setTotalForce(csPlayer.getMaxFore()) //.setTotalForce(crossArenaManager.getTotalForce())
|
||||
.setTotalForce(csPlayer.getMaxFore())
|
||||
.setUserTitle(csPlayer.getUserTitle())
|
||||
.setUserMount(csPlayer.getUserMount())
|
||||
.setGender(csPlayer.getSex())
|
||||
|
|
|
@ -1,12 +1,10 @@
|
|||
package com.ljsd.jieling.handler.explorerMap;
|
||||
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.globals.Global;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.ExplorerInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
|
@ -15,12 +13,9 @@ import manager.STableManager;
|
|||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.ExplorerMapRewardRequest> {
|
||||
|
@ -30,35 +25,35 @@ public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapRewardRequest proto) throws Exception{
|
||||
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapRewardRequest proto) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
PlayerInfoProto.ExplorerMapRewardResponse.Builder builder = PlayerInfoProto.ExplorerMapRewardResponse.newBuilder();
|
||||
PlayerInfoProto.ExplorerMapRewardResponse.Builder builder = PlayerInfoProto.ExplorerMapRewardResponse.newBuilder();
|
||||
int teamId = proto.getTeamId();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
if(!explorer.containsKey(teamId)){
|
||||
if (!explorer.containsKey(teamId)) {
|
||||
return;
|
||||
}
|
||||
if(proto.getType() == 0){
|
||||
if (proto.getType() == 0) {
|
||||
//停止探索
|
||||
ExplorerInfo exInfo = explorer.get(teamId);
|
||||
if(exInfo.getSendEndTime()> TimeUtils.nowInt()){
|
||||
int min = (exInfo.getSendEndTime() - TimeUtils.nowInt())/60;
|
||||
if (exInfo.getSendEndTime() > TimeUtils.nowInt()) {
|
||||
int min = (exInfo.getSendEndTime() - TimeUtils.nowInt()) / 60;
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(exInfo.getMapId());
|
||||
int itemId = exploreConfig.getCost()[0];
|
||||
int itemNum = exploreConfig.getCost()[1]*min;
|
||||
Map<Integer,Integer> comDropMap = new HashMap<>();
|
||||
Map<Integer,Integer> dropmap=explorer.get(teamId).getDropMap();
|
||||
int itemNum = exploreConfig.getCost()[1] * min;
|
||||
Map<Integer, Integer> comDropMap = new HashMap<>();
|
||||
Map<Integer, Integer> dropmap = explorer.get(teamId).getDropMap();
|
||||
comDropMap.putAll(dropmap);
|
||||
if(comDropMap.containsKey(itemId)){
|
||||
comDropMap.put(itemId,comDropMap.get(itemId)+itemNum);
|
||||
}else{
|
||||
comDropMap.put(itemId,itemNum);
|
||||
if (comDropMap.containsKey(itemId)) {
|
||||
comDropMap.put(itemId, comDropMap.get(itemId) + itemNum);
|
||||
} else {
|
||||
comDropMap.put(itemId, itemNum);
|
||||
}
|
||||
CommonProto.Drop.Builder dropPro = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
CommonProto.Drop.Builder dropPro = ItemUtil.drop(user, comDropMap.entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST_RETURN);
|
||||
explorer.get(teamId).getDropMap().clear();
|
||||
explorer.get(teamId).setDropMap(explorer.get(teamId).getDropMap());
|
||||
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(teamId).build();
|
||||
|
@ -66,6 +61,6 @@ public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
setExploreInfo(explorerMapInfo).build(), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -8,7 +8,6 @@ import com.ljsd.jieling.logic.GlobleSystemLogic;
|
|||
import com.ljsd.jieling.logic.dao.ExplorerInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.explorerMap.ExplorerMapLogic;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
|
@ -29,6 +28,7 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
|
||||
public static int hourMinute = 60;
|
||||
public static int hourSecond = 3600;
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.ExplorerMapSendRequest;
|
||||
|
@ -43,17 +43,17 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
}
|
||||
PlayerInfoProto.ExplorerMapSendResponse.Builder builder = PlayerInfoProto.ExplorerMapSendResponse.newBuilder();
|
||||
List<CommonProto.ExplorerMapSendInfo> reqInfo = proto.getSendDataList();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
Map<Integer,Integer> map = new HashMap<Integer, Integer>();
|
||||
for (CommonProto.ExplorerMapSendInfo info : reqInfo){
|
||||
//Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
Map<Integer, Integer> map = new HashMap<>();
|
||||
for (CommonProto.ExplorerMapSendInfo info : reqInfo) {
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(info.getMapId());
|
||||
map.put(exploreConfig.getCost()[0],info.getTime()*hourMinute*exploreConfig.getCost()[1]);
|
||||
map.put(exploreConfig.getCost()[0], info.getTime() * hourMinute * exploreConfig.getCost()[1]);
|
||||
}
|
||||
//消耗
|
||||
/*if(!ItemUtil.itemCost(user,map.entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).toArray(int[][]::new),BIReason.EXPLORE_MAP_COST,1)){
|
||||
if (!ItemUtil.itemCost(user, map.entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new), BIReason.EXPLORE_MAP_COST, 1)) {
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapSendResponse.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}*/
|
||||
}
|
||||
for (CommonProto.ExplorerMapSendInfo info : reqInfo) {
|
||||
int mapId = info.getMapId();
|
||||
int teamId = info.getTeamId();
|
||||
|
@ -63,11 +63,11 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
String key;
|
||||
if (crossGroup == -1) {
|
||||
key = Integer.toString(mapId);
|
||||
}else{
|
||||
} else {
|
||||
//跨服分组
|
||||
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
|
||||
key = Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
|
||||
}
|
||||
redisUtil.sSet(RedisKey.EXPLORER_MAP_PLAYER+ RedisKey.Delimiter_colon +key, String.valueOf(user.getId()));
|
||||
redisUtil.sSet(RedisKey.EXPLORER_MAP_PLAYER + RedisKey.Delimiter_colon + key, String.valueOf(user.getId()));
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(mapId);
|
||||
if (exploreConfig == null) {
|
||||
continue;
|
||||
|
@ -81,8 +81,7 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
|
||||
explorerInfo.setPlayerHp(teamForce);
|
||||
explorerInfo.setEnemyHp(mapMonsterForce);
|
||||
explorerInfo.setBatteTime(TimeUtils.nowInt()+60);
|
||||
|
||||
explorerInfo.setBatteTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());
|
||||
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().
|
||||
setTeamId(teamId).setMapId(mapId).setHp(explorerInfo.getPlayerHp()).
|
||||
setExploreTime(explorerInfo.getSendEndTime()).build();
|
||||
|
|
|
@ -27,11 +27,11 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ExplorerMapLogic {
|
||||
|
||||
|
@ -45,109 +45,95 @@ public class ExplorerMapLogic {
|
|||
return ExplorerMapLogic.Instance.instance;
|
||||
}
|
||||
|
||||
//战斗 派遣
|
||||
public static void battle(User user, int mapId, int teamId) {
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String key2 = RedisKey.getKey(RedisKey.EXPLORER_MAP_PLAYER, String.valueOf(mapId), false);
|
||||
redisUtil.lSet(key2, String.valueOf(user.getId()));
|
||||
}
|
||||
|
||||
//单场战斗
|
||||
public static void singleBattle(User user, ExplorerInfo explorerInfo, int teamId, int time) throws Exception {
|
||||
if (explorerInfo == null) {
|
||||
return;
|
||||
}
|
||||
LOGGER.error("开始战斗");
|
||||
{
|
||||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(explorerInfo.getMapId());
|
||||
if (exploreConfig == null) {
|
||||
return;
|
||||
LOGGER.info("开始战斗");
|
||||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(explorerInfo.getMapId());
|
||||
if (exploreConfig == null) {
|
||||
return;
|
||||
}
|
||||
//怪物的初始血量
|
||||
int mapMonsterForce = exploreConfig.getMonsterForce();
|
||||
float ratio = (float) teamForce / mapMonsterForce;
|
||||
SExploreFight exploreFightData = SExploreFight.getConfigByFightDownAndFightUp(ratio);
|
||||
if (exploreFightData == null) {
|
||||
return;
|
||||
}
|
||||
LOGGER.info("探索表id:={}", exploreFightData.getId());
|
||||
//掉血比例
|
||||
float reduceRatio = exploreFightData.getLoseFight();
|
||||
//玩家掉血
|
||||
int reducePlayer = (int) (teamForce * reduceRatio);
|
||||
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - reducePlayer);
|
||||
LOGGER.info("玩家掉血:=》{},剩余血量-》{}", reducePlayer, explorerInfo.getPlayerHp());
|
||||
//怪物掉血
|
||||
int reduceMonster = (int) (mapMonsterForce * reduceRatio);
|
||||
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (reduceMonster));
|
||||
LOGGER.info("怪物掉血:=》{},剩余血量-》{}", reduceMonster, explorerInfo.getEnemyHp());
|
||||
//输赢判断
|
||||
if (reducePlayer > reduceMonster) {
|
||||
//怪物赢了 保留血量 下次打
|
||||
LOGGER.info("怪物赢了:");
|
||||
} else {
|
||||
LOGGER.info("玩家赢了:");
|
||||
Map<Integer, Integer> dropMap = explorerInfo.getDropMap();
|
||||
if (dropMap == null) {
|
||||
dropMap = new HashMap<>();
|
||||
}
|
||||
//怪物的初始血量
|
||||
int mapMonsterForce = exploreConfig.getMonsterForce();
|
||||
float ratio = (float) teamForce / mapMonsterForce;
|
||||
SExploreFight exploreFightData = SExploreFight.getConfigByFightDownAndFightUp(ratio);
|
||||
if (exploreFightData == null) {
|
||||
return;
|
||||
Map<Integer, Integer> itemMap = ItemUtil.getItemMapByGroupId(user, exploreConfig.getReward(), 1, 0, BIReason.EXPLORE_MAP_GET);
|
||||
for (Map.Entry<Integer, Integer> keyVal : itemMap.entrySet()) {
|
||||
if (dropMap.containsKey(keyVal.getKey())) {
|
||||
dropMap.put(keyVal.getKey(), dropMap.get(keyVal.getKey()) + keyVal.getValue());
|
||||
} else {
|
||||
dropMap.put(keyVal.getKey(), keyVal.getValue());
|
||||
}
|
||||
}
|
||||
LOGGER.error("探索表id:={}", exploreFightData.getId());
|
||||
//掉血比例
|
||||
float reduceRatio = exploreFightData.getLoseFight();
|
||||
//玩家掉血
|
||||
int reducePlayer = (int) (teamForce * reduceRatio);
|
||||
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - reducePlayer);
|
||||
LOGGER.error("玩家掉血:=》{},剩余血量-》{}", reducePlayer,explorerInfo.getPlayerHp());
|
||||
//怪物掉血
|
||||
int reduceMonster = (int) (mapMonsterForce * reduceRatio);
|
||||
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (reduceMonster));
|
||||
LOGGER.error("怪物掉血:=》{},剩余血量-》{}", reduceMonster,explorerInfo.getEnemyHp());
|
||||
//输赢判断
|
||||
if (reducePlayer > reduceMonster) {
|
||||
//怪物赢了 保留血量 下次打
|
||||
LOGGER.error("怪物赢了:");
|
||||
} else {
|
||||
LOGGER.error("玩家赢了:");
|
||||
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();
|
||||
|
||||
}
|
||||
//玩家死亡 设置重生时间
|
||||
if (explorerInfo.getPlayerHp() == 0) {
|
||||
int reliveTime= SSpecialConfig.getIntegerValue(SSpecialConfig.EXPLORERE_LIVETIME);
|
||||
reliveTime=300;
|
||||
if (time == 0) {
|
||||
explorerInfo.setPlayerReliveTime(TimeUtils.nowInt() + reliveTime);
|
||||
} else {
|
||||
explorerInfo.setPlayerReliveTime(time + reliveTime);
|
||||
}
|
||||
LOGGER.error("玩家死亡=》重生时间{}", explorerInfo.getPlayerReliveTime());
|
||||
}
|
||||
//怪物死亡 设置重生时间
|
||||
if (explorerInfo.getEnemyHp()== 0) {
|
||||
//玩家赢了
|
||||
Map<Integer,Integer> dropMap = explorerInfo.getDropMap();
|
||||
if(dropMap == null){
|
||||
dropMap = new HashMap<>();
|
||||
}
|
||||
Map<Integer, Integer> itemMap = ItemUtil.getItemMapByGroupId(user, exploreConfig.getReward(), 1, 0, BIReason.EXPLORE_MAP_GET);
|
||||
for(Map.Entry<Integer,Integer> keyVal:itemMap.entrySet()){
|
||||
if(dropMap.containsKey(keyVal.getKey())){
|
||||
dropMap.put(keyVal.getKey(),dropMap.get(keyVal.getKey())+keyVal.getValue());
|
||||
}else{
|
||||
dropMap.put(keyVal.getKey(),keyVal.getValue());
|
||||
}
|
||||
}
|
||||
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();
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, mapInfo, true);
|
||||
}
|
||||
if (time == 0) {
|
||||
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + 300);
|
||||
} else {
|
||||
explorerInfo.setEnemyReliveTime(time + 300);
|
||||
}
|
||||
LOGGER.error("怪物死亡=》重生时间{} 掉落=>{}", explorerInfo.getEnemyReliveTime(),exploreConfig.getReward());
|
||||
PlayerInfoProto.ExplorerMapIndicationResponse.Builder indication = PlayerInfoProto.ExplorerMapIndicationResponse.newBuilder();
|
||||
indication.setExploreInfo(mapInfo);
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
|
||||
}
|
||||
}
|
||||
//玩家死亡 设置重生时间
|
||||
if (explorerInfo.getPlayerHp() == 0) {
|
||||
int reliveTime = SSpecialConfig.getIntegerValue(SSpecialConfig.EXPLORERE_LIVETIME);
|
||||
if (time == 0) {
|
||||
explorerInfo.setPlayerReliveTime(TimeUtils.nowInt() + reliveTime);
|
||||
} else {
|
||||
explorerInfo.setPlayerReliveTime(time + reliveTime);
|
||||
}
|
||||
LOGGER.info("玩家死亡=》重生时间{}", explorerInfo.getPlayerReliveTime());
|
||||
}
|
||||
//怪物死亡 设置重生时间
|
||||
if (explorerInfo.getEnemyHp() != 0) {
|
||||
if (time == 0) {
|
||||
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());
|
||||
} else {
|
||||
explorerInfo.setEnemyReliveTime(time + exploreConfig.getBattleInterval());
|
||||
}
|
||||
LOGGER.info("怪物死亡=》重生时间{} 掉落=>{}", explorerInfo.getEnemyReliveTime(), exploreConfig.getReward());
|
||||
}
|
||||
|
||||
if (time == 0) {
|
||||
explorerInfo.setBatteTime(TimeUtils.nowInt() + 60);//设置下次战斗时间
|
||||
explorerInfo.setBatteTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());//设置下次战斗时间
|
||||
} else {
|
||||
explorerInfo.setBatteTime(time + 60);//设置下次战斗时间
|
||||
explorerInfo.setBatteTime(time + exploreConfig.getBattleInterval());//设置下次战斗时间
|
||||
}
|
||||
//user.getPlayerInfoManager().addExplorer(explorerInfo, teamId);
|
||||
LOGGER.error("战斗结束");
|
||||
|
||||
}
|
||||
|
||||
public static void battle(User user) {
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
|
||||
LOGGER.info("战斗结束");
|
||||
|
||||
}
|
||||
|
||||
|
@ -200,7 +186,7 @@ public class ExplorerMapLogic {
|
|||
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() <= i) {
|
||||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, keyVal.getKey(), false);
|
||||
keyVal.getValue().setPlayerHp(teamForce);
|
||||
LOGGER.error("复活玩家:");
|
||||
LOGGER.info("复活玩家:");
|
||||
}
|
||||
//复活怪物
|
||||
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() <= i) {
|
||||
|
@ -210,7 +196,7 @@ public class ExplorerMapLogic {
|
|||
}
|
||||
//怪物的初始血量
|
||||
int mapMonsterForce = exploreConfig.getMonsterForce();
|
||||
LOGGER.error("复活怪物:");
|
||||
LOGGER.info("复活怪物:");
|
||||
keyVal.getValue().setEnemyHp(mapMonsterForce);
|
||||
}
|
||||
singleBattle(user, keyVal.getValue(), keyVal.getKey(), i);
|
||||
|
@ -238,7 +224,7 @@ public class ExplorerMapLogic {
|
|||
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() <= TimeUtils.nowInt()) {
|
||||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, keyVal.getKey(), false);
|
||||
keyVal.getValue().setPlayerHp(teamForce);
|
||||
LOGGER.error("复活玩家:");
|
||||
LOGGER.info("复活玩家:" + uid);
|
||||
}
|
||||
//复活怪物
|
||||
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() <= TimeUtils.nowInt()) {
|
||||
|
@ -246,7 +232,7 @@ public class ExplorerMapLogic {
|
|||
if (exploreConfig == null) {
|
||||
continue;
|
||||
}
|
||||
LOGGER.error("复活怪物sfasdfas :");
|
||||
LOGGER.info("复活怪物" + uid);
|
||||
//怪物的初始血量
|
||||
int mapMonsterForce = exploreConfig.getMonsterForce();
|
||||
keyVal.getValue().setEnemyHp(mapMonsterForce);
|
||||
|
@ -255,35 +241,35 @@ public class ExplorerMapLogic {
|
|||
if (keyVal.getValue().getBatteTime() > TimeUtils.nowInt()) {
|
||||
continue;
|
||||
}
|
||||
if(keyVal.getValue().getEnemyHp()!=0&&keyVal.getValue().getPlayerHp()!=0){
|
||||
if (keyVal.getValue().getEnemyHp() != 0 && keyVal.getValue().getPlayerHp() != 0) {
|
||||
singleBattle(user, keyVal.getValue(), keyVal.getKey(), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int id : delayId) {
|
||||
if(!explorer.containsKey(id)){
|
||||
if (!explorer.containsKey(id)) {
|
||||
continue;
|
||||
}
|
||||
//到期后发奖励
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(explorer.get(id).getMapId());
|
||||
if(exploreConfig == null){
|
||||
if (exploreConfig == null) {
|
||||
continue;
|
||||
}
|
||||
String teamName = TeamEnum.getEnumByteamId(id).getRemarks();
|
||||
String mapName = exploreConfig.getName();
|
||||
int hour =explorer.get(id).getSendTime()/3600;
|
||||
int hour = explorer.get(id).getSendTime() / 3600;
|
||||
if (explorer.get(id).getDropMap().size() == 0 || explorer.get(id).getDropMap() == null) {
|
||||
LOGGER.error("到期啥都没得到发邮件");
|
||||
LOGGER.info("到期啥都没得到发邮件:" + uid);
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("explorefail_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("explorefail_mail_txt", new Object[]{teamName,mapName,hour});
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("explorefail_mail_txt", new Object[]{teamName, mapName, hour});
|
||||
MailLogic.getInstance().sendMail(uid, title, content,
|
||||
"", TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
} else {
|
||||
LOGGER.error("到期发邮件");
|
||||
LOGGER.info("到期发邮件:" + uid);
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("exploresuccess_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("exploresuccess_mail_txt", new Object[]{teamName,mapName,hour});
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("exploresuccess_mail_txt", new Object[]{teamName, mapName, hour});
|
||||
//CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(id).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
|
||||
int[][] dropArray = explorer.get(id).getDropMap().entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).toArray(int[][]::new);
|
||||
int[][] dropArray = explorer.get(id).getDropMap().entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new);
|
||||
MailLogic.getInstance().sendMail(uid, title, content,
|
||||
StringUtil.parseArrayToString(dropArray), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
|
@ -291,27 +277,27 @@ public class ExplorerMapLogic {
|
|||
explorer.remove(id);
|
||||
CommonProto.ExplorerMapInfo mapInfo = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(id).build();
|
||||
ISession sess = OnlineUserManager.sessionMap.get(uid);
|
||||
if (sess != null){
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, mapInfo, true);
|
||||
if (sess != null) {
|
||||
PlayerInfoProto.ExplorerMapIndicationResponse.Builder indication = PlayerInfoProto.ExplorerMapIndicationResponse.newBuilder();
|
||||
indication.setExploreInfo(mapInfo);
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
|
||||
}
|
||||
//
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
String key;
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
if (crossGroup == -1) {
|
||||
key = Integer.toString(mapId);
|
||||
}else{
|
||||
} else {
|
||||
//跨服分组
|
||||
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon +mapId;
|
||||
key = Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
|
||||
}
|
||||
//List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
|
||||
Set<String> set = redisUtil.sGet(RedisKey.EXPLORER_MAP_PLAYER+RedisKey.Delimiter_colon + key);
|
||||
if(set.contains(String.valueOf(user.getId()))){
|
||||
long remove = RedisUtil.getInstence().setRemove(RedisKey.EXPLORER_MAP_PLAYER+ RedisKey.Delimiter_colon +key, String.valueOf(uid));
|
||||
LOGGER.error("remove:"+remove);
|
||||
Set<String> set = redisUtil.sGet(RedisKey.EXPLORER_MAP_PLAYER + RedisKey.Delimiter_colon + key);
|
||||
if (set.contains(String.valueOf(user.getId()))) {
|
||||
long remove = RedisUtil.getInstence().setRemove(RedisKey.EXPLORER_MAP_PLAYER + RedisKey.Delimiter_colon + key, String.valueOf(uid));
|
||||
LOGGER.info("remove:" + remove);
|
||||
}
|
||||
}
|
||||
if(delayId.size()>0){
|
||||
if (delayId.size() > 0) {
|
||||
user.getPlayerInfoManager().setExplorer(explorer);
|
||||
}
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
|
@ -319,12 +305,8 @@ public class ExplorerMapLogic {
|
|||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//怪物刷新
|
||||
//邮件结算
|
||||
|
||||
public static class Instance {
|
||||
public final static ExplorerMapLogic instance = new ExplorerMapLogic();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue