心愿抽卡, 优化提交
parent
c708ffd3e6
commit
18df433074
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
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.dao.UserManager;
|
||||
|
@ -11,8 +12,11 @@ import org.springframework.stereotype.Component;
|
|||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import util.TimeUtils;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
|
@ -38,9 +42,16 @@ public class GetWishDrawCardInfoHandler extends BaseHandler<HeroInfoProto.choice
|
|||
if (proto != null && proto.getInfoListCount() > 0){
|
||||
HeroLogic.getInstance().updateWishDrawCardInfo(user,proto.getInfoListList());
|
||||
}
|
||||
|
||||
// 返回
|
||||
// 心愿信息
|
||||
List<CommonProto.wishDrawCardInfo> wishCard = CBean2Proto.getWishCard(user);
|
||||
return HeroInfoProto.choiceWishHeroResponse.newBuilder().addAllInfoList(wishCard).build();
|
||||
// 开服时间
|
||||
int openTime = HeroLogic.getInstance().getServerOpenTimeByWishCard();
|
||||
Set<Integer> heroList = new HashSet<>();
|
||||
if (openTime > 0){
|
||||
heroList = HeroLogic.getInstance().getWishOpenHeroList(user);
|
||||
}
|
||||
// 更新的英雄列表
|
||||
return HeroInfoProto.choiceWishHeroResponse.newBuilder()
|
||||
.addAllInfoList(wishCard).setServerOpenTime(openTime).addAllHeroList(heroList).build();
|
||||
}
|
||||
}
|
|
@ -89,6 +89,11 @@ public class HeroManager extends MongoBase {
|
|||
*/
|
||||
private Map<Integer, Map<Integer,Integer>> wishCountByStar = new HashMap<>();
|
||||
|
||||
/**
|
||||
* 心愿可以选择的英雄列表
|
||||
*/
|
||||
private Set<Integer> wishOpenHeroList = new HashSet<>();
|
||||
|
||||
public Map<Integer, Integer> getRandomCountByType() {
|
||||
return randomCountByType;
|
||||
}
|
||||
|
@ -439,5 +444,19 @@ public class HeroManager extends MongoBase {
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.hero;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.FamilyHeroInfo;
|
||||
import com.ljsd.jieling.chat.logic.ChatLogic;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
|
@ -601,6 +602,53 @@ public class HeroLogic{
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取可以加入
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* 从抽卡获取服务器开服时间
|
||||
* @return
|
||||
*/
|
||||
public int getServerOpenTimeByWishCard(){
|
||||
// 开服时间
|
||||
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
|
||||
// 根据格式获取时间戳 例子 :20210720
|
||||
int value = SSpecialConfig.getIntegerValue(SSpecialConfig.Data_Of_Unlock_All_Wish_Hero);
|
||||
long time = TimeUtils.stringToTimeLong(String.valueOf(value), "yyyyMMdd");
|
||||
// 规定时间之前开服的返回0
|
||||
if (openTime <= time){
|
||||
return 0;
|
||||
}else {
|
||||
return (int) (openTime/1000);
|
||||
}
|
||||
}
|
||||
|
||||
private void changeRandomItem(User user,int activityId,int[][] random){
|
||||
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(activityId);
|
||||
if(activityMission==null||activityMission.getActivityMissionMap().get(0)==null){
|
||||
|
|
|
@ -62,6 +62,8 @@ public class SCHero implements BaseConfig{
|
|||
|
||||
private int weight;
|
||||
|
||||
private int joinWishDay;
|
||||
|
||||
private Map<Integer,Integer> secondaryFactorMap;
|
||||
|
||||
private Map<Integer, List<Integer>> skillListByStar;
|
||||
|
@ -354,4 +356,8 @@ public class SCHero implements BaseConfig{
|
|||
public int getWeight() {
|
||||
return weight;
|
||||
}
|
||||
|
||||
public int getJoinWishDay() {
|
||||
return joinWishDay;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -109,6 +109,7 @@ public class SSpecialConfig implements BaseConfig {
|
|||
public static final String NUMOFCHOOSEREDSIGN ="NumOfChooseRedSign";//乾坤宝盒选择心愿红色魂印数量
|
||||
|
||||
public static final String LING_LONG_COST = "LingLongCost";//玲珑宝镜消耗道具ID
|
||||
public static final String Data_Of_Unlock_All_Wish_Hero = "DataOfUnlockAllWishHero";//在这个日期前开服的服务器默认解锁所有卡池内神将作为心愿,不走hero表加入心愿时长的判断
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue