back_recharge
parent
503ef57f57
commit
b9cc3dec5f
|
@ -265,7 +265,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
|
|||
endLessTreasureHandler(user);
|
||||
expeditionTreasureHandler(user);
|
||||
//探索挂机
|
||||
ExplorerMapLogic.getInstance().calOfflineReward(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);
|
||||
|
|
|
@ -11,6 +11,8 @@ import rpc.protocols.CommonProto;
|
|||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ExplorerMapInfoHandler extends BaseHandler<PlayerInfoProto.ExplorerMapInfoRequest> {
|
||||
|
@ -30,11 +32,15 @@ public class ExplorerMapInfoHandler extends BaseHandler<PlayerInfoProto.Explore
|
|||
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;
|
||||
List<CommonProto.CommKeyVal> dropKeyValList = new ArrayList<>();
|
||||
if(!explorer.containsKey(i)){
|
||||
record = CommonProto.ExplorerMapInfo.newBuilder().setTeamId(i).build();
|
||||
}else{
|
||||
for(int[]drop:explorer.get(i).getDropItem() ){
|
||||
dropKeyValList.add( CommonProto.CommKeyVal.newBuilder().setKey(drop[0]).setVal(drop[1]).build());
|
||||
}
|
||||
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();
|
||||
setExploreTime(explorer.get(i).getSendEndTime()).addAllDropReward(dropKeyValList).build();
|
||||
}
|
||||
builder.addExploreInfo(record);
|
||||
}
|
||||
|
|
|
@ -53,8 +53,7 @@ public class ExplorerMapRewardHandler extends BaseHandler<PlayerInfoProto.Explor
|
|||
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);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(teamId).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapInfoResponse.getNumber(), builder.setDrop(drop).build(), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,8 +7,12 @@ 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.logic.explorerMap.ExplorerMapLogic;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SExplore;
|
||||
import manager.STableManager;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
@ -19,6 +23,8 @@ import java.util.Map;
|
|||
|
||||
public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.ExplorerMapSendRequest> {
|
||||
|
||||
|
||||
public static int hourSecond = 3600;
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.ExplorerMapSendRequest;
|
||||
|
@ -33,14 +39,14 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
}
|
||||
PlayerInfoProto.ExplorerMapSendResponse.Builder builder = PlayerInfoProto.ExplorerMapSendResponse.newBuilder();
|
||||
List<CommonProto.ExplorerMapSendInfo> reqInfo = proto.getSendDataList();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
for (CommonProto.ExplorerMapSendInfo info : reqInfo) {
|
||||
int mapId = info.getMapId();
|
||||
int teamId = info.getTeamId();
|
||||
int time = info.getTime();
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
int time = info.getTime() * hourSecond;
|
||||
//TODO 消耗
|
||||
//TODO redis
|
||||
RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
/*RedisUtil redisUtil = RedisUtil.getInstence();
|
||||
String rkey;
|
||||
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
|
||||
String key;
|
||||
|
@ -54,18 +60,30 @@ public class ExplorerMapSendHandler extends BaseHandler<PlayerInfoProto.Explorer
|
|||
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()));
|
||||
}*/
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(mapId);
|
||||
if (exploreConfig == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ExplorerInfo explorerInfo = new ExplorerInfo();
|
||||
explorerInfo.setMapId(mapId);
|
||||
explorerInfo.setSendEndTime(TimeUtils.nowInt() + time);
|
||||
explorerInfo.setSendTime(time);
|
||||
explorer.put(teamId, explorerInfo);
|
||||
//怪物的初始血量
|
||||
int mapMonsterForce = exploreConfig.getMonsterForce();
|
||||
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, teamId, false);
|
||||
explorerInfo.setPlayerHp(teamForce);
|
||||
explorerInfo.setEnemyHp(mapMonsterForce);
|
||||
ExplorerMapLogic.singleBattle(user,teamId);
|
||||
|
||||
//explorer.put(teamId, explorerInfo);
|
||||
CommonProto.ExplorerMapInfo explorerMapInfo = CommonProto.ExplorerMapInfo.newBuilder().
|
||||
setTeamId(teamId).setMapId(mapId).setHp(explorerInfo.getPlayerHp()).
|
||||
setExploreTime(explorerInfo.getSendEndTime()).addAllDropReward(explorerInfo.getDropList()).build();
|
||||
setExploreTime(explorerInfo.getSendEndTime()).build();
|
||||
builder.addExploreInfo(explorerMapInfo);
|
||||
user.getPlayerInfoManager().addExplorer(explorerInfo);
|
||||
}
|
||||
//user.getPlayerInfoManager().setExplorer(explorer);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.ExplorerMapSendResponse.getNumber(), builder.build(), true);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,26 +1,43 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class ExplorerInfo {
|
||||
public class ExplorerInfo extends MongoBase {
|
||||
|
||||
private int MapId;
|
||||
private int mapId;
|
||||
private int sendEndTime;//派遣的截止时间
|
||||
private int sendTime;//派遣时间
|
||||
private int playerHp;//玩家当前血量
|
||||
private int playerReliveTime;//玩家复活时间
|
||||
private int enemyHp;//敌人血量
|
||||
private int enemyReliveTime;//敌人复活时间
|
||||
private List<int[]> dropItem = new ArrayList<>();
|
||||
|
||||
private List<Integer> dropList = new ArrayList<>();
|
||||
|
||||
public ExplorerInfo() {
|
||||
|
||||
}
|
||||
|
||||
public ExplorerInfo(int mapId, int sendEndTime, int sendTime, int playerHp, int playerReliveTime, int enemyHp, int enemyReliveTime, List<int[]> dropItem) {
|
||||
this.mapId = mapId;
|
||||
this.sendEndTime = sendEndTime;
|
||||
this.sendTime = sendTime;
|
||||
this.playerHp = playerHp;
|
||||
this.playerReliveTime = playerReliveTime;
|
||||
this.enemyHp = enemyHp;
|
||||
this.enemyReliveTime = enemyReliveTime;
|
||||
this.dropItem = dropItem;
|
||||
}
|
||||
|
||||
public int getMapId() {
|
||||
return MapId;
|
||||
return mapId;
|
||||
}
|
||||
|
||||
public void setMapId(int mapId) {
|
||||
MapId = mapId;
|
||||
this.mapId = mapId;
|
||||
}
|
||||
|
||||
public int getSendEndTime() {
|
||||
|
@ -69,14 +86,6 @@ public class ExplorerInfo {
|
|||
this.enemyReliveTime = enemyReliveTime;
|
||||
}
|
||||
|
||||
public List<Integer> getDropList() {
|
||||
return dropList;
|
||||
}
|
||||
|
||||
public void setDropList(List<Integer> dropList) {
|
||||
this.dropList = dropList;
|
||||
}
|
||||
|
||||
public int getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
|
@ -84,4 +93,12 @@ public class ExplorerInfo {
|
|||
public void setSendTime(int sendTime) {
|
||||
this.sendTime = sendTime;
|
||||
}
|
||||
|
||||
public List<int[]> getDropItem() {
|
||||
return dropItem;
|
||||
}
|
||||
|
||||
public void setDropItem(List<int[]> dropItem) {
|
||||
this.dropItem = dropItem;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1359,6 +1359,11 @@ public class PlayerManager extends MongoBase {
|
|||
return explorer;
|
||||
}
|
||||
|
||||
public void addExplorer(ExplorerInfo explorer) {
|
||||
explorer.init(this.getRootId(), getMongoKey() + ".explorer." + explorer.getMapId());
|
||||
updateString("explorer." + explorer.getMapId(), explorer);
|
||||
this.explorer.put(explorer.getMapId(),explorer);
|
||||
}
|
||||
public void setExplorer(Map<Integer, ExplorerInfo> explorer) {
|
||||
this.explorer = explorer;
|
||||
updateString("explorer",explorer);
|
||||
|
|
|
@ -29,6 +29,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ExplorerMapLogic {
|
||||
|
||||
|
@ -56,7 +57,8 @@ public class ExplorerMapLogic {
|
|||
|
||||
}
|
||||
|
||||
public void calOfflineReward(User user){
|
||||
public void calOfflineReward(User user) throws Exception{
|
||||
|
||||
//计算离线奖励
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
if (explorer == null || explorer.size() == 0) {
|
||||
|
@ -72,14 +74,15 @@ public class ExplorerMapLogic {
|
|||
if(TimeUtils.nowInt()> keyVal.getValue().getPlayerReliveTime()+300){
|
||||
keyVal.getValue().setPlayerReliveTime(keyVal.getValue().getPlayerReliveTime()+300);
|
||||
keyVal.getValue().setPlayerHp(teamForce);
|
||||
LOGGER.error("玩家复活");
|
||||
LOGGER.error("玩家={}复活 时间:",user.getId(),TimeUtils.getTimeStamp2(TimeUtils.now()));
|
||||
}
|
||||
}
|
||||
if(keyVal.getValue().getEnemyHp() == 0){
|
||||
if(TimeUtils.nowInt()> keyVal.getValue().getEnemyReliveTime()+300){
|
||||
keyVal.getValue().setEnemyReliveTime(keyVal.getValue().getEnemyReliveTime()+300);
|
||||
LOGGER.error("怪物复活");
|
||||
LOGGER.error("复活");
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(keyVal.getValue().getMapId());
|
||||
LOGGER.error("怪物地图={}复活 时间:",exploreConfig.getId(),TimeUtils.getTimeStamp2(TimeUtils.now()));
|
||||
if (exploreConfig == null) {
|
||||
continue;
|
||||
}
|
||||
|
@ -96,7 +99,7 @@ public class ExplorerMapLogic {
|
|||
|
||||
|
||||
//单场战斗
|
||||
public static void singleBattle(User user, int teamId) {
|
||||
public static void singleBattle(User user, int teamId)throws Exception {
|
||||
ExplorerInfo explorerInfo = user.getPlayerInfoManager().getExplorer().get(teamId);
|
||||
if (explorerInfo == null) {
|
||||
return;
|
||||
|
@ -120,10 +123,10 @@ public class ExplorerMapLogic {
|
|||
//掉血比例
|
||||
float reduceRatio = exploreFightData.getLoseFight();
|
||||
//玩家掉血
|
||||
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - (int) (explorerInfo.getPlayerHp() * reduceRatio));
|
||||
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - (int) (teamForce * reduceRatio));
|
||||
LOGGER.error("玩家掉血:=》{}",(int) (explorerInfo.getPlayerHp() * reduceRatio));
|
||||
//怪物掉血
|
||||
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (int) (explorerInfo.getEnemyHp() * reduceRatio));
|
||||
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (int) (mapMonsterForce * reduceRatio));
|
||||
LOGGER.error("怪物掉血:=》{}",(int) (explorerInfo.getEnemyHp() * reduceRatio));
|
||||
//玩家死亡 设置重生时间
|
||||
if (explorerInfo.getPlayerHp() == 0) {
|
||||
|
@ -135,11 +138,19 @@ public class ExplorerMapLogic {
|
|||
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + 300);
|
||||
LOGGER.error("怪物死亡=》重生时间={} 掉落id=>{}",explorerInfo.getEnemyReliveTime(),exploreConfig.getReward());
|
||||
//胜利添加掉落
|
||||
List<Integer> dropList = explorerInfo.getDropList();
|
||||
/* List<Integer> dropList = explorerInfo.getDropList();
|
||||
if (dropList == null) {
|
||||
dropList = new ArrayList<>();
|
||||
}
|
||||
dropList.add(exploreConfig.getReward());
|
||||
dropList.add(exploreConfig.getReward());*/
|
||||
List<int[]> dropitem = explorerInfo.getDropItem();
|
||||
if (dropitem == null) {
|
||||
dropitem = new ArrayList<>();
|
||||
}
|
||||
Map<Integer,Integer> itemMap = ItemUtil.getItemMapByGroupId(user,new int[]{exploreConfig.getReward()},1,0, BIReason.TA_SUI_LING_XIAO);
|
||||
//dropitem.add(new int[]{exploreConfig.getReward()});
|
||||
List<int[]> addDropitem = itemMap.entrySet().stream().map(n->new int[]{n.getKey(),n.getValue()}).collect(Collectors.toList());
|
||||
dropitem.addAll(addDropitem);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -158,12 +169,12 @@ public class ExplorerMapLogic {
|
|||
List<Integer> delayId = new ArrayList<>();
|
||||
for (Map.Entry<Integer, ExplorerInfo> keyVal : explorer.entrySet()) {
|
||||
//到期探索
|
||||
if (keyVal.getValue().getSendEndTime() < TimeUtils.now()) {
|
||||
if (keyVal.getValue().getSendEndTime() < TimeUtils.nowInt()) {
|
||||
delayId.add(keyVal.getKey());
|
||||
}
|
||||
//复活
|
||||
//复活玩家
|
||||
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() >= TimeUtils.nowInt()) {
|
||||
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("复活玩家:");
|
||||
|
@ -171,7 +182,7 @@ public class ExplorerMapLogic {
|
|||
singleBattle(user, keyVal.getKey());
|
||||
}
|
||||
//复活怪物
|
||||
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() >= TimeUtils.nowInt()) {
|
||||
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() <= TimeUtils.nowInt()) {
|
||||
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(keyVal.getValue().getMapId());
|
||||
if (exploreConfig == null) {
|
||||
continue;
|
||||
|
@ -186,19 +197,17 @@ public class ExplorerMapLogic {
|
|||
}
|
||||
for (int id : delayId) {
|
||||
//到期后发奖励
|
||||
if(explorer.get(id).getDropList().size() ==0 || explorer.get(id).getDropList() == null){
|
||||
if(explorer.get(id).getDropItem().size() ==0 || explorer.get(id).getDropItem() == 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);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(id).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
|
||||
int [][] dropArray= explorer.get(id).getDropItem().stream().toArray(int[][]::new);
|
||||
MailLogic.getInstance().sendMail(uid, "探索奖励", "您的队伍X在【地图名称】经过X时X分的探索,共获得以下奖励,清查收。",
|
||||
StringUtil.parseArrayToString(dropArray), TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
|
||||
|
||||
}
|
||||
|
||||
explorer.remove(id);
|
||||
//explorer.remove(id);
|
||||
}
|
||||
//探索队伍 map <id,(派遣到哪个地图里,派遣的截止时间,玩家,复活时间)>
|
||||
//地图怪物 map<地图id,List<>()地图上所有的怪物(怪物id,刷新时间,血量)>
|
||||
|
|
|
@ -243,10 +243,16 @@ public class ItemUtil {
|
|||
return dropBuilder;
|
||||
}
|
||||
|
||||
public static ItemMap getItemMapByGroupId(User user, int[] dropGroupIds,float dropRatio, int isMapping,int reason) throws Exception {
|
||||
public static Map<Integer,Integer> getItemMapByGroupId(User user, int[] dropGroupIds,float dropRatio, int isMapping,int reason) throws Exception {
|
||||
Map<Integer,Integer> combineItem = new HashMap<>();
|
||||
ItemMap itemObj = new ItemMap();
|
||||
combineRewardDropGroup(user, dropGroupIds, dropRatio,itemObj);
|
||||
return itemObj;
|
||||
//TODO Inconvertible types; cannot cast 'java.lang.Long' to 'java.lang.Integer'
|
||||
Map<Integer,Integer> itemMap = itemObj.getItemMap().entrySet().stream().collect(Collectors.toMap(e->e.getKey(),e->Integer.parseInt(e.getValue().toString())));
|
||||
combineItem.putAll(itemObj.getCardMap());
|
||||
combineItem.putAll(itemObj.getEquipMap());
|
||||
combineItem.putAll(itemMap);
|
||||
return combineItem;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue