back_recharge
wangyuan 2019-01-24 18:21:24 +08:00
parent b3ce98deaa
commit 5b701319c2
4 changed files with 121 additions and 19 deletions

View File

@ -3,7 +3,10 @@ package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
@Table(name ="AdventureConfig")
public class SAdventureConfig implements BaseConfig {
@ -25,16 +28,39 @@ public class SAdventureConfig implements BaseConfig {
private int[] recommendRewardGroup;
private int pooId;
private Set<Integer> recommendHeroSets;
@Override
public void init() throws Exception {
sAdventureConfigMap = STableManager.getConfig(SAdventureConfig.class);
Map<Integer, SAdventureConfig> config = STableManager.getConfig(SAdventureConfig.class);
for(SAdventureConfig sAdventureConfig : config.values()){
int[] recommendHeroIds = sAdventureConfig.getRecommendHeroIds();
Set<Integer> recommendHeroSetTmp = new HashSet<>(recommendHeroIds.length);
for(int i=0;i<recommendHeroIds.length;i++){
recommendHeroSetTmp.add(recommendHeroIds[i]);
}
sAdventureConfig.setRecommendHeroSets(recommendHeroSetTmp);
}
sAdventureConfigMap = config;
}
public static SAdventureConfig getsAdventureConfigByPosition(int position) {
return sAdventureConfigMap.get(position);
}
public Set<Integer> getRecommendHeroSets() {
return recommendHeroSets;
}
public void setRecommendHeroSets(Set<Integer> recommendHeroSets) {
this.recommendHeroSets = recommendHeroSets;
}
public int getId() {
return id;
}
@ -67,5 +93,7 @@ public class SAdventureConfig implements BaseConfig {
return recommendRewardGroup;
}
public int getPooId() {
return pooId;
}
}

View File

@ -16,13 +16,13 @@ public class SAdventureSetting implements BaseConfig {
private int[] consumeGemRatio;
private int[][] baseRewardRatio;
private float[][] baseRewardRatio;
private int[][] randomRewardRatio;
private float[][] randomRewardRatio;
private int perMapMaxHour;
private int[][] hourRewardRatio;
private float[] hourRewardRatio;
@Override
@ -30,8 +30,8 @@ public class SAdventureSetting implements BaseConfig {
sAdventureSettingMap = STableManager.getConfig(SAdventureSetting.class);
}
public static Map<Integer, SAdventureSetting> getsAdventureSettingMap() {
return sAdventureSettingMap;
public static SAdventureSetting getsAdventureSetting(int pooId) {
return sAdventureSettingMap.get(pooId);
}
public int getId() {
@ -46,11 +46,11 @@ public class SAdventureSetting implements BaseConfig {
return consumeGemRatio;
}
public int[][] getBaseRewardRatio() {
public float[][] getBaseRewardRatio() {
return baseRewardRatio;
}
public int[][] getRandomRewardRatio() {
public float[][] getRandomRewardRatio() {
return randomRewardRatio;
}
@ -58,7 +58,7 @@ public class SAdventureSetting implements BaseConfig {
return perMapMaxHour;
}
public int[][] getHourRewardRatio() {
public float[] getHourRewardRatio() {
return hourRewardRatio;
}

View File

@ -2,21 +2,19 @@ package com.ljsd.jieling.logic.fight;
import com.ljsd.jieling.config.SAdventureConfig;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.dao.AdventureManager;
import com.ljsd.jieling.logic.dao.AdventureStateInfo;
import com.ljsd.jieling.logic.dao.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.config.SAdventureSetting;
import com.ljsd.jieling.config.SCHero;
import com.ljsd.jieling.logic.dao.*;
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.FightInfoProto;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.*;
public class CombatLogic {
private static final Logger LOGGER = LoggerFactory.getLogger(CombatLogic.class);
@ -76,6 +74,7 @@ public class CombatLogic {
List<String> heroIds1 = adventureStateInfoTmp.getHeroIds();
for(String useHeroId : heroIds1){
if(heroIds.contains(useHeroId)){
//该英雄已上阵
return;
}
}
@ -110,10 +109,50 @@ public class CombatLogic {
SAdventureConfig sAdventureConfig = SAdventureConfig.getsAdventureConfigByPosition(position);
int recommendForce = sAdventureConfig.getRecommendForce();
int pooId = sAdventureConfig.getPooId();
SAdventureSetting sAdventureSetting = SAdventureSetting.getsAdventureSetting(pooId);
float[][] baseRewardRatio = sAdventureSetting.getBaseRewardRatio();
float[][] randomRewardRatio = sAdventureSetting.getRandomRewardRatio();
float[] hourRewardRatio = sAdventureSetting.getHourRewardRatio();
List<String> heroIds = adventureStateInfo.getHeroIds();
int totalForce =0;
HeroManager heroManager = user.getHeroManager();
Set<Integer> recommendHeroSets = sAdventureConfig.getRecommendHeroSets();
int myRecommendHeroSize =0;
Set<Integer> cacheHeroTid = new HashSet<>(recommendHeroSets.size());
for(String heroId : heroIds){
Hero hero = heroManager.getHero(heroId);
int templateId = hero.getTemplateId();
if(recommendHeroSets.contains(templateId) && !cacheHeroTid.contains(templateId)){
cacheHeroTid.add(templateId);
myRecommendHeroSize++;
}
totalForce += HeroLogic.getInstance().calHeoForce(hero);
}
float myForceRatio = totalForce*1.0f / recommendForce;
float hourRewardRatioTmp = calABX(hourDuration, hourRewardRatio);
float baseRewardRatioTmp = calRatio(myForceRatio, baseRewardRatio) * hourRewardRatioTmp;
float randomRewardRatioTmp = calRatio(myForceRatio, randomRewardRatio) * hourRewardRatioTmp;
int[] baseRewardGroup = sAdventureConfig.getBaseRewardGroup();
int[] recommendHeroIds = sAdventureConfig.getRecommendHeroIds();
int[] recommendRewardGroup = sAdventureConfig.getRecommendRewardGroup();
Map<int[],Float> dropInfoMap = new HashMap<>();
dropInfoMap.put(baseRewardGroup,baseRewardRatioTmp);
dropInfoMap.put(recommendRewardGroup,randomRewardRatioTmp);
dropInfoMap.put(recommendRewardGroup,myRecommendHeroSize*1.0f);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropInfoMap);
//清除占领
adventureManager.clearStation(position);
@ -121,6 +160,31 @@ public class CombatLogic {
//发送成功
}
public float calRatio(float value,float[][] base){
float result = 0;
int length = base.length;
for(int i=0;i< base.length;i++){
float weight = base[i][0];
value = value - weight;
if(value< weight){
result = base[i][1];
}
}
return result;
}
//ab x 公式
public float calABX(float source,float[] base){
float result = 0;
int length = base.length;
for(int i=0;i< base.length;i++){
double pow = Math.pow(source, --length);
result += base[i]*pow;
}
return result;
}
}

View File

@ -384,6 +384,16 @@ public class HeroLogic {
}
//todo 计算英雄战斗力 战斗力 = 生命*0.7 + (护甲 + 魔坑)*5 + 攻击 *10 + (暴击率 + 效果命中率 *5 +(属性攻击率 + 属性防御率)*30
public int calHeoForce(Hero hero){
double heroBaseForce = calHeroAttribute(hero, GlobalsDef.HP_TYPE) * 0.7 + (calHeroAttribute(hero, GlobalsDef.PhysicalDefence_TYPE) + calHeroAttribute(hero, GlobalsDef.MagicDefence_TYPE)) * 5 + calHeroAttribute(hero, GlobalsDef.ATTACK_TYPE) * 10;
//todo 计算装备加成
float equipAddForce =0.0f;
int result = (int) (heroBaseForce + equipAddForce);
return result;
}
}