back_recharge
xuexinpeng 2021-12-27 18:36:31 +08:00
parent 87bcc6d5d7
commit 6b07593757
5 changed files with 45 additions and 43 deletions

View File

@ -379,4 +379,6 @@ public interface BIReason {
int LIFE_STONE_UP = 1227;//命石合成
int GM_COST = 1228;//gm删除道具
int EXPLORE_MAP_COST = 1229;//探索地图消耗
int EXPLORE_MAP_GET = 1230;//探索地图消耗
}

View File

@ -15,6 +15,7 @@ import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import java.util.List;
import java.util.Set;
public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.ExplorerMapPlayerInfoRequest> {
@ -41,8 +42,8 @@ public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.Explor
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
}
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
for(String uidStr:list){
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()

View File

@ -51,18 +51,12 @@ public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.Explor
MailLogic.getInstance().sendMail(uid, "探索返还晶石", "您提前结束了队伍X在【地图名称】中的探索以下为尚未消耗的晶石请查收。",
StringUtil.parseArrayToString(drop), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
//MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.build(), true);
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(teamId).build();
CommonProto.Drop.Builder dropPro = ItemUtil.drop(user, explorer.get(teamId).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.setDrop(dropPro).
setExploreInfo(explorerMapInfo).build(), true);
}
}
/*else{
CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(teamId).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.setDrop(drop).build(), true);
}*/
}
}

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.handler.explorerMap;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
@ -10,6 +11,7 @@ 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;
import com.ljsd.jieling.util.MessageUtil;
import config.SExplore;
import manager.STableManager;
@ -18,12 +20,14 @@ import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import util.TimeUtils;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.ExplorerMapSendRequest> {
public static int hourMinute = 60;
public static int hourSecond = 3600;
@Override
public MessageTypeProto.MessageType getMessageCode() {
@ -40,14 +44,21 @@ 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){
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)){
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();
int time = info.getTime() * hourSecond;
//TODO 消耗
//TODO redis
RedisUtil redisUtil = RedisUtil.getInstence();
String rkey;
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
String key;
if (crossGroup == -1) {
@ -56,14 +67,7 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
//跨服分组
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
}
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
if(!list.contains(String.valueOf(user.getId()))){
//String key2 = RedisKey.getKey(RedisKey.EXPLORER_MAP_PLAYER, key, false);
redisUtil.lSet(RedisKey.EXPLORER_MAP_PLAYER+ RedisKey.Delimiter_colon +key, String.valueOf(user.getId()));
redisUtil.lRemove()
}
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;
@ -78,16 +82,13 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
explorerInfo.setPlayerHp(teamForce);
explorerInfo.setEnemyHp(mapMonsterForce);
explorerInfo.setBatteTime(TimeUtils.nowInt()+60);
//ExplorerMapLogic.singleBattle(user,teamId);
//explorer.put(teamId, explorerInfo);
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().
setTeamId(teamId).setMapId(mapId).setHp(explorerInfo.getPlayerHp()).
setExploreTime(explorerInfo.getSendEndTime()).build();
builder.addExploreInfo(explorerMapInfo);
user.getPlayerInfoManager().addExplorer(explorerInfo, teamId);
}
//user.getPlayerInfoManager().setExplorer(explorer);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapSendResponse.getNumber(), builder.build(), true);
}
}

View File

