心愿活动

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

View File

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

View File

@ -60,6 +60,13 @@ public class StartHardStageRequestHandler extends BaseHandler<PlayerInfoProto.Ha
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder(); CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
List<Integer> dropList = new ArrayList<Integer>(); List<Integer> dropList = new ArrayList<Integer>();
SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId); SHardStage nodeConfig = SHardStage.getConfigMap().get(nodeId);
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; int page = nodeConfig.getChapter() % 10 == 0 ? nodeConfig.getChapter() / 10 : nodeConfig.getChapter() / 10 + 1;
Map<Integer, HardStageChapter> chapterMap = user.getHardStageManager().getChapterMap(user); 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) {

View File

@ -492,7 +492,7 @@ public class GlobalDataManaager implements IManager {
// 惊喜礼盒,超值基金,零点逻辑(可以同用一个状态) // 惊喜礼盒,超值基金,零点逻辑(可以同用一个状态)
Poster.getPoster().dispatchEvent(new SuperBoxEvent(user.getId(),SuperBoxEvent.zero_init)); 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))); user.getArenaManager().setCrossYuxulundaoDailyRewad(new ArrayList<>(Arrays.asList(0,0,0)));
//终身卡在线跨天 //终身卡在线跨天

View File

@ -2028,4 +2028,73 @@ public class ActivityLogic implements IEventHandler{
} }
return 0; 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 DAILY_SPECIAL = 10004;//每日特惠
int WHOLE_LIFE_CARD = 99;//终生卡 int WHOLE_LIFE_CARD = 99;//终生卡
int WEEK_CARD = 102;//月卡 int WEEK_CARD = 102;//月卡
int DRAW_LV_CHEST = 117;//抽卡等级宝箱 int DRAW_HERO_LV_CHEST = 117;//抽卡等级宝箱
int FABAO_BOOK_REWARD = 118;//法宝图鉴宝箱 int FABAO_BOOK_REWARD = 118;//法宝图鉴宝箱
int DRAW_FABAO_LV_CHEST = 119;//抽卡等级宝箱
//***************************************bt活动=====================================// //***************************************bt活动=====================================//

View File

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

View File

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

View File

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

View File

@ -211,11 +211,6 @@ public class HeroManager extends MongoBase {
updateString("LifeGridMap."+gridId, LifeGridMap.get(gridId)); updateString("LifeGridMap."+gridId, LifeGridMap.get(gridId));
} }
/**
*
*/
private Set<Integer> wishOpenHeroList = new HashSet<>();
/** /**
* *
*/ */
@ -652,12 +647,6 @@ public class HeroManager extends MongoBase {
updateString("wishDrawCardInfoMap", wishDrawCardInfoMap); 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() { public HashMap<Integer, Integer> getBeautyBagCardInfoMap() {
return beautyBagCardInfoMap; return beautyBagCardInfoMap;
} }
@ -676,26 +665,6 @@ public class HeroManager extends MongoBase {
updateString("trumpSelectItemMap", trumpSelectItemMap); 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(){ public int GetSiXiangGongMingLv(){
int gongmingLv=0; int gongmingLv=0;

View File

@ -236,6 +236,21 @@ public class PlayerManager extends MongoBase {
*/ */
private HashSet<Integer> heroDispatchAgos = new HashSet<>(); 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(){ public PlayerManager(){
this.setRootCollection(User._COLLECTION_NAME); this.setRootCollection(User._COLLECTION_NAME);
} }
@ -296,6 +311,33 @@ public class PlayerManager extends MongoBase {
updateString("compensateMark", compensateMark); 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 type = sLotterySetting.getLotteryType();
int[] reward = sLotteryRewardConfig.getReward(); int[] reward = sLotteryRewardConfig.getReward();
// 限制满足次数 // 心愿抽卡开次数启限制
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH); int value = SSpecialConfig.getIntegerValue(SSpecialConfig.UNLOCKCARDWISH);
// 对应卡池抽奖次数 // 对应卡池抽奖次数
Integer num = heroManager.getRandomCountByType().getOrDefault(type, 0); Integer num = heroManager.getRandomCountByType().getOrDefault(type, 0);
// 心愿抽卡 int[] result = null;
int[] result = reward; // 抽卡逻辑
if (type == 1 && num >= value) { if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) {
// 钻石抽卡并且次数满足
result = wishDrawCardCheck(user, reward, type);
} else if (sLotterySetting.getLotteryType() == 3 && isActivityBeautyBag(sLotterySetting.getActivityId())) {
// 乾坤宝盒-许愿魂印 // 乾坤宝盒-许愿魂印
result = BeautyBagDrawCard(user, sLotteryRewardConfig); 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); result = TrumpGachaDrawCard(user, sLotteryRewardConfig);
} }
else if (num >= value) {
// 心愿抽卡
result = wishDrawCardCheck(user, reward, type);
}else {
// 默认奖励
result = reward;
}
//活动抽奖计数,触发活动 //活动抽奖计数,触发活动
if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) { if (isActivityByIdAndType(sLotterySetting.getActivityId(), ActivityType.BEAUTY_BAG)) {
@ -498,15 +503,6 @@ public class HeroLogic {
return result; 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) { private boolean isActivityByIdAndType(int activityId, int activityType) {
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId); SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
if (activity == null) { if (activity == null) {
@ -540,15 +536,15 @@ public class HeroLogic {
int randomInt = MathUtils.randomInt(10000); int randomInt = MathUtils.randomInt(10000);
if (randomInt <= weight){ if (randomInt <= weight){
// 读取格子信息 // 读取格子信息
WishDrawCardInfo cardInfo = user.getHeroManager().getWishDrawCardInfoMap().get(1); Integer integer = user.getPlayerInfoManager().getDesireDraw().getOrDefault(type, 0);
// null表示未中心愿, 该格子已锁定, 是空格子 // null表示未中心愿, 该格子已锁定, 是空格子
if (cardInfo == null || cardInfo.getStatus() == 1 || cardInfo.getHeroTid() == 0) { if (integer == 0) {
return item; return item;
} }
// new int[] // new int[]
int[] result = new int[2]; int[] result = new int[2];
// 赋值物品id和数量 // 赋值物品id和数量
result[0] = cardInfo.getHeroTid(); result[0] = integer;
result[1] = item[1]; result[1] = item[1];
return result; return result;
} }
@ -628,23 +624,23 @@ public class HeroLogic {
* *
* @param user * @param user
*/ */
private void sendWishCardIndication(User user) { // private void sendWishCardIndication(User user) {
List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user); // List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user);
HeroInfoProto.wishDrawCardIndication.Builder list = HeroInfoProto.wishDrawCardIndication.newBuilder().addAllInfoList(wishCard); // HeroInfoProto.wishDrawCardIndication.Builder list = HeroInfoProto.wishDrawCardIndication.newBuilder().addAllInfoList(wishCard);
MessageUtil.sendIndicationMessage(user.getId(), list.build()); // MessageUtil.sendIndicationMessage(user.getId(), list.build());
} // }
/** /**
* *
*/ */
public void resetWishDrawCardInfoMap(User user) { // public void resetWishDrawCardInfoMap(User user) {
// 重置状态 // // 重置状态
HashMap<Integer, WishDrawCardInfo> map = user.getHeroManager().getWishDrawCardInfoMap(); // HashMap<Integer, WishDrawCardInfo> map = user.getHeroManager().getWishDrawCardInfoMap();
map.values().forEach(v -> v.setStatus(0)); // map.values().forEach(v -> v.setStatus(0));
user.getHeroManager().setWishDrawCardInfoMap(map); // user.getHeroManager().setWishDrawCardInfoMap(map);
// 推送消息 // // 推送消息
sendWishCardIndication(user); // sendWishCardIndication(user);
} // }
/** /**
* *
@ -653,81 +649,51 @@ public class HeroLogic {
* @param list * @param list
* @throws ErrorCodeException * @throws ErrorCodeException
*/ */
public void updateWishDrawCardInfo(User user, List<CommonProto.wishDrawCardInfo> list) throws ErrorCodeException { // public void updateWishDrawCardInfo(User user, List<CommonProto.wishDrawCardInfo> list) throws ErrorCodeException {
HashMap<Integer, WishDrawCardInfo> wishDrawCardInfoMap = user.getHeroManager().getWishDrawCardInfoMap(); // HashMap<Integer, WishDrawCardInfo> wishDrawCardInfoMap = user.getHeroManager().getWishDrawCardInfoMap();
//
// 英雄拷贝 // // 英雄拷贝
HashMap<Integer, WishDrawCardInfo> map = new HashMap<>(wishDrawCardInfoMap.size()); // HashMap<Integer, WishDrawCardInfo> map = new HashMap<>(wishDrawCardInfoMap.size());
wishDrawCardInfoMap.forEach((k, v) -> { // wishDrawCardInfoMap.forEach((k, v) -> {
try { // try {
map.put(k, v.clone()); // map.put(k, v.clone());
} catch (CloneNotSupportedException e) { // } catch (CloneNotSupportedException e) {
e.printStackTrace(); // e.printStackTrace();
} // }
}); // });
//
// 遍历 // // 遍历
for (CommonProto.wishDrawCardInfo v : list) { // for (CommonProto.wishDrawCardInfo v : list) {
WishDrawCardInfo cardInfo = map.get(v.getId()); // WishDrawCardInfo cardInfo = map.get(v.getId());
// 英雄未锁定 // // 英雄未锁定
if (cardInfo != null && cardInfo.getStatus() == 0) { // if (cardInfo != null && cardInfo.getStatus() == 0) {
// 替换英雄 // // 替换英雄
cardInfo.setHeroTid(v.getHeroTid()); // cardInfo.setHeroTid(v.getHeroTid());
} // }
} // }
//
// 获取已选择英雄的类型set集合 // // 获取已选择英雄的类型set集合
Set<Integer> race = new HashSet<>(); // Set<Integer> race = new HashSet<>();
map.values().forEach(v -> { // map.values().forEach(v -> {
if (v.getHeroTid() != 0) { // if (v.getHeroTid() != 0) {
SCHero scHero = SCHero.getsCHero().get(v.getHeroTid()); // SCHero scHero = SCHero.getsCHero().get(v.getHeroTid());
race.add(scHero.getPropertyName()); // race.add(scHero.getPropertyName());
} // }
}); // });
//
// 去除空格子后队列的长度 // // 去除空格子后队列的长度
List<WishDrawCardInfo> infos = new ArrayList<>(map.values()); // List<WishDrawCardInfo> infos = new ArrayList<>(map.values());
infos.removeIf(v -> v.getHeroTid() == 0); // infos.removeIf(v -> v.getHeroTid() == 0);
//
// 类型唯一, 如果长度不一致代表有重复类型英雄 // // 类型唯一, 如果长度不一致代表有重复类型英雄
if (race.size() != infos.size()) { // if (race.size() != infos.size()) {
throw new ErrorCodeException("有重复类型英雄,替换失败"); // throw new ErrorCodeException("有重复类型英雄,替换失败");
} // }
// 入库 // // 入库
else { // else {
user.getHeroManager().setWishDrawCardInfoMap(map); // 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;
}
/** /**
* *

View File

@ -51,6 +51,8 @@ public class SGlobalActivity implements BaseConfig {
private int privilege; private int privilege;
private int lotteryType;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType; public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules; public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules;
@ -241,4 +243,8 @@ public class SGlobalActivity implements BaseConfig {
public int getPrivilege() { public int getPrivilege() {
return privilege; return privilege;
} }
public int getLotteryType() {
return lotteryType;
}
} }

View File

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