公会战代码重构

back_recharge
lvxinran 2019-08-29 03:58:45 +08:00
parent 37bab876b3
commit e7df45c50f
2 changed files with 37 additions and 27 deletions

View File

@ -8,13 +8,11 @@ import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.item.ItemLogic;
import com.ljsd.jieling.protocols.CommonProto;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.*;
public class BloodLogic {
@ -68,4 +66,37 @@ public class BloodLogic {
return heroAttribute;
}
/**
* 战斗数据组装
* @param user
* @param heroInfo
* @return
*/
public CommonProto.FightTeamInfo fightDataMakeUp(User user ,Map<String, FamilyHeroInfo> heroInfo,int teamId){
List<CommonProto.FightUnitInfo> heroDefendFightInfos = new ArrayList<>();
for (Map.Entry<String, FamilyHeroInfo> entry : heroInfo.entrySet()) {
Hero hero = user.getHeroManager().getHero(entry.getKey());
if (hero == null) {
continue;
}
StringBuilder skillSb = new StringBuilder();
StringBuilder propertySb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString();
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, entry.getValue().getAttribute()).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()
.setUnitId(Integer.toString(hero.getTemplateId()))
.setUnitSkillIds(heroSkill.substring(0, heroSkill.length() - 1))
.setProperty(property.substring(0, property.length() - 1))
.build();
heroDefendFightInfos.add(heroFightInfo);
}
CommonProto.FightTeamInfo fightDefendTeamInfo = CommonProto.FightTeamInfo.
newBuilder()
.addAllFightUnitList(heroDefendFightInfos)
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(user, teamId))
.build();
return fightDefendTeamInfo;
}
}

View File

@ -342,29 +342,8 @@ public class GuildFightLogic {
int defendBuildId = GuilidManager.guildInfoMap.get(defendGuildId).getDefendInfo().get(defendUid);
FamilyFightInfo defendInfo = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(defendGuildId), String.valueOf(userDefend.getId()), FamilyFightInfo.class);
Map<String, FamilyHeroInfo> heroAttribute = defendInfo.getHeroAttribute();
List<CommonProto.FightUnitInfo> heroDefendFightInfos = new ArrayList<>();
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
Hero hero = userDefend.getHeroManager().getHero(entry.getKey());
if (hero == null) {
continue;
}
StringBuilder skillSb = new StringBuilder();
StringBuilder propertySb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(userDefend, hero, skillSb).toString();
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero, entry.getValue().getAttribute()).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()
.setUnitId(Integer.toString(hero.getTemplateId()))
.setUnitSkillIds(heroSkill.substring(0, heroSkill.length() - 1))
.setProperty(property.substring(0, property.length() - 1))
.build();
heroDefendFightInfos.add(heroFightInfo);
}
CommonProto.FightTeamInfo fightDefendTeamInfo = CommonProto.FightTeamInfo.
newBuilder()
.addAllFightUnitList(heroDefendFightInfos)
.setTeamSkillList(HeroLogic.getInstance().getPokenmonSkills(userDefend, 1))
.build();
//防守血量处理
CommonProto.FightTeamInfo fightDefendTeamInfo = BloodLogic.getInstance().fightDataMakeUp(userDefend,heroAttribute,501);
//攻击者血量处理
CommonProto.FightTeamInfo fightAttackTeamInfo = null;
List<CommonProto.FightUnitInfo> heroAttackFightInfos = new ArrayList<>();