探索事件
parent
c15ab64462
commit
86a91c0c2a
|
@ -9,7 +9,6 @@ import com.ljsd.jieling.globals.Global;
|
|||
import com.ljsd.jieling.logic.GlobleSystemLogic;
|
||||
import com.ljsd.jieling.logic.OnlineUserManager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.activity.ActivityType;
|
||||
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
|
||||
import com.ljsd.jieling.logic.activity.crossService.CrossServiceLogic;
|
||||
import com.ljsd.jieling.logic.activity.event.ExploreEvent;
|
||||
|
@ -119,11 +118,11 @@ public class ExplorerMapLogic {
|
|||
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - reducePlayer);
|
||||
explorerInfo.setEnemyHp(0);
|
||||
LOGGER.info("{}玩家掉血:=》{},剩余血量-》{}", user.getId(), reducePlayer, explorerInfo.getPlayerHp());
|
||||
LOGGER.info("{}玩家赢了 怪物死 怪物走复活逻辑=>{} 掉落组=>{}",user.getId(), explorerInfo.getEnemyReliveTime(), exploreConfig.getReward());
|
||||
LOGGER.info("{}玩家赢了 怪物死 怪物走复活逻辑=>{} 掉落组=>{}", user.getId(), explorerInfo.getEnemyReliveTime(), exploreConfig.getReward());
|
||||
//活动是否开启
|
||||
Set<Integer> openActivityIdsByType = ActivityLogic.getInstance().getOpenActivityIdsByType(user, ActivityTypeEnum.EXPLORE_EXPECT_ACTIVITY.getType(), false);
|
||||
//if (ActivityLogic.checkActivityOpen(user, ActivityType.EXPLORE_EXPECT_ACTIVITY)) {
|
||||
if(openActivityIdsByType.size()>0){
|
||||
if (openActivityIdsByType.size() > 0) {
|
||||
//同个工会 死亡计数
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
if (guildId != 0) {
|
||||
|
@ -133,7 +132,7 @@ public class ExplorerMapLogic {
|
|||
Poster.getPoster().dispatchEvent(new ExploreEvent(user.getId(), 1));
|
||||
Set<Integer> allUid = new HashSet<>();
|
||||
allUid.addAll(guildInfo.getMembers().get(GlobalsDef.CHAIRMAN));
|
||||
if(guildInfo.getMembers().get(GlobalsDef.MEMBER)!=null){
|
||||
if (guildInfo.getMembers().get(GlobalsDef.MEMBER) != null) {
|
||||
allUid.addAll(guildInfo.getMembers().get(GlobalsDef.MEMBER));
|
||||
}
|
||||
for (int uid : allUid) {
|
||||
|
@ -161,7 +160,7 @@ public class ExplorerMapLogic {
|
|||
}
|
||||
//玩家死亡 设置重生时间
|
||||
if (explorerInfo.getPlayerHp() == 0) {
|
||||
explorerInfo.setDeathNum(explorerInfo.getDeathNum()+1);
|
||||
explorerInfo.setDeathNum(explorerInfo.getDeathNum() + 1);
|
||||
int reliveTime = SSpecialConfig.getIntegerValue(SSpecialConfig.EXPLORERE_LIVETIME);
|
||||
if (time == 0) {
|
||||
explorerInfo.setPlayerReliveTime(TimeUtils.nowInt() + reliveTime);
|
||||
|
@ -172,14 +171,14 @@ public class ExplorerMapLogic {
|
|||
}
|
||||
//怪物死亡 设置重生时间
|
||||
if (explorerInfo.getEnemyHp() == 0) {
|
||||
explorerInfo.setKillNum(explorerInfo.getKillNum()+1);
|
||||
explorerInfo.setKillNum(explorerInfo.getKillNum() + 1);
|
||||
if (time == 0) {
|
||||
explorerInfo.setEnemyReliveTime(TimeUtils.nowInt() + exploreConfig.getBattleInterval());
|
||||
} else {
|
||||
explorerInfo.setEnemyReliveTime(time + exploreConfig.getBattleInterval());
|
||||
}
|
||||
LOGGER.info("{}怪物死亡=》重生时间{}", user.getId(), explorerInfo.getEnemyReliveTime());
|
||||
RankEnum.toRank(RankEnum.EXPLORE_RANK.getType()).incrementRankScore(user.getId(),"",1);
|
||||
RankEnum.toRank(RankEnum.EXPLORE_RANK.getType()).incrementRankScore(user.getId(), "", 1);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.EXPLORE, MissionType.EXPLORE_ENEMY_NUM,
|
||||
1);
|
||||
|
||||
|
@ -225,6 +224,27 @@ public class ExplorerMapLogic {
|
|||
.build();
|
||||
}
|
||||
|
||||
public static void sendRandomEvent(User user) {
|
||||
ISession sess = OnlineUserManager.sessionMap.get(user.getId());
|
||||
Map<Integer, SExplore> config = STableManager.getConfig(SExplore.class);
|
||||
Map<Integer, SExploreEvent> exploreEventConfig = STableManager.getConfig(SExploreEvent.class);
|
||||
List<SExplore> limitConfig = config.values().stream().filter(n -> n.getLevel() <= user.getPlayerInfoManager().getLevel()).collect(Collectors.toList());
|
||||
Random random = new Random();
|
||||
int randomMapId = random.nextInt(limitConfig.size());
|
||||
SExplore rankExplore = limitConfig.get(randomMapId);
|
||||
int randomEventId = random.nextInt(rankExplore.getEventList().length);
|
||||
int eventId = rankExplore.getEventList()[randomEventId];
|
||||
LOGGER.info("explore add eventId:" + eventId + " randomMapId: " + randomMapId);
|
||||
user.getPlayerInfoManager().addExploreEvent(new KeyVal(eventId, TimeUtils.nowInt() + exploreEventConfig.get(eventId).getTime(), randomMapId + 1));
|
||||
PlayerInfoProto.ExplorerMapIndicationResponse.Builder indication = PlayerInfoProto.ExplorerMapIndicationResponse.newBuilder();
|
||||
List<KeyVal> event = user.getPlayerInfoManager().getExploreEvent();
|
||||
for (KeyVal keyVal : event) {
|
||||
indication.addRandEvent(CommonProto.CommKeyVal.newBuilder().setKey(keyVal.getKey()).setVal(keyVal.getVal()).
|
||||
setVal2(keyVal.getVa2()).build());
|
||||
}
|
||||
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
|
||||
}
|
||||
|
||||
public void calOfflineReward(User user) throws Exception {
|
||||
//计算离线奖励
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
|
@ -252,6 +272,11 @@ public class ExplorerMapLogic {
|
|||
continue;
|
||||
}
|
||||
LOGGER.info("离线玩家队伍id", keyVal.getKey());
|
||||
//探索事件
|
||||
long gapDay = TimeUtils.getGapDaysByTwoTime( TimeUtils.getTimeStamp2(keyVal.getValue().getBatteTime()*1000L), TimeUtils.getTimeStamp2(offlineEndTime*1000L));
|
||||
for(int i = 0;i< gapDay;i++){
|
||||
sendRandomEvent(user);
|
||||
}
|
||||
for (int i = keyVal.getValue().getBatteTime(); i <= offlineEndTime; i = i + battleInterval) {
|
||||
//复活玩家
|
||||
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() <= i) {
|
||||
|
@ -282,21 +307,13 @@ public class ExplorerMapLogic {
|
|||
long now = TimeUtils.now();
|
||||
for (int uid : uids) {
|
||||
User user = UserManager.getUser(uid);
|
||||
if(user == null){
|
||||
if (user == null) {
|
||||
continue;
|
||||
}
|
||||
//登录一分钟后才执行 避免消息线程和分钟线程同时修改数据
|
||||
if(now < user.getPlayerInfoManager().getLoginTime()+60000){
|
||||
if (now < user.getPlayerInfoManager().getLoginTime() + 60000) {
|
||||
continue;
|
||||
}
|
||||
//整点刷出随机事件
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
int minute = calendar.get(Calendar.MINUTE);
|
||||
//sendRandomEvent(user);
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
if(minute == 0){
|
||||
sendRandomEvent(user);
|
||||
}
|
||||
Map<Integer, ExplorerInfo> explorer = user.getPlayerInfoManager().getExplorer();
|
||||
if (explorer == null || explorer.size() == 0) {
|
||||
continue;
|
||||
|
@ -304,7 +321,7 @@ public class ExplorerMapLogic {
|
|||
List<Integer> delayId = new ArrayList<>();
|
||||
List<Integer> deleteMapPlayer = new ArrayList<>(); //地图玩家信息
|
||||
for (Map.Entry<Integer, ExplorerInfo> keyVal : explorer.entrySet()) {
|
||||
if(keyVal.getValue().getMapId() == 0){
|
||||
if (keyVal.getValue().getMapId() == 0) {
|
||||
delayId.add(keyVal.getKey());
|
||||
continue;
|
||||
}
|
||||
|
@ -384,14 +401,13 @@ public class ExplorerMapLogic {
|
|||
MailLogic.getInstance().sendMail(uid, title, content,
|
||||
"", TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
} else {
|
||||
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("exploresuccess_mail_title");
|
||||
String content = SErrorCodeEerverConfig.getFormatMessage("exploresuccess_mail_txt", new Object[]{
|
||||
teamName, mapName, hour,explorer.get(id).getKillNum(),explorer.get(id).getDeathNum()});
|
||||
teamName, mapName, hour, explorer.get(id).getKillNum(), explorer.get(id).getDeathNum()});
|
||||
//CommonProto.Drop.Builder drop = ItemUtil.drop(user, explorer.get(id).getDropItem().stream().toArray(int[][]::new), BIReason.EXPEDITION_BOX_REWARD);
|
||||
int[][] dropArray = explorer.get(id).getDropMap().entrySet().stream().map(n -> new int[]{n.getKey(), n.getValue()}).toArray(int[][]::new);
|
||||
String reward = StringUtil.parseArrayToString(dropArray);
|
||||
LOGGER.info("{}探索{}小时到期发id=>{}邮件,邮件内容=>{}",uid,hour,id,reward);
|
||||
LOGGER.info("{}探索{}小时到期发id=>{}邮件,邮件内容=>{}", uid, hour, id, reward);
|
||||
MailLogic.getInstance().sendMail(uid, title, content,
|
||||
reward, TimeUtils.nowInt(), Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
|
@ -407,6 +423,17 @@ public class ExplorerMapLogic {
|
|||
if (delayId.size() > 0) {
|
||||
user.getPlayerInfoManager().setExplorer(explorer);
|
||||
}
|
||||
|
||||
//探索有消耗 整点刷出随机事件
|
||||
if (explorer.size() > 0) {
|
||||
Calendar calendar = Calendar.getInstance();
|
||||
/*int minute = calendar.get(Calendar.MINUTE);
|
||||
if (minute == 0) {
|
||||
sendRandomEvent(user);
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
}*/
|
||||
sendRandomEvent(user);
|
||||
}
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
@ -414,22 +441,6 @@ public class ExplorerMapLogic {
|
|||
}
|
||||
}
|
||||
|
||||
public static void sendRandomEvent(User user){
|
||||
//map
|
||||
Map<Integer, SExplore> config = STableManager.getConfig(SExplore.class);
|
||||
Map<Integer, SExploreEvent> exploreEventConfig = STableManager.getConfig(SExploreEvent.class);
|
||||
List<SExplore> limitConfig = config.values().stream().filter(n->n.getLevel()<= user.getPlayerInfoManager().getLevel()).collect(Collectors.toList());
|
||||
Random random = new Random();
|
||||
int randomMapId = random.nextInt(limitConfig.size());
|
||||
SExplore rankExplore = limitConfig.get(randomMapId);
|
||||
//user.getPlayerInfoManager().getExploreEvent();
|
||||
|
||||
int randomEventId = random.nextInt(rankExplore.getEventList().length);
|
||||
int eventId = rankExplore.getEventList()[randomEventId];
|
||||
LOGGER.error("explore add eventId:"+eventId+" randomMapId: "+randomMapId);
|
||||
user.getPlayerInfoManager().addExploreEvent(new KeyVal(eventId,TimeUtils.nowInt()+exploreEventConfig.get(eventId).getTime(),randomMapId+1));
|
||||
|
||||
}
|
||||
public static class Instance {
|
||||
public final static ExplorerMapLogic instance = new ExplorerMapLogic();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue