back_recharge
xuexinpeng 2021-12-22 18:04:05 +08:00
parent e683d993d5
commit 503ef57f57
11 changed files with 220 additions and 26 deletions

View File

@ -372,7 +372,6 @@ public class RedisKey {
public static final String CROSS_LINGMAI_RANK_PERSON = "CROSS_LINGMAI_RANK_PERSON";//灵脉积分排行
public static Set<String> familyKey = new HashSet<>();
/**
* 01

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.activity.fourChallenge.FourChallengeLogic;
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.explorerMap.ExplorerMapLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.player.PlayerLogic;
import com.ljsd.jieling.logic.question.QuestionLogic;
@ -263,6 +264,9 @@ public class GetPlayerInfoHandler extends BaseHandler{
// 无尽秘宝处理
endLessTreasureHandler(user);
expeditionTreasureHandler(user);
//探索挂机
ExplorerMapLogic.getInstance().calOfflineReward(user);
user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_TASK_TYPE,0,user);
MessageUtil.sendIndicationMessage(iSession, 1, MessageTypeProto.MessageType.WorldLevelIndication_VALUE, PlayerInfoProto.WorldLevelIndication.newBuilder().setWorldLeve(GlobleSystemLogic.getGlobalWorldLevelCache()).build(), true);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GET_PLAYERINFO_RESPONSE_VALUE, getPlayerInfoResponse, true);

View File

@ -2,9 +2,12 @@ package com.ljsd.jieling.handler.explorerMap;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
import com.ljsd.jieling.logic.dao.TeamEnum;
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 rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
@ -23,13 +26,18 @@ public class ExplorerMapInfoHandler extends BaseHandler<PlayerInfoProto.Explore
if (user == null) {
return;
}
PlayerInfoProto.ExplorerMapInfoResponse.Builder builder = PlayerInfoProto.ExplorerMapInfoResponse.newBuilder();
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
for(int i = TeamEnum.EXPLORE_TEAM_ONE.getTeamId();i<=TeamEnum.EXPLORE_TEAM_FIVE.getTeamId();i++){
CommonProto.ExplorerMapInfo record;
if(!explorer.containsKey(i)){
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).build();
}else{
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).setMapId(explorer.get(i).getMapId()).setHp(explorer.get(i).getPlayerHp()).
setExploreTime(explorer.get(i).getSendEndTime()).addAllDropReward(explorer.get(i).getDropList()).build();
}
builder.addExploreInfo(record);
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.build(), true);
}
}

View File

@ -1,21 +1,67 @@
package com.ljsd.jieling.handler.explorerMap;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.MessageUtil;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.ExplorerMapPlayerInfoRequest> {
import java.util.List;
public class ExplorerMapPlayerHandler extends BaseHandler<PlayerInfoProto.ExplorerMapPlayerInfoRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ExplorerMapPlayerInfoRequest;
}
@Override
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapPlayerInfoRequest proto) throws Exception{
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user == null) {
return;
}
PlayerInfoProto.ExplorerMapPlayerInfoResponse.Builder builder = PlayerInfoProto.ExplorerMapPlayerInfoResponse.newBuilder();
int mapId = proto.getMapId();
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
RedisUtil redisUtil = RedisUtil.getInstence();
String key;
if (crossGroup == -1) {
key = Integer.toString(mapId);
}else{
//跨服分组
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
}
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
for(String uidStr:list){
CSPlayer csPlayer = CrossServiceLogic.getPlayerByRedis(Integer.parseInt(uidStr));
String serverName = CrossServiceLogic.simplifyServerName(csPlayer.getServerId());
CommonProto.ArenaPersonInfo playerInfo = CommonProto.ArenaPersonInfo.newBuilder()
.setUid(Integer.parseInt(uidStr))
.setLevel(csPlayer.getLevel())
.setName(csPlayer.getName())
.setServername(serverName)
.setTotalForce(csPlayer.getMaxFore()) //.setTotalForce(crossArenaManager.getTotalForce())
.setUserTitle(csPlayer.getUserTitle())
.setUserMount(csPlayer.getUserMount())
.setGender(csPlayer.getSex())
.setUserSkin(csPlayer.getSkin())
.setPracticeLevel(csPlayer.getPracticeLevel())
.setScore(csPlayer.getCrossYuxulundaoNewScore())
.setHead(csPlayer.getHead())
.setHeadFrame(csPlayer.getHeadFrame())
.build();
builder.addPlayerInfo(playerInfo);
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapPlayerInfoResponse.getNumber(), builder.build(), true);
}
}

View File

@ -1,9 +1,24 @@
package com.ljsd.jieling.handler.explorerMap;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SExplore;
import manager.STableManager;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import util.StringUtil;
import util.TimeUtils;
import java.util.Map;
public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.ExplorerMapRewardRequest> {
@Override
@ -13,8 +28,35 @@ public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.Explor
@Override
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapRewardRequest proto) throws Exception{
}
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user == null) {
return;
}
PlayerInfoProto.ExplorerMapRewardResponse.Builder builder = PlayerInfoProto.ExplorerMapRewardResponse.newBuilder();
int teamId = proto.getTeamId();
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
if(!explorer.containsKey(teamId)){
return;
}
if(proto.getType() == 0){
//停止探索
ExplorerInfo exInfo = explorer.get(teamId);
if(exInfo.getSendEndTime()> TimeUtils.nowInt()){
int min = (exInfo.getSendEndTime() - TimeUtils.nowInt())/60;
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(exInfo.getMapId());
int [][] drop = new int[1][2];
drop[0][0]=exploreConfig.getCost()[0];
drop[0][1]=exploreConfig.getCost()[1]*min;
MailLogic.getInstance().sendMail(uid, "探索返还晶石", "您提前结束了队伍X在【地图名称】中的探索以下为尚未消耗的晶石请查收。",
StringUtil.parseArrayToString(drop), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.build(), true);
}
}else{
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
ItemUtil.drop(user,explorer.get(teamId).getDropList().stream().mapToInt(Integer::intValue).toArray(),drop,1,0, BIReason.TA_SUI_LING_XIAO);
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.setDrop(drop).build(), true);
}
}
}

View File

@ -1,11 +1,21 @@
package com.ljsd.jieling.handler.explorerMap;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.GlobleSystemLogic;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
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 rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import util.TimeUtils;
import java.util.List;
import java.util.Map;
public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.ExplorerMapSendRequest> {
@ -16,15 +26,46 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
@Override
public void processWithProto(ISession session, PlayerInfoProto.ExplorerMapSendRequest proto) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
if (user == null) {
return;
}
PlayerInfoProto.ExplorerMapSendResponse.Builder builder = PlayerInfoProto.ExplorerMapSendResponse.newBuilder();
List<CommonProto.ExplorerMapSendInfo> reqInfo = proto.getSendDataList();
for (CommonProto.ExplorerMapSendInfo info : reqInfo) {
int mapId = info.getMapId();
int teamId = info.getTeamId();
int time = info.getTime();
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
//TODO 消耗
//TODO redis
RedisUtil redisUtil = RedisUtil.getInstence();
String rkey;
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
String key;
if (crossGroup == -1) {
key = Integer.toString(mapId);
}else{
//跨服分组
key =Integer.toString(crossGroup) + RedisKey.Delimiter_colon + mapId;
}
//rkey = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, key);
List<String> list = redisUtil.lGet(RedisKey.EXPLORER_MAP_PLAYER, key, 0, -1);
if(!list.contains(String.valueOf(user.getId()))){
redisUtil.lSet(key, String.valueOf(user.getId()));
}
ExplorerInfo explorerInfo = new ExplorerInfo();
explorerInfo.setMapId(mapId);
explorerInfo.setSendEndTime(TimeUtils.nowInt() + time);
explorerInfo.setSendTime(time);
explorer.put(teamId, explorerInfo);
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().
setTeamId(teamId).setMapId(mapId).setHp(explorerInfo.getPlayerHp()).
setExploreTime(explorerInfo.getSendEndTime()).addAllDropReward(explorerInfo.getDropList()).build();
builder.addExploreInfo(explorerMapInfo);
}
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapSendResponse.getNumber(), builder.build(), true);
}
}

View File

@ -7,6 +7,7 @@ public class ExplorerInfo {
private int MapId;
private int sendEndTime;//派遣的截止时间
private int sendTime;//派遣时间
private int playerHp;//玩家当前血量
private int playerReliveTime;//玩家复活时间
private int enemyHp;//敌人血量
@ -75,4 +76,12 @@ public class ExplorerInfo {
public void setDropList(List<Integer> dropList) {
this.dropList = dropList;
}
public int getSendTime() {
return sendTime;
}
public void setSendTime(int sendTime) {
this.sendTime = sendTime;
}
}

View File

@ -37,11 +37,11 @@ public enum TeamEnum {
FOURCHALLENGE_MORALITY_TEAM(3004,"四灵试炼-道"),
SEVEN_WORLD_TEAM(2101,"七届试炼编队",1,0),
EXPLORE_TEAM_ONE(2102,"探索第一编队",1,0),
EXPLORE_TEAM_TWO(2103,"探索第二编队",1,0),
EXPLORE_TEAM_TREE(2104,"探索第三编队",1,0),
EXPLORE_TEAM_FOUR(2105,"探索第四编队",1,0),
EXPLORE_TEAM_FIVE(2106,"探索第五编队",1,0),
EXPLORE_TEAM_ONE(3101,"探索第一编队",1,0),
EXPLORE_TEAM_TWO(3102,"探索第二编队",1,0),
EXPLORE_TEAM_TREE(3103,"探索第三编队",1,0),
EXPLORE_TEAM_FOUR(3104,"探索第四编队",1,0),
EXPLORE_TEAM_FIVE(3105,"探索第五编队",1,0),
;
/**

View File

@ -2,6 +2,8 @@ package com.ljsd.jieling.logic.explorerMap;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
@ -9,12 +11,18 @@ import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.util.ItemMap;
import com.ljsd.jieling.util.ItemUtil;
import config.SErrorCodeEerverConfig;
import config.SExplore;
import config.SExploreFight;
import config.SRewardGroup;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
import util.StringUtil;
import util.TimeUtils;
import java.util.ArrayList;
@ -48,7 +56,7 @@ public class ExplorerMapLogic {
}
public static void calOfflineReward(User user){
public void calOfflineReward(User user){
//计算离线奖励
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
if (explorer == null || explorer.size() == 0) {
@ -64,11 +72,13 @@ public class ExplorerMapLogic {
if(TimeUtils.nowInt()> keyVal.getValue().getPlayerReliveTime()+300){
keyVal.getValue().setPlayerReliveTime(keyVal.getValue().getPlayerReliveTime()+300);
keyVal.getValue().setPlayerHp(teamForce);
LOGGER.error("玩家复活");
}
}
if(keyVal.getValue().getEnemyHp() == 0){
if(TimeUtils.nowInt()> keyVal.getValue().getEnemyReliveTime()+300){
keyVal.getValue().setEnemyReliveTime(keyVal.getValue().getEnemyReliveTime()+300);
LOGGER.error("怪物复活");
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(keyVal.getValue().getMapId());
if (exploreConfig == null) {
continue;
@ -106,19 +116,24 @@ public class ExplorerMapLogic {
if (exploreFightData == null) {
return;
}
LOGGER.error("探索表id:={}",exploreFightData.getId());
//掉血比例
float reduceRatio = exploreFightData.getLoseFight();
//玩家掉血
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - (int) (explorerInfo.getPlayerHp() * reduceRatio));
LOGGER.error("玩家掉血:=》{}",(int) (explorerInfo.getPlayerHp() * reduceRatio));
//怪物掉血
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (int) (explorerInfo.getEnemyHp() * reduceRatio));
LOGGER.error("怪物掉血:=》{}",(int) (explorerInfo.getEnemyHp() * reduceRatio));
//玩家死亡 设置重生时间
if (explorerInfo.getPlayerHp() == 0) {
explorerInfo.setPlayerReliveTime(TimeUtils.nowInt() + 300);
LOGGER.error("玩家死亡=》重生时间{}",explorerInfo.getPlayerReliveTime());
}
//怪物死亡 设置重生时间
if (explorerInfo.getEnemyHp() == 0) {
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + 300);
LOGGER.error("怪物死亡=》重生时间={} 掉落id=>{}",explorerInfo.getEnemyReliveTime(),exploreConfig.getReward());
//胜利添加掉落
List<Integer> dropList = explorerInfo.getDropList();
if (dropList == null) {
@ -131,7 +146,7 @@ public class ExplorerMapLogic {
}
//复活怪物 自己血量之类的 在线每分钟监听
public static void recycleFight() {
public void recycleFight() {
try {
Set<Integer> uids = OnlineUserManager.sessionMap.keySet();
for (int uid : uids) {
@ -151,6 +166,7 @@ public class ExplorerMapLogic {
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() >= TimeUtils.nowInt()) {
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, keyVal.getKey(), false);
keyVal.getValue().setPlayerHp(teamForce);
LOGGER.error("复活玩家:");
//打架 TODO
singleBattle(user, keyVal.getKey());
}
@ -162,12 +178,26 @@ public class ExplorerMapLogic {
}
//怪物的初始血量
int mapMonsterForce = exploreConfig.getMonsterForce();
LOGGER.error("复活怪物:");
keyVal.getValue().setEnemyHp(mapMonsterForce);
//打架 TODO
singleBattle(user, keyVal.getKey());
}
}
for (int id : delayId) {
//到期后发奖励
if(explorer.get(id).getDropList().size() ==0 || explorer.get(id).getDropList() == null){
MailLogic.getInstance().sendMail(uid, "探索失败", "您的队伍X在【地图名称】经过X时X分的探索未获取到任何奖励请选择更合适此队伍的地图进行探索。",
"", TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
}else {
ItemMap itemMap = ItemUtil.getItemMapByGroupId(user,explorer.get(id).getDropList().stream().mapToInt(n->n.intValue()).toArray(),1,0, BIReason.TA_SUI_LING_XIAO) ;
int [][] dropArray= itemMap.getItemMap().entrySet().stream().map(n->new int[]{n.getKey(),n.getValue().intValue()}).toArray(int[][]::new);
MailLogic.getInstance().sendMail(uid, "探索奖励", "您的队伍X在【地图名称】经过X时X分的探索共获得以下奖励清查收。",
StringUtil.parseArrayToString(dropArray), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
}
explorer.remove(id);
}
//探索队伍 map <id,(派遣到哪个地图里,派遣的截止时间,玩家,复活时间)>

View File

@ -26,6 +26,7 @@ import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.explorerMap.ExplorerMapLogic;
import com.ljsd.jieling.logic.family.CrossDeathPathLogic;
import com.ljsd.jieling.logic.family.DeathPathLogic;
import com.ljsd.jieling.logic.family.GuildFightLogic;
@ -182,6 +183,13 @@ public class MinuteTask extends Thread {
e.printStackTrace();
LOGGER.error("Exception::=>{}",e.toString());
}
//探索挂机
try {
ExplorerMapLogic.getInstance().recycleFight();
}catch (Exception e){
e.printStackTrace();
LOGGER.error("Exception::=>{}",e.toString());
}
LOGGER.info("MinuteTask end...");
} catch (Exception e) {

View File

@ -232,6 +232,7 @@ public class ItemUtil {
return dropBuilder;
}
public static CommonProto.Drop.Builder drop(User user, int[] dropGroupIds,CommonProto.Drop.Builder dropBuilder,float dropRatio, int isMapping,int reason) throws Exception {
ItemMap itemObj = new ItemMap();
@ -242,6 +243,12 @@ public class ItemUtil {
return dropBuilder;
}
public static ItemMap getItemMapByGroupId(User user, int[] dropGroupIds,float dropRatio, int isMapping,int reason) throws Exception {
ItemMap itemObj = new ItemMap();
combineRewardDropGroup(user, dropGroupIds, dropRatio,itemObj);
return itemObj;
}
/**
* @param user
* @param dropGroupIds