|
|
|
|
@ -17,10 +17,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|
|
|
|
import com.ljsd.jieling.util.ItemUtil;
|
|
|
|
|
import com.ljsd.jieling.util.MessageUtil;
|
|
|
|
|
import com.ljsd.jieling.util.MonsterUtil;
|
|
|
|
|
import config.MapPointConfig;
|
|
|
|
|
import config.SCMap;
|
|
|
|
|
import config.SFreeTravel;
|
|
|
|
|
import config.SFreeTravelStore;
|
|
|
|
|
import config.*;
|
|
|
|
|
import manager.STableManager;
|
|
|
|
|
import util.CellUtil;
|
|
|
|
|
import util.MathUtils;
|
|
|
|
|
@ -140,11 +137,11 @@ public class JourneyMap {
|
|
|
|
|
}
|
|
|
|
|
MapInfoProto.JourneyGetOneInfoResponse.Builder response = MapInfoProto.JourneyGetOneInfoResponse.newBuilder();
|
|
|
|
|
PathInfo pathInfo = journeyInfo.get(mapId);
|
|
|
|
|
clearByTime(pathInfo);//清除过期信息
|
|
|
|
|
if(pathInfo.getCurrentPath()>=pathInfo.getAllPathInfo().length){
|
|
|
|
|
init(user,mapId);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//地图格子信息
|
|
|
|
|
Arrays.stream(pathInfo.getAllPathInfo()).forEach(path->{
|
|
|
|
|
CommonProto.JourneyCell cell = CommonProto.JourneyCell.newBuilder()
|
|
|
|
|
@ -195,6 +192,36 @@ public class JourneyMap {
|
|
|
|
|
}
|
|
|
|
|
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
|
|
|
|
}
|
|
|
|
|
private void clearByTime(PathInfo info){
|
|
|
|
|
if(info.getRemainRandomTime()<TimeUtils.nowInt()){
|
|
|
|
|
info.setRandomReward(null);
|
|
|
|
|
info.setRemainRandomTime(0);
|
|
|
|
|
info.setRamainRandomAmount(0);
|
|
|
|
|
}
|
|
|
|
|
Set<Integer> removeId = new HashSet<>();
|
|
|
|
|
if(!info.getMonsterMap().isEmpty()){
|
|
|
|
|
for(Map.Entry<Integer,JourneyMonster> entry:info.getMonsterMap().entrySet()){
|
|
|
|
|
if(entry.getValue().getRemainTime()<TimeUtils.nowInt()){
|
|
|
|
|
removeId.add(entry.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(int id:removeId){
|
|
|
|
|
info.removeMonster(id);
|
|
|
|
|
}
|
|
|
|
|
removeId = new HashSet<>();
|
|
|
|
|
}
|
|
|
|
|
if(!info.getGoodsMap().isEmpty()) {
|
|
|
|
|
for(Map.Entry<Integer,JourneyGoods> entry:info.getGoodsMap().entrySet()){
|
|
|
|
|
if(entry.getValue().getGoodsRemainTime()<TimeUtils.nowInt()){
|
|
|
|
|
removeId.add(entry.getKey());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for(int id:removeId){
|
|
|
|
|
info.removeGoods(id);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 投骰子,进行游历
|
|
|
|
|
@ -212,6 +239,11 @@ public class JourneyMap {
|
|
|
|
|
throw new ErrorCodeException(ErrorCode.DAILY_ALREADY_PASS);
|
|
|
|
|
}
|
|
|
|
|
SFreeTravel travelConfig = SFreeTravel.journeyMapByMapId.get(mapId);
|
|
|
|
|
int[] consume = travelConfig.getConsume();
|
|
|
|
|
Map<Integer, Integer> map = ItemUtil.arrayToMap(new int[][]{consume});
|
|
|
|
|
if(!ItemUtil.checkCost(user,map)){
|
|
|
|
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
|
|
|
|
}
|
|
|
|
|
int diceNum = pathInfo.getDiceNum();
|
|
|
|
|
List<Integer> randomNum = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
@ -232,19 +264,24 @@ public class JourneyMap {
|
|
|
|
|
//取总点数和最大格子数,算出走的步数
|
|
|
|
|
diceAmount =Math.min(diceAmount,pathInfo.getAllPathInfo().length-pathInfo.getCurrentPath());
|
|
|
|
|
|
|
|
|
|
// diceAmount = 1;
|
|
|
|
|
if(diceAmount==0){
|
|
|
|
|
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// randomNum.clear();
|
|
|
|
|
// randomNum.add(1);
|
|
|
|
|
pathInfo.setCurrentPath(pathInfo.getCurrentPath()+diceAmount);
|
|
|
|
|
Path arrivePath = pathInfo.getAllPathInfo()[pathInfo.getCurrentPath() - 1];
|
|
|
|
|
int mapPointId = arrivePath.getMapPointId();
|
|
|
|
|
MapInfoProto.JourneyDoResponse.Builder builder = MapInfoProto.JourneyDoResponse.newBuilder().addAllPointes(randomNum);
|
|
|
|
|
//基础奖励
|
|
|
|
|
int common = travelConfig.getCommonReward();
|
|
|
|
|
int[] common = travelConfig.getCommonReward();
|
|
|
|
|
|
|
|
|
|
int[] commonRewardArray = new int[diceAmount];
|
|
|
|
|
Arrays.stream(commonRewardArray).forEach(n->n=common);
|
|
|
|
|
int[] commonRewardArray= new int[randomNum.size()] ;
|
|
|
|
|
for(int i=0;i<commonRewardArray.length;i++){
|
|
|
|
|
commonRewardArray[i] = common[randomNum.get(i)-1];
|
|
|
|
|
}
|
|
|
|
|
CommonProto.Drop.Builder drop = ItemUtil.drop(user,commonRewardArray,1,0, BIReason.JOURNEY_COMMON_REWARD);
|
|
|
|
|
|
|
|
|
|
//地图点判断
|
|
|
|
|
@ -257,8 +294,10 @@ public class JourneyMap {
|
|
|
|
|
|
|
|
|
|
case EventType.reward:
|
|
|
|
|
//奖励节点完成
|
|
|
|
|
commonRewardArray = new int[diceAmount+1];
|
|
|
|
|
Arrays.stream(commonRewardArray).forEach(n->n=common);
|
|
|
|
|
commonRewardArray = new int[randomNum.size()+1];
|
|
|
|
|
for(int i=0;i<commonRewardArray.length-1;i++){
|
|
|
|
|
commonRewardArray[i] = common[randomNum.get(i)-1];
|
|
|
|
|
}
|
|
|
|
|
// int[][] treasureChest = travelConfig.getTreasureChest();
|
|
|
|
|
// int[] reward = MathUtils.randomFromWeightWithTaking(treasureChest, 1);
|
|
|
|
|
// commonRewardArray[commonRewardArray.length-1] = reward[0];
|
|
|
|
|
@ -275,7 +314,7 @@ public class JourneyMap {
|
|
|
|
|
|
|
|
|
|
pathInfo.setRamainRandomAmount(pathInfo.getRamainRandomAmount()+1);
|
|
|
|
|
|
|
|
|
|
pathInfo.setRemainRandomTime((int)((TimeUtils.now()+TimeUtils.HOUR*2)/1000));
|
|
|
|
|
pathInfo.setRemainRandomTime((int)((TimeUtils.now()+TimeUtils.ONE_MINUTE* SSpecialConfig.getIntegerValue(SSpecialConfig.FREETRAVEL_EVENT_TIME))/1000));
|
|
|
|
|
|
|
|
|
|
List<Integer> rewardList = Arrays.stream(pathInfo.getRandomReward()).boxed().collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
@ -290,7 +329,7 @@ public class JourneyMap {
|
|
|
|
|
int[] freeTravelBossReward = travelConfig.getFreeTravelBossReward();
|
|
|
|
|
int bossId = MathUtils.randomFromArray(freeTravelBoss);
|
|
|
|
|
int bossReward = MathUtils.randomFromArray(freeTravelBossReward);
|
|
|
|
|
JourneyMonster monster = new JourneyMonster(bossId, (int)((TimeUtils.now()+TimeUtils.HOUR*2)/1000),0,bossReward);
|
|
|
|
|
JourneyMonster monster = new JourneyMonster(bossId, (int)((TimeUtils.now()+TimeUtils.ONE_MINUTE* SSpecialConfig.getIntegerValue(SSpecialConfig.FREETRAVEL_EVENT_TIME))/1000),0,bossReward);
|
|
|
|
|
Map<Integer, List<Integer>> monsterHpByGroup = MonsterUtil.getMonsterHpByGroup(bossId);
|
|
|
|
|
List<Integer> list = monsterHpByGroup.get(0);
|
|
|
|
|
Map<Integer,Integer> hpMap = new HashMap<>();
|
|
|
|
|
@ -302,11 +341,13 @@ public class JourneyMap {
|
|
|
|
|
for(Map.Entry<Integer,Integer> hp:monster.getRemainHp().entrySet()){
|
|
|
|
|
allHp+=hp.getValue();
|
|
|
|
|
}
|
|
|
|
|
pathInfo.addMonster(TimeUtils.nowInt(),monster);
|
|
|
|
|
int monsterId = TimeUtils.nowInt();
|
|
|
|
|
pathInfo.addMonster(monsterId,monster);
|
|
|
|
|
builder.setMonster(CommonProto.JourneyMonsterInfo.newBuilder().setAttackNum(monster.getAttackNum())
|
|
|
|
|
.setMonsterHp(allHp)
|
|
|
|
|
.setMonsterId(monster.getMonsterId())
|
|
|
|
|
.setMonsterIndex(pathInfo.getMonsterMap().size())
|
|
|
|
|
.setMonsterIndex(monsterId)
|
|
|
|
|
.setRemainTime(monster.getRemainTime())
|
|
|
|
|
.setRewardShow(monster.getReward()));
|
|
|
|
|
builder.setOverTime(monster.getRemainTime());
|
|
|
|
|
pathType = 5;
|
|
|
|
|
@ -318,7 +359,7 @@ public class JourneyMap {
|
|
|
|
|
goodsArray[i] = sFreeTravelStores.get(i).getID();
|
|
|
|
|
}
|
|
|
|
|
int goodsId = MathUtils.randomFromArray(goodsArray);
|
|
|
|
|
JourneyGoods journeyGoods = new JourneyGoods(goodsId, (int) ((TimeUtils.now() + TimeUtils.HOUR * 2) / 1000));
|
|
|
|
|
JourneyGoods journeyGoods = new JourneyGoods(goodsId, (int) ((TimeUtils.now()+TimeUtils.ONE_MINUTE* SSpecialConfig.getIntegerValue(SSpecialConfig.FREETRAVEL_EVENT_TIME)) / 1000));
|
|
|
|
|
int index = TimeUtils.nowInt();
|
|
|
|
|
pathInfo.addGoods(index,journeyGoods);
|
|
|
|
|
|
|
|
|
|
@ -341,9 +382,11 @@ public class JourneyMap {
|
|
|
|
|
pathType = 2;
|
|
|
|
|
break;
|
|
|
|
|
case EventType.journeyFinal:
|
|
|
|
|
pathType = 1;
|
|
|
|
|
commonRewardArray = new int[diceAmount+1];
|
|
|
|
|
Arrays.stream(commonRewardArray).forEach(n->n=common);
|
|
|
|
|
pathType = 7;
|
|
|
|
|
commonRewardArray = new int[randomNum.size()+1];
|
|
|
|
|
for(int i=0;i<commonRewardArray.length-1;i++){
|
|
|
|
|
commonRewardArray[i] = common[randomNum.get(i)-1];
|
|
|
|
|
}
|
|
|
|
|
int finalReward = travelConfig.getFinalReward();
|
|
|
|
|
commonRewardArray[commonRewardArray.length-1] = finalReward;
|
|
|
|
|
drop = ItemUtil.drop(user,commonRewardArray,1,0, BIReason.JOURNEY_COMMON_REWARD);
|
|
|
|
|
@ -357,6 +400,7 @@ public class JourneyMap {
|
|
|
|
|
builder.setDrop(drop);
|
|
|
|
|
arrivePath.setMapPointId(0);
|
|
|
|
|
user.getMapManager().updateJourneyInfoByMapId(mapId,pathInfo);
|
|
|
|
|
ItemUtil.itemCost(user,map,BIReason.JOURNEY_DO_CONSUME,1);
|
|
|
|
|
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -406,17 +450,14 @@ public class JourneyMap {
|
|
|
|
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PVEFightEvent pveFightEvent = new PVEFightEvent(session.getUid(), GlobalsDef.FORMATION_NORMAL, 10, "", GameFightType.MapFastFight, monster.getMonsterId(), 3);
|
|
|
|
|
|
|
|
|
|
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
|
|
|
|
|
|
|
|
|
int[] checkResult = fightResult.getCheckResult();
|
|
|
|
|
PVEFightEvent pveFightEvent = new PVEFightEvent(session.getUid(), GlobalsDef.FORMATION_NORMAL, 20, "", GameFightType.MapFastFight, monster.getMonsterId(), 3);
|
|
|
|
|
|
|
|
|
|
Map<Integer, Integer> remainHp = monster.getRemainHp();
|
|
|
|
|
List<Integer> hps = new ArrayList<>(remainHp.values());
|
|
|
|
|
|
|
|
|
|
pveFightEvent.setMonsterRemainHp(hps);
|
|
|
|
|
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
|
|
|
|
|
|
|
|
|
int[] checkResult = fightResult.getCheckResult();
|
|
|
|
|
MapInfoProto.JourneyFightResponse.Builder response =MapInfoProto.JourneyFightResponse.newBuilder();
|
|
|
|
|
|
|
|
|
|
if(checkResult[0]==1){
|
|
|
|
|
@ -424,8 +465,10 @@ public class JourneyMap {
|
|
|
|
|
response.setDrop(drop);
|
|
|
|
|
pathInfo.removeMonster(bossIndex);
|
|
|
|
|
}else if(checkResult[0]==0){
|
|
|
|
|
long allHp = 0;
|
|
|
|
|
for(int i = 2;i<checkResult.length;i++){
|
|
|
|
|
remainHp.put(i-1,checkResult[i]);
|
|
|
|
|
allHp+=checkResult[i];
|
|
|
|
|
}
|
|
|
|
|
monster.setRemainHp(remainHp);
|
|
|
|
|
CommonProto.JourneyMonsterInfo monsterInfo = CommonProto.JourneyMonsterInfo.newBuilder()
|
|
|
|
|
@ -433,13 +476,15 @@ public class JourneyMap {
|
|
|
|
|
.setRemainTime(monster.getRemainTime())
|
|
|
|
|
.setMonsterIndex(bossIndex)
|
|
|
|
|
.setMonsterId(monster.getMonsterId())
|
|
|
|
|
.setRewardShow(monster.getReward()).build();
|
|
|
|
|
.setRewardShow(monster.getReward())
|
|
|
|
|
.setMonsterHp(allHp)
|
|
|
|
|
.build();
|
|
|
|
|
response.setMonster(monsterInfo);
|
|
|
|
|
}else{
|
|
|
|
|
throw new ErrorCodeException(ErrorCode.FIGHT_EXCEPTION);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ItemUtil.itemCost(user,new int[][]{bossConsume},BIReason.JOURNEY_FIGHT_CONCUME,1);
|
|
|
|
|
ItemUtil.itemCost(user,new int[][]{bossConsume},BIReason.JOURNEY_FIGHT_CONSUME,1);
|
|
|
|
|
response.setFightData(fightResult.getFightData());
|
|
|
|
|
|
|
|
|
|
monster.setAttackNum(monster.getAttackNum()+1);
|
|
|
|
|
|