公会战代码重构
parent
eca20927e6
commit
31590ea1c8
|
@ -115,6 +115,8 @@ public class RedisKey {
|
|||
|
||||
public static final String FAMILY_ID = "FAMILY_ID";
|
||||
|
||||
public static final String FAMILY_JOIN = "FAMILY_JOIN";
|
||||
|
||||
public static final String FAMILY_FIGHT = "FAMILY_FIGHT" ;
|
||||
public static final String FAMILY_ATTACK_BLOOD = "FAMILY_ATTACK_BLOOD";
|
||||
public static final String FAMILY_FIGHT_RANK = "FAMILY_FIGHT_RANK";
|
||||
|
|
|
@ -20,7 +20,7 @@ public class EndlessMapInfo {
|
|||
|
||||
private Set<Integer> openMap;
|
||||
|
||||
private Map<Integer,Integer> cellRefreshTime;
|
||||
private Map<Integer,Integer> cellRefreshTime = new HashMap<>();
|
||||
|
||||
private Set<Integer> walkCell = new HashSet<>();
|
||||
|
||||
|
|
|
@ -934,7 +934,7 @@ public class MapLogic {
|
|||
}
|
||||
case 10:{
|
||||
Map<Integer, Integer> cellRefreshTime = user.getMapManager().getEndlessMapInfo().getCellRefreshTime();
|
||||
Integer time = cellRefreshTime.get(mapManager.getCurMapId());
|
||||
Integer time = cellRefreshTime.get(mapManager.getCurXY());
|
||||
if(time!=null&&time>TimeUtils.now()/1000){
|
||||
nextEventId=jumpTypeValues[0][0];
|
||||
}else{
|
||||
|
|
|
@ -775,7 +775,7 @@ public class ActivityLogic {
|
|||
continue;
|
||||
}
|
||||
if (i < BlessInfoConfig.REWARD_VIEW_START_ID) {
|
||||
LOGGER.info("显示顺序是{}", entry.getKey());
|
||||
// LOGGER.info("显示顺序是{}", entry.getKey());
|
||||
CommonProto.blessReward blessReward = CommonProto.blessReward.newBuilder()
|
||||
.setLocationId(i - BlessInfoConfig.START_CAPACITY)
|
||||
.setState(1)
|
||||
|
|
|
@ -0,0 +1,71 @@
|
|||
package com.ljsd.jieling.logic.blood;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
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 org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class BloodLogic {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(BloodLogic.class);
|
||||
|
||||
private BloodLogic(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static BloodLogic instance = new BloodLogic();
|
||||
}
|
||||
|
||||
public static BloodLogic getInstance() {
|
||||
return BloodLogic.Instance.instance;
|
||||
}
|
||||
|
||||
//根据buff,team获得英雄快照
|
||||
public Map<String, FamilyHeroInfo> battleRecord(User user ,int teamId,int[] buffInfo){
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = teamPosManager.getTeamPosForHero().get(teamId);
|
||||
Iterator<TeamPosHeroInfo> it = teamPosHeroInfos.iterator();
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
while (it.hasNext()) {
|
||||
TeamPosHeroInfo heroInfo = it.next();
|
||||
Hero hero = heroManager.getHero(heroInfo.getHeroId());
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, 501);
|
||||
//加buff
|
||||
if(buffInfo.length>0){
|
||||
for(int i = 0 ; i < buffInfo.length ; i++){
|
||||
heroAttributeMap = CombatLogic.getInstance().bufferOneHeroAttrAfterEat(heroAttributeMap,buffInfo[i]);
|
||||
}
|
||||
}
|
||||
heroAllAttribute.put(heroInfo.getHeroId(), new FamilyHeroInfo(hero.getTemplateId(), hero.getLevel(), heroAttributeMap));
|
||||
}
|
||||
return heroAllAttribute;
|
||||
}
|
||||
//战斗之后血量计算
|
||||
public Map<String, FamilyHeroInfo> afterBattleRecord(Map<String, FamilyHeroInfo> heroAttribute,int[] fightResult){
|
||||
int index = 2;
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
FamilyHeroInfo value = entry.getValue();
|
||||
Map<Integer, Integer> attribute = value.getAttribute();
|
||||
if(fightResult[0]==0) {
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), fightResult[index]);
|
||||
}else{
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), 0);
|
||||
}
|
||||
value.setAttribute(attribute);
|
||||
index++;
|
||||
}
|
||||
return heroAttribute;
|
||||
}
|
||||
|
||||
}
|
|
@ -10,6 +10,7 @@ import com.ljsd.jieling.db.redis.RedisKey;
|
|||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.family.FamilyRound;
|
||||
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
|
||||
import com.ljsd.jieling.logic.blood.BloodLogic;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
|
@ -267,25 +268,10 @@ public class GuildFightLogic {
|
|||
for (Map.Entry<Integer, Integer> entry : defendInfo.entrySet()) {
|
||||
User user = UserManager.getUser(entry.getKey());
|
||||
int memberType = GuildLogic.getMemberType(entry.getKey(), guildInfo.getMembers());
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||
List<TeamPosHeroInfo> teamPosHeroInfos = teamPosManager.getTeamPosForHero().get(501);
|
||||
Iterator<TeamPosHeroInfo> it = teamPosHeroInfos.iterator();
|
||||
int[] buffInfo = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT_BUFF, gid.toString(), entry.getValue().toString(), int[].class);
|
||||
FamilyFightInfo fightInfo = new FamilyFightInfo();
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = new HashMap<>();
|
||||
while (it.hasNext()) {
|
||||
TeamPosHeroInfo heroInfo = it.next();
|
||||
Hero hero = heroManager.getHero(heroInfo.getHeroId());
|
||||
Map<Integer, Integer> heroAttributeMap = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero, false, 501);
|
||||
//加防守buff
|
||||
int[] buffInfo = redisUtil.getMapEntry(RedisKey.FAMILY_FIGHT_BUFF, gid.toString(), entry.getValue().toString(), int[].class);
|
||||
if(buffInfo.length>0){
|
||||
for(int i = 0 ; i < buffInfo.length ; i++){
|
||||
heroAttributeMap = CombatLogic.getInstance().bufferOneHeroAttrAfterEat(heroAttributeMap,buffInfo[i]);
|
||||
}
|
||||
}
|
||||
heroAllAttribute.put(heroInfo.getHeroId(), new FamilyHeroInfo(hero.getTemplateId(), hero.getLevel(), heroAttributeMap));
|
||||
}
|
||||
//血量处理,buff处理
|
||||
Map<String, FamilyHeroInfo> heroAllAttribute = BloodLogic.getInstance().battleRecord(user, 501, buffInfo);
|
||||
fightInfo.setHeroAttribute(heroAllAttribute);
|
||||
fightInfo.setBuildId(entry.getValue());
|
||||
fightInfo.setStarCount(guildSetting.getStarNum()[memberType-1]);
|
||||
|
@ -432,25 +418,20 @@ public class GuildFightLogic {
|
|||
for (int i = 0; i < fightResult.length; i++) {
|
||||
System.out.println(fightResult[i]);
|
||||
}
|
||||
int index = 2;
|
||||
int dieCount = 0;
|
||||
|
||||
// 战斗之后数据处理
|
||||
for (Map.Entry<String, FamilyHeroInfo> entry : heroAttribute.entrySet()) {
|
||||
FamilyHeroInfo value = entry.getValue();
|
||||
Map<Integer, Integer> attribute = value.getAttribute();
|
||||
for(int i = 2 ; i <fightResult.length;i++){
|
||||
if(fightResult[0]==0) {
|
||||
if(fightResult[index]==0){
|
||||
if(fightResult[i]==0){
|
||||
dieCount++;
|
||||
}
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), fightResult[index]);
|
||||
}else{
|
||||
dieCount = 5;
|
||||
attribute.put(HeroAttributeEnum.CurHP.getPropertyId(), 0);
|
||||
}
|
||||
value.setAttribute(attribute);
|
||||
index++;
|
||||
}
|
||||
defendInfo.setHeroAttribute(heroAttribute);
|
||||
|
||||
defendInfo.setHeroAttribute(BloodLogic.getInstance().afterBattleRecord(heroAttribute,fightResult));
|
||||
//获得星数
|
||||
int getStar;
|
||||
if (fightResult[0] == 1) {
|
||||
|
|
|
@ -232,7 +232,7 @@ public class GuildLogic {
|
|||
}finally {
|
||||
RedisUtil.getInstence().releaseDistributedLock(RedisKey.OPERATE_FAMILY,Integer.toString(guildId), Integer.toString(uid));
|
||||
}
|
||||
|
||||
RedisUtil.getInstence().expire(RedisKey.getKey(RedisKey.FAMILY_JOIN,String.valueOf(uid),false),TimeUtils.DAY);
|
||||
addGuildLog(guildInfo.getId(),GuildDef.Log.JOIN,user.getPlayerInfoManager().getNickName());
|
||||
Family.FamilyJoinIndicaion build = Family.FamilyJoinIndicaion.newBuilder().setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo)).setFamilyUserInfo(CBean2Proto.getFamilyUserInfo(user, GlobalsDef.MEMBER)).build();
|
||||
Family.FamilyJoinResponse response = Family.FamilyJoinResponse.newBuilder().setFamilyJoinIndicaion(build).build();
|
||||
|
|
Loading…
Reference in New Issue