装备特性随机提交
parent
3b2ebae2c5
commit
98e2309523
|
|
@ -20,13 +20,13 @@ public class SEquipConfig implements BaseConfig {
|
||||||
|
|
||||||
private int[] propertyMax;
|
private int[] propertyMax;
|
||||||
|
|
||||||
private int pool;
|
private int[] pool;
|
||||||
|
|
||||||
private int secondNumMin;
|
private int secondNumMin;
|
||||||
|
|
||||||
private int secondNumMax;
|
private int secondNumMax;
|
||||||
|
|
||||||
private int skillId;
|
private int[] skillPoolId;
|
||||||
|
|
||||||
private int quality;
|
private int quality;
|
||||||
|
|
||||||
|
|
@ -66,7 +66,7 @@ public class SEquipConfig implements BaseConfig {
|
||||||
return propertyMax;
|
return propertyMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPool() {
|
public int[] getPool() {
|
||||||
return pool;
|
return pool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -78,8 +78,8 @@ public class SEquipConfig implements BaseConfig {
|
||||||
return secondNumMax;
|
return secondNumMax;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSkillId() {
|
public int[] getSkillPoolId() {
|
||||||
return skillId;
|
return skillPoolId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getIfClear() {
|
public int getIfClear() {
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,11 @@ public class SPassiveSkillLogicConfig implements BaseConfig {
|
||||||
|
|
||||||
private float[] value;
|
private float[] value;
|
||||||
|
|
||||||
private static Map<Integer, SPassiveSkillLogicConfig> config;
|
private int poolNum;
|
||||||
|
|
||||||
|
private int weight;
|
||||||
|
|
||||||
|
public static Map<Integer, SPassiveSkillLogicConfig> config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
|
|
@ -37,5 +41,11 @@ public class SPassiveSkillLogicConfig implements BaseConfig {
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getPoolNum() {
|
||||||
|
return poolNum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getWeight() {
|
||||||
|
return weight;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -10,9 +10,7 @@ import com.ljsd.jieling.util.TimeUtils;
|
||||||
import com.ljsd.jieling.util.UUIDEnum;
|
import com.ljsd.jieling.util.UUIDEnum;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class Equip extends MongoBase implements Cloneable{
|
public class Equip extends MongoBase implements Cloneable{
|
||||||
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Equip.class);
|
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Equip.class);
|
||||||
|
|
@ -35,6 +33,7 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
|
|
||||||
private int createTime;
|
private int createTime;
|
||||||
|
|
||||||
|
private int skill;
|
||||||
|
|
||||||
public Equip() {
|
public Equip() {
|
||||||
this.setRootCollection(User._COLLECTION_NAME);
|
this.setRootCollection(User._COLLECTION_NAME);
|
||||||
|
|
@ -65,6 +64,9 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
int secondValue = MathUtils.random(secondNumMin, secondNumMax);
|
int secondValue = MathUtils.random(secondNumMin, secondNumMax);
|
||||||
this.secondValueByIdMap = getSecondValue(sEquipConfig.getPool(), secondValue,promoteMap);
|
this.secondValueByIdMap = getSecondValue(sEquipConfig.getPool(), secondValue,promoteMap);
|
||||||
this.createTime = (int)(TimeUtils.now()/1000);
|
this.createTime = (int)(TimeUtils.now()/1000);
|
||||||
|
//skill库随机
|
||||||
|
this.skill = getRandomSkill(sEquipConfig.getSkillPoolId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//锻造
|
//锻造
|
||||||
|
|
@ -91,6 +93,7 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
this.propertyValueByIdMap.put(properTyId,finalProperValue);
|
this.propertyValueByIdMap.put(properTyId,finalProperValue);
|
||||||
setForRunnes(runneIds,promoteMap);
|
setForRunnes(runneIds,promoteMap);
|
||||||
this.createTime = (int)(TimeUtils.now()/1000);
|
this.createTime = (int)(TimeUtils.now()/1000);
|
||||||
|
this.skill = getRandomSkill(sEquipConfig.getSkillPoolId());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -150,9 +153,12 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<Integer,Integer> getSecondValue(int poolId,int nums,Map<Integer, Integer> promoteMap){
|
private Map<Integer,Integer> getSecondValue(int[] poolId,int nums,Map<Integer, Integer> promoteMap){
|
||||||
Map<Integer,Integer> result = new HashMap<>();
|
Map<Integer,Integer> result = new HashMap<>();
|
||||||
List<SEquipPropertyPool> sEquipPropertyPoolList = SEquipPropertyPool.getSEquipPropertyPool(poolId);
|
List<SEquipPropertyPool> sEquipPropertyPoolList = new ArrayList<>();
|
||||||
|
for(Integer pid:poolId){
|
||||||
|
sEquipPropertyPoolList.addAll(SEquipPropertyPool.getSEquipPropertyPool(pid));
|
||||||
|
}
|
||||||
if(sEquipPropertyPoolList.size()<nums){
|
if(sEquipPropertyPoolList.size()<nums){
|
||||||
LOGGER.error("the equip config is wrong,the equipTid={},the poolId={},the poolNum={},the requireNum={}",equipId,poolId,sEquipPropertyPoolList.size(),nums);
|
LOGGER.error("the equip config is wrong,the equipTid={},the poolId={},the poolNum={},the requireNum={}",equipId,poolId,sEquipPropertyPoolList.size(),nums);
|
||||||
return result;
|
return result;
|
||||||
|
|
@ -195,7 +201,25 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
private int getRandomSkill(int[] skills){
|
||||||
|
if(skills.length<0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
int poolId = MathUtils.randomFromArray(skills);
|
||||||
|
if(poolId==0){
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
Iterator<SPassiveSkillLogicConfig> it = SPassiveSkillLogicConfig.config.values().iterator();
|
||||||
|
List<int[]> skillData = new ArrayList<>();
|
||||||
|
while (it.hasNext()){
|
||||||
|
SPassiveSkillLogicConfig next = it.next();
|
||||||
|
if(next.getPoolNum()==poolId&&next.getWeight()!=0) {
|
||||||
|
skillData.add(new int[]{next.getId(), next.getWeight()});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int[][] skillWeight = skillData.toArray(new int[skillData.size()][2]);
|
||||||
|
return MathUtils.randomFromWeight(skillWeight);
|
||||||
|
}
|
||||||
public void rebuildEquip(int workShopLevle){
|
public void rebuildEquip(int workShopLevle){
|
||||||
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(this.equipId);
|
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(this.equipId);
|
||||||
int properTyId = sEquipConfig.getPropertyMin()[0];
|
int properTyId = sEquipConfig.getPropertyMin()[0];
|
||||||
|
|
@ -218,8 +242,10 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
int finalProperValue = MathUtils.random(properMinNum * (100 + propertyPromote) / 100, properMaxNum* (100 + propertyPromote) / 100);
|
int finalProperValue = MathUtils.random(properMinNum * (100 + propertyPromote) / 100, properMaxNum* (100 + propertyPromote) / 100);
|
||||||
this.propertyValueByIdMap.put(properTyId,finalProperValue);
|
this.propertyValueByIdMap.put(properTyId,finalProperValue);
|
||||||
}
|
}
|
||||||
|
List<SEquipPropertyPool> sEquipPropertyPoolList = new ArrayList<>();
|
||||||
List<SEquipPropertyPool> sEquipPropertyPoolList = SEquipPropertyPool.getSEquipPropertyPool(sEquipConfig.getPool());
|
for(Integer equipPool:sEquipConfig.getPool()){
|
||||||
|
sEquipPropertyPoolList.addAll(SEquipPropertyPool.getSEquipPropertyPool(equipPool));
|
||||||
|
}
|
||||||
for(SEquipPropertyPool sEquipPropertyPool : sEquipPropertyPoolList){
|
for(SEquipPropertyPool sEquipPropertyPool : sEquipPropertyPoolList){
|
||||||
int secondPropertyId = sEquipPropertyPool.getPropertyId();
|
int secondPropertyId = sEquipPropertyPool.getPropertyId();
|
||||||
if(!secondValueByIdMap.containsKey(secondPropertyId)){
|
if(!secondValueByIdMap.containsKey(secondPropertyId)){
|
||||||
|
|
@ -314,4 +340,9 @@ public class Equip extends MongoBase implements Cloneable{
|
||||||
public int getCreateTime() {
|
public int getCreateTime() {
|
||||||
return createTime;
|
return createTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public int getSkill() {
|
||||||
|
return skill;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -763,9 +763,7 @@ public class HeroLogic {
|
||||||
if(StringUtil.isEmpty(equipId)){
|
if(StringUtil.isEmpty(equipId)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int equipTid = equipMap.get(equipId).getEquipId();
|
int skillId = equipMap.get(equipId).getSkill();
|
||||||
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(equipTid);
|
|
||||||
int skillId = sEquipConfig.getSkillId();
|
|
||||||
if(skillId!=0){
|
if(skillId!=0){
|
||||||
sb.append(skillId).append(DIVISION);
|
sb.append(skillId).append(DIVISION);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -109,6 +109,7 @@ public class CBean2Proto {
|
||||||
.addAllSecondAttribute(parseFromMap(secondValueByIdMap))
|
.addAllSecondAttribute(parseFromMap(secondValueByIdMap))
|
||||||
.setRebuildLevel(equip.getRebuildLevel())
|
.setRebuildLevel(equip.getRebuildLevel())
|
||||||
.setCreateTime(equip.getCreateTime())
|
.setCreateTime(equip.getCreateTime())
|
||||||
|
.setSkillId(equip.getSkill())
|
||||||
.build();
|
.build();
|
||||||
return equipProto;
|
return equipProto;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@ public class MathUtils {
|
||||||
|
|
||||||
public static void main(String [] args){
|
public static void main(String [] args){
|
||||||
for (int i = 0 ; i <100;i++){
|
for (int i = 0 ; i <100;i++){
|
||||||
System.out.println(randomInt(100));
|
System.out.println(randomInt(10));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public static int randomForStrArray(String [] rateArray) {
|
public static int randomForStrArray(String [] rateArray) {
|
||||||
|
|
@ -168,5 +168,11 @@ public class MathUtils {
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
public static int randomFromArray(int[] array){
|
||||||
|
if(array.length>1){
|
||||||
|
return array[randomInt(array.length-1)];
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue