探索达人

xuexinpeng 2022-02-10 00:04:06 +08:00
parent 1f3fce5ece
commit 9310dcfc4f
8 changed files with 185 additions and 23 deletions

View File

@ -114,6 +114,7 @@ public interface ActivityType {
int NEW_PLAYER_SHOP = 91; // 新人商城
int HERO_UP_STAR_ACTIVITY=94;//限时升星活动
int fESTIVAL_LOGIN_ACTIVITY=95;//节日登录活动
int EXPLORE_EXPECT_ACTIVITY=96;//探索达人活动
int NEW_GENERAL_ATTACK = 200;//新将来袭

View File

@ -102,7 +102,8 @@ public enum ActivityTypeEnum {
NEW_DAILY_RECHARGE(ActivityType.NEW_DAILY_RECHARGE, RechargeRewardActivity::new),
HERO_UP_STAR_ACTIVITY(ActivityType.HERO_UP_STAR_ACTIVITY,HeroUpStarActivity::new),
DAILY_SPECIAL(ActivityType.DAILY_SPECIAL,DefaultEmptyActivity::new),//每日特惠
fESTIVAL_LOGIN_ACTIVITY(ActivityType.fESTIVAL_LOGIN_ACTIVITY,NewEightActivity::new)//节日登录活动
fESTIVAL_LOGIN_ACTIVITY(ActivityType.fESTIVAL_LOGIN_ACTIVITY,NewEightActivity::new),//节日登录活动
EXPLORE_EXPECT_ACTIVITY(ActivityType.EXPLORE_EXPECT_ACTIVITY,ExploreExpectActivity::new)
;
private int type;

View File

@ -0,0 +1,68 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.logic.activity.event.ExploreEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
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.network.session.ISession;
import config.SActivityRewardConfig;
public class ExploreExpectActivity extends AbstractActivity {
public ExploreExpectActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, ExploreEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if (!(event instanceof ExploreEvent))
return;
update(UserManager.getUser(((ExploreEvent) event).getUid()), ((ExploreEvent) event).getNum());
}
@Override
void updateProgress(ActivityMission activityMission, int count) {
activityMission.setV(activityMission.getV() + count);
}
@Override
public void onActivityEnd() throws Exception {
//所有帮会探索计数清0
//GuildInfo guildInfo = GuilidManager.guildInfoMap
}
@Override
boolean takeRewardsProcess(ISession session, SActivityRewardConfig sActivityRewardConfig, ActivityProgressInfo activityProgressInfo) throws Exception {
int[][] values = sActivityRewardConfig.getValues();
//int missionProgress = activityProgressInfo.getProgrss();
User user = UserManager.getUser(session.getUid(), true);
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId != 0 ){
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
return guildInfo.getExploreKillMonsterNum() >= values[0][0];
}
return false;
}
/**
*
*/
@Override
public void onActivityEndOnMySelf(User user) throws Exception {
int guildId = user.getPlayerInfoManager().getGuildId();
if(guildId !=0){
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
if(guildInfo.getExploreKillMonsterNum()!=0){
guildInfo.setExploreKillMonsterNum(0);
}
}
}
}

View File

@ -0,0 +1,27 @@
package com.ljsd.jieling.logic.activity.event;
public class ExploreEvent implements IEvent {
private int uid;
private int num;
public ExploreEvent(int uid, int num) {
this.uid = uid;
this.num = num;
}
public int getUid() {
return uid;
}
public void setUid(int uid) {
this.uid = uid;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
}

View File

@ -66,6 +66,8 @@ public class GuildInfo extends MongoBase {
private List<Integer> historyMember = new ArrayList<>();
private int exploreKillMonsterNum;
public GuildInfo() {
setRootCollection(_COLLECTION_NAME);
}
@ -342,4 +344,14 @@ public class GuildInfo extends MongoBase {
public void updateHistoryMember() {
updateString("historyMember",historyMember);
}
public int getExploreKillMonsterNum() {
return exploreKillMonsterNum;
}
public void setExploreKillMonsterNum(int exploreKillMonsterNum) {
updateString("exploreKillMonsterNum",exploreKillMonsterNum);
this.exploreKillMonsterNum = exploreKillMonsterNum;
}
}

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.explorerMap;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -7,11 +8,18 @@ import com.ljsd.jieling.globals.BIReason;
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;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.ExplorerInfo;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.TeamEnum;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.cross.CSPlayer;
import com.ljsd.jieling.logic.dao.root.GuildInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mail.MailLogic;
@ -25,6 +33,7 @@ import config.SSpecialConfig;
import manager.STableManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.ActivityProto;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
@ -44,7 +53,8 @@ public class ExplorerMapLogic {
public static ExplorerMapLogic getInstance() {
return ExplorerMapLogic.Instance.instance;
}
public static void sendIndication(int uid, ExplorerInfo explorerInfo, int teamId){
public static void sendIndication(int uid, ExplorerInfo explorerInfo, int teamId) {
ISession sess = OnlineUserManager.sessionMap.get(uid);
if (sess != null) {
List<CommonProto.CommKeyVal> dropKeyValList = new ArrayList<>();
@ -59,6 +69,7 @@ public class ExplorerMapLogic {
}
}
//单场战斗
public static void singleBattle(User user, ExplorerInfo explorerInfo, int teamId, int time) throws Exception {
if (explorerInfo == null) {
@ -73,7 +84,7 @@ public class ExplorerMapLogic {
//怪物的初始血量
int mapMonsterForce = exploreConfig.getMonsterForce();
//玩家掉血
float ratio = (float) explorerInfo.getPlayerHp() /explorerInfo.getEnemyHp() ;
float ratio = (float) explorerInfo.getPlayerHp() / explorerInfo.getEnemyHp();
SExploreFight exploreFightData = SExploreFight.getConfigByFightDownAndFightUp(ratio);
if (exploreFightData == null) {
return;
@ -84,7 +95,7 @@ public class ExplorerMapLogic {
//玩家掉血
int reducePlayer = (int) (teamForce * reduceRatio);
//怪物掉血
ratio = (float) explorerInfo.getEnemyHp()/explorerInfo.getPlayerHp();
ratio = (float) explorerInfo.getEnemyHp() / explorerInfo.getPlayerHp();
exploreFightData = SExploreFight.getConfigByFightDownAndFightUp(ratio);
if (exploreFightData == null) {
return;
@ -99,8 +110,8 @@ public class ExplorerMapLogic {
//怪物赢了 保留血量 下次打
explorerInfo.setEnemyHp(explorerInfo.getEnemyHp() - (reduceMonster));
explorerInfo.setPlayerHp(0);
LOGGER.info("{} 怪物赢了,怪物掉血:=》{},剩余血量-》{}", user.getId(),reduceMonster, explorerInfo.getEnemyHp());
sendIndication(user.getId(),explorerInfo,teamId);
LOGGER.info("{} 怪物赢了,怪物掉血:=》{},剩余血量-》{}", user.getId(), reduceMonster, explorerInfo.getEnemyHp());
sendIndication(user.getId(), explorerInfo, teamId);
} else {
Map<Integer, Integer> dropMap = explorerInfo.getDropMap();
if (dropMap == null) {
@ -109,8 +120,35 @@ public class ExplorerMapLogic {
Map<Integer, Integer> itemMap = ItemUtil.getItemMapByGroupId(user, exploreConfig.getReward(), 1, 0, BIReason.EXPLORE_MAP_GET);
explorerInfo.setPlayerHp(explorerInfo.getPlayerHp() - reducePlayer);
explorerInfo.setEnemyHp(0);
LOGGER.info("{}玩家掉血:=》{},剩余血量-》{}", user.getId(),reducePlayer, explorerInfo.getPlayerHp());
LOGGER.info("{}玩家掉血:=》{},剩余血量-》{}", user.getId(), reducePlayer, explorerInfo.getPlayerHp());
LOGGER.info("玩家赢了 怪物死 怪物走复活逻辑=>{} 掉落组=>{}", 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){
//同个工会 死亡计数
int guildId = user.getPlayerInfoManager().getGuildId();
if (guildId != 0) {
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
if (guildInfo != null) {
guildInfo.setExploreKillMonsterNum(guildInfo.getExploreKillMonsterNum() + 1);
Poster.getPoster().dispatchEvent(new ExploreEvent(user.getId(), 1));
Set<Integer> allUid = new HashSet<>();
allUid.addAll(guildInfo.getMembers().get(GlobalsDef.CHAIRMAN));
allUid.addAll(guildInfo.getMembers().get(GlobalsDef.MEMBER));
for (int uid : allUid) {
ISession session = OnlineUserManager.getSessionByUid(uid);
if (session == null) {
continue;
}
ActivityProto.ExploreActivityIndication.Builder indication = ActivityProto.ExploreActivityIndication.newBuilder();
indication.setGuildId(guildId);
indication.setExploreKillMonsterNum(guildInfo.getExploreKillMonsterNum());
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ExploreActivityIndication_VALUE, indication.build(), true);
}
}
}
}
for (Map.Entry<Integer, Integer> keyVal : itemMap.entrySet()) {
if (dropMap.containsKey(keyVal.getKey())) {
dropMap.put(keyVal.getKey(), dropMap.get(keyVal.getKey()) + keyVal.getValue());
@ -119,7 +157,7 @@ public class ExplorerMapLogic {
}
}
explorerInfo.setDropMap(dropMap);
sendIndication(user.getId(),explorerInfo,teamId);
sendIndication(user.getId(), explorerInfo, teamId);
}
//玩家死亡 设置重生时间
if (explorerInfo.getPlayerHp() == 0) {
@ -129,7 +167,7 @@ public class ExplorerMapLogic {
} else {
explorerInfo.setPlayerReliveTime(time + reliveTime);
}
LOGGER.info("{}玩家死亡=》重生时间{}", user.getId(),explorerInfo.getPlayerReliveTime());
LOGGER.info("{}玩家死亡=》重生时间{}", user.getId(), explorerInfo.getPlayerReliveTime());
}
//怪物死亡 设置重生时间
if (explorerInfo.getEnemyHp() == 0) {
@ -192,26 +230,26 @@ public class ExplorerMapLogic {
} else {
offlineEndTime = keyVal.getValue().getSendEndTime();
}
if(keyVal.getValue() == null){
LOGGER.info("ExplorerInfo 数据为空 =>{}",user.getId());
if (keyVal.getValue() == null) {
LOGGER.info("ExplorerInfo 数据为空 =>{}", user.getId());
continue;
}
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(keyVal.getValue().getMapId());
if (exploreConfig == null) {
LOGGER.info("{} SExplore 不存在的id =>{}",user.getId(),keyVal.getValue().getMapId());
LOGGER.info("{} SExplore 不存在的id =>{}", user.getId(), keyVal.getValue().getMapId());
continue;
}
int battleInterval = exploreConfig.getBattleInterval();
if (keyVal.getValue().getBatteTime() >= offlineEndTime) {
continue;
}
LOGGER.info("离线玩家队伍id",keyVal.getKey());
LOGGER.info("离线玩家队伍id", keyVal.getKey());
for (int i = keyVal.getValue().getBatteTime(); i <= offlineEndTime; i = i + battleInterval) {
//复活玩家
if (keyVal.getValue().getPlayerHp() == 0 && keyVal.getValue().getPlayerReliveTime() <= i) {
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, keyVal.getKey(), false);
keyVal.getValue().setPlayerHp(teamForce);
LOGGER.info("{} 离线复活玩家: 玩家战斗时间=》{}",user.getId(),i);
LOGGER.info("{} 离线复活玩家: 玩家战斗时间=》{}", user.getId(), i);
}
//复活怪物
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() <= i) {
@ -221,7 +259,7 @@ public class ExplorerMapLogic {
}
//怪物的初始血量
int mapMonsterForce = exploreConfig.getMonsterForce();
LOGGER.info("{} 离线复活怪物:",user.getId(),i);
LOGGER.info("{} 离线复活怪物:", user.getId(), i);
keyVal.getValue().setEnemyHp(mapMonsterForce);
}
singleBattle(user, keyVal.getValue(), keyVal.getKey(), i);
@ -243,6 +281,9 @@ public class ExplorerMapLogic {
List<Integer> deleteMapPlayer = new ArrayList<>(); //地图玩家信息
for (Map.Entry<Integer, ExplorerInfo> keyVal : explorer.entrySet()) {
//探索时间到期
if(keyVal.getValue().getMapId() == 0){
delayId.add(keyVal.getKey());
}
if (keyVal.getValue().getSendEndTime() < TimeUtils.nowInt()) {
delayId.add(keyVal.getKey());
deleteMapPlayer.add(keyVal.getValue().getMapId());
@ -252,7 +293,7 @@ public class ExplorerMapLogic {
int teamForce = HeroLogic.getInstance().calTeamTotalForce(user, keyVal.getKey(), false);
keyVal.getValue().setPlayerHp(teamForce);
LOGGER.info("复活玩家:" + uid);
sendIndication(user.getId(),keyVal.getValue(),keyVal.getKey());
sendIndication(user.getId(), keyVal.getValue(), keyVal.getKey());
}
//复活怪物
if (keyVal.getValue().getEnemyHp() == 0 && keyVal.getValue().getEnemyReliveTime() <= TimeUtils.nowInt()) {
@ -275,12 +316,12 @@ public class ExplorerMapLogic {
}
}
//地图内到期玩家删除
for(int mapId:deleteMapPlayer){
for (int mapId : deleteMapPlayer) {
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();
String key;
RedisUtil redisUtil = RedisUtil.getInstence();
if (crossGroup == -1) {
key = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER,String.valueOf(mapId));
key = RedisUtil.getInstence().getKey(RedisKey.EXPLORER_MAP_PLAYER, String.valueOf(mapId));
Set<String> set = redisUtil.sGet(key);
if (set.contains(String.valueOf(user.getId()))) {
long remove = RedisUtil.getInstence().setRemove(key, String.valueOf(uid));
@ -305,6 +346,7 @@ public class ExplorerMapLogic {
//到期后发奖励
SExplore exploreConfig = STableManager.getConfig(SExplore.class).get(explorer.get(id).getMapId());
if (exploreConfig == null) {
explorer.remove(id);
continue;
}
String teamName = TeamEnum.getEnumByteamId(id).getRemarks();
@ -333,7 +375,6 @@ public class ExplorerMapLogic {
indication.setExploreInfo(mapInfo);
MessageUtil.sendIndicationMessage(sess, 1, MessageTypeProto.MessageType.ExplorerMapIndicationResponse_VALUE, indication.build(), true);
}
}
if (delayId.size() > 0) {
user.getPlayerInfoManager().setExplorer(explorer);

View File

@ -11,13 +11,15 @@ import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.ktbeans.ReportEventEnum;
import com.ljsd.jieling.ktbeans.ReportUtil;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.CommitSheJiEvent;
import com.ljsd.jieling.logic.activity.event.GuildForceChangeEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UserMainTeamForceEvent;
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.event.*;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.*;
import com.ljsd.jieling.logic.mail.MailLogic;
@ -389,6 +391,15 @@ public class GuildLogic {
Family.FamilyJoinIndicaion build = Family.FamilyJoinIndicaion.newBuilder().setFamilyBaseInfo(CBean2Proto.getFamilyBaseInfo(guildInfo)).setFamilyUserInfo(CBean2Proto.getFamilyUserInfo(user, GlobalsDef.MEMBER)).build();
Family.FamilyJoinResponse response = Family.FamilyJoinResponse.newBuilder().setFamilyJoinIndicaion(build).build();
MessageUtil.sendMessage(session,1,msgId,response,true);
//探索活动个人计数重置
Set<Integer> openActivityIdsByType = ActivityLogic.getInstance().getOpenActivityIdsByType(user, ActivityTypeEnum.EXPLORE_EXPECT_ACTIVITY.getType(), false);
if(openActivityIdsByType.size()!= 0){
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(openActivityIdsByType.toArray()[0]);
if(guildInfo!=null){
activityMission.setV(0);
ActivityLogic.getInstance().sendActivityInfo(user, ActivityType.EXPLORE_EXPECT_ACTIVITY);
}
}
}

View File

@ -959,6 +959,7 @@ public class CBean2Proto {
.setFightResult(familyContribute)
.setPlayerIntoLevel(guildInfo.getIntoLevel())
.setFete(guildInfo.getFete())
.setExploreTimes(guildInfo.getExploreKillMonsterNum())
.build();
}