back_recharge
xuexinpeng 2021-12-28 18:02:46 +08:00
parent 705e81c629
commit eab1eb0b89
6 changed files with 143 additions and 168 deletions

View File

@ -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);
}

View File

@ -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,6 +22,7 @@ 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 {
int uid = session.getUid();
@ -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())

View File

@ -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> {

View File

@ -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>();
//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]);
}
//消耗
/*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();
@ -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();

View File

@ -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,20 +45,12 @@ 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("开始战斗");
{
LOGGER.info("开始战斗");
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(explorerInfo.getMapId());
if (exploreConfig == null) {
@ -71,39 +63,23 @@ public class ExplorerMapLogic {
if (exploreFightData == null) {
return;
}
LOGGER.error("探索表id:={}", exploreFightData.getId());
LOGGER.info("探索表id:={}", exploreFightData.getId());
//掉血比例
float reduceRatio = exploreFightData.getLoseFight();
//玩家掉血
int reducePlayer = (int) (teamForce * reduceRatio);
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - reducePlayer);
LOGGER.error("玩家掉血:=》{},剩余血量-》{}", reducePlayer,explorerInfo.getPlayerHp());
LOGGER.info("玩家掉血:=》{},剩余血量-》{}", reducePlayer, explorerInfo.getPlayerHp());
//怪物掉血
int reduceMonster = (int) (mapMonsterForce * reduceRatio);
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (reduceMonster));
LOGGER.error("怪物掉血:=》{},剩余血量-》{}", reduceMonster,explorerInfo.getEnemyHp());
LOGGER.info("怪物掉血:=》{},剩余血量-》{}", reduceMonster, explorerInfo.getEnemyHp());
//输赢判断
if (reducePlayer > reduceMonster) {
//怪物赢了 保留血量 下次打
LOGGER.error("怪物赢了:");
LOGGER.info("怪物赢了:");
} else {
LOGGER.error("玩家赢了:");
}
//玩家死亡 设置重生时间
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) {
//玩家赢了
LOGGER.info("玩家赢了:");
Map<Integer, Integer> dropMap = explorerInfo.getDropMap();
if (dropMap == null) {
dropMap = new HashMap<>();
@ -125,29 +101,39 @@ public class ExplorerMapLogic {
}
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);
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.setEnemyReliveTime(TimeUtils.nowInt() + 300);
explorerInfo.setPlayerReliveTime(TimeUtils.nowInt() + reliveTime);
} else {
explorerInfo.setEnemyReliveTime(time + 300);
}
LOGGER.error("怪物死亡=》重生时间{} 掉落=>{}", explorerInfo.getEnemyReliveTime(),exploreConfig.getReward());
explorerInfo.setPlayerReliveTime(time + reliveTime);
}
LOGGER.info("玩家死亡=》重生时间{}", explorerInfo.getPlayerReliveTime());
}
//怪物死亡 设置重生时间
if (explorerInfo.getEnemyHp() != 0) {
if (time == 0) {
explorerInfo.setBatteTime(TimeUtils.nowInt() + 60);//设置下次战斗时间
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());
} else {
explorerInfo.setBatteTime(time + 60);//设置下次战斗时间
explorerInfo.setEnemyReliveTime(time + exploreConfig.getBattleInterval());
}
LOGGER.info("怪物死亡=》重生时间{} 掉落=>{}", explorerInfo.getEnemyReliveTime(), exploreConfig.getReward());
}
if (time == 0) {
explorerInfo.setBatteTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());//设置下次战斗时间
} else {
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);
@ -273,13 +259,13 @@ public class ExplorerMapLogic {
String mapName = exploreConfig.getName();
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});
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});
//CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(id).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
@ -292,9 +278,10 @@ public class ExplorerMapLogic {
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);
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();
@ -304,11 +291,10 @@ public class ExplorerMapLogic {
//跨服分组
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);
LOGGER.info("remove:" + remove);
}
}
if (delayId.size() > 0) {
@ -319,12 +305,8 @@ public class ExplorerMapLogic {
} catch (Exception e) {
e.printStackTrace();
}
}
//怪物刷新
//邮件结算
public static class Instance {
public final static ExplorerMapLogic instance = new ExplorerMapLogic();
}