助战系统,初版未完成
parent
3c83e55d89
commit
bca44c2d71
|
@ -305,9 +305,13 @@ public class RedisKey {
|
|||
public final static String WORLD_ARE_JOIN = "WORLD_ARE_JOIN";//跨服参与人员
|
||||
public final static String WARLD_DIS_ARENA_RANK = "WARLD_DIS_ARENA_RANK";//跨服榜单
|
||||
|
||||
public final static String FOUR_CHALLENGE_FIRST = "FOUR_CHALLENGE_FIRST";//四灵试炼首次通关
|
||||
public final static String FOUR_CHALLENGE_MINI_FORCE = "FOUR_CHALLENGE_MINI_FORCE";//四灵试炼最低战力
|
||||
public final static String FOUR_CHALLENGE_TIER_RANK = "FOUR_CHALLENGE_TIER_RANK";//四灵试炼层数排行榜
|
||||
//四灵试炼,0:首次通关,1:最低战力
|
||||
public final static String FOUR_CHALLENGE = "FOUR_CHALLENGE";
|
||||
//四灵试炼层数排行榜
|
||||
public final static String FOUR_CHALLENGE_TIER_RANK = "FOUR_CHALLENGE_TIER_RANK";
|
||||
|
||||
// 助战
|
||||
public final static String HELP_FIGHT = "HELP_FIGHT";
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
|
||||
|
|
|
@ -223,6 +223,8 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
.setWorldLeve(GlobleSystemLogic.getGloableWorldLeveCache())
|
||||
.addAllDemonsTrialRewardInfo(user.getMapManager().getDemonsTrialRewardInfo())
|
||||
.addAllHeadFrameBag(CBean2Proto.getHeadFrameList(user))
|
||||
.addAllHelpFightList(CBean2Proto.gethelpFightList(user))
|
||||
.addAllIsUseHelpHero(CBean2Proto.getisUseHelpHero(user))
|
||||
.build();
|
||||
ReportUtil.onReportEvent(user, ReportEventEnum.APP_LOGIN.getType());
|
||||
try {
|
||||
|
|
|
@ -204,22 +204,22 @@ public class FourChallengeLogic {
|
|||
|
||||
|
||||
// 首次通关记录
|
||||
Map<String, ArenaRecord> first = RedisUtil.getInstence().getMapValues(RedisKey.FOUR_CHALLENGE_FIRST, "", String.class, ArenaRecord.class);
|
||||
Map<String, ArenaRecord> first = RedisUtil.getInstence().getMapValues(RedisKey.FOUR_CHALLENGE, "0", String.class, ArenaRecord.class);
|
||||
if (first.get(floorIds) == null){
|
||||
// 记录redis
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE_FIRST, "", floorIds, arenaRecord);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE, "0", floorIds, arenaRecord);
|
||||
}
|
||||
|
||||
// 最低战力记录
|
||||
Map<String, ArenaRecord> force = RedisUtil.getInstence().getMapValues(RedisKey.FOUR_CHALLENGE_MINI_FORCE, "", String.class, ArenaRecord.class);
|
||||
Map<String, ArenaRecord> force = RedisUtil.getInstence().getMapValues(RedisKey.FOUR_CHALLENGE, "1", String.class, ArenaRecord.class);
|
||||
if (force.get(floorIds) == null){
|
||||
// 记录redis
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE_MINI_FORCE, "", floorIds, arenaRecord);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE, "1", floorIds, arenaRecord);
|
||||
}else {
|
||||
int attackForce = force.get(floorIds).getAttackForce();
|
||||
if (myforce < attackForce){
|
||||
// 记录redis
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE_MINI_FORCE, "", floorIds, arenaRecord);
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FOUR_CHALLENGE, "1", floorIds, arenaRecord);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -515,10 +515,10 @@ public class ArenaLogic {
|
|||
String[] split = fightId.split("#");
|
||||
if ("0".equals(split[1])){
|
||||
// 首通
|
||||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.FOUR_CHALLENGE_FIRST, "", split[0], ArenaRecord.class);
|
||||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.FOUR_CHALLENGE, "0", split[0], ArenaRecord.class);
|
||||
}else if ("1".equals(split[1])){
|
||||
// 最低战力
|
||||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.FOUR_CHALLENGE_MINI_FORCE, "", split[0], ArenaRecord.class);
|
||||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.FOUR_CHALLENGE, "1", split[0], ArenaRecord.class);
|
||||
}
|
||||
}
|
||||
if(arenaRecord == null){
|
||||
|
|
|
@ -137,6 +137,12 @@ public class PlayerManager extends MongoBase {
|
|||
|
||||
private int treeLevel;
|
||||
|
||||
// 使用的助战英雄列表
|
||||
private Set<Integer> helpfights = new HashSet<>();
|
||||
// 是否使用过助战英雄
|
||||
// 0:未选中,1:已选未使用,2:已使用
|
||||
private int[] isUseHelpHero = new int[4];
|
||||
|
||||
private Map<Integer,Integer> situationPass = new HashMap<>();
|
||||
|
||||
// 四灵试炼层数
|
||||
|
@ -946,5 +952,22 @@ public class PlayerManager extends MongoBase {
|
|||
updateString("treeLevel",treeLevel);
|
||||
}
|
||||
|
||||
public Set<Integer> getHelpfights() {
|
||||
return helpfights;
|
||||
}
|
||||
|
||||
public void addHelpfights(Integer heroId) {
|
||||
helpfights.add(heroId);
|
||||
updateString("helpfights",helpfights);
|
||||
}
|
||||
|
||||
public int[] getIsUseHelpHero() {
|
||||
return isUseHelpHero;
|
||||
}
|
||||
|
||||
public void updateIsUseHelpHero(int index,int value) {
|
||||
isUseHelpHero[index] = value;
|
||||
updateString("isUseHelpHero",isUseHelpHero);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,39 @@
|
|||
package com.ljsd.jieling.logic.help;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class GetHelpHeroListHandler extends BaseHandler<PlayerInfoProto.HelpFightListRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.HelpFightListRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(int uid, PlayerInfoProto.HelpFightListRequest proto) throws Exception {
|
||||
|
||||
// 用户信息
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||
}
|
||||
|
||||
// 根据类型获取枚举对象
|
||||
HelpTypeEnum type = HelpTypeEnum.getType(proto.getType());
|
||||
|
||||
List<CommonProto.HelpFightList> helpFighList = HelpHeroLogic.getInstance().getHelpFighList(user, type);
|
||||
|
||||
return PlayerInfoProto.HelpFightListResponse.newBuilder().addAllHelpHeros(helpFighList).build();
|
||||
}
|
||||
}
|
|
@ -0,0 +1,38 @@
|
|||
package com.ljsd.jieling.logic.help;
|
||||
|
||||
import rpc.protocols.CommonProto;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 包装类
|
||||
*/
|
||||
public class HelpFightListVo {
|
||||
private CommonProto.HelpFightList helpFightList;
|
||||
|
||||
public CommonProto.HelpFightList getHelpFightList() {
|
||||
return helpFightList;
|
||||
}
|
||||
|
||||
public void setHelpFightList(CommonProto.HelpFightList helpFightList) {
|
||||
this.helpFightList = helpFightList;
|
||||
}
|
||||
|
||||
public HelpFightListVo(CommonProto.HelpFightList helpFightList) {
|
||||
this.helpFightList = helpFightList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
HelpFightListVo that = (HelpFightListVo) o;
|
||||
return Objects.equals(helpFightList, that.helpFightList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(helpFightList);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,70 @@
|
|||
package com.ljsd.jieling.logic.help;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 援助英雄类
|
||||
*/
|
||||
public class HelpHero {
|
||||
/**
|
||||
* 援助用户id
|
||||
*/
|
||||
private int uid;
|
||||
/**
|
||||
* 援助类型:好友,公会
|
||||
*/
|
||||
private int helpType;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private long creatTime;
|
||||
/**
|
||||
* 功能类型
|
||||
*/
|
||||
private HelpTypeEnum functionType;
|
||||
/**
|
||||
* 英雄信息
|
||||
*/
|
||||
private Hero hero;
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getHelpType() {
|
||||
return helpType;
|
||||
}
|
||||
|
||||
public void setHelpType(int helpType) {
|
||||
this.helpType = helpType;
|
||||
}
|
||||
|
||||
public long getCreatTime() {
|
||||
return creatTime;
|
||||
}
|
||||
|
||||
public void setCreatTime(long creatTime) {
|
||||
this.creatTime = creatTime;
|
||||
}
|
||||
|
||||
public HelpTypeEnum getFunctionType() {
|
||||
return functionType;
|
||||
}
|
||||
|
||||
public void setFunctionType(HelpTypeEnum functionType) {
|
||||
this.functionType = functionType;
|
||||
}
|
||||
|
||||
public Hero getHero() {
|
||||
return hero;
|
||||
}
|
||||
|
||||
public void setHero(Hero hero) {
|
||||
this.hero = hero;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,154 @@
|
|||
package com.ljsd.jieling.logic.help;
|
||||
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import config.SCHero;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import rpc.protocols.CommonProto;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
import static com.ljsd.jieling.logic.help.HelpTypeEnum.Me;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 助战
|
||||
*/
|
||||
public class HelpHeroLogic {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(HelpHeroLogic.class);
|
||||
|
||||
private HelpHeroLogic() {
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static HelpHeroLogic instance = new HelpHeroLogic();
|
||||
}
|
||||
|
||||
public static HelpHeroLogic getInstance() {
|
||||
return HelpHeroLogic.Instance.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据类型获取助战列表
|
||||
* @param user
|
||||
* @param typeEnum
|
||||
* @return
|
||||
*/
|
||||
public List<CommonProto.HelpFightList> getHelpFighList(User user,HelpTypeEnum typeEnum) throws Exception{
|
||||
|
||||
List<CommonProto.HelpFightList> result = new ArrayList<>();
|
||||
|
||||
Set<HelpFightListVo> lists = new HashSet<>();
|
||||
|
||||
// 如果类型是自己,则获取
|
||||
int subKey = typeEnum.getPropertyId() == Me.getPropertyId()?user.getId():typeEnum.getPropertyId();
|
||||
|
||||
// redis获取对应类型的列表 map<uid,助战英雄信息>
|
||||
Map<String, HelpHero> helpHeroMap = RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, String.valueOf(subKey), String.class, HelpHero.class);
|
||||
if (helpHeroMap == null || helpHeroMap.isEmpty()){
|
||||
return result;
|
||||
}
|
||||
|
||||
switch (typeEnum){
|
||||
case Me:
|
||||
// 我的助战
|
||||
for (Map.Entry<String, HelpHero> data:helpHeroMap.entrySet()){
|
||||
lists.add(CBean2Proto.getHelpFight(data.getValue()));
|
||||
}
|
||||
break;
|
||||
case FourChallenge_People:
|
||||
case FourChallenge_Buddha:
|
||||
case FourChallenge_Monster:
|
||||
case FourChallenge_Morality:
|
||||
// 获取四灵类型状态
|
||||
int status = FourChallengeLogic.getInstance().status[typeEnum.getPropertyId()-1];
|
||||
if (status == 0){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"该功能当前未开启");
|
||||
}
|
||||
|
||||
// 好友列表
|
||||
List<Integer> friends = user.getFriendManager().getFriends();
|
||||
// 公会列表
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(user.getPlayerInfoManager().getGuildId());
|
||||
Map<Integer, Set<Integer>> members = guildInfo.getMembers();
|
||||
|
||||
for (Map.Entry<String, HelpHero> data:helpHeroMap.entrySet()){
|
||||
// 好友助战,好友助战必须先于公会助战,这样当同时是好友和公会成员时会显示好友(策划文档要求)
|
||||
if (friends.contains(Integer.parseInt(data.getKey()))){
|
||||
// 此处进行助战类型赋值
|
||||
data.getValue().setHelpType(0);
|
||||
lists.add(CBean2Proto.getHelpFight(data.getValue()));
|
||||
}
|
||||
// 公会助战
|
||||
for (Set<Integer> mem:members.values()){
|
||||
if (mem.contains(Integer.parseInt(data.getKey()))){
|
||||
// 不能获得自己的助战
|
||||
if (Integer.parseInt(data.getKey()) == user.getId()){
|
||||
continue;
|
||||
}
|
||||
// 此处进行助战类型赋值
|
||||
data.getValue().setHelpType(1);
|
||||
lists.add(CBean2Proto.getHelpFight(data.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return result;
|
||||
}
|
||||
|
||||
// 包装类转换
|
||||
for (HelpFightListVo vo:lists){
|
||||
result.add(vo.getHelpFightList());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加助战英雄
|
||||
* @param user
|
||||
* @param heroId
|
||||
* @throws Exception
|
||||
*/
|
||||
public void addHelpFighList(User user,String heroId) throws Exception{
|
||||
Hero hero = user.getHeroManager().getHero(heroId);
|
||||
if (hero == null){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"神将不存在");
|
||||
}
|
||||
// 自己的助战列表
|
||||
Map<String, HelpHero> meMap = RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, String.valueOf(user.getId()), String.class, HelpHero.class);
|
||||
|
||||
// 英雄类型
|
||||
int propertyName = SCHero.getsCHero().get(hero.getTemplateId()).getPropertyName();
|
||||
|
||||
for (Map.Entry<String,HelpHero> data:meMap.entrySet()){
|
||||
if (propertyName == data.getValue().getFunctionType().getPropertyId()){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他神将!");
|
||||
}
|
||||
}
|
||||
// 自己的助战列表添加
|
||||
meMap.put(String.valueOf(user.getId()),CBean2Proto.getHelpHero2(user,hero));
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, String.valueOf(user.getId()), String.valueOf(user.getId()), meMap);
|
||||
|
||||
// 类型助战列表添加
|
||||
Map<String, HelpHero> fourChallengeMap = RedisUtil.getInstence().getMapValues(RedisKey.HELP_FIGHT, String.valueOf(propertyName), String.class, HelpHero.class);
|
||||
// 自己的助战列表没有改类型英雄,那么对应类型的助战列表也应该没有对应英雄,所以这里不再循环验证
|
||||
fourChallengeMap.put(String.valueOf(user.getId()),CBean2Proto.getHelpHero2(user,hero));
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.HELP_FIGHT, String.valueOf(propertyName), String.valueOf(user.getId()), fourChallengeMap);
|
||||
}
|
||||
|
||||
public void useHelpHero(User user,String heroId) throws Exception{
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ljsd.jieling.logic.help;
|
||||
|
||||
/**
|
||||
* @author hj
|
||||
* 助战类型
|
||||
*/
|
||||
public enum HelpTypeEnum {
|
||||
// 我的助战
|
||||
Me(0),
|
||||
// 四灵试炼:人
|
||||
FourChallenge_People(1),
|
||||
// 四灵试炼:佛
|
||||
FourChallenge_Buddha(2),
|
||||
// 四灵试炼:妖
|
||||
FourChallenge_Monster(3),
|
||||
// 四灵试炼:道
|
||||
FourChallenge_Morality(4),
|
||||
|
||||
Error(99999999),
|
||||
;
|
||||
|
||||
private int propertyId;
|
||||
|
||||
HelpTypeEnum(int propertyId) {
|
||||
this.propertyId = propertyId;
|
||||
}
|
||||
|
||||
public int getPropertyId() {
|
||||
return propertyId;
|
||||
}
|
||||
|
||||
public static HelpTypeEnum getType(int type){
|
||||
for (HelpTypeEnum typeEnum:values()){
|
||||
if (typeEnum.propertyId == type){
|
||||
return typeEnum;
|
||||
}
|
||||
}
|
||||
return Error;
|
||||
}
|
||||
}
|
|
@ -13,6 +13,9 @@ import com.ljsd.jieling.logic.dao.*;
|
|||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.help.HelpFightListVo;
|
||||
import com.ljsd.jieling.logic.help.HelpHero;
|
||||
import com.ljsd.jieling.logic.help.HelpTypeEnum;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import config.*;
|
||||
import manager.STableManager;
|
||||
|
@ -109,6 +112,60 @@ public class CBean2Proto {
|
|||
return headFrameLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* 助战,redis类型转hero对象
|
||||
* @param helpHero
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
public static HelpFightListVo getHelpFight(HelpHero helpHero) throws Exception {
|
||||
User user = UserManager.getUser(helpHero.getUid());
|
||||
// 获取英雄信息
|
||||
CommonProto.HelpFightList helpFightList = CommonProto.HelpFightList.newBuilder()
|
||||
.setUid(helpHero.getUid())
|
||||
.setUserName(user.getPlayerInfoManager().getNickName())
|
||||
.setGuildName(helpHero.getFunctionType().getPropertyId())
|
||||
.setTrailType(helpHero.getHelpType())
|
||||
.setHero(getHero(helpHero.getHero()))
|
||||
.build();
|
||||
|
||||
return new HelpFightListVo(helpFightList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 助战,hero对象转redis类型
|
||||
* @param user
|
||||
* @param hero
|
||||
* @return
|
||||
*/
|
||||
public static HelpHero getHelpHero2(User user,Hero hero){
|
||||
|
||||
// 获取神将类型
|
||||
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
|
||||
HelpTypeEnum type = HelpTypeEnum.getType(scHero.getPropertyName());
|
||||
|
||||
// 结果返回,援助类型不在这里写
|
||||
HelpHero helpHero = new HelpHero();
|
||||
helpHero.setUid(user.getId());
|
||||
helpHero.setFunctionType(type);
|
||||
helpHero.setCreatTime(TimeUtils.now());
|
||||
|
||||
return helpHero;
|
||||
}
|
||||
|
||||
public static List<CommonProto.HelpFightList> gethelpFightList(User user){
|
||||
Set<Integer> helpfights = user.getPlayerInfoManager().getHelpfights();
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Integer> getisUseHelpHero(User user){
|
||||
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static CommonProto.Hero getHero(Hero hero){
|
||||
List<CommonProto.SoulPos> soulPoss = new ArrayList<>();
|
||||
Map<Integer, Integer> soulEquipMap = hero.getSoulEquipByPositionMap();
|
||||
|
|
Loading…
Reference in New Issue