From 97d32d93dd5c16a5f54263e68f998b30e0e8d030 Mon Sep 17 00:00:00 2001 From: mengchengzhen <13682025901@163.com> Date: Wed, 19 May 2021 11:18:46 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E7=BA=A2=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jieling/logic/GlobalDataManaager.java | 2 + .../ljsd/jieling/logic/dao/PlayerManager.java | 11 ++ .../ljsd/jieling/logic/family/GuildLogic.java | 110 +++++++++++++++++- .../main/java/config/SGuildRedPackConfig.java | 51 +++++++- 4 files changed, 172 insertions(+), 2 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java index 929999725..c0e05c9c0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/GlobalDataManaager.java @@ -13,6 +13,7 @@ import com.ljsd.jieling.logic.activity.ActivityLogic; import com.ljsd.jieling.logic.activity.FightMainEventHandler; import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler; import com.ljsd.jieling.logic.activity.UserLevelEventHandler; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackSendHandler; import com.ljsd.jieling.logic.activity.eventhandler.ActivityStateChangeHandler; import com.ljsd.jieling.logic.activity.eventhandler.BuyGoodsDirectHandler; import com.ljsd.jieling.logic.activity.eventhandler.GuildForceChangeEventHandler; @@ -256,6 +257,7 @@ public class GlobalDataManaager implements IManager { new RemoveEventHeroHandler(); new FightMainEventHandler(); new BuyGoodsDirectHandler(); + new WelfareRedPackSendHandler(); new ActivityStateChangeHandler(); new GuildForceChangeEventHandler(); ChampionshipLogic.minuteCheck(true); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java index a4604eb8c..9e8d19411 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java @@ -149,6 +149,8 @@ public class PlayerManager extends MongoBase { private Map situationPass = new HashMap<>(); + private Map welfareRedPackets = new HashMap<>(); + public PlayerManager(){ this.setRootCollection(User._COLLECTION_NAME); @@ -1011,6 +1013,15 @@ public class PlayerManager extends MongoBase { updateString("situationPass",situationPass); } + public Map getWelfareRedPackets() { + return welfareRedPackets; + } + + public void setWelfareRedPackets(Map welfareRedPackets) { + this.welfareRedPackets = welfareRedPackets; + updateString("welfareRedPackets",welfareRedPackets); + } + public int getSheJiOpenTime() { return sheJiOpenTime; } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java index 5988c0109..f70d636b0 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java @@ -1,6 +1,7 @@ package com.ljsd.jieling.logic.family; import com.google.protobuf.GeneratedMessage; +import com.google.protobuf.Message; import com.ljsd.GameApplication; import com.ljsd.jieling.core.GlobalsDef; import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType; @@ -1161,16 +1162,123 @@ public class GuildLogic { } AbstractRank rank = RankContext.getRankEnum(RankEnum.GUILD_RED_PACKAGE_RANK.getType()); double scoreById = rank.getScoreById(uid, String.valueOf(user.getPlayerInfoManager().getGuildId())); - double price = SRechargeCommodityNewConfig.configMap.get(config.getTradeId()).getPrice(); + double price = 0; + if(config.getBaseType() == 1){ + price = SRechargeCommodityNewConfig.configMap.get(config.getTradeId()).getPrice(); + } if(scoreById==-1||scoreById==0){ price+=TimeUtils.getDoubleTime(); }else{ price+=scoreById; } + if(config.getBaseType() == 2){ + Map map = user.getPlayerInfoManager().getWelfareRedPackets(); + int old = map.get(redId); + SGuildRedPackConfig redPacket = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId); + if(redPacket.getRuleType() != 1){ + map.put(redId,-1); + }else{ + map.put(redId,old-1); + } + user.getPlayerInfoManager().setWelfareRedPackets(map); + } rank.addRank(uid,String.valueOf(user.getPlayerInfoManager().getGuildId()),price); RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,config.getLastTime()); } + /** + * 福利红包添加 + * @param uid + * @param redId + * @throws Exception + */ + public static void addWelfareRedPacket(int uid,int redId) throws Exception { + User user = UserManager.getUser(uid); + SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId); + if(config==null || config.getBaseType() != 2){ + return; + } + Map redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets(); + switch (config.getRuleType()){ + case 1: + if(redPacketsMap.get(config.getId())>0){ + if(redPacketsMap.get(config.getId()) < config.getMaxNum()){ + redPacketsMap.put(config.getId(),redPacketsMap.get(config.getId())+1); + } + }else{ + redPacketsMap.put(config.getId(),1); + } + break; + case 2: + if(redPacketsMap.get(config.getId())>=0){ + redPacketsMap.put(config.getId(),1); + } + break; + case 3: + List serise = SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId()); + for(SGuildRedPackConfig c : serise){ + if(redPacketsMap.containsKey(c.getId())){ + if(redPacketsMap.get(c.getId())>-1){ + if(c.getId() == config.getId()){ + redPacketsMap.put(c.getId(),1); + break; + } + }else{ + continue; + } + }else{ + if(c.getId() == config.getId()){ + redPacketsMap.put(config.getId(),1); + }else{ + break; + } + } + } + break; + } + user.getPlayerInfoManager().setWelfareRedPackets(redPacketsMap); + sendWelfareRedPacketInfo(user); + } + + public static void sendWelfareRedPacketInfo(User user){ + Map redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets(); + if(redPacketsMap.size() == 0){//初始化 + initWelfareRedPacketInfo(user); + } + PlayerInfoProto.WelfareRedPacketPush.Builder build = PlayerInfoProto.WelfareRedPacketPush.newBuilder(); + for(Map.Entry entry : redPacketsMap.entrySet()){ + if(entry.getValue() >= 0){ + build.addRedpacket(CommonProto.WelfareRedPacket.newBuilder().setId(entry.getKey()).setNum(entry.getValue())); + } + } + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_INFO.getNumber(),build.build(),true); + } + + public static void initWelfareRedPacketInfo(User user){ + Map redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets(); + for(SGuildRedPackConfig config : SGuildRedPackConfig.sWelfareRedPackByRule.values()){ + if(config.getRuleType() == 3){ + if(config.getGroupId() == 2){ + int num = user.getMapManager().getLastMonsterAttack(); + for(SGuildRedPackConfig config1 : SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId())){ + if(num >= config1.getRuleId()[1]){ + redPacketsMap.put(config.getId(),1); + }else{ + redPacketsMap.put(config.getId(),0); + break; + } + } + }else{ + if(config.getId()==SGuildRedPackConfig.welfareRedPackBySerise.get(config.getGroupId()).get(0).getId()) + redPacketsMap.put(config.getId(),0); + } + }else{ + redPacketsMap.put(config.getId(),0); + } + } + } + /** * 获取所有红包信息 * @param session diff --git a/tablemanager/src/main/java/config/SGuildRedPackConfig.java b/tablemanager/src/main/java/config/SGuildRedPackConfig.java index 4734a51b0..227b31063 100644 --- a/tablemanager/src/main/java/config/SGuildRedPackConfig.java +++ b/tablemanager/src/main/java/config/SGuildRedPackConfig.java @@ -4,7 +4,9 @@ package config; import manager.STableManager; import manager.Table; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Map; @Table(name ="GuildRedPackConfig") @@ -28,19 +30,48 @@ public class SGuildRedPackConfig implements BaseConfig { private int tradeId; + private int baseType; + + private int ruleType; + + private int maxNum; + + private int groupId; + + private int[] ruleId; + public static Map sGuildRedPackConfigMap; public static Map sGuildRedPackByGoodsId; + public static Map sWelfareRedPackByRule; + + public static Map> welfareRedPackBySerise; + @Override public void init() throws Exception { sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class); sGuildRedPackByGoodsId = new HashMap<>(); + + sWelfareRedPackByRule = new HashMap<>(); + welfareRedPackBySerise = new HashMap<>(); for(Map.Entry entry:sGuildRedPackConfigMap.entrySet()){ int tradeId = entry.getValue().getTradeId(); - if(!sGuildRedPackConfigMap.containsKey(tradeId)){ + if(entry.getValue().getBaseType() == 1 && !sGuildRedPackConfigMap.containsKey(tradeId)){ sGuildRedPackByGoodsId.put(tradeId,entry.getValue()); } + if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId())){ + sWelfareRedPackByRule.put(entry.getValue().getRuleId()[0],entry.getValue()); + } + if(entry.getValue().getRuleType() == 3){ + if(welfareRedPackBySerise.containsKey(entry.getValue().getGroupId())){ + welfareRedPackBySerise.get(entry.getValue().getGroupId()).add(entry.getValue()); + }else{ + List list = new ArrayList<>(); + list.add(entry.getValue()); + welfareRedPackBySerise.put(entry.getValue().getGroupId(),list); + } + } } } @@ -81,5 +112,23 @@ public class SGuildRedPackConfig implements BaseConfig { return tradeId; } + public int getBaseType() { + return baseType; + } + public int getRuleType() { + return ruleType; + } + + public int getMaxNum() { + return maxNum; + } + + public int getGroupId() { + return groupId; + } + + public int[] getRuleId() { + return ruleId; + } } \ No newline at end of file From 4a2df26e2ee3a800d9ceb54a39091544caa44ef0 Mon Sep 17 00:00:00 2001 From: mengchengzhen <13682025901@163.com> Date: Fri, 21 May 2021 18:52:19 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A6=8F=E5=88=A9=E7=BA=A2=E5=8C=85?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/ljsd/jieling/exception/ErrorCode.java | 3 +- .../jieling/handler/GetPlayerInfoHandler.java | 4 +- .../ljsd/jieling/handler/map/MapLogic.java | 4 ++ .../handler/map/miniGame/CircleGame.java | 20 +++++- .../ljsd/jieling/logic/arena/ArenaLogic.java | 6 ++ .../logic/championship/ChampionshipLogic.java | 6 ++ .../ljsd/jieling/logic/dao/PlayerManager.java | 11 +++ .../ljsd/jieling/logic/family/GuildLogic.java | 68 ++++++++++++++++++- .../ljsd/jieling/logic/hero/HeroLogic.java | 39 ++++++++++- .../jieling/logic/player/PlayerLogic.java | 2 +- .../main/java/config/SGuildRedPackConfig.java | 8 ++- .../src/main/java/config/SSpecialConfig.java | 1 + .../src/main/java/config/SSpiritAnimal.java | 4 ++ 13 files changed, 167 insertions(+), 9 deletions(-) diff --git a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java index cc22d09c4..65f58e7e5 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/exception/ErrorCode.java @@ -168,7 +168,8 @@ public enum ErrorCode implements IErrorCode { HONGMENG_ING(139,"英雄在鸿蒙阵中,操作失败"), - LOCK_FILL(138,"锁定数量已满,无法刷新"), + LOCK_FILL(140,"锁定数量已满,无法刷新"), + REDPACKET_DAILY_LIMIT(141,"今日福利红包已达领取上限"), ; private static final Set CodeSet = new HashSet<>(); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java index d3abd1bb9..85d173980 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/GetPlayerInfoHandler.java @@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.dao.*; import com.ljsd.jieling.logic.dao.root.GlobalSystemControl; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.family.GuildLogic; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.logic.question.QuestionLogic; @@ -70,7 +71,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ PlayerManager playerInfoManager = user.getPlayerInfoManager(); ActivityLogic.getInstance().flushForLogin(user,iSession); GlobalDataManaager.checkNeedReFlush(iSession,user,null); - + GuildLogic.sendWelfareRedPacketInfo(user); BuyGoodsNewLogic.refreshWelfareState(user); // Poster.getPoster().dispatchEvent(new UserOnlineEvent(userId)); user.getUserMissionManager().onGameEvent(user, GameEvent.LOGIN_GAME,0); @@ -219,6 +220,7 @@ public class GetPlayerInfoHandler extends BaseHandler{ .addAllUserMountList(CBean2Proto.getUserMountList(user)) .addAllUserSkinList(CBean2Proto.getUserSkinList(user)) .addAllUserTitleList(CBean2Proto.getUserTitleList(user)) + .setDailyredpack(playerInfoManager.getDailyWelfareRedPacket()) .build(); ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType()); try { 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 cf9eef485..5826bd466 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 @@ -40,6 +40,8 @@ import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; import com.ljsd.jieling.logic.rank.RankContext; import com.ljsd.jieling.logic.rank.RankEnum; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.logic.store.StoreType; @@ -2288,6 +2290,8 @@ public class MapLogic { itemIdList.add(item.getItemId()); itemNumList.add((int)item.getItemNum()); }); + //发福利红包 + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.soul_demon.getType(),checkFightId)); ReportUtil.onReportEvent(user,ReportEventEnum.COMPLETE_XINMO.getType(),checkFightId,sFloodConfig.getMonster(),MonsterUtil.getMonsterForce(new int[]{sFloodConfig.getMonster()}),new Date(),"",itemIdList,itemNumList,"成功"); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java index dc4298e8e..d46b0eb75 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/handler/map/miniGame/CircleGame.java @@ -2,7 +2,14 @@ package com.ljsd.jieling.handler.map.miniGame; import com.ljsd.jieling.globals.BIReason; import com.ljsd.jieling.handler.map.MapGameInfo; +import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.dao.root.User; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; +import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; +import com.ljsd.jieling.network.session.ISession; +import config.SSpiritAnimal; import rpc.protocols.CommonProto; import rpc.protocols.MapInfoProto; import com.ljsd.jieling.util.ItemUtil; @@ -63,7 +70,9 @@ public class CircleGame extends ColorGame{ //todo 需要告诉前端一个拿到的id STrialGameConfig config = STrialGameConfig.trialGameConfigMap.get(id[0]); CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{config.getRewardID(), config.getMin()}}, BIReason.MAP_EVENET_REWARD); - + if(drop.getPokemonList().size()>0){ + fiveStarPokemonPushByRandom(user,drop.getPokemonList().get(0).getTempId()); + } MapInfoProto.MapGameUpdateResponse response = MapInfoProto.MapGameUpdateResponse.newBuilder() .setGameStatus(0) @@ -73,4 +82,13 @@ public class CircleGame extends ColorGame{ user.getMapManager().updateMapGameInfo(new MapGameInfo()); return response; } + + private void fiveStarPokemonPushByRandom(User user,int itemId) throws Exception{ + SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(itemId); + if(ssa != null && ssa.getQuality()==5){ + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.game_pokemon.getType(),1)); + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + BuyGoodsNewLogic.openPush(session,user,8,5,1); + } + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java index 401351b5a..ed2766d6c 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/arena/ArenaLogic.java @@ -15,6 +15,7 @@ import com.ljsd.jieling.globals.Global; import com.ljsd.jieling.handler.map.behavior.BehaviorUtil; import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.OnlineUserManager; +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.fight.*; @@ -24,6 +25,8 @@ import com.ljsd.jieling.logic.mail.MailLogic; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.mission.event.MissionEventDistributor; import com.ljsd.jieling.logic.player.PlayerLogic; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; import com.ljsd.jieling.network.server.GlobalidHelper; import com.ljsd.jieling.network.server.WorldHelper; import com.ljsd.jieling.network.session.ISession; @@ -565,6 +568,9 @@ public class ArenaLogic { if(!"".equals(rewardByRank)){ MailLogic.getInstance().sendMail(user.getId(),title,content,rewardByRank,nowTime, Global.MAIL_EFFECTIVE_TIME); } + if(rank == 1){ + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.arena_rank.getType(),1)); + } } MongoUtil.getInstence().lastUpdate(); } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java index b0fa23cd4..008ac454e 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/championship/ChampionshipLogic.java @@ -19,6 +19,7 @@ import com.ljsd.jieling.ktbeans.ReportEventEnum; import com.ljsd.jieling.ktbeans.ReportUtil; import com.ljsd.jieling.logic.GlobalDataManaager; import com.ljsd.jieling.logic.OnlineUserManager; +import com.ljsd.jieling.logic.activity.event.Poster; import com.ljsd.jieling.logic.arena.ArenaLogic; import com.ljsd.jieling.logic.blood.BloodLogic; import com.ljsd.jieling.logic.dao.*; @@ -28,6 +29,8 @@ import com.ljsd.jieling.logic.hero.HeroLogic; import com.ljsd.jieling.logic.mail.MailLogic; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; import com.ljsd.jieling.network.server.ProtocolsManager; import com.ljsd.jieling.network.session.ISession; import rpc.protocols.ArenaInfoProto; @@ -415,6 +418,9 @@ public class ChampionshipLogic { String title = SErrorCodeEerverConfig.getI18NMessage("champion_reward_title"); String content = SErrorCodeEerverConfig.getI18NMessageNeedConvert("champion_reward_txt", new Object[]{sChampionshipReward.getTitleDesc()},new int[]{1},"#"); MailLogic.getInstance().sendMail(user.getId(), title, content, ItemUtil.getMailReward(sChampionshipReward.getSeasonReward()), nowTime, Global.MAIL_EFFECTIVE_TIME); + if(rank == 1){ + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.top_match_rank.getType(),1)); + } } }catch (Exception e){ LOGGER.info("Exception e = "+"size"+ arenaRankInfo.size()+ e.toString()); diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java index 9e8d19411..2ace3a515 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/dao/PlayerManager.java @@ -151,6 +151,8 @@ public class PlayerManager extends MongoBase { private Map welfareRedPackets = new HashMap<>(); + private int dailyWelfareRedPacket; + public PlayerManager(){ this.setRootCollection(User._COLLECTION_NAME); @@ -1049,4 +1051,13 @@ public class PlayerManager extends MongoBase { this.newRechargeInfo = newRechargeInfo; updateString("newRechargeInfo", newRechargeInfo); } + + public int getDailyWelfareRedPacket() { + return dailyWelfareRedPacket; + } + + public void setDailyWelfareRedPacket(int dailyWelfareRedPacket) { + this.dailyWelfareRedPacket = dailyWelfareRedPacket; + updateString("dailyWelfareRedPacket",dailyWelfareRedPacket); + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java index f70d636b0..f6cb55778 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/family/GuildLogic.java @@ -25,6 +25,8 @@ import com.ljsd.jieling.logic.player.PlayerLogic; import com.ljsd.jieling.logic.rank.RankContext; import com.ljsd.jieling.logic.rank.RankEnum; import com.ljsd.jieling.logic.rank.rankImpl.AbstractRank; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; import com.ljsd.jieling.logic.store.StoreLogic; import com.ljsd.jieling.network.server.ProtocolsManager; import com.ljsd.jieling.network.session.ISession; @@ -620,7 +622,7 @@ public class GuildLogic { } targetUser.getGuildMyInfo().setJoinTime(TimeUtils.nowInt()); ReportUtil.onReportEvent(targetUser, ReportEventEnum.JOIN_GUILD.getType(),String.valueOf(guildInfo.getId()),guildInfo.getName(),guildInfo.getLevel(),guildInfo.getTotalMembers()); - + sendNewGuyRedPacket(guildInfo); } /** @@ -1171,21 +1173,46 @@ public class GuildLogic { }else{ price+=scoreById; } - if(config.getBaseType() == 2){ + if(config.getBaseType() == 2){//福利红包 Map map = user.getPlayerInfoManager().getWelfareRedPackets(); int old = map.get(redId); SGuildRedPackConfig redPacket = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId); if(redPacket.getRuleType() != 1){ map.put(redId,-1); + if(redPacket.getRuleType() == 3){ + openNext(map,redPacket.getGroupId(),redId); + } }else{ map.put(redId,old-1); } user.getPlayerInfoManager().setWelfareRedPackets(map); + + PlayerInfoProto.WelfareRedPacketSendResponse.Builder build = PlayerInfoProto.WelfareRedPacketSendResponse.newBuilder(); + for(Map.Entry entry : map.entrySet()){ + if(entry.getValue() >= 0){ + build.addRedpacket(CommonProto.WelfareRedPacket.newBuilder().setId(entry.getKey()).setNum(entry.getValue())); + } + } + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_SEND_RESPONSE.getNumber(),build.build()); } rank.addRank(uid,String.valueOf(user.getPlayerInfoManager().getGuildId()),price); RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,config.getLastTime()); } + public static void openNext(Map map,int groupId,int cur){ + boolean f = false; + for(SGuildRedPackConfig config : SGuildRedPackConfig.welfareRedPackBySerise.get(groupId)){ + if(f){ + map.put(config.getId(),0); + break; + } + if(config.getId() == cur){ + f = true; + } + } + } + /** * 福利红包添加 * @param uid @@ -1237,10 +1264,25 @@ public class GuildLogic { break; } user.getPlayerInfoManager().setWelfareRedPackets(redPacketsMap); - sendWelfareRedPacketInfo(user); + sendWelfareRedPacketInfoIndication(user); } public static void sendWelfareRedPacketInfo(User user){ + Map redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets(); + if(redPacketsMap.size() == 0){//初始化 + initWelfareRedPacketInfo(user); + } + PlayerInfoProto.WelfareRedPacketPush.Builder build = PlayerInfoProto.WelfareRedPacketPush.newBuilder(); + for(Map.Entry entry : redPacketsMap.entrySet()){ + if(entry.getValue() >= 0){ + build.addRedpacket(CommonProto.WelfareRedPacket.newBuilder().setId(entry.getKey()).setNum(entry.getValue())); + } + } + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WELFARE_RED_PACKET_INFO.getNumber(),build.build(),true); + } + + public static void sendWelfareRedPacketInfoIndication(User user){ Map redPacketsMap = user.getPlayerInfoManager().getWelfareRedPackets(); if(redPacketsMap.size() == 0){//初始化 initWelfareRedPacketInfo(user); @@ -1317,6 +1359,7 @@ public class GuildLogic { */ public static void robRedPackage(ISession session, int redId, MessageTypeProto.MessageType messageType) throws Exception{ int uid = session.getUid(); + AcceptRedInfo isAlready = RedisUtil.getInstence().getMapValue("red_already_list", String.valueOf(redId), String.valueOf(uid), AcceptRedInfo.class); if(isAlready!=null){ throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE); @@ -1329,6 +1372,17 @@ public class GuildLogic { if(packInfo==null){ throw new ErrorCodeException(ErrorCode.FAMILY_NULL); } + //福利红包 + if(SGuildRedPackConfig.welfareRedPackIds.contains(packInfo.getTypeId())){ + User user = UserManager.getUser(uid); + int dailyGet = user.getPlayerInfoManager().getDailyWelfareRedPacket(); + int maxGet = SSpecialConfig.getIntegerValue(SSpecialConfig.WELFAREREDPACKET_LIMIT); + if(dailyGet < maxGet){ + user.getPlayerInfoManager().setDailyWelfareRedPacket(dailyGet+1); + }else{ + throw new ErrorCodeException(ErrorCode.REDPACKET_DAILY_LIMIT); + } + } SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(packInfo.getTypeId()); int count = Integer.parseInt(String.valueOf(redPackage)); ItemUtil.drop(UserManager.getUser(uid),new int[][]{new int[]{config.getTotalMoney()[0],count}},BIReason.RED_PACKAGE_REWARD); @@ -1647,5 +1701,13 @@ public class GuildLogic { return true; } + private static void sendNewGuyRedPacket(GuildInfo guildInfo) throws Exception{ + for(int id : guildInfo.getMembers().get(GlobalsDef.CHAIRMAN)){ + User user = UserManager.getUser(id); + if(user == null) + continue; + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.newfish_come.getType(),0)); + } + } } 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 139ae772a..901578f7e 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 @@ -18,6 +18,7 @@ import com.ljsd.jieling.jbean.ActivityMission; import com.ljsd.jieling.jbean.ActivityProgressInfo; import com.ljsd.jieling.ktbeans.ReportEventEnum; import com.ljsd.jieling.ktbeans.ReportUtil; +import com.ljsd.jieling.logic.OnlineUserManager; import com.ljsd.jieling.logic.activity.ActivityType; import com.ljsd.jieling.logic.activity.event.*; import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler; @@ -29,6 +30,9 @@ import com.ljsd.jieling.logic.fight.passiveSkillCal.PassiveskillCalEnum; import com.ljsd.jieling.logic.item.ItemLogic; import com.ljsd.jieling.logic.mission.GameEvent; import com.ljsd.jieling.logic.player.PlayerLogic; +import com.ljsd.jieling.logic.redpacket.WelfareRedPackEvent; +import com.ljsd.jieling.logic.redpacket.WelfareRedPacketType; +import com.ljsd.jieling.logic.store.BuyGoodsNewLogic; import com.ljsd.jieling.network.server.ProtocolsManager; import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.util.*; @@ -344,6 +348,7 @@ public class HeroLogic{ heroManager.updateRandCount(type,perCount); CommonProto.Drop.Builder drop = ItemUtil.dropPer(user, resultRandom,BIReason.HERO_RANDOM); fiveStarPushByRandom(user,resultRandom); + fiveStarPokemonPushByRandom(user,resultRandom); builder.setDrop(drop); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true); // System.out.println(System.currentTimeMillis()-time); @@ -1152,6 +1157,7 @@ public class HeroLogic{ } String consume = StringUtil.parseArrayToString(consumeMaterial); + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.hero_star.getType(),targetHero.getStar())); ReportUtil.onReportEvent(user, ReportEventEnum.HERO_STRENGTHEN.getType(),String.valueOf(targetHero.getTemplateId()),String.valueOf(oldStar),String.valueOf(targetHero.getStar()),consume,reportConsumeHero.toString()); } @@ -2455,6 +2461,9 @@ public class HeroLogic{ if(drop.getHeroList().size()>0){ fiveStarPushByCombine(user,drop.getHero(0).getHeroId(), composeNum); } + if(drop.getPokemonList().size()>0){ + fiveStarPokemonPushByCombine(user,drop.getPokemonList().get(0).getTempId()); + } HeroInfoProto.HeroComposeResponse heroComposeResponse = HeroInfoProto.HeroComposeResponse .newBuilder() .setDrop(drop) @@ -3645,7 +3654,7 @@ public class HeroLogic{ consumeBuilder.append(consume[0]).append("#").append(consume[1]); } ReportUtil.onReportEvent(user,ReportEventEnum.BEAST_STAR.getType(),pokemon.getTmpId(),oldStar,pokemon.getStar(),consumeBuilder.toString()); - + BuyGoodsNewLogic.openPush(session,user,9,pokemon.getStar(),1); } @@ -4562,4 +4571,32 @@ public class HeroLogic{ } } + /** + *五星灵兽推送 + */ + public static void fiveStarPokemonPushByRandom(User user,int[][] getHeros) throws Exception{ + int fiveStarNum = 0; + for(int[] i : getHeros){ + SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(i); + if(ssa != null && ssa.getQuality()==5){ + fiveStarNum = 1; + Poster.getPoster().dispatchEvent(new WelfareRedPackEvent(user.getId(), WelfareRedPacketType.random_pokemon.getType(),1)); + } + } + if(fiveStarNum > 0){ + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + BuyGoodsNewLogic.openPush(session,user,8,5,fiveStarNum); + } + } + + /** + *五星灵兽合成推送 + */ + public static void fiveStarPokemonPushByCombine(User user,int itemId) throws Exception{ + SSpiritAnimal ssa = SSpiritAnimal.mapConfig.get(itemId); + if(ssa != null && ssa.getQuality()==5){ + ISession session = OnlineUserManager.getSessionByUid(user.getId()); + BuyGoodsNewLogic.openPush(session,user,8,5,1); + } + } } diff --git a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java index 3143688c8..52660d0f9 100644 --- a/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java +++ b/serverlogic/src/main/java/com/ljsd/jieling/logic/player/PlayerLogic.java @@ -423,7 +423,7 @@ public class PlayerLogic { } } - + playerInfoManager.setDailyWelfareRedPacket(0); } public void modifyDecoration(ISession session, int type,int decorationId,MessageTypeProto.MessageType messageType) throws Exception { diff --git a/tablemanager/src/main/java/config/SGuildRedPackConfig.java b/tablemanager/src/main/java/config/SGuildRedPackConfig.java index 227b31063..1dbde0186 100644 --- a/tablemanager/src/main/java/config/SGuildRedPackConfig.java +++ b/tablemanager/src/main/java/config/SGuildRedPackConfig.java @@ -48,6 +48,8 @@ public class SGuildRedPackConfig implements BaseConfig { public static Map> welfareRedPackBySerise; + public static List welfareRedPackIds; + @Override public void init() throws Exception { sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class); @@ -55,12 +57,16 @@ public class SGuildRedPackConfig implements BaseConfig { sWelfareRedPackByRule = new HashMap<>(); welfareRedPackBySerise = new HashMap<>(); + welfareRedPackIds = new ArrayList<>(); for(Map.Entry entry:sGuildRedPackConfigMap.entrySet()){ int tradeId = entry.getValue().getTradeId(); if(entry.getValue().getBaseType() == 1 && !sGuildRedPackConfigMap.containsKey(tradeId)){ sGuildRedPackByGoodsId.put(tradeId,entry.getValue()); } - if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId())){ + if(entry.getValue().getBaseType() == 2){ + welfareRedPackIds.add(entry.getKey()); + } + if(entry.getValue().getBaseType() == 2 && !sWelfareRedPackByRule.containsKey(entry.getValue().getRuleId()[0])){ sWelfareRedPackByRule.put(entry.getValue().getRuleId()[0],entry.getValue()); } if(entry.getValue().getRuleType() == 3){ diff --git a/tablemanager/src/main/java/config/SSpecialConfig.java b/tablemanager/src/main/java/config/SSpecialConfig.java index 6fb54c0f5..0d1a6e6cd 100644 --- a/tablemanager/src/main/java/config/SSpecialConfig.java +++ b/tablemanager/src/main/java/config/SSpecialConfig.java @@ -100,6 +100,7 @@ public class SSpecialConfig implements BaseConfig { public static final String FU_XING = "FuXing";//福星高照可购买天数和可领取天数 public static final String FU_XING_STORE = "FuXingStore";//福星高照购买解锁奖励 public static final String YIJIANGOUMAI = "YiJianGouMai";//一件购买 + public static final String WELFAREREDPACKET_LIMIT = "RedPackMaxGainNum";//每日领取红包数量上限 @Override public void init() throws Exception { diff --git a/tablemanager/src/main/java/config/SSpiritAnimal.java b/tablemanager/src/main/java/config/SSpiritAnimal.java index cc45db747..62fe0bf0e 100644 --- a/tablemanager/src/main/java/config/SSpiritAnimal.java +++ b/tablemanager/src/main/java/config/SSpiritAnimal.java @@ -44,15 +44,19 @@ public class SSpiritAnimal implements BaseConfig { private int[] returnCost; public static Map pieceConfig; + public static Map mapConfig; @Override public void init() throws Exception { Map config = STableManager.getConfig(SSpiritAnimal.class); Map pieceConfigTemp = new HashMap<>(); + Map tempMap = new HashMap<>(); for(Map.Entry entry :config.entrySet()){ pieceConfigTemp.put(entry.getValue().getPiecesId(),entry.getValue()); + tempMap.put(entry.getKey(),entry.getValue()); } pieceConfig = pieceConfigTemp; + mapConfig = tempMap; }