心愿活动

back_recharge
duhui 2023-06-06 10:30:25 +08:00
parent a14a867b48
commit 41012e5528
15 changed files with 355 additions and 243 deletions

View File

@ -0,0 +1,57 @@
package com.ljsd.jieling.handler;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.logic.dao.PlayerManager;
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.util.MessageUtil;
import org.springframework.stereotype.Component;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import java.util.Set;
/**
* @Author hj
* @Date 2021/6/29 14:38
* @Description:
* @Version 1.0
*/
@Component
public class DesireDrawCardHandler extends BaseHandler<PlayerInfoProto.DesireDrawCardRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.DESIRE_DRAW_CARD_REQUEST;
}
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.DesireDrawCardRequest proto) throws Exception {
// 用户信息
User user = UserManager.getUser(iSession.getUid());
PlayerManager playerManager = user.getPlayerInfoManager();
int type = proto.getType();
int tempId = proto.getTempId();
switch (type){
case 1: //英雄心愿
Set<Integer> heroList = playerManager.getDesireOpenHeroList();
if (heroList.contains(tempId) || tempId == 0){
playerManager.putDesireDraw(type, tempId);
}
break;
case 4: //法宝心愿
Set<Integer> fabaoList = playerManager.getDesireOpenFabaoList();
if (fabaoList.contains(tempId) || tempId == 0){
playerManager.putDesireDraw(type, tempId);
}
break;
default:
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE);
}
// 更新的英雄列表
PlayerInfoProto.DesireDrawCardResponse build = PlayerInfoProto.DesireDrawCardResponse.newBuilder().setType(type).setTempId(tempId).build();
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.DESIRE_DRAW_CARD_RESPONSE_VALUE, build, true);
}
}

View File

@ -457,21 +457,21 @@ public class GetPlayerInfoHandler extends BaseHandler{
* @param user
*/
private void wishOldUserRandomNumInit(User user){
// 玩家创建时间
long createTime = user.getPlayerInfoManager().getCreateTime();
// 截止时间 2021-10-28 00:00:00
long endTime = 1635350400000L;
// 截止时间之前创建的角色
if (createTime <= endTime){
// 钻石卡池抽奖次数
Integer num = user.getHeroManager().getRandomCountByType().getOrDefault(1,0);
// 限制次数
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
if (num < value){
// 修改次数
user.getHeroManager().putRandomType(1,value);
}
}
// // 玩家创建时间
// long createTime = user.getPlayerInfoManager().getCreateTime();
// // 截止时间 2021-10-28 00:00:00
// long endTime = 1635350400000L;
// // 截止时间之前创建的角色
// if (createTime <= endTime){
// // 钻石卡池抽奖次数
// Integer num = user.getHeroManager().getRandomCountByType().getOrDefault(1,0);
// // 限制次数
// int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
// if (num < value){
// // 修改次数
// user.getHeroManager().putRandomType(1,value);
// }
// }
}
//修行技能数据兼容
private void calPractiveSkillData(User user) {

View File

@ -4,14 +4,13 @@ import com.google.protobuf.GeneratedMessage;
import com.ljsd.GameApplication;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.util.CBean2Proto;
import org.springframework.stereotype.Component;
import rpc.protocols.CommonProto;
import rpc.protocols.HeroInfoProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.*;
import util.TimeUtils;
import java.util.HashSet;
@ -25,33 +24,32 @@ import java.util.Set;
* @Version 1.0
*/
@Component
public class GetWishDrawCardInfoHandler extends BaseHandler<HeroInfoProto.choiceWishHeroRequest> {
public class GetWishDrawCardInfoHandler extends BaseHandler<PlayerInfoProto.choiceWishHeroRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.choiceWishHeroRequest;
}
@Override
public GeneratedMessage processWithProto(int uid, HeroInfoProto.choiceWishHeroRequest proto) throws Exception {
public GeneratedMessage processWithProto(int uid, PlayerInfoProto.choiceWishHeroRequest proto) throws Exception {
// 用户信息
User user = UserManager.getUser(uid);
if (user == null) {
throw new ErrorCodeException(ErrorCode.UNKNOWN);
}
if (proto != null && proto.getInfoListCount() > 0){
HeroLogic.getInstance().updateWishDrawCardInfo(user,proto.getInfoListList());
}
// 心愿信息
List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user);
// 开服时间
int openTime = HeroLogic.getInstance().getServerOpenTimeByWishCard();
Set<Integer> heroList = new HashSet<>();
if (openTime > 0){
heroList = HeroLogic.getInstance().getWishOpenHeroList(user);
int type = proto.getType();
Set<Integer> set = new HashSet<>();
int tmpId = 0;
switch (type){
case 1://英雄卡池
set = ActivityLogic.getInstance().getDesireOpenHeroList(user);
tmpId = user.getPlayerInfoManager().getDesireDraw().getOrDefault(type, 0);
break;
case 4://法宝卡池
set = ActivityLogic.getInstance().getDesireOpenFabaoList(user);
tmpId = user.getPlayerInfoManager().getDesireDraw().getOrDefault(type, 0);
break;
default:
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE);
}
// 更新的英雄列表
return HeroInfoProto.choiceWishHeroResponse.newBuilder()
.addAllInfoList(wishCard).setServerOpenTime(openTime).addAllHeroList(heroList).build();
return PlayerInfoProto.choiceWishHeroResponse.newBuilder().setDesireId(tmpId).addAllNewList(set).build();
}
}

View File

@ -60,16 +60,23 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
List<Integer> dropList = new ArrayList<Integer>();
SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId);
int page = nodeConfig.getChapter()%10 == 0? nodeConfig.getChapter()/10:nodeConfig.getChapter()/10+1;
long createTime = user.getPlayerInfoManager().getCreateTime();
int days = TimeUtils.getSoFarWentDays(createTime, TimeUtils.now());
if (days < nodeConfig.getOpenTime()){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE, "关卡未开启");
}
int page = nodeConfig.getChapter() % 10 == 0 ? nodeConfig.getChapter() / 10 : nodeConfig.getChapter() / 10 + 1;
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user);
if (!chapterMap.containsKey(nodeConfig.getChapter()) ||chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null) {
if (!chapterMap.containsKey(nodeConfig.getChapter()) || chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null) {
//上一个节点
SHardStage preNodeConfig = SHardStage.getConfigMap().get(nodeConfig.getNextLevel());
if(preNodeConfig != null){
if(chapterMap.containsKey(preNodeConfig.getChapter())){
for(int i=0;i< chapterMap.get(preNodeConfig.getChapter()).getNodeList().size();i++){
if(chapterMap.get(preNodeConfig.getChapter()).getNodeList().get(i).getId() ==preNodeConfig.getId()
&& chapterMap.get(preNodeConfig.getChapter()).getNodeList().get(i).isHasPass()){
if (preNodeConfig != null) {
if (chapterMap.containsKey(preNodeConfig.getChapter())) {
for (int i = 0; i < chapterMap.get(preNodeConfig.getChapter()).getNodeList().size(); i++) {
if (chapterMap.get(preNodeConfig.getChapter()).getNodeList().get(i).getId() == preNodeConfig.getId()
&& chapterMap.get(preNodeConfig.getChapter()).getNodeList().get(i).isHasPass()) {
//开启新章节 新节点
if (user.getPlayerInfoManager().getLevel() >= nodeConfig.getLevelLimit()) {
int level = user.getPlayerInfoManager().getLevel();
@ -77,14 +84,14 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
}
}
}
} else{
} else {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
}
}else{
} else {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
}
}
if (!chapterMap.containsKey(nodeConfig.getChapter()) ||chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null) {
if (!chapterMap.containsKey(nodeConfig.getChapter()) || chapterMap.get(nodeConfig.getChapter()).getNode(nodeId) == null) {
throw new ErrorCodeException(ErrorCode.newDefineCode("节点信息错误 节点不存在或未开启"));
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
@ -102,7 +109,7 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
node.setHasPass(true);
node.setState(1);
dropList.addAll(HardStageLogic.getFirstRewards(user, nodeConfig));
HardStageLogic.updateChapterAndNodeLevel(user,nodeConfig);
HardStageLogic.updateChapterAndNodeLevel(user, nodeConfig);
logResult = 1;
user.getHardStageManager().updateString("chapterMap." + nodeConfig.getChapter(), chapterMap.get(nodeConfig.getChapter()));
}
@ -110,12 +117,12 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
throw new ErrorCodeException(ErrorCode.newDefineCode("阵容有误!!"));
}
if(nodeConfig.getStageType() == 1){
if(teamId != TeamEnum.HARD_STAGE_TEAM.getTeamId()){
if (nodeConfig.getStageType() == 1) {
if (teamId != TeamEnum.HARD_STAGE_TEAM.getTeamId()) {
return;
}
}else if(nodeConfig.getStageType() == 3){
if(teamId != TeamEnum.VICE_HARD_STAGE_TEAM.getTeamId()){
} else if (nodeConfig.getStageType() == 3) {
if (teamId != TeamEnum.VICE_HARD_STAGE_TEAM.getTeamId()) {
return;
}
}
@ -154,18 +161,18 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
//战斗回放
int force = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
// 首次通关记录
ArenaRecord minForceRecord = RedisUtil.getInstence().get(RedisKey.HARD_STAGE_PASS_MIN_FORCE,String.valueOf(nodeId),ArenaRecord.class);
if(minForceRecord!=null){
if(force< minForceRecord.getAttackForce()){
RedisUtil.getInstence().remove(RedisUtil.getInstence().getKey(RedisKey.HARD_STAGE_PASS_MIN_FORCE,String.valueOf(nodeId),true));
ArenaRecord minForceRecord = RedisUtil.getInstence().get(RedisKey.HARD_STAGE_PASS_MIN_FORCE, String.valueOf(nodeId), ArenaRecord.class);
if (minForceRecord != null) {
if (force < minForceRecord.getAttackForce()) {
RedisUtil.getInstence().remove(RedisUtil.getInstence().getKey(RedisKey.HARD_STAGE_PASS_MIN_FORCE, String.valueOf(nodeId), true));
}
}
LjsdMongoTemplate ljsdMongoTemplate = MongoUtil.getLjsdMongoTemplate();
com.ljsd.jieling.logic.dao.root.ArenaRecord firstPassRecord = ljsdMongoTemplate.findByIdMy(com.ljsd.jieling.logic.dao.root.ArenaRecord._COLLECTION_NAME,"1_"+nodeId, com.ljsd.jieling.logic.dao.root.ArenaRecord.class);
com.ljsd.jieling.logic.dao.root.ArenaRecord minForcePassRecordMongo = ljsdMongoTemplate.findByIdMy(com.ljsd.jieling.logic.dao.root.ArenaRecord._COLLECTION_NAME,"2_"+nodeId, com.ljsd.jieling.logic.dao.root.ArenaRecord.class);
if(firstPassRecord == null ){
com.ljsd.jieling.logic.dao.root.ArenaRecord firstPassRecord = ljsdMongoTemplate.findByIdMy(com.ljsd.jieling.logic.dao.root.ArenaRecord._COLLECTION_NAME, "1_" + nodeId, com.ljsd.jieling.logic.dao.root.ArenaRecord.class);
com.ljsd.jieling.logic.dao.root.ArenaRecord minForcePassRecordMongo = ljsdMongoTemplate.findByIdMy(com.ljsd.jieling.logic.dao.root.ArenaRecord._COLLECTION_NAME, "2_" + nodeId, com.ljsd.jieling.logic.dao.root.ArenaRecord.class);
if (firstPassRecord == null) {
com.ljsd.jieling.logic.dao.root.ArenaRecord arenaRecord = new com.ljsd.jieling.logic.dao.root.ArenaRecord();
arenaRecord.setId("1_"+ nodeId);
arenaRecord.setId("1_" + nodeId);
arenaRecord.setType(1);
arenaRecord.setStageId(nodeId);
arenaRecord.setCreateTime(TimeUtils.nowInt());
@ -176,11 +183,11 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
arenaRecord.setHeadFrame(user.getPlayerInfoManager().getHeadFrame());
arenaRecord.setFightData(fightData.toByteArray());
arenaRecord.setAttackForce(force);
ljsdMongoTemplate.save(user.getId(),arenaRecord);
ljsdMongoTemplate.save(user.getId(), arenaRecord);
}
if(minForcePassRecordMongo == null){
if (minForcePassRecordMongo == null) {
com.ljsd.jieling.logic.dao.root.ArenaRecord minForcePassRecord = new com.ljsd.jieling.logic.dao.root.ArenaRecord();
minForcePassRecord.setId("2_"+ nodeId);
minForcePassRecord.setId("2_" + nodeId);
minForcePassRecord.setType(2);
minForcePassRecord.setStageId(nodeId);
minForcePassRecord.setCreateTime(TimeUtils.nowInt());
@ -191,9 +198,9 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
minForcePassRecord.setHeadFrame(user.getPlayerInfoManager().getHeadFrame());
minForcePassRecord.setFightData(fightData.toByteArray());
minForcePassRecord.setAttackForce(force);
ljsdMongoTemplate.save(user.getId(),minForcePassRecord);
}else {
if(force<minForcePassRecordMongo.getAttackForce()){
ljsdMongoTemplate.save(user.getId(), minForcePassRecord);
} else {
if (force < minForcePassRecordMongo.getAttackForce()) {
minForcePassRecordMongo.setCreateTime(TimeUtils.nowInt());
minForcePassRecordMongo.setAttackId(user.getId());
minForcePassRecordMongo.setLevel(user.getPlayerInfoManager().getLevel());
@ -202,30 +209,30 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
minForcePassRecordMongo.setHeadFrame(user.getPlayerInfoManager().getHeadFrame());
minForcePassRecordMongo.setFightData(fightData.toByteArray());
minForcePassRecordMongo.setAttackForce(force);
ljsdMongoTemplate.save(user.getId(),minForcePassRecordMongo);
ljsdMongoTemplate.save(user.getId(), minForcePassRecordMongo);
}
}
//排行榜星级
int starSum = HardStageLogic.getHardStageStarsSum(user);
if(starSum >0){
if (starSum > 0) {
Poster.getPoster().dispatchEvent(new ShanHeSheJiTuStarEvent(iSession.getUid(), 2, starSum));
//成就任务
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_STARS,starSum);
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_STARS, starSum);
user.getUserMissionManager().onGameEvent(user, GameEvent.MISTY_TRIP);
}
//大关卡通过成就+1
if(nodeConfig.getStageType() == 1){
if (nodeConfig.getStageType() == 1) {
//nodeConfig
int bigStageNumber = SHardStage.getBigStageNumberById(nodeConfig.getId());
if( bigStageNumber>0 ){
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_NODE,bigStageNumber);
if (bigStageNumber > 0) {
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_NODE, bigStageNumber);
}
}
}
}
//参与奖励
if(nodeConfig.getStageType()!= 2){
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_PARTICIPATION_REWARD,1);
if (nodeConfig.getStageType() != 2) {
user.getUserMissionManager().onGameEvent(user, GameEvent.HARSTAGE_PARTICIPATION_REWARD, 1);
}
//排行榜章节
int hardStageId = SHardStage.getStageIdByChapterAndSection(user.getHardStageManager().getCurChapter(), user.getHardStageManager().getCurNode());
@ -242,18 +249,18 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
}
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.HARD_STAGE_FIGHT_START_RESPONSE.getNumber(), fightStartResponse.build(), true);
//更新消息
HardStageLogic.sendHardStageIndication(user,page);
HardStageLogic.sendHardStageIndication(user, page);
//开新分页 新章的时候 推送刷新消息
int maxChapter = chapterMap.keySet().stream().max(Comparator.comparing(Integer::intValue)).orElse(0);
if(maxChapter%10==1){
int nextPage = maxChapter%10 == 0? maxChapter/10:maxChapter/10+1;
if(nextPage!=page){
int maxChapter = chapterMap.keySet().stream().max(Comparator.comparing(Integer::intValue)).orElse(0);
if (maxChapter % 10 == 1) {
int nextPage = maxChapter % 10 == 0 ? maxChapter / 10 : maxChapter / 10 + 1;
if (nextPage != page) {
//更新消息
HardStageLogic.sendHardStageIndication(user,nextPage);
HardStageLogic.sendHardStageIndication(user, nextPage);
}
}
//埋点数据
ReportUtil.onReportEvent(user, ReportEventEnum.HARD_STAGE.getType(),logType ,logSectionId ,String.valueOf(logResult) ,logStarNum );
ReportUtil.onReportEvent(user, ReportEventEnum.HARD_STAGE.getType(), logType, logSectionId, String.valueOf(logResult), logStarNum);
}
}

View File

@ -492,7 +492,7 @@ public class GlobalDataManaager implements IManager {
// 惊喜礼盒,超值基金,零点逻辑(可以同用一个状态)
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),SuperBoxEvent.zero_init));
// 心愿格子信息刷新
HeroLogic.getInstance().resetWishDrawCardInfoMap(user);
// HeroLogic.getInstance().resetWishDrawCardInfoMap(user);
//玉虚论道每日刷新
user.getArenaManager().setCrossYuxulundaoDailyRewad(new ArrayList<>(Arrays.asList(0,0,0)));
//终身卡在线跨天

View File

@ -2028,4 +2028,73 @@ public class ActivityLogic implements IEventHandler{
}
return 0;
}
/**
*
*
* @param user
* @return
*/
public Set<Integer> getDesireOpenHeroList(User user) {
// 开服时间戳
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
// 当前时间戳
long now = TimeUtils.now();
// 差值
long time = now - openTime;
// set存储最新的英雄列表
HashSet<Integer> set = new HashSet<>();
// 全部的英雄列表
Map<Integer, SCHero> heroMap = SCHero.getsCHero();
// 满足条件的放入set
for (SCHero hero : heroMap.values()) {
if (time >= hero.getJoinWishDay()*TimeUtils.DAY){
set.add(hero.getId());
}
}
// set 返回给客户端最新的set
HashSet<Integer> result = new HashSet<>();
// 目前存储的全部set
Set<Integer> heroList = user.getPlayerInfoManager().getDesireOpenHeroList();
// 之前没有记录的为新开放,需要返回给客户端
set.stream().filter(v -> !heroList.contains(v)).forEach(result::add);
// 更新玩家数据库
user.getPlayerInfoManager().setDesireOpenHeroList(set);
return result;
}
/**
*
*
* @param user
* @return
*/
public Set<Integer> getDesireOpenFabaoList(User user) {
// 开服时间戳
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
// 当前时间戳
long now = TimeUtils.now();
// 差值
long time = now - openTime;
// set存储最新的列表
HashSet<Integer> set = new HashSet<>();
// 全部的英雄列表
Map<Integer, SCHero> heroMap = SCHero.getsCHero();
// 满足条件的放入set
for (SCHero hero : heroMap.values()) {
if (time >= hero.getJoinWishDay()*TimeUtils.DAY && hero.getEquipTalismana() != null && hero.getEquipTalismana().length > 1){
set.add(hero.getEquipTalismana()[1]);
}
}
// set 返回给客户端最新的set
HashSet<Integer> result = new HashSet<>();
// 目前存储的全部set
Set<Integer> fabaoList = user.getPlayerInfoManager().getDesireOpenFabaoList();
// 之前没有记录的为新开放,需要返回给客户端
set.stream().filter(v -> !fabaoList.contains(v)).forEach(result::add);
// 更新玩家数据库
user.getPlayerInfoManager().setDesireOpenFabaoList(set);
return result;
}
}

View File

@ -131,8 +131,9 @@ public interface ActivityType {
int DAILY_SPECIAL = 10004;//每日特惠
int WHOLE_LIFE_CARD = 99;//终生卡
int WEEK_CARD = 102;//月卡
int DRAW_LV_CHEST = 117;//抽卡等级宝箱
int DRAW_HERO_LV_CHEST = 117;//抽卡等级宝箱
int FABAO_BOOK_REWARD = 118;//法宝图鉴宝箱
int DRAW_FABAO_LV_CHEST = 119;//抽卡等级宝箱
//***************************************bt活动=====================================//

View File

@ -114,8 +114,9 @@ public enum ActivityTypeEnum {
WHOEL_LIFE_ACTIVITY(ActivityType.WHOLE_LIFE_CARD,WholeLifeActivity::new),//终生卡
ENCHANTER_STORE(ActivityType.ENCHANTER_STORE,DefaultEmptyActivity::new),//寻仙商城
WEEK_CARD(ActivityType.WEEK_CARD,WeekCardActivity::new),//周卡
DRAW_LV_CHEST(ActivityType.DRAW_LV_CHEST,DrawLvChestActivity::new),//抽卡等级宝箱
DRAW_LV_CHEST(ActivityType.DRAW_HERO_LV_CHEST,DrawLvChestActivity::new),//抽卡等级宝箱
FABAO_BOOK_REWARD(ActivityType.FABAO_BOOK_REWARD,FabaoBookRewardActivity::new),//法宝图鉴宝箱
DRAW_FABAO_LV_CHEST(ActivityType.DRAW_FABAO_LV_CHEST,DrawLvChestActivity::new),//抽卡等级宝箱
/****************************************************** bt **********************************************************/
BRUSH_PRIVILEGE(ActivityType.BRUSH_PRIVILEGE, BrushPrivilegeActivity::new),//刷充特权

View File

@ -48,12 +48,13 @@ public class DrawLvChestActivity extends AbstractActivity {
@Override
public List<CommonProto.ActivityInfo.MissionInfo> getAllMissInfo(User user, ActivityMission activityMission, Set<Integer> filter) {
List<CommonProto.ActivityInfo.MissionInfo> missionInfo = new ArrayList<>();
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
// 验证活动是否开启
if (activityMission == null){
if (activityMission == null || activity == null){
return missionInfo;
}
Map<Integer, SWishConfig> map = SWishConfig.map;
int count = user.getHeroManager().getCountByDraw(1);
int count = user.getHeroManager().getCountByDraw(activity.getLotteryType());
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
for (SWishConfig config : map.values()) {
int missionId = config.getId();
@ -120,7 +121,8 @@ public class DrawLvChestActivity extends AbstractActivity {
* @return
*/
boolean checkRewardsProcess(User user, SWishConfig config) {
int count = user.getHeroManager().getCountByDraw(1);
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
int count = user.getHeroManager().getCountByDraw(activity.getLotteryType());
return count >= config.getDrawCardNumber();
}

View File

@ -1,26 +1,19 @@
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.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.EspecialEquipUpEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.SuperBoxEvent;
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.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SWishConfig;
import rpc.protocols.CommonProto;
import rpc.protocols.PlayerInfoProto;
import java.text.MessageFormat;
import java.util.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
/**
* @author hj
@ -125,8 +118,7 @@ public class FabaoBookRewardActivity extends AbstractActivity {
* @return
*/
boolean checkRewardsProcess(User user, SWishConfig config) {
int count = user.getHeroManager().getCountByDraw(1);
return count >= config.getDrawCardNumber();
return true;
}
@Override

View File

@ -211,11 +211,6 @@ public class HeroManager extends MongoBase {
updateString("LifeGridMap."+gridId, LifeGridMap.get(gridId));
}
/**
*
*/
private Set<Integer> wishOpenHeroList = new HashSet<>();
/**
*
*/
@ -652,12 +647,6 @@ public class HeroManager extends MongoBase {
updateString("wishDrawCardInfoMap", wishDrawCardInfoMap);
}
public void putWishDrawCardInfoMap(WishDrawCardInfo wishDrawCardInfo) {
int key = wishDrawCardInfo.getId();
wishDrawCardInfoMap.put(key,wishDrawCardInfo);
updateString("wishDrawCardInfoMap." + key, wishDrawCardInfo);
}
public HashMap<Integer, Integer> getBeautyBagCardInfoMap() {
return beautyBagCardInfoMap;
}
@ -676,26 +665,6 @@ public class HeroManager extends MongoBase {
updateString("trumpSelectItemMap", trumpSelectItemMap);
}
public void putBeautyBagCardInfoMap(Integer key,Integer val) {
this.beautyBagCardInfoMap.put(key,val);
updateString("beautyBagCardInfoMap", beautyBagCardInfoMap);
}
public Set<Integer> getWishOpenHeroList() {
return wishOpenHeroList;
}
public void setWishOpenHeroList(Set<Integer> wishOpenHeroList) {
this.wishOpenHeroList = wishOpenHeroList;
updateString("wishOpenHeroList", wishOpenHeroList);
}
public void addWishOpenHeroList(int heroTid) {
wishOpenHeroList.add(heroTid);
updateString("wishOpenHeroList", wishOpenHeroList);
}
///获取四象心法共鸣等级
public int GetSiXiangGongMingLv(){
int gongmingLv=0;

View File

@ -236,6 +236,21 @@ public class PlayerManager extends MongoBase {
*/
private HashSet<Integer> heroDispatchAgos = new HashSet<>();
/**
*
*/
private Set<Integer> desireOpenHeroList = new HashSet<>();
/**
*
*/
private Set<Integer> desireOpenFabaoList = new HashSet<>();
/**
*
*/
private Map<Integer, Integer> desireDraw = new HashMap<>();
public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME);
}
@ -296,6 +311,33 @@ public class PlayerManager extends MongoBase {
updateString("compensateMark", compensateMark);
}
public Map<Integer, Integer> getDesireDraw() {
return desireDraw;
}
public void putDesireDraw(int type, int tempId) {
this.desireDraw.put(type, tempId);
updateString("desireDraw", desireDraw);
}
public Set<Integer> getDesireOpenHeroList() {
return desireOpenHeroList;
}
public void setDesireOpenHeroList(Set<Integer> set) {
this.desireOpenHeroList = set;
updateString("desireOpenHeroList", desireOpenHeroList);
}
public Set<Integer> getDesireOpenFabaoList() {
return desireOpenFabaoList;
}
public void setDesireOpenFabaoList(Set<Integer> set) {
this.desireOpenFabaoList = set;
updateString("desireOpenFabaoList", desireOpenFabaoList);
}
/**
*
*/

View File

@ -395,22 +395,27 @@ public class HeroLogic {
// 参数
int type = sLotterySetting.getLotteryType();
int[] reward = sLotteryRewardConfig.getReward();
// 限制满足次数
// 心愿抽卡开次数启限制
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
// 对应卡池抽奖次数
Integer num = heroManager.getRandomCountByType().getOrDefault(type, 0);
// 心愿抽卡
int[] result = reward;
if (type == 1 && num >= value) {
// 钻石抽卡并且次数满足
result = wishDrawCardCheck(user, reward, type);
} else if (sLotterySetting.getLotteryType() == 3 && isActivityBeautyBag(sLotterySetting.getActivityId())) {
//乾坤宝盒-许愿魂印
int[] result = null;
// 抽卡逻辑
if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) {
// 乾坤宝盒-许愿魂印
result = BeautyBagDrawCard(user, sLotteryRewardConfig);
} else if(isActivityByIdAndType(sLotterySetting.getActivityId(),ActivityType.TRUMP_GACHA_ACTIVITY)){
}
else if(isActivityByIdAndType(sLotterySetting.getActivityId(),ActivityType.TRUMP_GACHA_ACTIVITY)){
// 天地烘炉
result = TrumpGachaDrawCard(user, sLotteryRewardConfig);
}
else if (num >= value) {
// 心愿抽卡
result = wishDrawCardCheck(user, reward, type);
}else {
// 默认奖励
result = reward;
}
//活动抽奖计数,触发活动
if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) {
@ -498,15 +503,6 @@ public class HeroLogic {
return result;
}
private boolean isActivityBeautyBag(int activityId) {
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
if (activity == null) {
return false;
}
return activity.getType() == ActivityType.BEAUTY_BAG;
}
private boolean isActivityByIdAndType(int activityId, int activityType) {
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
if (activity == null) {
@ -540,15 +536,15 @@ public class HeroLogic {
int randomInt = MathUtils.randomInt(10000);
if (randomInt <= weight){
// 读取格子信息
WishDrawCardInfo cardInfo = user.getHeroManager().getWishDrawCardInfoMap().get(1);
Integer integer = user.getPlayerInfoManager().getDesireDraw().getOrDefault(type, 0);
// null表示未中心愿, 该格子已锁定, 是空格子
if (cardInfo == null || cardInfo.getStatus() == 1 || cardInfo.getHeroTid() == 0) {
if (integer == 0) {
return item;
}
// new int[]
int[] result = new int[2];
// 赋值物品id和数量
result[0] = cardInfo.getHeroTid();
result[0] = integer;
result[1] = item[1];
return result;
}
@ -628,23 +624,23 @@ public class HeroLogic {
*
* @param user
*/
private void sendWishCardIndication(User user) {
List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user);
HeroInfoProto.wishDrawCardIndication.Builder list = HeroInfoProto.wishDrawCardIndication.newBuilder().addAllInfoList(wishCard);
MessageUtil.sendIndicationMessage(user.getId(), list.build());
}
// private void sendWishCardIndication(User user) {
// List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user);
// HeroInfoProto.wishDrawCardIndication.Builder list = HeroInfoProto.wishDrawCardIndication.newBuilder().addAllInfoList(wishCard);
// MessageUtil.sendIndicationMessage(user.getId(), list.build());
// }
/**
*
*/
public void resetWishDrawCardInfoMap(User user) {
// 重置状态
HashMap<Integer, WishDrawCardInfo> map = user.getHeroManager().getWishDrawCardInfoMap();
map.values().forEach(v -> v.setStatus(0));
user.getHeroManager().setWishDrawCardInfoMap(map);
// 推送消息
sendWishCardIndication(user);
}
// public void resetWishDrawCardInfoMap(User user) {
// // 重置状态
// HashMap<Integer, WishDrawCardInfo> map = user.getHeroManager().getWishDrawCardInfoMap();
// map.values().forEach(v -> v.setStatus(0));
// user.getHeroManager().setWishDrawCardInfoMap(map);
// // 推送消息
// sendWishCardIndication(user);
// }
/**
*
@ -653,81 +649,51 @@ public class HeroLogic {
* @param list
* @throws ErrorCodeException
*/
public void updateWishDrawCardInfo(User user, List<CommonProto.wishDrawCardInfo> list) throws ErrorCodeException {
HashMap<Integer, WishDrawCardInfo> wishDrawCardInfoMap = user.getHeroManager().getWishDrawCardInfoMap();
// 英雄拷贝
HashMap<Integer, WishDrawCardInfo> map = new HashMap<>(wishDrawCardInfoMap.size());
wishDrawCardInfoMap.forEach((k, v) -> {
try {
map.put(k, v.clone());
} catch (CloneNotSupportedException e) {
e.printStackTrace();
}
});
// 遍历
for (CommonProto.wishDrawCardInfo v : list) {
WishDrawCardInfo cardInfo = map.get(v.getId());
// 英雄未锁定
if (cardInfo != null && cardInfo.getStatus() == 0) {
// 替换英雄
cardInfo.setHeroTid(v.getHeroTid());
}
}
// 获取已选择英雄的类型set集合
Set<Integer> race = new HashSet<>();
map.values().forEach(v -> {
if (v.getHeroTid() != 0) {
SCHero scHero = SCHero.getsCHero().get(v.getHeroTid());
race.add(scHero.getPropertyName());
}
});
// 去除空格子后队列的长度
List<WishDrawCardInfo> infos = new ArrayList<>(map.values());
infos.removeIf(v -> v.getHeroTid() == 0);
// 类型唯一, 如果长度不一致代表有重复类型英雄
if (race.size() != infos.size()) {
throw new ErrorCodeException("有重复类型英雄,替换失败");
}
// 入库
else {
user.getHeroManager().setWishDrawCardInfoMap(map);
}
}
/**
*
*
* @param user
* @return
*/
public Set<Integer> getWishOpenHeroList(User user) {
// 开服时间戳
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
// 当前时间戳
long now = TimeUtils.now();
// 差值
long time = now - openTime;
// set存储最新的英雄列表
HashSet<Integer> set = new HashSet<>();
// 全部的英雄列表
Map<Integer, SCHero> heroMap = SCHero.getsCHero();
// 满足条件的放入set
heroMap.values().stream().filter(v -> v.getJoinWishDay() > 0 && time >= v.getJoinWishDay() * TimeUtils.DAY).forEach(v -> set.add(v.getId()));
// set 返回给客户端最新的set
HashSet<Integer> result = new HashSet<>();
// 目前存储的全部set
Set<Integer> heroList = user.getHeroManager().getWishOpenHeroList();
// 之前没有记录的为新开放,需要返回给客户端
set.stream().filter(v -> !heroList.contains(v)).forEach(result::add);
// 更新玩家数据库
user.getHeroManager().setWishOpenHeroList(set);
return result;
}
// public void updateWishDrawCardInfo(User user, List<CommonProto.wishDrawCardInfo> list) throws ErrorCodeException {
// HashMap<Integer, WishDrawCardInfo> wishDrawCardInfoMap = user.getHeroManager().getWishDrawCardInfoMap();
//
// // 英雄拷贝
// HashMap<Integer, WishDrawCardInfo> map = new HashMap<>(wishDrawCardInfoMap.size());
// wishDrawCardInfoMap.forEach((k, v) -> {
// try {
// map.put(k, v.clone());
// } catch (CloneNotSupportedException e) {
// e.printStackTrace();
// }
// });
//
// // 遍历
// for (CommonProto.wishDrawCardInfo v : list) {
// WishDrawCardInfo cardInfo = map.get(v.getId());
// // 英雄未锁定
// if (cardInfo != null && cardInfo.getStatus() == 0) {
// // 替换英雄
// cardInfo.setHeroTid(v.getHeroTid());
// }
// }
//
// // 获取已选择英雄的类型set集合
// Set<Integer> race = new HashSet<>();
// map.values().forEach(v -> {
// if (v.getHeroTid() != 0) {
// SCHero scHero = SCHero.getsCHero().get(v.getHeroTid());
// race.add(scHero.getPropertyName());
// }
// });
//
// // 去除空格子后队列的长度
// List<WishDrawCardInfo> infos = new ArrayList<>(map.values());
// infos.removeIf(v -> v.getHeroTid() == 0);
//
// // 类型唯一, 如果长度不一致代表有重复类型英雄
// if (race.size() != infos.size()) {
// throw new ErrorCodeException("有重复类型英雄,替换失败");
// }
// // 入库
// else {
// user.getHeroManager().setWishDrawCardInfoMap(map);
// }
// }
/**
*

View File

@ -51,10 +51,12 @@ public class SGlobalActivity implements BaseConfig {
private int privilege;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules;
private int lotteryType;
public static Map<Integer, Integer> sRechargeId2ActivityId;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules;
public static Map<Integer, Integer> sRechargeId2ActivityId;
@Override
public void init() throws Exception {
Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByTypeTmp = new HashMap<>();
@ -241,4 +243,8 @@ public class SGlobalActivity implements BaseConfig {
public int getPrivilege() {
return privilege;
}
public int getLotteryType() {
return lotteryType;
}
}

View File

@ -27,6 +27,8 @@ public class SHardStage implements BaseConfig {
private int levelLimit;
private int openTime;
private int star;
private int monsterGroup;
@ -161,8 +163,8 @@ public class SHardStage implements BaseConfig {
return bigStageNumber;
}
public void setBigStageNumber(int bigStageNumber) {
this.bigStageNumber = bigStageNumber;
public int getOpenTime() {
return openTime;
}
public static int getStageIdByChapterAndSection(int chapter, int section){