奖励优化
parent
550ce57411
commit
91593f8fa0
|
@ -24,6 +24,7 @@ import com.ljsd.jieling.util.ItemUtil;
|
|||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SExpeditionFloorConfig;
|
||||
import config.SExpeditionHolyConfig;
|
||||
import config.SExpeditionNodeConfig;
|
||||
import config.SExpeditionSetting;
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
@ -195,11 +196,11 @@ public class EndExpeditionBattleRequest extends BaseHandler<Expedition.EndExpedi
|
|||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.EXPEDITION_NOINFO_INDICATION_VALUE, builder.build(), true);
|
||||
|
||||
//drop
|
||||
SExpeditionFloorConfig sExpeditionFloorConfig = STableManager.getConfig(SExpeditionFloorConfig.class).get(oldlay);
|
||||
if (sExpeditionFloorConfig == null) {
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(nodeInfo.getType());
|
||||
if (sExpeditionNodeConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sExpeditionFloorConfig.getReward(),1,0,BIReason.EXPEDITION_DROP_REWARD);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sExpeditionNodeConfig.getreward(),1,0,BIReason.EXPEDITION_DROP_REWARD);
|
||||
Expedition.EndExpeditionBattleResponse.Builder response = Expedition.EndExpeditionBattleResponse.newBuilder();
|
||||
response.setResult(resultCode);
|
||||
response.setDrop(drop);
|
||||
|
|
|
@ -40,7 +40,7 @@ public class HotfixUtil implements IEventHandler {
|
|||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
doWork(SysUtil.getPath("../conf/hotfix.json"));
|
||||
doWork(SysUtil.getPath("conf/hotfix.json"));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -356,9 +356,15 @@ public class ExpeditionLogic {
|
|||
// }
|
||||
|
||||
|
||||
|
||||
Set<Integer> staffsSet = new HashSet<>();
|
||||
while (staffsSet.size()<3){
|
||||
int[][] holyProbability = cfg.getHolyProbability();
|
||||
SExpeditionNodeConfig sExpeditionNodeConfig = STableManager.getConfig(SExpeditionNodeConfig.class).get(type);
|
||||
if(null!=sExpeditionNodeConfig && sExpeditionNodeConfig.getHolyProbability().length==3){
|
||||
for (int j = 0; j <holyProbability.length ; j++) {
|
||||
holyProbability[j][1]+= sExpeditionNodeConfig.getHolyProbability()[j][1];
|
||||
}
|
||||
}
|
||||
int ints = MathUtils.randomFromWeight(cfg.getHolyProbability());
|
||||
Map<Integer, Integer> type2holy2weight = STableManager.getFigureConfig(CommonStaticConfig.class).getType2holy2weight(ints);
|
||||
int i1 = ranndomFromWeight(type2holy2weight);
|
||||
|
|
|
@ -45,6 +45,7 @@ import java.util.stream.Collectors;
|
|||
|
||||
public class ItemUtil {
|
||||
private static Map<Integer,String> dropRewardMap = new ConcurrentHashMap<>();
|
||||
private static Set<Integer> dropAddition = new HashSet<>();//掉落权重加成id
|
||||
public static Map<Integer,String> equipQulityNameMap = new HashMap<>(2);
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ItemUtil.class);
|
||||
|
||||
|
@ -170,14 +171,14 @@ public class ItemUtil {
|
|||
if (sRewardGroup == null) {
|
||||
continue;
|
||||
}
|
||||
selectDrop(sRewardGroup, itemMap, cardMap, equipMap, randomMap, dropRatio);
|
||||
selectDrop(user,sRewardGroup, itemMap, cardMap, equipMap, randomMap, dropRatio);
|
||||
int[] extraDropGroupIds = activityExtraDropGroupId(user, dropGroupId);
|
||||
for (int dropExtraGroupId : extraDropGroupIds) {
|
||||
SRewardGroup sRewardGroupExtra = SRewardGroup.getsRewardItemMap().get(dropExtraGroupId);
|
||||
if (sRewardGroupExtra == null) {
|
||||
continue;
|
||||
}
|
||||
selectDrop(sRewardGroupExtra, itemMap, cardMap, equipMap, randomMap, dropRatio);
|
||||
selectDrop(user,sRewardGroupExtra, itemMap, cardMap, equipMap, randomMap, dropRatio);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -353,20 +354,41 @@ public class ItemUtil {
|
|||
getMap(items.getKey(), items.getValue(), itemMap, cardMap,equipMap,randomMap,1);
|
||||
}
|
||||
}
|
||||
private static void selectDrop(SRewardGroup sRewardGroup,Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap,Map<Integer,Integer> equipMap,Map<Integer,Integer> randomMap , float dropRatio) {
|
||||
private static void selectDrop(User user, SRewardGroup sRewardGroup,Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap,Map<Integer,Integer> equipMap,Map<Integer,Integer> randomMap , float dropRatio) {
|
||||
String dropInfo = dropRewardMap.get(sRewardGroup.getId());
|
||||
String rewardStr = dropInfo.split("\\|")[0];
|
||||
String weight = dropInfo.split("\\|")[1];
|
||||
String[] rewards= rewardStr.split("#");
|
||||
String[] weights= rewardStr.split("#");
|
||||
for (int i = 0; i < rewards.length; i++) {
|
||||
int rewardId = Integer.valueOf(rewards[i]);
|
||||
if (dropAddition.contains(rewardId)) {
|
||||
int dropWeight = Integer.valueOf(weights[i]);
|
||||
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(rewardId);
|
||||
//权重加成 1等级权重加成
|
||||
int[] chanceAddition = sRewardItem.getChanceAddition();
|
||||
if(chanceAddition.length==3){
|
||||
int part= chanceAddition[1];
|
||||
int sumWeight= chanceAddition[2];
|
||||
if(chanceAddition[0]==1){//等级
|
||||
dropWeight = dropWeight+sumWeight*(user.getPlayerInfoManager().getLevel()/ part);
|
||||
}
|
||||
//扩展其他权重
|
||||
}
|
||||
weights[i] =String.valueOf(dropWeight);
|
||||
}
|
||||
}
|
||||
|
||||
switch (sRewardGroup.getIsUpset()) {
|
||||
case GlobalItemType.ALL_DROP:
|
||||
getMap(StringUtil.parseFiledInt(rewardStr),itemMap,cardMap,equipMap,randomMap,dropRatio);
|
||||
getMap(user,StringUtil.parseFiledInt(rewardStr),itemMap,cardMap,equipMap,randomMap,dropRatio);
|
||||
break;
|
||||
case GlobalItemType.WEIGHT_DROP:
|
||||
getRandomMap(sRewardGroup.getRewardMaxNum(),rewardStr.split("#"),weight.split("#"),
|
||||
getRandomMap(user,sRewardGroup.getRewardMaxNum(),rewards,weights,
|
||||
itemMap,cardMap,equipMap,randomMap,dropRatio);
|
||||
break;
|
||||
case GlobalItemType.SUCCESSIVELY_RANDOM:
|
||||
getSuccessivelyRandmoMap(sRewardGroup,rewardStr.split("#"),weight.split("#"),
|
||||
getSuccessivelyRandmoMap(user,sRewardGroup,rewards,weights,
|
||||
itemMap,cardMap,equipMap,randomMap,dropRatio);
|
||||
break;
|
||||
default:
|
||||
|
@ -374,7 +396,7 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static void getSuccessivelyRandmoMap(SRewardGroup sRewardGroup, String[]
|
||||
private static void getSuccessivelyRandmoMap(User user,SRewardGroup sRewardGroup, String[]
|
||||
rewardArr, String[] weightArr, Map<Integer, Integer> itemMap, Map<Integer, Integer>
|
||||
cardMap, Map<Integer,Integer> equipMap, Map<Integer,Integer> randomMap, float dropRatio) {
|
||||
for (int i = 0 ; i < sRewardGroup.getRewardMaxNum();i++){
|
||||
|
@ -391,7 +413,7 @@ public class ItemUtil {
|
|||
id = Integer.parseInt(rewardArr[index]);
|
||||
}
|
||||
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id);
|
||||
int itemNum = getItemNum(sRewardItem);
|
||||
int itemNum = getItemNum(user,sRewardItem);
|
||||
if (itemNum <= 0){
|
||||
continue;
|
||||
}
|
||||
|
@ -399,7 +421,7 @@ public class ItemUtil {
|
|||
}
|
||||
}
|
||||
|
||||
private static void getRandomMap(int randomItemNum ,String[] rewardArr,String[] weightArr, Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap,
|
||||
private static void getRandomMap(User user,int randomItemNum ,String[] rewardArr,String[] weightArr, Map<Integer, Integer> itemMap, Map<Integer, Integer> cardMap,
|
||||
Map<Integer,Integer> equipMap,Map<Integer,Integer> randomMap ,float dropRatio) {
|
||||
for (int i = 0 ; i < randomItemNum;i++){
|
||||
int index = MathUtils.randomForStrArray(weightArr);
|
||||
|
@ -408,7 +430,7 @@ public class ItemUtil {
|
|||
}
|
||||
int id = Integer.parseInt(rewardArr[index]);
|
||||
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id);
|
||||
int itemNum = getItemNum(sRewardItem);
|
||||
int itemNum = getItemNum(user,sRewardItem);
|
||||
if (itemNum <= 0){
|
||||
continue;
|
||||
}
|
||||
|
@ -421,17 +443,34 @@ public class ItemUtil {
|
|||
* @param sRewardItem
|
||||
* @return
|
||||
*/
|
||||
private static int getItemNum(SRewardItem sRewardItem) {
|
||||
private static int getItemNum(User user,SRewardItem sRewardItem) {
|
||||
int itemNum ;
|
||||
if (sRewardItem.getRandomMin() == sRewardItem.getRandomMax()) {
|
||||
return sRewardItem.getRandomMin();
|
||||
itemNum = sRewardItem.getRandomMin();
|
||||
}else {
|
||||
itemNum = MathUtils.numRount(MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()) * sRewardItem.getGrowChance());
|
||||
}
|
||||
return MathUtils.numRount(MathUtils.random(sRewardItem.getRandomMin(), sRewardItem.getRandomMax()) * sRewardItem.getGrowChance());
|
||||
|
||||
//权重加成 1等级权重加成
|
||||
int[] addition = sRewardItem.getAddition();
|
||||
if(addition.length==2){
|
||||
int weight= addition[1];
|
||||
if(addition[0]==1){
|
||||
itemNum = itemNum+(int)(itemNum*((float)user.getPlayerInfoManager().getLevel()/(float) weight));
|
||||
}
|
||||
//扩展其他权重
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return itemNum;
|
||||
}
|
||||
|
||||
private static void getMap(int[] itemInfo, Map<Integer, Integer> itemMap,Map<Integer, Integer> cardMap,Map<Integer,Integer> equipMap,Map<Integer,Integer> randomMap ,float dropRatio) {
|
||||
private static void getMap(User user,int[] itemInfo, Map<Integer, Integer> itemMap,Map<Integer, Integer> cardMap,Map<Integer,Integer> equipMap,Map<Integer,Integer> randomMap ,float dropRatio) {
|
||||
for (int id :itemInfo){
|
||||
SRewardItem sRewardItem = SRewardItem.getsDropMap().get(id);
|
||||
int itemNum = getItemNum(sRewardItem);
|
||||
int itemNum = getItemNum(user,sRewardItem);
|
||||
if (itemNum <= 0){
|
||||
continue;
|
||||
}
|
||||
|
@ -1396,6 +1435,9 @@ public class ItemUtil {
|
|||
if (sRewardItem == null){
|
||||
continue;
|
||||
}
|
||||
if(sRewardItem.getChanceAddition().length!=0){
|
||||
dropAddition.add(dropId);
|
||||
}
|
||||
if (rewardStr.length() == 0){
|
||||
rewardStr = new StringBuilder(String.valueOf(sRewardItem.getId()));
|
||||
}else{
|
||||
|
@ -1406,8 +1448,8 @@ public class ItemUtil {
|
|||
}else{
|
||||
weight.append("#").append(sRewardItem.getChance());
|
||||
}
|
||||
dropMap.put(sRewardGroup.getId(),rewardStr +"|"+weight);
|
||||
}
|
||||
dropMap.put(sRewardGroup.getId(),rewardStr +"|"+weight);
|
||||
}
|
||||
dropRewardMap = dropMap;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ExpeditionNodeConfig")
|
||||
public class SExpeditionNodeConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int type;
|
||||
|
||||
private int[] reward;
|
||||
|
||||
private int[][] holyProbability;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int gettype() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public int[] getreward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int[][] getHolyProbability() {
|
||||
return holyProbability;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue