公会战开始战斗提交

back_recharge
lvxinran 2019-08-12 14:30:32 +08:00
parent 8395912f43
commit 9364fbda6d
5 changed files with 108 additions and 9 deletions

View File

@ -3,13 +3,13 @@ package com.ljsd.jieling.logic.dao;
import java.util.Map;
public class FamilyFightInfo {
private Map<String, Map<Integer,Integer>> heroAttribute;
private Map<String, FamilyHeroInfo> heroAttribute;
private int uid;
private int familyId;
private int buildId;
private int starCount;
public Map<String, Map<Integer, Integer>> getHeroAttribute() {
public Map<String, FamilyHeroInfo> getHeroAttribute() {
return heroAttribute;
}
@ -29,7 +29,7 @@ public class FamilyFightInfo {
return starCount;
}
public void setHeroAttribute(Map<String, Map<Integer, Integer>> heroAttribute) {
public void setHeroAttribute(Map<String, FamilyHeroInfo> heroAttribute) {
this.heroAttribute = heroAttribute;
}

View File

@ -0,0 +1,43 @@
package com.ljsd.jieling.logic.dao;
import java.util.Map;
public class FamilyHeroInfo {
private int templeteId;
private int level;
private Map<Integer,Integer> attribute;
public int getTempleteId() {
return templeteId;
}
public int getLevel() {
return level;
}
public Map<Integer, Integer> getAttribute() {
return attribute;
}
public void setTempleteId(int templeteId) {
this.templeteId = templeteId;
}
public void setLevel(int level) {
this.level = level;
}
public void setAttribute(Map<Integer, Integer> attribute) {
this.attribute = attribute;
}
public FamilyHeroInfo(int templeteId, int level, Map<Integer, Integer> attribute) {
this.templeteId = templeteId;
this.level = level;
this.attribute = attribute;
}
public FamilyHeroInfo() {
}
}

View File

@ -36,6 +36,8 @@ public class GuildInfo extends MongoBase {
private Map<Integer,Integer> defendInfo;
private Map<Integer,Integer> fightResult;
public GuildInfo() {
setRootCollection(_COLLECTION_NAME);
}

View File

@ -8,18 +8,22 @@ import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.GuildApply;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.GuildLog;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CheckFight;
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.Family;
import com.ljsd.jieling.protocols.MessageTypeProto;
import com.ljsd.jieling.util.*;
import org.luaj.vm2.LuaValue;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -840,6 +844,11 @@ public class GuildLogic {
}
}
}
/**
*
* @throws Exception
*/
public static void familyFightMatching() throws Exception {
Set<Integer> guildIds= GuilidManager.guildInfoMap.keySet();
if(guildIds.size()<1){
@ -857,19 +866,62 @@ public class GuildLogic {
TeamPosManager teamPosManager = user.getTeamPosManager();
List<TeamPosHeroInfo> teamPosHeroInfos = teamPosManager.getTeamPosForHero().get(501);
Iterator<TeamPosHeroInfo> it = teamPosHeroInfos.iterator();
FamilyFightInfo fightInfo = new FamilyFightInfo();
Map<String ,Map<Integer,Integer>> heroAllAttribute = new HashMap<>();
FamilyFightInfo fightInfo = new FamilyFightInfo();
Map<String ,FamilyHeroInfo> heroAllAttribute = new HashMap<>();
while (it.hasNext()){
TeamPosHeroInfo heroInfo = it.next();
heroManager.getHero(heroInfo.getHeroId());
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, heroManager.getHero(heroInfo.getHeroId()), false,501);
heroAllAttribute.put(heroInfo.getHeroId(),heroAttributeMap);
Hero hero = heroManager.getHero(heroInfo.getHeroId());
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false,501);
heroAllAttribute.put(heroInfo.getHeroId(),new FamilyHeroInfo(hero.getTemplateId(),hero.getLevel(),heroAttributeMap));
}
fightInfo.setHeroAttribute(heroAllAttribute);
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_FIGHT,String.valueOf(guildInfo.getId()),String.valueOf(entry.getKey()),fightInfo);
}
}
}
public void familyFightResult(User userAttack,User userDefend){
int defendGuildId =userDefend.getPlayerInfoManager().getGuildId();
FamilyFightInfo defendInfo = RedisUtil.getInstence().getMapEntry(RedisKey.FAMILY_FIGHT, String.valueOf(defendGuildId), String.valueOf(userDefend.getId()), FamilyFightInfo.class);
Map<String, FamilyHeroInfo> heroAttribute = defendInfo.getHeroAttribute();
int seed = (int)(System.currentTimeMillis()/1000);
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 fightAttackTeamInfo = BehaviorUtil.getFightTeamInfo(userAttack, 502, true);
LuaValue getFightData = FightDataUtil.getFinalPlayerFightData(fightAttackTeamInfo, fightDefendTeamInfo);
LuaValue getOptionData = FightDataUtil.getOptionData("");
int[] fightResult = CheckFight.getInstance().checkFight(seed,1000,getFightData,getOptionData);
int index = 2;
// 战斗之后数据处理
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
FamilyHeroInfo value = entry.getValue();
Map<Integer, Integer> attribute = value.getAttribute();
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(),fightResult[index]);
value.setAttribute(attribute);
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_FIGHT,String.valueOf(defendGuildId),String.valueOf(userDefend.getId()),attribute);
index++;
}
}
}

View File

@ -829,7 +829,9 @@ public class HeroLogic {
}else {
heroAttributeMap=calHeroFinalAttributeWhenInMap(user, hero,false,teamId);
}
return getHeroPropertyBuilder(sb,hero,heroAttributeMap);
}
public StringBuilder getHeroPropertyBuilder(StringBuilder sb,Hero hero,Map<Integer, Integer> heroAttributeMap){
sb.append(hero.getLevel()).append(DIVISION);
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
List<Integer> templatePropetyIds = transTemplateByHeroPropertyName.get(scHero.getPropertyName());