抽卡逻辑修改
parent
7c0e200d18
commit
06ba20787b
|
@ -15,7 +15,9 @@ public class HeroManager extends MongoBase {
|
||||||
|
|
||||||
Map<Integer, Integer> totalCount;
|
Map<Integer, Integer> totalCount;
|
||||||
|
|
||||||
Map<Integer, Integer> randomPoolByType;
|
private Map<Integer, Map<Integer, Integer>> randomPoolByType;
|
||||||
|
|
||||||
|
private Map<Integer,Integer> mustRandomCount;
|
||||||
|
|
||||||
Map<Integer,Integer> heroHandBook;
|
Map<Integer,Integer> heroHandBook;
|
||||||
|
|
||||||
|
@ -27,6 +29,7 @@ public class HeroManager extends MongoBase {
|
||||||
totalCount = new HashMap();
|
totalCount = new HashMap();
|
||||||
heroHandBook = new HashMap<>();
|
heroHandBook = new HashMap<>();
|
||||||
randomPoolByType = new HashMap<>();
|
randomPoolByType = new HashMap<>();
|
||||||
|
mustRandomCount = new HashMap<>();
|
||||||
this.setRootCollection(User._COLLECTION_NAME);
|
this.setRootCollection(User._COLLECTION_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,9 +38,15 @@ public class HeroManager extends MongoBase {
|
||||||
totalCount.put(type,count);
|
totalCount.put(type,count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateRandPoolTypeCount(int mergePool,int count){
|
public void updateRandPoolTypeCount(int type,int profession,int count){
|
||||||
updateString("randomPoolByType." + mergePool, count);
|
updateString("randomPoolByType." + type+"."+profession, count);
|
||||||
randomPoolByType.put(mergePool,count);
|
randomPoolByType.get(type).put(profession,count);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateRandomPoolByType(int type,Map<Integer,Integer> map){
|
||||||
|
randomPoolByType.put(type,map);
|
||||||
|
updateString("randomPoolByType." + type, map);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, Hero> getItemMap() {
|
public Map<String, Hero> getItemMap() {
|
||||||
|
@ -104,7 +113,16 @@ public class HeroManager extends MongoBase {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, Integer> getRandomPoolByType() {
|
public Map<Integer, Map<Integer, Integer>> getRandomPoolByType() {
|
||||||
return randomPoolByType;
|
return randomPoolByType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Map<Integer, Integer> getMustRandomCount() {
|
||||||
|
return mustRandomCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMustRandomCount(Map<Integer, Integer> mustRandomCount) {
|
||||||
|
this.mustRandomCount = mustRandomCount;
|
||||||
|
updateString("mustRandomCount",mustRandomCount);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,8 +5,6 @@ import com.ljsd.jieling.chat.logic.ChatLogic;
|
||||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||||
import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig;
|
import com.ljsd.jieling.config.clazzStaticCfg.HeroStaticConfig;
|
||||||
import com.ljsd.jieling.core.GlobalsDef;
|
import com.ljsd.jieling.core.GlobalsDef;
|
||||||
import com.ljsd.jieling.core.SimpleTransaction;
|
|
||||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
|
||||||
import com.ljsd.jieling.db.redis.RedisKey;
|
import com.ljsd.jieling.db.redis.RedisKey;
|
||||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||||
import com.ljsd.jieling.exception.ErrorCode;
|
import com.ljsd.jieling.exception.ErrorCode;
|
||||||
|
@ -45,6 +43,7 @@ import java.math.BigDecimal;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class HeroLogic{
|
public class HeroLogic{
|
||||||
|
@ -248,81 +247,158 @@ public class HeroLogic{
|
||||||
// else{
|
// else{
|
||||||
// user.getPlayerInfoManager().updateVipPrivilage(privilege, 1);
|
// user.getPlayerInfoManager().updateVipPrivilage(privilege, 1);
|
||||||
// }
|
// }
|
||||||
//额外获取
|
int[][] tenTimesMustGetItem = new int[perCount][];
|
||||||
int length = perCount;
|
for(int i = 0 ;i<perCount;i++){
|
||||||
int[][] tenTimesMustGetItem = null;
|
tenTimesMustGetItem[i] = new int[]{randomOne(user,type),1};
|
||||||
if(sLotterySetting.getTenTimesMustGetItem()!=null &&sLotterySetting.getTenTimesMustGetItem().length>0){
|
|
||||||
tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem();
|
|
||||||
length+=tenTimesMustGetItem.length;
|
|
||||||
}
|
}
|
||||||
int[][] dropHeroAndItem = new int[length][];
|
// if(sLotterySetting.getTenTimesMustGetItem()!=null &&sLotterySetting.getTenTimesMustGetItem().length>0){
|
||||||
int randCount = 0;
|
// tenTimesMustGetItem = sLotterySetting.getTenTimesMustGetItem();
|
||||||
int poolCount = 0;
|
// length+=tenTimesMustGetItem.length;
|
||||||
Map<Integer, Integer> totalCountMap = heroManager.getTotalCount();
|
// }
|
||||||
Map<Integer, Integer> randomPoolByType = heroManager.getRandomPoolByType();
|
// int[][] dropHeroAndItem = new int[length][];
|
||||||
if (totalCountMap.containsKey(type)) {
|
// int randCount = 0;
|
||||||
randCount = totalCountMap.get(type);
|
// int poolCount = 0;
|
||||||
}
|
// Map<Integer, Integer> totalCountMap = heroManager.getTotalCount();
|
||||||
if (randomPoolByType.containsKey(sLotterySetting.getMergePool())) {
|
// Map<Integer, Integer> randomPoolByType = heroManager.getRandomPoolByType();
|
||||||
poolCount = randomPoolByType.get(sLotterySetting.getMergePool());
|
// if (totalCountMap.containsKey(type)) {
|
||||||
}
|
// randCount = totalCountMap.get(type);
|
||||||
int totalCount = 0;
|
// }
|
||||||
for(Integer count : totalCountMap.values()){
|
// if (randomPoolByType.containsKey(sLotterySetting.getMergePool())) {
|
||||||
totalCount+=count;
|
// poolCount = randomPoolByType.get(sLotterySetting.getMergePool());
|
||||||
}
|
// }
|
||||||
|
// int totalCount = 0;
|
||||||
int j=0;
|
// for(Integer count : totalCountMap.values()){
|
||||||
// //标记是否触发保底
|
// totalCount+=count;
|
||||||
// boolean specialTrigger=false;
|
// }
|
||||||
for(int i=0;i<perCount;i++){
|
//
|
||||||
randCount++;
|
// int j=0;
|
||||||
poolCount++;
|
//// //标记是否触发保底
|
||||||
int randomPoolId = pooId;
|
//// boolean specialTrigger=false;
|
||||||
int specialPoolId = getSpecialPoolByRandcount(sLotterySetting, randCount,poolCount);
|
// for(int i=0;i<perCount;i++){
|
||||||
if(specialPoolId == 0){
|
// randCount++;
|
||||||
if(randomPoolId==0){
|
// poolCount++;
|
||||||
randomPoolId = getPooId(sLotterySetting);
|
// int randomPoolId = pooId;
|
||||||
}
|
// int specialPoolId = getSpecialPoolByRandcount(sLotterySetting, randCount,poolCount);
|
||||||
}else{
|
// if(specialPoolId == 0){
|
||||||
randomPoolId =specialPoolId;
|
// if(randomPoolId==0){
|
||||||
}
|
// randomPoolId = getPooId(sLotterySetting);
|
||||||
totalCount++;
|
// }
|
||||||
SLotteryRewardConfig sLotteryRewardConfig = randomHeroByPoolId(randomPoolId, totalCount, user.getPlayerInfoManager().getLevel());
|
// }else{
|
||||||
LOGGER.info("the uid={},the type={},the poolId={},reward={},poolCount={}",uid,type,randomPoolId,sLotteryRewardConfig.getId(),poolCount);
|
// randomPoolId =specialPoolId;
|
||||||
if(sLotteryRewardConfig.getStar() == 1){
|
// }
|
||||||
poolCount=0;
|
// totalCount++;
|
||||||
}
|
// SLotteryRewardConfig sLotteryRewardConfig = randomHeroByPoolId(randomPoolId, totalCount, user.getPlayerInfoManager().getLevel());
|
||||||
int[] reward =sLotteryRewardConfig.getReward();
|
// LOGGER.info("the uid={},the type={},the poolId={},reward={},poolCount={}",uid,type,randomPoolId,sLotteryRewardConfig.getId(),poolCount);
|
||||||
if(reward!=null){
|
// if(sLotteryRewardConfig.getStar() == 1){
|
||||||
dropHeroAndItem[j++] = reward;
|
// poolCount=0;
|
||||||
}
|
// }
|
||||||
}
|
// int[] reward =sLotteryRewardConfig.getReward();
|
||||||
heroManager.updateRandPoolTypeCount(sLotterySetting.getMergePool(),poolCount);
|
// if(reward!=null){
|
||||||
|
// dropHeroAndItem[j++] = reward;
|
||||||
//1群英招募
|
// }
|
||||||
|
// }
|
||||||
|
// heroManager.updateRandPoolTypeCount(sLotterySetting.getMergePool(),poolCount);
|
||||||
|
//
|
||||||
|
// //1群英招募
|
||||||
HeroInfoProto.HeroRandResponse.Builder builder = HeroInfoProto.HeroRandResponse.newBuilder();
|
HeroInfoProto.HeroRandResponse.Builder builder = HeroInfoProto.HeroRandResponse.newBuilder();
|
||||||
if(sLotterySetting.getLotteryType() == 1){
|
// if(sLotterySetting.getLotteryType() == 1){
|
||||||
Poster.getPoster().dispatchEvent(new HeroRandomEvent(uid,perCount));
|
// Poster.getPoster().dispatchEvent(new HeroRandomEvent(uid,perCount));
|
||||||
}
|
// }
|
||||||
user.getUserMissionManager().onGameEvent(user,GameEvent.RANDOM_HERO,sLotterySetting.getLotteryType(),perCount);
|
// user.getUserMissionManager().onGameEvent(user,GameEvent.RANDOM_HERO,sLotterySetting.getLotteryType(),perCount);
|
||||||
heroManager.updateRandCount(type,randCount);
|
// heroManager.updateRandCount(type,randCount);
|
||||||
if(tenTimesMustGetItem!=null){
|
// if(tenTimesMustGetItem!=null){
|
||||||
for(int i=0;i<tenTimesMustGetItem.length;i++){
|
// for(int i=0;i<tenTimesMustGetItem.length;i++){
|
||||||
dropHeroAndItem[j++] = tenTimesMustGetItem[i];
|
// dropHeroAndItem[j++] = tenTimesMustGetItem[i];
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
Poster.getPoster().dispatchEvent(new RandomCardEvent(uid,sLotterySetting.getLotteryType(),SSpecialConfig.getIntegerValue(SSpecialConfig.TIME_LIMIT_RECRUITMENT_INTEGRAL)*sLotterySetting.getPerCount(),dropHeroAndItem));
|
// Poster.getPoster().dispatchEvent(new RandomCardEvent(uid,sLotterySetting.getLotteryType(),SSpecialConfig.getIntegerValue(SSpecialConfig.TIME_LIMIT_RECRUITMENT_INTEGRAL)*sLotterySetting.getPerCount(),dropHeroAndItem));
|
||||||
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, dropHeroAndItem,BIReason.HERO_RANDOM);
|
CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, tenTimesMustGetItem,BIReason.HERO_RANDOM);
|
||||||
builder.setDrop(drop);
|
builder.setDrop(drop);
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
|
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
|
||||||
}
|
}
|
||||||
|
private int randomOne(User user,int type) throws Exception {
|
||||||
|
SLotterySetting sLotterySetting = STableManager.getConfig(SLotterySetting.class).get(type);
|
||||||
|
int mergePool = sLotterySetting.getMergePool();
|
||||||
|
List<SLotterySpecialConfig> specialConfigs = SLotterySpecialConfig.getLotterySpecialConfigListByType(mergePool);
|
||||||
|
HeroManager heroManager = user.getHeroManager();
|
||||||
|
//设置必出计数器
|
||||||
|
if(specialConfigs!=null&&!specialConfigs.isEmpty()){
|
||||||
|
for(SLotterySpecialConfig config:specialConfigs){
|
||||||
|
if(!heroManager.getRandomPoolByType().containsKey(mergePool)){
|
||||||
|
Map<Integer,Integer> map = new HashMap<>();
|
||||||
|
map.put(config.getDifferentType(),0);
|
||||||
|
heroManager.getRandomPoolByType().put(mergePool,new HashMap<>());
|
||||||
|
}
|
||||||
|
// heroManager.getRandomPoolByType().computeIfAbsent(mergePool,n->new HashMap<>()).put(config.getId(),0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Map<Integer, Integer> countMap = heroManager.getRandomPoolByType().get(mergePool);
|
||||||
|
Set<Integer> mustSet = new HashSet<>();
|
||||||
|
//次数计算
|
||||||
|
for(Map.Entry<Integer,Integer> countEntry:countMap.entrySet()){
|
||||||
|
SLotterySpecialConfig config = null;
|
||||||
|
if(specialConfigs==null||specialConfigs.isEmpty()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for(SLotterySpecialConfig everyConfig:specialConfigs){
|
||||||
|
if(everyConfig.getDifferentType()!=countEntry.getKey()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
config = everyConfig;
|
||||||
|
}
|
||||||
|
if(config==null){
|
||||||
|
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||||
|
}
|
||||||
|
if(countEntry.getValue()+1<config.getCount()){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
Map<Integer, Integer> mustRandomCount = heroManager.getMustRandomCount();
|
||||||
|
if(mustRandomCount.containsKey(countEntry.getKey())) {
|
||||||
|
if(mustRandomCount.get(countEntry.getKey())>=config.getMin_num()) {
|
||||||
|
continue;
|
||||||
|
}else{
|
||||||
|
mustRandomCount.put(countEntry.getKey(), mustRandomCount.get(countEntry.getKey())+1);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
mustRandomCount.put(countEntry.getKey(),1);
|
||||||
|
}
|
||||||
|
heroManager.setMustRandomCount(mustRandomCount);
|
||||||
|
mustSet.add(countEntry.getKey());
|
||||||
|
}
|
||||||
|
|
||||||
|
SLotteryRewardConfig sLotteryRewardConfig;
|
||||||
|
//是否有必出
|
||||||
|
if(mustSet.isEmpty()){
|
||||||
|
sLotteryRewardConfig = randomHeroByPoolId(getPooId(sLotterySetting), 1, user.getPlayerInfoManager().getLevel());
|
||||||
|
int star = sLotteryRewardConfig.getStar();
|
||||||
|
for(int key:countMap.keySet()){
|
||||||
|
if(star==key){
|
||||||
|
countMap.put(key,0);
|
||||||
|
}else{
|
||||||
|
countMap.put(key,countMap.get(key)+1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
int maxId = 0;
|
||||||
|
for(int mustId:mustSet){
|
||||||
|
maxId = mustId;
|
||||||
|
}
|
||||||
|
|
||||||
|
sLotteryRewardConfig = randomHeroByPoolId(STableManager.getConfig(SLotterySpecialConfig.class).get(maxId).getpool_id(), 1, user.getPlayerInfoManager().getLevel());
|
||||||
|
countMap.put(maxId,0);
|
||||||
|
}
|
||||||
|
heroManager.updateRandomPoolByType(mergePool,countMap);
|
||||||
|
int result = sLotteryRewardConfig.getReward()[0];
|
||||||
|
System.out.print(result+"、");
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
private int getSpecialPoolByRandcount(SLotterySetting sLotterySetting, int randCount,int poolCount) {
|
private int getSpecialPoolByRandcount(SLotterySetting sLotterySetting, int randCount,int poolCount) {
|
||||||
int id = sLotterySetting.getId();
|
int id = sLotterySetting.getId();
|
||||||
List<SLotterySpecialConfig> list = SLotterySpecialConfig.getLotterySpecialConfigListByType(1,id);
|
List<SLotterySpecialConfig> list = SLotterySpecialConfig.getLotterySpecialConfigListByType(id);
|
||||||
|
|
||||||
if (list == null) {
|
if (list == null) {
|
||||||
list = SLotterySpecialConfig.getLotterySpecialConfigListByType(2,sLotterySetting.getMergePool());
|
list = SLotterySpecialConfig.getLotterySpecialConfigListByType(sLotterySetting.getMergePool());
|
||||||
if(list == null){
|
if(list == null){
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,32 +26,33 @@ public class SLotterySpecialConfig implements BaseConfig {
|
||||||
private int pool_id;
|
private int pool_id;
|
||||||
|
|
||||||
|
|
||||||
private static Map<Integer, Map<Integer,List<SLotterySpecialConfig>>> lotterySpecialConfigMap;
|
private static Map<Integer, List<SLotterySpecialConfig>> lotterySpecialConfigMap;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init() throws Exception {
|
public void init() throws Exception {
|
||||||
Map<Integer, SLotterySpecialConfig> config = STableManager.getConfig(SLotterySpecialConfig.class);
|
Map<Integer, SLotterySpecialConfig> config = STableManager.getConfig(SLotterySpecialConfig.class);
|
||||||
Map<Integer, Map<Integer,List<SLotterySpecialConfig>>> lotterySpecialConfigMapTmp = new HashMap<>();
|
Map<Integer, List<SLotterySpecialConfig>> lotterySpecialConfigMapTmp = new HashMap<>();
|
||||||
for(SLotterySpecialConfig sLotterySpecialConfig : config.values()){
|
for(SLotterySpecialConfig sLotterySpecialConfig : config.values()){
|
||||||
int differentType = sLotterySpecialConfig.getDifferentType();
|
// int differentType = sLotterySpecialConfig.getDifferentType();
|
||||||
if(!lotterySpecialConfigMapTmp.containsKey(differentType)){
|
// if(!lotterySpecialConfigMapTmp.containsKey(differentType)){
|
||||||
lotterySpecialConfigMapTmp.put(differentType,new HashMap<>());
|
// lotterySpecialConfigMapTmp.put(differentType,new HashMap<>());
|
||||||
}
|
// }
|
||||||
int type = sLotterySpecialConfig.getType();
|
// int type = sLotterySpecialConfig.getType();
|
||||||
if(!lotterySpecialConfigMapTmp.get(differentType).containsKey(type)){
|
// if(!lotterySpecialConfigMapTmp.get(differentType).containsKey(type)){
|
||||||
lotterySpecialConfigMapTmp.get(differentType).put(type,new ArrayList<>());
|
// lotterySpecialConfigMapTmp.get(differentType).put(type,new ArrayList<>());
|
||||||
}
|
// }
|
||||||
lotterySpecialConfigMapTmp.get(differentType).get(type).add(sLotterySpecialConfig);
|
// lotterySpecialConfigMapTmp.get(differentType).get(type).add(sLotterySpecialConfig);
|
||||||
|
lotterySpecialConfigMapTmp.computeIfAbsent(sLotterySpecialConfig.getType(),n->new ArrayList<>()).add(sLotterySpecialConfig);
|
||||||
}
|
}
|
||||||
lotterySpecialConfigMap = lotterySpecialConfigMapTmp;
|
lotterySpecialConfigMap = lotterySpecialConfigMapTmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<SLotterySpecialConfig> getLotterySpecialConfigListByType(int differentType,int type) {
|
public static List<SLotterySpecialConfig> getLotterySpecialConfigListByType(int type) {
|
||||||
if(!lotterySpecialConfigMap.containsKey(differentType)){
|
if(!lotterySpecialConfigMap.containsKey(type)){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return lotterySpecialConfigMap.get(differentType).get(type);
|
return lotterySpecialConfigMap.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
|
|
Loading…
Reference in New Issue