无尽修改第三版

lvxinran 2021-06-01 00:06:40 +08:00
parent a597b3545e
commit dfd2bdc968
13 changed files with 172 additions and 57 deletions

View File

@ -125,6 +125,15 @@ public class MathUtils {
}
return original;
}
public static long setBetweenWithMax(long original, long min, long max) {
if (original >= max) {
original = max;
}
if (original < min) {
original = min;
}
return original;
}
public static int getMaxNum(int a, int b) {
if(a>=b){

View File

@ -1,9 +1,6 @@
package com.ljsd.jieling.handler.map;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.*;
public class EndlessMapInfo {
private int curMapId;
@ -32,6 +29,10 @@ public class EndlessMapInfo {
private int moraleLevel;
private Set<Integer> openCell = new HashSet<>();
private Map<Integer, List<Long>> monsterHp = new HashMap<>();
public int getCurMapId() {
@ -146,4 +147,26 @@ public class EndlessMapInfo {
public void setMoraleLevel(int moraleLevel) {
this.moraleLevel = moraleLevel;
}
public Set<Integer> getOpenCell() {
return openCell;
}
public void setOpenCell(Set<Integer> openCell) {
this.openCell = openCell;
}
public Map<Integer, List<Long>> getMonsterHp() {
return monsterHp;
}
public void setMonsterHp(int position, List<Long> monsterHpList) {
monsterHp.put(position,monsterHpList);
}
public void clearMonsterHp(){
monsterHp = new HashMap<>();
}
public void monsterRemoveOne(int position){
monsterHp.remove(position);
}
}

View File

@ -22,7 +22,7 @@ public class EndlessTreasureReward extends MongoBase {
public void reset(){
createTime = (int)(TimeUtils.getMonthStartTime(1,1)/1000) -1;
updataCreateTime((int)(TimeUtils.getMonthStartTime(1,1)/1000) -1);
setRewardStatusMap(new HashMap<>());
setIsBuy(0);
}
@ -68,4 +68,8 @@ public class EndlessTreasureReward extends MongoBase {
this.isBuy = isBuy;
updateString("isBuy",isBuy);
}
public void updataCreateTime(int createTime){
this.createTime = createTime;
updateString("createTime",createTime);
}
}

View File

@ -122,6 +122,8 @@ public class EventType {
public static final int fiftyone = 51;
public static final int fiftytwo = 52;
public static final int fiftythree = 53;
public static final int fiftyFour = 54;
public static final int updatePonintEvent = 1;
public static final int fightEvent = 2;

View File

@ -77,8 +77,9 @@ public class GetEndlessHeroInfoListHandler extends BaseHandler<HeroInfoProto.Get
mapManager.updateEndlessMapId(0);
mapManager.endlessWalkCellSave(new HashSet<>());
mapManager.endlessMapInfoSave(new HashMap<>());
//清除当前副本信息
mapManager.updateEndlessMoraleLevel(0);
mapManager.clearEndlessOpenCell();
mapManager.removeEndlessMonsterHp();
// 清理无尽副本道具
MapLogic.getInstance().clearEndLessDrop(iSession.getUid());
//新创建地图

View File

@ -68,6 +68,8 @@ public class MapLogic {
public Map<Integer, MapGame> baseGameMap = new HashMap<>();
public static Set<Integer> endlessMapCell = new HashSet<>();
public static int endlessMapId;
public static final int STAR_1 = 1; // 完成任务
@ -84,6 +86,12 @@ public class MapLogic {
for (MapGame mapGame : beansOfMapGame.values()) {
baseGameMap.put(mapGame.getType(), mapGame);
}
for(int i = 1;i<=30;i++){
for(int j = 1;j<30;j++){
endlessMapCell.add(i*256+j);
}
}
}
private MapLogic() {
@ -701,10 +709,27 @@ public class MapLogic {
if(mapManager.getCurMapType()==2){
Item item = user.getItemManager().getItemMap().get(1);
ItemUtil.itemCost(user,new int[][]{{1,Math.min((int)item.getItemNum(),cells.size())}},BIReason.ENDLESS_CONSUME_EXECUTION,1);
Set<Integer> openCells = getOpenCells(cells);
mapManager.addEndlessOpenCell(openCells);
Set<Integer> walkCells = mapManager.getEndlessMapInfo().getOpenCell();
user.getUserMissionManager().onGameEvent(user,GameEvent.ENDLESS_OPEN_MAP,walkCells.size()*100/(30*30));
}
LOGGER.info("the uid+{},the lastXy={}",uid,lastXY);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse.build(), true);
}
private Set<Integer> getOpenCells(List<Integer> cells){
int[] offset = new int[]{-256,-512,256,512,-1,-2,1,2,-257,257,-255,255,0};
Set<Integer> openCells= new HashSet<>();
for(int cell:cells){
for(int off:offset){
if(!endlessMapCell.contains(cell+off)){
continue;
}
openCells.add(cell+off);
}
}
return openCells;
}
/**

View File

@ -904,6 +904,30 @@ public class MapManager extends MongoBase {
public EndlessTreasureReward getEndlessTreasureReward() {
return endlessTreasureReward;
}
public void addEndlessOpenCell(Set<Integer> openCell){
endlessMapInfo.getOpenCell().addAll(openCell);
updateString("endlessMapInfo.openCell",endlessMapInfo.getOpenCell());
}
public void clearEndlessOpenCell(){
endlessMapInfo.setOpenCell(new HashSet<>());
updateString("endlessMapInfo.openCell",endlessMapInfo.getOpenCell());
}
public void updataEndlessMonsterHp(int position,List<Long> hp){
endlessMapInfo.setMonsterHp(position,hp);
updateString("endlessMapInfo.monsterHp."+position,hp);
}
public void removeEndlessMonsterHp(){
endlessMapInfo.clearMonsterHp();
updateString("endlessMapInfo.monsterHp",new HashMap<>());
}
public void removeEndlessOneMonsterHp(int position){
endlessMapInfo.monsterRemoveOne(position);
removeString("endlessMapInfo.monsterHp."+position);
}
}

View File

@ -162,7 +162,7 @@ public class BehaviorUtil {
* @param fightStartRespons
* @throws Exception
*/
public static void getFightInfo(User user, int teamId,int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String pointId,int maxTime,boolean isMyself,Map<String,Integer> bloodMap) throws Exception {
public static void getEndlessFightInfo(User user, int teamId,int groupId, FightInfoProto.FightStartResponse.Builder fightStartRespons, String pointId,int maxTime,boolean isMyself,Map<String,Integer> bloodMap,List<Long> monsterHp) throws Exception {
MapManager mapManager = user.getMapManager();
CommonProto.FightData.Builder fightData = CommonProto.FightData.newBuilder();
@ -173,12 +173,21 @@ public class BehaviorUtil {
fightTeamInfo = getFightTeamInfo(user, teamId,isMyself);
}
fightData.setHeroFightInfos(fightTeamInfo);
//monster
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
//monsterHp带入
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup;
if(monsterHp!=null&&monsterHp.size()>0){
Map<Integer,List<Long>> monsterHpMap = new HashMap<>();
monsterHpMap.put(0,monsterHp);
monsterByGroup = MonsterUtil.getMonsterByGroup(groupId,monsterHpMap);
}else{
monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
}
List<CommonProto.FightUnitInfo> monsterPokemonByGroup = MonsterUtil.getMonsterPokemonByGroup(groupId);
List<CommonProto.FightTeamInfo> monsterGroupList = getFightTeamInfos(monsterByGroup,monsterPokemonByGroup, Global.MONSTER_1);
List<CommonProto.FightTeamInfo> monsterGroupList1 = getFightTeamInfos(monsterByGroup,monsterPokemonByGroup, Global.MONSTER_2);
List<CommonProto.FightTeamInfo> monsterGroupList2 = getFightTeamInfos(monsterByGroup,monsterPokemonByGroup, Global.MONSTER_3);
for(Map.Entry<Integer,Map<Integer,Integer>> entry :mapManager.getMonsterTempSkill().entrySet()){
if(groupId!=entry.getKey()){
continue;

View File

@ -69,11 +69,13 @@ public class EndlessMap extends AbstractMap{
MapLogic.resetMapInfo(user,false);
}
List<TeamPosHeroInfo> teamPosForHero = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (TeamPosHeroInfo aTeamPosForHero : teamPosForHero) {
String endlessHeroId = aTeamPosForHero.getHeroId();
Map<Integer, Long> propsMap = SEndlessHeroProp.propsMap.get(user.getHeroManager().getEndlessHeroInfo().get(endlessHeroId).getTemplateId());
long hp = propsMap.get(1);
mapManager.addEndlessHero(aTeamPosForHero.getHeroId(),(int) hp);
if(teamPosForHero!=null){
for (TeamPosHeroInfo aTeamPosForHero : teamPosForHero) {
String endlessHeroId = aTeamPosForHero.getHeroId();
Map<Integer, Long> propsMap = SEndlessHeroProp.propsMap.get(user.getHeroManager().getEndlessHeroInfo().get(endlessHeroId).getTemplateId());
long hp = propsMap.get(1);
mapManager.addEndlessHero(aTeamPosForHero.getHeroId(),(int) hp);
}
}
EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo();
//是否是新的周期
@ -224,6 +226,10 @@ public class EndlessMap extends AbstractMap{
String heroId= endteam.get(i).getHeroId();
bloodMap.put(heroId,(10000-endlessHeroInfo.get(heroId))/100);
}
List<Long> monsterHpRemain = mapManager.getEndlessMapInfo().getMonsterHp().get(mapManager.getTriggerXY());
if(monsterHpRemain!=null){
pveFightEvent.setMonsterRemainHp(monsterHpRemain);
}
pveFightEvent.setAttackBloodMap(bloodMap);
//怪物剩余血量
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
@ -239,10 +245,15 @@ public class EndlessMap extends AbstractMap{
if (resultCode == -1) {
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
}else if(resultCode==0) {
user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, new ArrayList<>());
// user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, new ArrayList<>());
for (int i = 0 ; i <team.size();i++) {
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),0);
}
List<Long> monsterHp = new ArrayList<>();
for(int i = 2;i<checkResult.length;i++){
monsterHp.add(checkResult[i]);
}
mapManager.updataEndlessMonsterHp(mapManager.getTriggerXY(),monsterHp);
}else{
for (TeamPosHeroInfo info:team) {
int position = info.getPosition();
@ -257,15 +268,17 @@ public class EndlessMap extends AbstractMap{
mapManager.updateEndlessHeroHp(info.getHeroId(),per);
}
endlessRefreshMonster(uid,mapManager.getTriggerXY());
List<TeamPosHeroInfo> updateTeam = new ArrayList<>();
Map<String, Integer> endlessThisHeroInfo = mapManager.getEndlessMapInfo().getEndlessHeroInfo();
for(TeamPosHeroInfo info:team){
if(endlessThisHeroInfo.containsKey(info.getHeroId())&&endlessThisHeroInfo.get(info.getHeroId())!=0){
updateTeam.add(info);
}
}
user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, updateTeam);
// List<TeamPosHeroInfo> updateTeam = new ArrayList<>();
// Map<String, Integer> endlessThisHeroInfo = mapManager.getEndlessMapInfo().getEndlessHeroInfo();
// for(TeamPosHeroInfo info:team){
// if(endlessThisHeroInfo.containsKey(info.getHeroId())&&endlessThisHeroInfo.get(info.getHeroId())!=0){
// updateTeam.add(info);
// }
// }
// user.getTeamPosManager().updateTeamPosByTeamId(GlobalsDef.ENDLESS_TEAM, updateTeam);
user.getUserMissionManager().onGameEvent(user,GameEvent.ENDLESS_KILL_MONTER);
mapManager.removeEndlessOneMonsterHp(mapManager.getTriggerXY());
}
@ -575,7 +588,8 @@ public class EndlessMap extends AbstractMap{
String heroId= endteam.get(i).getHeroId();
bloodMap.put(heroId,(10000-endlessHeroInfo.get(heroId))/100);
}
BehaviorUtil.getFightInfo(user,401, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true,bloodMap);
List<Long> monsterHp = mapManager.getEndlessMapInfo().getMonsterHp().get(mapManager.getTriggerXY());
BehaviorUtil.getEndlessFightInfo(user,401, groupId, responseBuilder, pointId, sChallengeConfig.getMostTime(), true,bloodMap,monsterHp);
}
public void endFight(int uid, String frames, FightInfoProto.FightEndResponse.Builder builder,int dropout) throws Exception {
User user = UserManager.getUser(uid);
@ -659,26 +673,30 @@ public class EndlessMap extends AbstractMap{
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),0);
}
}
List<Long> monsterHp = new ArrayList<>();
for(int i = 2;i<checkResult.length;i++){
monsterHp.add(checkResult[i]);
}
mapManager.updataEndlessMonsterHp(mapManager.getTriggerXY(),monsterHp);
return;
}
//无尽本更新血量
if(mapManager.getCurMapType()==MapEnum.ENDLESS_MAP.getType()){
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (int i = 0 ; i <team.size();i++) {
int position = team.get(i).getPosition();
Hero hero = user.getHeroManager().getEndlessHeroInfo().get(team.get(i).getHeroId());
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(GlobalsDef.ENDLESS_TEAM);
for (int i = 0 ; i <team.size();i++) {
int position = team.get(i).getPosition();
Hero hero = user.getHeroManager().getEndlessHeroInfo().get(team.get(i).getHeroId());
Map<Integer, Long> heroAttributeMap = SEndlessHeroProp.propsMap.get(hero.getTemplateId());
Map<Integer, Long> heroAttributeMap = SEndlessHeroProp.propsMap.get(hero.getTemplateId());
int per = (int)(checkResult[position+1] / (double) heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+1]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
int per = (int)(checkResult[position+1] / (double) heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+1]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
}
for (int i = 2; i < checkResult.length; i++) {
if (checkResult[i] <= 0) {
remainHp.add((long) 0);
@ -686,6 +704,7 @@ public class EndlessMap extends AbstractMap{
remainHp.add(checkResult[i]);
}
}
mapManager.removeEndlessOneMonsterHp(mapManager.getCurXY());
//血量更新
// refreshHp(user, mapManager.getTeamId(),checkResult);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 0, BIReason.MAP_GENERAL_FIGHT_REWARD);
@ -727,14 +746,5 @@ public class EndlessMap extends AbstractMap{
if (monsterGroupId == mapManager.getSuddenlyBoss()) {
mapManager.findSuddenlyBoss(0, 0);
}
if(mapManager.getTrialInfo().getFloor()==STrialConfig.getHighestTower()&&mapManager.getBossType()!=0){
int time = (int)((TimeUtils.now()-mapManager.getTowerStartTime())/1000);
mapManager.setCurrTowerTime(time*1000);
LOGGER.info("此层为最后一层,使用时间为{}",time);
builder.setLastTowerTime(time);
}else{
builder.setLastTowerTime(0);
}
}
}

View File

@ -156,7 +156,9 @@ public class Hero extends MongoBase implements Comparable<Hero> {
this.templateId=heroId;
this.level=propConfig.getLevel();
this.star = propConfig.getStar();
this.starBreakId=propConfig.getRank();
this.starBreakId=propConfig.getHeroStarId() ;
this.breakId=propConfig.getRank();
this.especialEquipLevel = propConfig.getEquipTalismanaLevel();
soulEquipByPositionMap = new HashMap<>();
int[] equipSign = propConfig.getEquipSign();
@ -164,10 +166,10 @@ public class Hero extends MongoBase implements Comparable<Hero> {
soulEquipByPositionMap.put(i+1,equipSign[i]);
}
int[] equip = propConfig.getEquipList();
// for(int i = 0; i < equip.length; i++){
// equipByPositionMap.put(i+1,equipSign[i]);
// }
equipByPositionMap = new HashMap<>();
for(int i = 0; i < equip.length; i++){
equipByPositionMap.put(i+1,equip[i]);
}
}
public void upStar(int upStar) throws Exception {

View File

@ -351,8 +351,8 @@ public class FightUtil {
moraleMap.put(prop[0],moraleMap.getOrDefault(prop[0],0)+prop[1]);
}
if(morale.getSkill()!=0) {
moraleSkillBuilder.append("#");
moraleSkillBuilder.append(morale.getSkill());
moraleSkillBuilder.append("#");
}
}
}

View File

@ -112,10 +112,10 @@ public enum GameEvent {
COW_FLY_SKY_REFRESH,//牛气冲天刷新
COW_FLY_SKY_REWEARD,//牛气冲天奖励
ENDLESS_MISSION_REFRESH,//无尽副本任务刷新
ENDLESS_MISSION_REWARD,
ENDLESS_MORALE_LEVEL_UP,
ENDLESS_KILL_MONTER,
ENDLESS_KILL_SMALL_BOSS,
ENDLESS_KILL_LAST_BOSS,
ENDLESS_OPEN_MAP
ENDLESS_MISSION_REWARD,//无尽任务奖励
ENDLESS_MORALE_LEVEL_UP,//无尽士气等级提升
ENDLESS_KILL_MONTER,//无尽杀小怪
ENDLESS_KILL_SMALL_BOSS,//无尽杀小boss
ENDLESS_KILL_LAST_BOSS,//无尽击杀最终boss
ENDLESS_OPEN_MAP//无尽提升探索度
}

View File

@ -26,6 +26,8 @@ public class SEndlessHeroProp implements BaseConfig {
private int[][] props;
private int heroStarId;
public static Map<Integer,Map<Integer,Long>> propsMap = new HashMap<>();
@Override
@ -77,4 +79,8 @@ public class SEndlessHeroProp implements BaseConfig {
public int[][] getProps() {
return props;
}
public int getHeroStarId() {
return heroStarId;
}
}