@ -17,6 +17,7 @@ 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;
import config.SErrorCodeEerverConfig;
import config.SExplore;
import config.SExploreFight;
import manager.STableManager;
@ -87,15 +88,8 @@ public class ExplorerMapLogic {
//怪物赢了 保留血量 下次打
LOGGER.error("怪物赢了:");
} else {
//玩家赢了
List<int[]> dropitem = explorerInfo.getDropItem();
if (dropitem == null) {
dropitem = new ArrayList<>();
}
Map<Integer, Integer> itemMap = ItemUtil.getItemMapByGroupId(user, new int[]{exploreConfig.getReward()}, 1, 0, BIReason.TA_SUI_LING_XIAO);
List<int[]> addDropitem = itemMap.entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).collect(Collectors.toList());
dropitem.addAll(addDropitem);
explorerInfo.setDropItem(dropitem);
LOGGER.error("玩家赢了:");
}
//玩家死亡 设置重生时间
if (explorerInfo.getPlayerHp() == 0) {
@ -109,12 +103,23 @@ public class ExplorerMapLogic {
}
//怪物死亡 设置重生时间
if (explorerInfo.getEnemyHp() == 0) {
//玩家赢了
List<int[]> dropitem = explorerInfo.getDropItem();
if (dropitem == null) {
dropitem = new ArrayList<>();
}
Map<Integer, Integer> itemMap = ItemUtil.getItemMapByGroupId(user, new int[]{exploreConfig.getReward()}, 1, 0, BIReason.EXPLORE_MAP_GET);
List<int[]> addDropitem = itemMap.entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).collect(Collectors.toList());
dropitem.addAll(addDropitem);
explorerInfo.setDropItem(dropitem);
if (time == 0) {
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + 300);
} else {
explorerInfo.setEnemyReliveTime(time + 300);
}
LOGGER.error("怪物死亡=》重生时间={} 掉落id=>{}", explorerInfo.getEnemyReliveTime(), exploreConfig.getReward());
LOGGER.error("玩家死亡=》重生时间{} 掉落=>{}", explorerInfo.getEnemyReliveTime(),exploreConfig.getReward());
}
}
if (time == 0) {
@ -122,7 +127,7 @@ public class ExplorerMapLogic {
} else {
explorerInfo.setBatteTime(time + 60);//设置下次战斗时间
}
user.getPlayerInfoManager().addExplorer(explorerInfo, teamId);
//user.getPlayerInfoManager().addExplorer(explorerInfo, teamId);
LOGGER.error("战斗结束");
}
@ -167,7 +172,6 @@ public class ExplorerMapLogic {
if (explorer == null || explorer.size() == 0) {
return;
}
//int offlineTime = (int) (user.getPlayerInfoManager().getOffLineTime() / 1000);
for (Map.Entry<Integer, ExplorerInfo> keyVal : explorer.entrySet()) {
int offlineEndTime = 0;
if (keyVal.getValue().getSendEndTime() >= TimeUtils.nowInt()) {
@ -246,7 +250,8 @@ public class ExplorerMapLogic {
for (int id : delayId) {
//到期后发奖励
if (explorer.get(id).getDropItem().size() == 0 || explorer.get(id).getDropItem() == null) {
MailLogic.getInstance().sendMail(uid, "探索失败", "您的队伍X在【地图名称】经过X时X分的探索未获取到任何奖励请选择更合适此队伍的地图进行探索。",
//String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("MsRankContent",new Object[]{(i + 1)},new int[0],"#");
MailLogic.getInstance().sendMail(uid, "探索失败", "您的队伍在%经过%时%分的探索,未获取到任何奖励,请选择更合适此队伍的地图进行探索。",
"", TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
} else {
CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(id).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
@ -254,34 +259,33 @@ public class ExplorerMapLogic {
MailLogic.getInstance().sendMail(uid, "探索奖励", "您的队伍X在【地图名称】经过X时X分的探索共获得以下奖励清查收。",
StringUtil.parseArrayToString(dropArray), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
}
int mapId = explorer.get(id).getMapId();
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);
}
//
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
String key;
RedisUtil redisUtil = RedisUtil.getInstence();
if (crossGroup == -1) {
key = Integer.toString(explorer.get(id).getMapId());
key = Integer.toString(mapId);
}else{
//跨服分组
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + explorer.get(id).getMapId();
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon +mapId;
}
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
if(list.contains(String.valueOf(user.getId()))){
//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);
}
}
if(delayId.size()>0){
user.getPlayerInfoManager().setExplorer(explorer);
}
//探索队伍 map <id,(派遣到哪个地图里,派遣的截止时间,玩家,复活时间)>
//地图怪物 map<地图id,List<>()地图上所有的怪物怪物id,刷新时间,血量)>
MongoUtil.getLjsdMongoTemplate().lastUpdate();
}
} catch (Exception e) {