back_recharge
jiahuiwen 2019-04-19 18:16:16 +08:00
commit 0367c5fbcb
6 changed files with 92 additions and 123 deletions

View File

@ -200,14 +200,14 @@ public class MapLogic {
return "阵容不存在";
}
List<String> heroes = new ArrayList<>(teamPosHeroInfos.size());
Map<String,Map<Integer, Integer>> heroAllAttributeMap = new HashMap<>(teamPosHeroInfos.size());
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
break;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId()));
Map<Integer, Integer> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero);
heroAllAttributeMap.put(hero.getId(),heroAllAttribute);
heroes.add(heroInfo.getHeroId());
}
if (heroes.size() != teamPosHeroInfos.size()) {
@ -215,6 +215,7 @@ public class MapLogic {
return "阵容有误";
}
mapManager.setTeamId(teamId);
mapManager.setHeroAllAttributeMap(heroAllAttributeMap);
return "";
}
@ -363,6 +364,7 @@ public class MapLogic {
.setLeftTime(getLeftTime(user))
.build();
LOGGER.info("enterMap() uid=>{} mapId =>{} ", uid, mapManager.getCurMapId());
mapManager.updateFoodBufferByStep(cells.size());
MessageUtil.sendMessage(session, 1, messageType.getNumber(), mapUpdateResponse, true);
}
@ -639,7 +641,7 @@ public class MapLogic {
if (values[0][0] == 1) {
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
Map<Integer, Integer> map = HeroLogic.getInstance().calHeroAllAttribute(hero);
Map<Integer, Integer> map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user,hero);
Integer integer = map.get(values[0][1]);
if (integer == null || integer < values[0][2]) {
return jumpTypeValues[0][1];
@ -649,7 +651,7 @@ public class MapLogic {
} else if (values[0][0] == 0){
for (TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
Map<Integer, Integer> map = HeroLogic.getInstance().calHeroAllAttribute(hero);
Map<Integer, Integer> map = HeroLogic.getInstance().calHeroFinalAttributeWhenInMap(user,hero);
Integer integer = map.get(values[0][1]);
if (integer != null && integer >= values[0][2]) {
return jumpTypeValues[0][0];
@ -728,14 +730,6 @@ public class MapLogic {
public void resetMapInfo(User user, boolean needTemporaryItem) throws Exception {
MapManager mapManager = user.getMapManager();
mapManager.setFoodBufferMap(new HashMap<>());
int teamId = mapManager.getTeamId();
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : team){
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
}
mapManager.setMapMissionProgres(null);
mapManager.setMission(null);
mapManager.setMapInfo(new HashMap<>());
@ -862,10 +856,8 @@ public class MapLogic {
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId()));
remainHp.add((int) hero.getCurHp());
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero);
remainHp.add(heroAttributeMap.get(HeroAttributeEnum.CurHP.getPropertyId()));
}
}
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
@ -881,8 +873,9 @@ public class MapLogic {
int teamId = mapManager.getTeamId();
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : team){
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
hero.setCurHp(checkResult[teamPosHeroInfo.getPosition()]);
// Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
// hero.setCurHp(checkResult[teamPosHeroInfo.getPosition()]);
mapManager.updateHeroOneAttribute(teamPosHeroInfo.getHeroId(),HeroAttributeEnum.CurHP.getPropertyId(),checkResult[teamPosHeroInfo.getPosition()]);
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[0], 1, 1);
FightInfoProto.FastFightResponse.Builder fastFightResponse = FightInfoProto.FastFightResponse.newBuilder();
@ -1054,16 +1047,15 @@ public class MapLogic {
if (leftTime <= (int) (time / 1000)) {
resetMapInfo(user, false);
} else {
initTeamInfo(mapManager.getTeamId(), uid, user, mapManager);
Map<String, Map<Integer, Integer>> heroAllAttributeMap = mapManager.getHeroAllAttributeMap();
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(mapManager.getTeamId());
for (TeamPosHeroInfo heroInfo : teamPosHeroInfos) {
Hero hero = user.getHeroManager().getHero(heroInfo.getHeroId());
if (hero == null) {
continue;
}
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroFinalAttribute(user, hero);
hero.setCurHp(heroAttributeMap.get(HeroAttributeEnum.Hp.getPropertyId()));
hero.setSpeed(heroAttributeMap.get(HeroAttributeEnum.Speed.getPropertyId()));
remainHp.add((int) hero.getCurHp());
remainHp.add(heroAllAttributeMap.get(hero.getId()).get(HeroAttributeEnum.CurHP.getPropertyId()));
}
}
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
@ -1080,8 +1072,7 @@ public class MapLogic {
int teamId = mapManager.getTeamId();
List<TeamPosHeroInfo> team = user.getTeamPosManager().getTeamPosForHero().get(teamId);
for (TeamPosHeroInfo teamPosHeroInfo : team){
Hero hero = user.getHeroManager().getHero(teamPosHeroInfo.getHeroId());
hero.setCurHp(checkResult[teamPosHeroInfo.getPosition()]);
mapManager.updateHeroOneAttribute(teamPosHeroInfo.getHeroId(),HeroAttributeEnum.CurHP.getPropertyId(),checkResult[teamPosHeroInfo.getPosition()]);
}
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMonsterGroup.getRewardgroup(), 1, 1);
FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder();
@ -1196,9 +1187,6 @@ public class MapLogic {
addScore+=score;
}
}
if(logic == MapMissionType.CONSUME_ACTION_POWER_EVENT.getMissionTypeValue()){
mapManager.updateFoodBufferByStep(bossIdOrItemId);
}
}
//处理采矿 、宝箱

View File

@ -40,6 +40,7 @@ public class MapManager extends MongoBase {
private TemporaryItems temporaryItems;
private Map<Integer,Integer> foodBufferMap = new HashMap<>();
private Map<String,Map<Integer, Integer>> heroAllAttributeMap = new HashMap<>(5);
private MapMission mapMissionProgres;
private int energy;
@ -158,9 +159,6 @@ public class MapManager extends MongoBase {
public void eatFood(int foodId,int remainStep){
if(remainStep == 0){
remainStep = -1; //表示一次性生效
}
int finalRemainStep = remainStep;
if(this.foodBufferMap.containsKey(foodId)){
finalRemainStep += this.foodBufferMap.get(foodId);
@ -178,9 +176,6 @@ public class MapManager extends MongoBase {
for(Map.Entry<Integer, Integer> item : entries){
Integer foodId = item.getKey();
Integer remainStep = item.getValue();
if(remainStep < 0){
continue;
}
int finalRemainStep = remainStep - step;
if(finalRemainStep<=0){
removeFoodIds.add(foodId);
@ -226,12 +221,6 @@ public class MapManager extends MongoBase {
item.setEndingTime(time);
}
public static void main(String [] args){
int lastUpdateEnergyTime = 1552170600;
int nowTime = 1552170735;
int time = lastUpdateEnergyTime + ((nowTime -lastUpdateEnergyTime)/60 )* 60;
System.out.println(time);
}
public void setLastUpdateEnergyTime(int lastUpdateEnergyTime) {
updateString("lastUpdateEnergyTime", lastUpdateEnergyTime);
this.lastUpdateEnergyTime = lastUpdateEnergyTime;
@ -326,4 +315,27 @@ public class MapManager extends MongoBase {
updateString("buyFightCount", buyFightCount);
this.buyFightCount = buyFightCount;
}
public Map<Integer, Integer> getHeroAllAttributeByHeroId(String heroId) {
return heroAllAttributeMap.get(heroId);
}
public void updateHeroAttribute(String id, Map<Integer, Integer> heroAllAttribute) {
heroAllAttributeMap.put(id,heroAllAttribute);
updateString("heroAllAttributeMap." + id, heroAllAttribute);
}
public void updateHeroOneAttribute(String id, int attribute,int value) {
heroAllAttributeMap.get(id).put(attribute,value);
updateString("heroAllAttributeMap." + id +"." + attribute, value);
}
public Map<String, Map<Integer, Integer>> getHeroAllAttributeMap() {
return heroAllAttributeMap;
}
public void setHeroAllAttributeMap(Map<String, Map<Integer, Integer>> heroAllAttributeMap) {
updateString("heroAllAttributeMap" , heroAllAttributeMap);
this.heroAllAttributeMap = heroAllAttributeMap;
}
}

View File

@ -13,6 +13,7 @@ import com.ljsd.jieling.handler.mission.Mission;
import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.FightInfoProto;

View File

@ -38,8 +38,6 @@ public class Hero extends MongoBase {
private int lastUpdateEnergyTime;
private float curHp;
private int speed;
public Hero(){
@ -61,7 +59,6 @@ public class Hero extends MongoBase {
if(skillIds!=null && !skillIds.isEmpty()){
this.skillList.addAll(skillIds);
}
this.curHp = HeroLogic.getInstance().calHeroAttribute(this, GlobalsDef.HP_TYPE);
createTime = (int)(System.currentTimeMillis()/1000);
lastUpdateEnergyTime = createTime;
breakId = 0;
@ -93,15 +90,6 @@ public class Hero extends MongoBase {
this.templateId = templateId;
}
public float getCurHp() {
return curHp;
}
public void setCurHp(float curHp) throws Exception {
updateString("curHp",curHp);
this.curHp = curHp;
}
public void setLevel(int level) throws Exception {
updateString("level",level);
this.level = level;

View File

@ -135,7 +135,7 @@ public class CombatLogic {
continue;
}
int startTime = adventureStateInfoTmp.getStartTime();
int times = (now - startTime)%adventureRefresh;
int times = (now - startTime)/adventureRefresh;
int size = adventureStateInfoTmp.getHeroIds().size();
if(times>0){
adventureStateInfoTmp.setStartTime(startTime+times*adventureRefresh);
@ -174,45 +174,35 @@ public class CombatLogic {
}
//在地图吃东西
public void eatFood(ISession session, int foodId) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MapManager mapManager = user.getMapManager();
if (mapManager.getMapInfo() == null) {
LOGGER.info("mapManager.getMapInfo() == null");
return;
}
boolean enough = ItemUtil.itemCost(user, new int[][]{{foodId, 1}});
if(!enough){
return;
}
bufferAddByEatFoodOrEventTrigger(mapManager,foodId);
}
public void bufferAddByEatFoodOrEventTrigger(MapManager mapManager,int foodIdOrEventId) throws Exception {
SFoodsConfig sFoodsConfig = SFoodsConfig.getsFoodsConfigByFoodId(foodIdOrEventId);
int contiue = sFoodsConfig.getContiue();
if(contiue==0){
int type = sFoodsConfig.getType();
int[][] effectParas = sFoodsConfig.getEffectPara();
if(type == GlobalsDef.FOOD_ADDITION_EXPLORE_TYPE){
for(int[] effectPara : effectParas){
if(effectPara[0] == GlobalsDef.EXPLORE_MAP_ACTION_POWER_RORMULA_TYPE){
// SCMapConfig scMapConfig = SCMapConfig.getsCMapSize().get(mapManager.getCurMapId());
// int totalStep = mapManager.getTotalStep();
// if (totalStep < scMapConfig.getMoveConfused() * 5) {
// totalStep = scMapConfig.getMoveConfused() * 5;
// }
// mapManager.setTotalStep(totalStep + effectPara[1]);
if(contiue == 0){
int typeTmp = sFoodsConfig.getType();
int targetTmp = sFoodsConfig.getTarget();
if( typeTmp== GlobalsDef.FOOD_ADDITION_BATTLE_TYPE && targetTmp==GlobalsDef.FOOD_EAT_AFFECT_PERSON ){
boolean change = false;
int[][] effectParas = sFoodsConfig.getEffectPara();
Map<String, Map<Integer, Integer>> heroAllAttributeMap = mapManager.getHeroAllAttributeMap();
for(Map.Entry<String,Map<Integer,Integer>> item : heroAllAttributeMap.entrySet()){
Map<Integer, Integer> value = item.getValue();
for(int[] effectPara : effectParas){
int effectId = effectPara[0];
int effectValue = effectPara[1];
if(!value.containsKey(effectId)){
value.put(effectId,effectValue);
continue;
}
value.put( effectId,value.get(effectId) + effectValue );
change = true;
}
}
if(change){
mapManager.setHeroAllAttributeMap(heroAllAttributeMap);
}
}
if(type == GlobalsDef.FOOD_ADDITION_BATTLE_TYPE){
mapManager.eatFood(foodIdOrEventId,sFoodsConfig.getContiue());
}
}else{
}else {
mapManager.eatFood(foodIdOrEventId,sFoodsConfig.getContiue());
}
}
@ -220,16 +210,9 @@ public class CombatLogic {
public Map<Integer,Integer> attributeByEatFood( User user,int type,int target){
Map<Integer,Integer> foddAddResult = new HashMap<>();
MapManager mapManager = user.getMapManager();
Set<Integer> removeFoodBufferIds = new HashSet<>();
Map<Integer, Integer> foodBufferMap = mapManager.getFoodBufferMap();
for(Map.Entry<Integer,Integer> foodBuffer : foodBufferMap.entrySet()){
int foodId = foodBuffer.getKey();
Integer step = foodBuffer.getValue();
int times =1;
if(step<0){
times = step*-1;
removeFoodBufferIds.add(foodId);
}
SFoodsConfig sFoodsConfig = SFoodsConfig.getsFoodsConfigByFoodId(foodId);
int typeTmp = sFoodsConfig.getType();
int targetTmp = sFoodsConfig.getTarget();
@ -237,7 +220,7 @@ public class CombatLogic {
int[][] effectParas = sFoodsConfig.getEffectPara();
for(int[] effectPara : effectParas){
int effectId = effectPara[0];
int effectValue = effectPara[1] * times;
int effectValue = effectPara[1];
if(!foddAddResult.containsKey(effectId)){
foddAddResult.put(effectId,effectValue);
continue;
@ -246,14 +229,7 @@ public class CombatLogic {
}
}
}
if(!removeFoodBufferIds.isEmpty()){
for(Integer removeFoodId : removeFoodBufferIds){
foodBufferMap.remove(removeFoodId);
}
mapManager.setFoodBufferMap(foodBufferMap);
}
return foddAddResult;
}
}

View File

@ -4,7 +4,6 @@ import com.ljsd.GameApplication;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.dao.UserManager;
@ -423,7 +422,7 @@ public class HeroLogic {
}else{
hero.setBreakId(breakId);
}
Map<Integer, Integer> heroAllAttribute = calHeroFinalAttribute(user,hero);
Map<Integer, Integer> heroAllAttribute = calHeroNotBufferAttribute(user,hero);
for(Map.Entry<Integer,Integer> item : heroAllAttribute.entrySet() ){
LOGGER.info("the heroTdd={},the heroLevel={},the attID is={},attValue={}",hero.getTemplateId(),hero.getLevel(),item.getKey(),item.getValue() );
}
@ -551,7 +550,7 @@ public class HeroLogic {
}
//初始属性*1+化境增长)*等级系数 + 初始属性*突破系数
public Map<Integer,Integer> calHeroAllAttribute(Hero hero){
private Map<Integer,Integer> calHeroAllAttribute(Hero hero){
Map<Integer,Integer> result = new HashMap<>();
int templateId = hero.getTemplateId();
SCHero scHero = SCHero.getsCHero().get(templateId);
@ -681,7 +680,7 @@ public class HeroLogic {
}
public StringBuilder getHeroProperty(User user, Hero hero, StringBuilder sb){
Map<Integer, Integer> heroAttributeMap = calHeroFinalAttribute(user, hero);
Map<Integer, Integer> heroAttributeMap = calHeroFinalAttributeWhenInMap(user, hero);
sb.append(hero.getLevel()).append(DIVISION);
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
List<Integer> templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName());
@ -720,27 +719,24 @@ public class HeroLogic {
return pokenSkillResult.toString();
}
//获取英雄所有属性
public Map<Integer,Integer> calHeroFinalAttribute(User user, Hero hero){
public Map<Integer,Integer> calHeroNotBufferAttribute(User user, Hero hero){
Map<Integer, Integer> heroAllAttribute = calHeroAllAttribute(hero);
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),(int)hero.getCurHp());
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE));
Collection<String> values = hero.getEquipByPositionMap().values();
EquipManager equipManager = user.getEquipManager();
PokemonManager pokemonManager = user.getPokemonManager();
Map<Integer, Pokemon> pokemonMap = pokemonManager.getPokemonMap();
for(Map.Entry<Integer,Pokemon> item : pokemonMap.entrySet()){
Pokemon pokemon = item.getValue();
Map<Integer, Integer> comonpentsLevelMap = pokemon.getComonpentsLevelMap();
for(Map.Entry<Integer, Integer> comonpentsLevelItem : comonpentsLevelMap.entrySet()){
Integer comonpentId = comonpentsLevelItem.getKey();
Integer comonpentLevel = comonpentsLevelItem.getValue();
Map<Integer, SDifferDemonsComonpentsConfig> sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId);
SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(comonpentLevel);
combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(),heroAllAttribute);
}
}
for(Map.Entry<Integer,Pokemon> item : pokemonMap.entrySet()){
Pokemon pokemon = item.getValue();
Map<Integer, Integer> comonpentsLevelMap = pokemon.getComonpentsLevelMap();
for(Map.Entry<Integer, Integer> comonpentsLevelItem : comonpentsLevelMap.entrySet()){
Integer comonpentId = comonpentsLevelItem.getKey();
Integer comonpentLevel = comonpentsLevelItem.getValue();
Map<Integer, SDifferDemonsComonpentsConfig> sDifferDemonsComonpentsConfigMap = SDifferDemonsComonpentsConfig.getsDifferDemonsComonpentsConfigMap(comonpentId);
SDifferDemonsComonpentsConfig sDifferDemonsComonpentsConfig = sDifferDemonsComonpentsConfigMap.get(comonpentLevel);
combinedAttribute(sDifferDemonsComonpentsConfig.getBaseAttribute(),heroAllAttribute);
}
}
for(String equipId:values){
Equip equip = equipManager.getEquipMap().get(equipId);
@ -749,15 +745,23 @@ public class HeroLogic {
combinedAttribute(propertyValueByIdMap,heroAllAttribute);
combinedAttribute(secondValueByIdMap,heroAllAttribute);
}
return heroAllAttribute;
}
//获取英雄所有属性
public Map<Integer,Integer> calHeroFinalAttributeWhenInMap(User user, Hero hero){
Map<Integer, Integer> heroAllAttribute = user.getMapManager().getHeroAllAttributeByHeroId(hero.getId());
//食物buffer加成
Map<Integer, Integer> foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_EXPLORE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_TEAM);
Map<Integer, Integer> foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON);
combinedAttribute(foodAddMap,heroAllAttribute);
return heroAllAttribute;
}
public int calHeoForce(User user, Hero hero){
Map<Integer, Integer> heroAllAttribute = calHeroFinalAttribute(user, hero);
Map<Integer, Integer> heroAllAttribute = calHeroFinalAttributeWhenInMap(user, hero);
heroAllAttribute.remove(0);
double result = 0;
for(Map.Entry<Integer, Integer> item : heroAllAttribute.entrySet()){