灵脉秘境
parent
34c0d4bd69
commit
676dce9bf8
|
|
@ -133,6 +133,13 @@ public class CoreService implements RPCRequestIFace.Iface {
|
|||
yxldTree.forEach(n->rpcYxldTree.add(new TeamPosHeroInfo().setHeroId(n.getHeroId()).setPosition(n.getPosition())));
|
||||
teams.put(TeamEnum.CROSS_YU_XU_LUN_DAO_THREE.getTeamId(),rpcYxldTree);
|
||||
set.addAll(rpcYxldTree);
|
||||
|
||||
//灵脉秘境编队
|
||||
List<com.ljsd.jieling.logic.dao.TeamPosHeroInfo> lmmj = user.getTeamPosManager().getTeamPosForHero().getOrDefault(TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(),new ArrayList<>());
|
||||
List<TeamPosHeroInfo> rpclmmj = new ArrayList<TeamPosHeroInfo>();
|
||||
lmmj.forEach(n->rpclmmj.add(new TeamPosHeroInfo().setHeroId(n.getHeroId()).setPosition(n.getPosition())));
|
||||
teams.put(TeamEnum.CROSS_YU_XU_LUN_DAO_THREE.getTeamId(),rpclmmj);
|
||||
set.addAll(rpclmmj);
|
||||
// 英雄
|
||||
Map<String,ArenaOfHero> heroes = new HashMap<>();
|
||||
Map<String, Hero> heroMap = user.getHeroManager().getHeroMap();
|
||||
|
|
|
|||
|
|
@ -1,24 +1,39 @@
|
|||
package com.ljsd.jieling.handler.crossServer;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.fight.LingMaiSecretArea;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.handler.gtw.GetWorldArenaChallengeRequestHandler;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.arena.CrossLingmaiLogic;
|
||||
import com.ljsd.jieling.logic.dao.ArenaManager;
|
||||
import com.ljsd.jieling.logic.dao.TeamEnum;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.FightUtil;
|
||||
import com.ljsd.jieling.logic.fight.GameFightType;
|
||||
import com.ljsd.jieling.logic.fight.PVEFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.thrift.idl.CrossArenaManager;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SArenaSetting;
|
||||
import config.SLodeConfig;
|
||||
import config.SMServerLodeSetting;
|
||||
import rpc.protocols.ArenaInfoProto;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
|
|
@ -30,7 +45,7 @@ public class CrossLingmaiSecretAreaBattleHandler extends BaseHandler<ArenaInfoPr
|
|||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession session, ArenaInfoProto.CrossLingmaiSecretAreaRequest request) throws Exception{
|
||||
public void processWithProto(ISession session, ArenaInfoProto.CrossLingmaiSecretAreaRequest request) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
|
|
@ -46,26 +61,77 @@ public class CrossLingmaiSecretAreaBattleHandler extends BaseHandler<ArenaInfoPr
|
|||
ArenaManager arenaManager = user.getArenaManager();
|
||||
int group = SMServerLodeSetting.getGroupByLevel(arenaManager.getCrossLingmaiFirstLevel());
|
||||
//CROSS_LINGMAISECRET_INFO:跨服分组:分组
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup+RedisKey.Delimiter_colon+group, String.class, LingMaiSecretArea.class);
|
||||
if(!lingMaiMap.containsKey(String.valueOf(id))){
|
||||
//TODO
|
||||
return;
|
||||
}
|
||||
//组装机器人数据
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.class, LingMaiSecretArea.class);
|
||||
if (!lingMaiMap.containsKey(String.valueOf(id))) {
|
||||
//没人占领 攻击机器人 pve
|
||||
SLodeConfig config = SLodeConfig.lodeConfig.get(id);
|
||||
if (config == null) {
|
||||
return;
|
||||
}
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), 20, "", GameFightType.CrossLingMaiSecretFight, config.getGuard(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
//response.setFightData(fightResult.getFightData());
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(20)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.setFightType(FightType.CrossLingMaiSecretFight.getType())
|
||||
.setFightId(FightUtil.getFightId(user.getId(), FightType.TaSuiLingXiao.getType()))
|
||||
.build();
|
||||
res.setFightData(fightData);
|
||||
if(fightResult.getResult()==-1){
|
||||
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
||||
}else if (fightResult.getResult() == 1){
|
||||
//赢了
|
||||
LingMaiSecretArea lingMaiSecretArea = CrossLingmaiLogic.getLingaMaiData(id,uid,user);;
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.valueOf(id),lingMaiSecretArea);
|
||||
}
|
||||
}else {
|
||||
//PVP
|
||||
// 组装真人数据
|
||||
// 战斗逻辑
|
||||
SLodeConfig config = SLodeConfig.lodeConfig.get(id);
|
||||
if(config == null){
|
||||
return;
|
||||
}
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), 20, "", GameFightType.CrossLingMaiSecretFight, config.getGuard(), 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
//response.setFightData(fightResult.getFightData());
|
||||
int defUid = lingMaiMap.get(String.valueOf(id)).getUid();
|
||||
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(defUid);
|
||||
if (csPlayer == null){
|
||||
throw new ErrorCodeException(ErrorCode.USE_NOT_EXIT);
|
||||
}
|
||||
//其他服玩家rpc 数据调用
|
||||
CrossArenaManager crossArenaManager = null;
|
||||
int myforce = HeroLogic.getInstance().calTeamTotalForce(user, TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), false);
|
||||
int defforce = 0;
|
||||
|
||||
if(GameApplication.serverId != csPlayer.getServerId()){
|
||||
crossArenaManager = PlayerLogic.getInstance().getCrossArenaManagerData(csPlayer);
|
||||
defforce = crossArenaManager.getTotalForceByTeam().getOrDefault( TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(),0);
|
||||
}
|
||||
CommonProto.FightTeamInfo fightTeamInfo = FightUtil.makePersonFightData(user, TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), null, null);
|
||||
//对手
|
||||
CommonProto.FightTeamInfo defteamInfo = FightUtil.makeCrossPersonData(csPlayer, TeamEnum.CROSS_LING_MAI_SECRET_AREA.getTeamId(), null, crossArenaManager);
|
||||
|
||||
FightResult fightResult = GetWorldArenaChallengeRequestHandler.getFightForPVP(uid, defUid,
|
||||
fightTeamInfo, defteamInfo, FightUtil.getFightSeed(), myforce < defforce);
|
||||
int seed = fightResult.getSeed();
|
||||
CommonProto.FightData build = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
|
||||
.setFightSeed(seed)
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addMonsterList(fightResult.getDefFightTeamInfo())
|
||||
.setFightType(FightType.CrossYuxulundaoFight.getType())
|
||||
.setFightId(FightUtil.getFightId(uid, FightType.CrossLingMaiSecretFight.getType()))
|
||||
.build();
|
||||
int result = (int) fightResult.getCheckResult()[0];
|
||||
res.setFightData(build);
|
||||
if(result == 1){
|
||||
//赢了 易主
|
||||
LingMaiSecretArea lingMaiSecretArea = CrossLingmaiLogic.getLingaMaiData(id,uid,user);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + group, String.valueOf(id),lingMaiSecretArea);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.CrossLingmaiSecretAreaResponse.getNumber(), res.build(), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -86,6 +86,10 @@ public class CrossLingmaiSecretAreaInfoHandler extends BaseHandler<ArenaInfoProt
|
|||
setServerName(lingMaiMap.get(config.getId()).getServerName()).
|
||||
setUserName(lingMaiMap.get(config.getId()).getName()).build();
|
||||
res.addRecordData(lingMaiSecret);
|
||||
}else{
|
||||
//没人占领 给机器人数据
|
||||
CommonProto.LingMaiSecret lingMaiSecret =CommonProto.LingMaiSecret.newBuilder().setId(config.getId()).build();
|
||||
res.addRecordData(lingMaiSecret);
|
||||
}
|
||||
}
|
||||
res.setMyOccupyId(myOccupyId);
|
||||
|
|
|
|||
|
|
@ -1,7 +1,23 @@
|
|||
package com.ljsd.jieling.logic.arena;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.LingMaiSecretArea;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SLodeConfig;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 跨服 灵脉秘境
|
||||
|
|
@ -23,5 +39,58 @@ public class CrossLingmaiLogic {
|
|||
}
|
||||
|
||||
|
||||
public static LingMaiSecretArea getLingaMaiData(int id, int uid, User user){
|
||||
LingMaiSecretArea lingMaiSecretArea = new LingMaiSecretArea();
|
||||
lingMaiSecretArea.setId(id);
|
||||
lingMaiSecretArea.setId(uid);
|
||||
String serverName = CrossServiceLogic.simplifyServerName(GameApplication.serverId);
|
||||
lingMaiSecretArea.setServerName(serverName);
|
||||
lingMaiSecretArea.setName(user.getPlayerInfoManager().getNickName());
|
||||
lingMaiSecretArea.setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
return lingMaiSecretArea;
|
||||
}
|
||||
|
||||
/**
|
||||
* 占领奖励 每十分钟发放一次
|
||||
*/
|
||||
public void sendOccypyReward(){
|
||||
|
||||
//周二 四 六 日开放 9点-21点
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup == -1){
|
||||
return;
|
||||
}
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int w = calendar.get(Calendar.DAY_OF_WEEK) - 1;
|
||||
if(w==0 || w ==2|| w==4 || w == 6){
|
||||
if(hour>9&&hour<21){
|
||||
Map<String, LingMaiSecretArea> lingMaiMap1 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 1, String.class, LingMaiSecretArea.class);
|
||||
Map<String, LingMaiSecretArea> lingMaiMap2 = RedisUtil.getInstence().getMapValues(RedisKey.CROSS_LINGMAISECRET_INFO, crossGroup + RedisKey.Delimiter_colon + 2, String.class, LingMaiSecretArea.class);
|
||||
Map<String, LingMaiSecretArea> lingMaiMap = new HashMap<String, LingMaiSecretArea>();
|
||||
lingMaiMap.putAll(lingMaiMap1);
|
||||
lingMaiMap.putAll(lingMaiMap2);
|
||||
int nowTime = TimeUtils.nowInt();
|
||||
for(Map.Entry<String, LingMaiSecretArea> map:lingMaiMap.entrySet()){
|
||||
try{
|
||||
User user = UserManager.getUser(map.getValue().getUid());
|
||||
if(user!=null){
|
||||
SLodeConfig config = SLodeConfig.lodeConfig.get(map.getValue().getId());
|
||||
if(config!=null){
|
||||
int occupyTime = (int) map.getValue().getGetAwardTimeOrOccupyTime();
|
||||
int difVal = (nowTime-occupyTime)/60>10?10:(nowTime-occupyTime)/60;
|
||||
for(int i=0;i<difVal;i++){
|
||||
ItemUtil.drop(user,config.getRewardList(), BIReason.GM_REWARD);
|
||||
}
|
||||
map.getValue().setGetAwardTimeOrOccupyTime(TimeUtils.nowInt());
|
||||
}
|
||||
}
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ import com.ljsd.jieling.logic.activity.event.MinuteTaskEvent;
|
|||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.arena.CrossLingmaiLogic;
|
||||
import com.ljsd.jieling.logic.arena.CrossYuxulundaoLogic;
|
||||
import com.ljsd.jieling.logic.dao.GuildMyInfo;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
|
|
@ -115,7 +116,7 @@ public class MinuteTask extends Thread {
|
|||
LOGGER.error("Exception::=>{}",e.toString());
|
||||
}
|
||||
try {
|
||||
//周日23.50执行
|
||||
//周日23.30执行
|
||||
everySundaySpecialClockTask();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
|
|
@ -174,6 +175,14 @@ public class MinuteTask extends Thread {
|
|||
e.printStackTrace();
|
||||
LOGGER.error("Exception::=>{}",e.toString());
|
||||
}
|
||||
|
||||
try {
|
||||
every10IntMul();
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
LOGGER.error("Exception::=>{}",e.toString());
|
||||
}
|
||||
|
||||
LOGGER.info("MinuteTask end...");
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
|
@ -219,6 +228,12 @@ public class MinuteTask extends Thread {
|
|||
// 助战
|
||||
HelpHeroLogic.getInstance().zeroClearRedisHelp();
|
||||
|
||||
//灵脉秘境占位数据重置
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
if (crossGroup != -1){
|
||||
RedisUtil.getInstence().remove(RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO,crossGroup + RedisKey.Delimiter_colon + 1,true));
|
||||
RedisUtil.getInstence().remove(RedisUtil.getInstence().getKey(RedisKey.CROSS_LINGMAISECRET_INFO,crossGroup + RedisKey.Delimiter_colon + 2,true));
|
||||
}
|
||||
// 公会信息处理
|
||||
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
||||
for(Map.Entry<Integer,GuildInfo> guildInfoEntry:guildInfoMap.entrySet()){
|
||||
|
|
@ -292,7 +307,14 @@ public class MinuteTask extends Thread {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//每日分钟数是10的倍数执行 0 分 10分 20分 30分....60分
|
||||
public void every10IntMul()throws Exception {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
int mod = minute%10;
|
||||
if(mod ==0 ){
|
||||
CrossLingmaiLogic.getInstance().sendOccypyReward();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue