元素招募 & 新活动(新手福利)

back_recharge
wangyuan 2019-11-22 16:39:54 +08:00
parent 56338b360f
commit db8aeac335
14 changed files with 235 additions and 9 deletions

View File

@ -20,6 +20,7 @@ public class HeroStaticConfig extends AbstractClassStaticConfig {
private Map<Integer, Map<Integer, Map<Integer, SCHeroRankUpConfig>>> scHeroRankUpConfigByType;
private Set<Integer> randomHeroIds;
private Map<Integer,Integer> randomPoolByType;
@Override
public void registConfigs(Set<String> registConfigs) {
@ -75,12 +76,15 @@ public class HeroStaticConfig extends AbstractClassStaticConfig {
try {
Set<Integer> randomHeroIdTmp = new HashSet<>();
Map<Integer, SLotterySetting> config = STableManager.getConfig(SLotterySetting.class);
Map<Integer,Integer> 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<Integer> getRandomHeroIds() {
return randomHeroIds;
}
public Map<Integer, Integer> getRandomPoolByType() {
return randomPoolByType;
}
}

View File

@ -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的

View File

@ -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);

View File

@ -46,6 +46,8 @@ public interface ActivityType {
int ESPECIALEQUIP_EXPERT = 37;//法宝达人
int SOULEQUIP_EXPERT = 38;//魂印达人
int NEW_WELFARE = 42;//萌新福利
}

View File

@ -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<Integer, AbstractActivity> toActivityFunction;

View File

@ -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<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
Map<Integer, ActivityProgressInfo> 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<Integer, ActivityProgressInfo> 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<SActivityRewardConfig> 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<int[][]> itemAttrs){
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (sGlobalActivity == null || !user.getActivityManager().getActivityMissionMap().containsKey(id)) {
return;
}
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityProgressInfoMap();
for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){
if(activityProgressInfo.getState() != 1){
return;
}
}
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
itemAttrs.add(sActivityRewardConfigs.get(0).getValues());
}
}

View File

@ -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;
}
}

View File

@ -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;
}
}

View File

@ -15,6 +15,8 @@ public class HeroManager extends MongoBase {
Map<Integer, Integer> totalCount;
Map<Integer, Integer> randomPoolByType;
Map<Integer,Integer> 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<String, Hero> getItemMap() {
return heroMap;
}
@ -89,4 +97,8 @@ public class HeroManager extends MongoBase {
updateString("firstTenth" , 1);
}
public Map<Integer, Integer> getRandomPoolByType() {
return randomPoolByType;
}
}

View File

@ -217,10 +217,15 @@ public class HeroLogic {
}
int[][] dropHeroAndItem = new int[length][];
int randCount = 0;
int poolCount = 0;
Map<Integer, Integer> totalCountMap = heroManager.getTotalCount();
Map<Integer, Integer> 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<perCount;i++){
randCount++;
if(pooId == 0){
pooId = getSpecialPoolByRandcount(type, randCount);
pooId = getSpecialPoolByRandcount(type, randCount,poolCount);
if(pooId==0){
pooId = getPooId(sLotterySetting, pooId);
}
}
LOGGER.info("the uid={},the type={},the poolId={}",uid,type,pooId);
totalCount++;
int[] reward = randomHeroByPoolId(pooId,totalCount,user.getPlayerInfoManager().getLevel());
SLotteryRewardConfig sLotteryRewardConfig = randomHeroByPoolId(pooId, totalCount, user.getPlayerInfoManager().getLevel());
if(sLotteryRewardConfig.getStar() == 1){
poolCount=0;
}else{
poolCount++;
}
int[] reward =sLotteryRewardConfig.getReward();
if(reward!=null){
dropHeroAndItem[j++] = reward;
}
@ -246,6 +257,7 @@ public class HeroLogic {
}
}
heroManager.updateRandPoolTypeCount(sLotterySetting.getMergePool(),poolCount);
//1群英招募
HeroInfoProto.HeroRandResponse.Builder builder = HeroInfoProto.HeroRandResponse.newBuilder();
@ -275,13 +287,17 @@ public class HeroLogic {
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
}
private int getSpecialPoolByRandcount(int type, int randCount) {
private int getSpecialPoolByRandcount(int type, int randCount,int poolCount) {
List<SLotterySpecialConfig> 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<SLotteryRewardConfig> sLotteryRewardConfigs = new ArrayList<>();
List<SLotteryRewardConfig> 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<Integer,Integer> pokemonAttributeMap = new HashMap<>();
Map<Integer, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
for(Pokemon pokemon : pokemonMap.values()){
combinePokemonAttribute(pokemonAttributeMap, pokemon,false);
}
for(Map.Entry<Integer,Integer> item : pokemonAttributeMap.entrySet()){
LOGGER.info("the proId={},the value={}",item.getKey(),item.getValue());
}
}
}

View File

@ -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;
}

View File

@ -23,6 +23,8 @@ public class SLotteryRewardConfig implements BaseConfig {
private int[] openRules;
private int star;
private static Map<Integer, List<SLotteryRewardConfig>> sLotteryRewardConfigsByPoolId;
private static Map<Integer, Integer> sLotteryRewardWeightByPoolId;
@ -82,4 +84,8 @@ public class SLotteryRewardConfig implements BaseConfig {
public int[] getOpenRules() {
return openRules;
}
public int getStar() {
return star;
}
}

View File

@ -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;
}
}

View File

@ -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<Integer, List<SLotterySpecialConfig>> lotterySpecialConfigMap;
@ -68,5 +71,7 @@ public class SLotterySpecialConfig implements BaseConfig {
return pool_id;
}
public int getDifferentType() {
return differentType;
}
}