From db8aeac335ad356dd480a8fbe616dc2874f581a4 Mon Sep 17 00:00:00 2001 From: wangyuan Date: Fri, 22 Nov 2019 16:39:54 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E7=B4=A0=E6=8B=9B=E5=8B=9F=20&=20?= =?UTF-8?q?=E6=96=B0=E6=B4=BB=E5=8A=A8=EF=BC=88=E6=96=B0=E6=89=8B=E7=A6=8F?= =?UTF-8?q?=E5=88=A9=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../clazzStaticCfg/HeroStaticConfig.java | 8 ++ .../ljsd/jieling/handler/map/MapLogic.java | 5 +- .../jieling/logic/activity/ActivityLogic.java | 4 + .../jieling/logic/activity/ActivityType.java | 2 + .../logic/activity/ActivityTypeEnum.java | 2 + .../logic/activity/NewWelfareActivity.java | 110 ++++++++++++++++++ .../logic/activity/event/NewWelfareEvent.java | 25 ++++ .../activity/event/NewWelfareTypeEnum.java | 17 +++ .../ljsd/jieling/logic/dao/HeroManager.java | 12 ++ .../ljsd/jieling/logic/hero/HeroLogic.java | 35 +++++- .../jieling/logic/store/BuyGoodsLogic.java | 5 + .../java/config/SLotteryRewardConfig.java | 6 + .../src/main/java/config/SLotterySetting.java | 6 + .../java/config/SLotterySpecialConfig.java | 7 +- 14 files changed, 235 insertions(+), 9 deletions(-) create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/NewWelfareActivity.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareEvent.java create mode 100644 serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareTypeEnum.java diff --git a/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/HeroStaticConfig.java b/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/HeroStaticConfig.java index 5cc7699af..56242b6b7 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/HeroStaticConfig.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/config/clazzStaticCfg/HeroStaticConfig.java @@ -20,6 +20,7 @@ public class HeroStaticConfig extends AbstractClassStaticConfig { private Map>> scHeroRankUpConfigByType; private Set randomHeroIds; + private Map randomPoolByType; @Override public void registConfigs(Set registConfigs) { @@ -75,12 +76,15 @@ public class HeroStaticConfig extends AbstractClassStaticConfig { try { Set randomHeroIdTmp = new HashSet<>(); Map config = STableManager.getConfig(SLotterySetting.class); + Map randomPoolByType = new HashMap<>(); for(SLotterySetting sLotterySetting : config.values()){ if(sLotterySetting.getLotteryType() == GlobalsDef.RANDOM_LOTTERY_TYPE){ randomHeroIdTmp.add(sLotterySetting.getId()); } + randomPoolByType.put(sLotterySetting.getId(),sLotterySetting.getMergePool()); } randomHeroIds = randomHeroIdTmp; + randomPoolByType = randomPoolByType; } catch (Exception e) { LOGGER.error("SLotterySetting init fail"); } @@ -97,4 +101,8 @@ public class HeroStaticConfig extends AbstractClassStaticConfig { public Set getRandomHeroIds() { return randomHeroIds; } + + public Map getRandomPoolByType() { + return randomPoolByType; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java index b51caf74a..0a12bc58d 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/MapLogic.java @@ -21,9 +21,7 @@ import com.ljsd.jieling.ktbeans.KtEventUtils; import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean; import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.OnlineUserManager; -import com.ljsd.jieling.logic.activity.event.FightMainEvent; -import com.ljsd.jieling.logic.activity.event.Poster; -import com.ljsd.jieling.logic.activity.event.StoryEvent; +import com.ljsd.jieling.logic.activity.event.*; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.fight.CheckFight; @@ -2248,6 +2246,7 @@ public class MapLogic { state =2; } Poster.getPoster().dispatchEvent(new FightMainEvent(user.getId(),fightId)); + Poster.getPoster().dispatchEvent(new NewWelfareEvent(user.getId(), NewWelfareTypeEnum.LEVEL_FIGHT.getType(),fightId)); user.getMainLevelManager().updateFight(updateFightId,state); if(state == -1){ //删除为0的 diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java index 84d100a94..68777bdfc 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityLogic.java @@ -10,6 +10,9 @@ import com.ljsd.jieling.exception.ErrorCodeException; import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.handler.activity.BlessInfoConfig; import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.event.NewWelfareEvent; +import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum; +import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.mission.GameEvent; @@ -61,6 +64,7 @@ public class ActivityLogic { ActivityLogic.getInstance().resumeActivity(user, ActivityType.RECHARGE_SUM_DAY); user.getPlayerInfoManager().setRechargedaily(0); updateActivityMissionProgress(user, ActivityType.SevenLogin, 1); + Poster.getPoster().dispatchEvent(new NewWelfareEvent(user.getId(), NewWelfareTypeEnum.LOGIN_TIMES.getType(),1)); //幸运转盘活动刷新 ActivityLogic.getInstance().resumeActivity(user, ActivityType.LUCK_WHEEL); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java index d1dc3be3a..1eecc521f 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityType.java @@ -46,6 +46,8 @@ public interface ActivityType { int ESPECIALEQUIP_EXPERT = 37;//法宝达人 int SOULEQUIP_EXPERT = 38;//魂印达人 + int NEW_WELFARE = 42;//萌新福利 + } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java index 8936384dd..db61e24a1 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/ActivityTypeEnum.java @@ -1,5 +1,6 @@ package com.ljsd.jieling.logic.activity; +import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum; import config.SGlobalActivity; import java.util.HashMap; @@ -35,6 +36,7 @@ public enum ActivityTypeEnum { SOULEQUIP_EXPERT(ActivityType.SOULEQUIP_EXPERT, SoulEquipExpectActivity::new), LUCK_WHEEL(ActivityType.LUCK_WHEEL, LuckWheelNormalActivity::new), LUCK_WHEEL_ADVANCE(ActivityType.LUCK_WHEEL_ADVANCE, LuckWheelAdvancedActivity::new), + NEW_WELFARE(ActivityType.NEW_WELFARE, NewWelfareActivity::new), ; private int type; private Function toActivityFunction; diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/NewWelfareActivity.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/NewWelfareActivity.java new file mode 100644 index 000000000..ba1fbbd97 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/NewWelfareActivity.java @@ -0,0 +1,110 @@ +package com.ljsd.jieling.logic.activity; + +import com.ljsd.jieling.exception.ErrorCode; +import com.ljsd.jieling.exception.ErrorCodeException; +import com.ljsd.jieling.globals.BIReason; +import com.ljsd.jieling.ktbeans.KtEventUtils; +import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean; +import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.event.*; +import com.ljsd.jieling.logic.dao.ActivityMission; +import com.ljsd.jieling.logic.dao.ActivityProgressInfo; +import com.ljsd.jieling.logic.dao.UserManager; +import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.network.session.ISession; +import com.ljsd.jieling.protocols.CommonProto; +import com.ljsd.jieling.protocols.PlayerInfoProto; +import com.ljsd.jieling.util.ItemUtil; +import com.ljsd.jieling.util.MessageUtil; +import config.SActivityRewardConfig; +import config.SGlobalActivity; + +import java.util.List; +import java.util.Map; + +public class NewWelfareActivity extends AbstractActivity { + + private int loginTimes;//登陆次数 + public NewWelfareActivity(int id) { + super(id); + Poster.getPoster().listenEvent(this, NewWelfareEvent.class); + } + + @Override + public void onEvent(IEvent event) throws Exception { + if(! (event instanceof NewWelfareEvent) ){ + return; + } + NewWelfareEvent newWelfareEvent = (NewWelfareEvent) event; + User user = UserManager.getUser(newWelfareEvent.getUid()); + ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id); + List sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id); + Map activityProgressInfoMap = activityMission.getActivityProgressInfoMap(); + boolean isUpdate = false; + for(SActivityRewardConfig sActivityRewardConfig : sActivityRewardConfigs){ + ActivityProgressInfo activityProgressInfo = activityProgressInfoMap.get(sActivityRewardConfig.getId()); + if(activityProgressInfo.getState() == 1){ + continue; + } + if(sActivityRewardConfig.getValues()[0][0] == newWelfareEvent.getType() ){ + int parm = newWelfareEvent.getParm(); + if( newWelfareEvent.getType() == NewWelfareTypeEnum.LOGIN_TIMES.getType()){ + activityProgressInfo.setProgrss(activityProgressInfo.getProgrss()+1); + parm=activityProgressInfo.getProgrss(); + } + if(parm ==sActivityRewardConfig.getValues()[1][0]){ + activityProgressInfo.setState(1); + activityMission.updateProgressInfo(sActivityRewardConfig.getId(), activityProgressInfo); + isUpdate = true; + } + } + } + if(isUpdate){ + //更新进度 + ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId()); + sendActivityProgress(sessionByUid, activityMission, null); + } + } + + @Override + public boolean takeReward(ISession session, int missionId) throws Exception { + User user = UserManager.getUser(session.getUid()); + SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id); + if (sGlobalActivity == null || !user.getActivityManager().getActivityMissionMap().containsKey(id)) { + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id); + Map activityProgressInfoMap = activityMission.getActivityProgressInfoMap(); + for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){ + if(activityProgressInfo.getState() != 1){ + throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); + } + } + for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){ + activityProgressInfo.setState(2); + } + List sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id); + CommonProto.Drop.Builder drop = ItemUtil.drop(user, sActivityRewardConfigs.get(0).getReward(), BIReason.TAKE_ACTIVITY_REWARD); + KtEventUtils.onKtEvent(user, ParamEventBean.UserActivityEvent, id, missionId); + PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build(); + MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true); + return true; + } + + @Override + public void getAllMissRewards(User user, ISession session, List itemAttrs){ + SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id); + if (sGlobalActivity == null || !user.getActivityManager().getActivityMissionMap().containsKey(id)) { + return; + } + ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id); + Map activityProgressInfoMap = activityMission.getActivityProgressInfoMap(); + for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){ + if(activityProgressInfo.getState() != 1){ + return; + } + } + List sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id); + itemAttrs.add(sActivityRewardConfigs.get(0).getValues()); + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareEvent.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareEvent.java new file mode 100644 index 000000000..1077e6a75 --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareEvent.java @@ -0,0 +1,25 @@ +package com.ljsd.jieling.logic.activity.event; + +public class NewWelfareEvent implements IEvent{ + private int uid; + private int type; + private int parm; + + public NewWelfareEvent(int uid, int type, int parm) { + this.uid = uid; + this.type = type; + this.parm = parm; + } + + public int getUid() { + return uid; + } + + public int getType() { + return type; + } + + public int getParm() { + return parm; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareTypeEnum.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareTypeEnum.java new file mode 100644 index 000000000..052d18dec --- /dev/null +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/activity/event/NewWelfareTypeEnum.java @@ -0,0 +1,17 @@ +package com.ljsd.jieling.logic.activity.event; + +public enum NewWelfareTypeEnum { + LEVEL_FIGHT(1), + LOGIN_TIMES(2), + RECHARGE_BUY(3) + ; + + private int type; + private NewWelfareTypeEnum(int type) { + this.type = type; + } + + public int getType() { + return type; + } +} diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java index 8dddf5543..3b67022d0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/HeroManager.java @@ -15,6 +15,8 @@ public class HeroManager extends MongoBase { Map totalCount; + Map randomPoolByType; + Map heroHandBook; private int firstTenth; @@ -24,6 +26,7 @@ public class HeroManager extends MongoBase { heroMap = new HashMap(); totalCount = new HashMap(); heroHandBook = new HashMap<>(); + randomPoolByType = new HashMap<>(); this.setRootCollection(User._COLLECTION_NAME); } @@ -32,6 +35,11 @@ public class HeroManager extends MongoBase { totalCount.put(type,count); } + public void updateRandPoolTypeCount(int mergePool,int count){ + updateString("randomPoolByType." + mergePool, count); + randomPoolByType.put(mergePool,count); + } + public Map getItemMap() { return heroMap; } @@ -89,4 +97,8 @@ public class HeroManager extends MongoBase { updateString("firstTenth" , 1); } + + public Map getRandomPoolByType() { + return randomPoolByType; + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java index 164678142..c70ea0674 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/hero/HeroLogic.java @@ -217,10 +217,15 @@ public class HeroLogic { } int[][] dropHeroAndItem = new int[length][]; int randCount = 0; + int poolCount = 0; Map totalCountMap = heroManager.getTotalCount(); + Map randomPoolByType = heroManager.getRandomPoolByType(); if (totalCountMap.containsKey(type)) { randCount = totalCountMap.get(type); } + if (randomPoolByType.containsKey(sLotterySetting.getMergePool())) { + poolCount = randomPoolByType.get(sLotterySetting.getMergePool()); + } int totalCount = 0; for(Integer count : totalCountMap.values()){ totalCount+=count; @@ -230,14 +235,20 @@ public class HeroLogic { for(int i=0;i list = SLotterySpecialConfig.getLotterySpecialConfigListByType(type); if (list == null) { return 0; } int poolId = 0; for (SLotterySpecialConfig data : list) { + if(data.getDifferentType() == 2 && poolCount==data.getCount()){ + poolId = data.getpool_id(); + break; + } if (randCount % data.getCount() != 0) { continue; } @@ -333,7 +349,7 @@ public class HeroLogic { - public int[] randomHeroByPoolId(int poolId,int randomCount,int userLevel){ + public SLotteryRewardConfig randomHeroByPoolId(int poolId,int randomCount,int userLevel){ List sLotteryRewardConfigs = new ArrayList<>(); List sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId); int totalCountByPoolId =0; @@ -363,7 +379,7 @@ public class HeroLogic { for(SLotteryRewardConfig sLotteryRewardConfig :sLotteryRewardConfigs){ weight += sLotteryRewardConfig.getWeight(); if(weight>=randCount){ - return sLotteryRewardConfig.getReward(); + return sLotteryRewardConfig; } } return null; @@ -2082,5 +2098,14 @@ public class HeroLogic { } hero.setIsLock(lockState); MessageUtil.sendMessage(session,1,responseMsgId,null,true); + + Map pokemonAttributeMap = new HashMap<>(); + Map pokemonMap = user.getPokemonManager().getPokemonMap(); + for(Pokemon pokemon : pokemonMap.values()){ + combinePokemonAttribute(pokemonAttributeMap, pokemon,false); + } + for(Map.Entry item : pokemonAttributeMap.entrySet()){ + LOGGER.info("the proId={},the value={}",item.getKey(),item.getValue()); + } } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java index 9e93dbeff..df676079b 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/store/BuyGoodsLogic.java @@ -11,6 +11,10 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean; import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.activity.ActivityLogic; import com.ljsd.jieling.logic.activity.ActivityType; +import com.ljsd.jieling.logic.activity.event.NewWelfareEvent; +import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum; +import com.ljsd.jieling.logic.activity.event.Poster; +import com.ljsd.jieling.logic.activity.event.SecretEvent; import com.ljsd.jieling.logic.dao.RechargeInfo; import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.root.User; @@ -206,6 +210,7 @@ public class BuyGoodsLogic { KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent,goodsId,orderId,resultRes.getResultCode(),price); notifyPaySuccessFul(uid,goodsId,amount != -999); MongoUtil.getLjsdMongoTemplate().lastUpdate(); + Poster.getPoster().dispatchEvent(new NewWelfareEvent(user.getId(), NewWelfareTypeEnum.RECHARGE_BUY.getType(),goodsId)); return resultRes; } diff --git a/tablemanager/src/main/java/config/SLotteryRewardConfig.java b/tablemanager/src/main/java/config/SLotteryRewardConfig.java index 0fa8e5a94..667be6c48 100644 --- a/tablemanager/src/main/java/config/SLotteryRewardConfig.java +++ b/tablemanager/src/main/java/config/SLotteryRewardConfig.java @@ -23,6 +23,8 @@ public class SLotteryRewardConfig implements BaseConfig { private int[] openRules; + private int star; + private static Map> sLotteryRewardConfigsByPoolId; private static Map sLotteryRewardWeightByPoolId; @@ -82,4 +84,8 @@ public class SLotteryRewardConfig implements BaseConfig { public int[] getOpenRules() { return openRules; } + + public int getStar() { + return star; + } } \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SLotterySetting.java b/tablemanager/src/main/java/config/SLotterySetting.java index edb08235d..75bc77670 100644 --- a/tablemanager/src/main/java/config/SLotterySetting.java +++ b/tablemanager/src/main/java/config/SLotterySetting.java @@ -31,6 +31,8 @@ public class SLotterySetting implements BaseConfig { private int lotteryType; + private int mergePool; + @Override public void init() throws Exception { @@ -89,4 +91,8 @@ public class SLotterySetting implements BaseConfig { public int getLotteryType() { return lotteryType; } + + public int getMergePool() { + return mergePool; + } } \ No newline at end of file diff --git a/tablemanager/src/main/java/config/SLotterySpecialConfig.java b/tablemanager/src/main/java/config/SLotterySpecialConfig.java index 735613eac..cbe99aeaa 100644 --- a/tablemanager/src/main/java/config/SLotterySpecialConfig.java +++ b/tablemanager/src/main/java/config/SLotterySpecialConfig.java @@ -13,6 +13,8 @@ public class SLotterySpecialConfig implements BaseConfig { private int id; + private int differentType; + private int type; private int count; @@ -23,6 +25,7 @@ public class SLotterySpecialConfig implements BaseConfig { private int pool_id; + private static Map> lotterySpecialConfigMap; @@ -68,5 +71,7 @@ public class SLotterySpecialConfig implements BaseConfig { return pool_id; } - + public int getDifferentType() { + return differentType; + } } \ No newline at end of file