new fight

back_recharge
wangyuan 2019-09-25 09:58:02 +08:00
parent 08d695dd53
commit 20e9b0f8ec
29 changed files with 482 additions and 595 deletions

View File

@ -129,7 +129,6 @@ local function addBattleData()
end
function BattleMain.Execute(args, fightData, optionData)
print("trfghjdfgucvhbjnfdcgvj")
_seed = args.seed
_type = args.type
_fightData = fightData

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.dao.GuilidManager;
import com.ljsd.jieling.logic.dao.MailingSystemManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.fight.CheckFight;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.netty.server.NettyGameServer;
@ -191,6 +192,7 @@ public class GameApplication {
}
LOGGER.info("close->nettyServer.stop-------------------");
configurableApplicationContext.close();
LOGGER.info("-------------------configurableApplicationContext.close-------------------");

View File

@ -1,108 +0,0 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name ="AdventureConfig")
public class SAdventureConfig implements BaseConfig {
private int id;
private String areaName;
private int[] openLevel;
private int[][] areaLevelLimit;
private int systemBoss;
private int systemBossTime;
private int[] baseRewardGroup;
private int[][] upgradeConsume;
private int[][] randomRewardGroup;
private int[][][] invasionBoss;
private int[][][] invasionBossReward;
private int invasionBossTime;
private int invasionBossRefresh;
private int invasionBossHolding;
private static Map<Integer, SAdventureConfig> config;
public String getAreaName() {
return areaName;
}
@Override
public void init() throws Exception {
config = STableManager.getConfig(SAdventureConfig.class);
}
public static Map<Integer, SAdventureConfig> getConfig() {
return config;
}
public int getId() {
return id;
}
public int[] getOpenLevel() {
return openLevel;
}
public int[][] getAreaLevelLimit() {
return areaLevelLimit;
}
public int getSystemBoss() {
return systemBoss;
}
public int getSystemBossTime() {
return systemBossTime;
}
public int[] getBaseRewardGroup() {
return baseRewardGroup;
}
public int[][] getUpgradeConsume() {
return upgradeConsume;
}
public int[][] getRandomRewardGroup() {
return randomRewardGroup;
}
public int[][][] getInvasionBoss() {
return invasionBoss;
}
public int[][][] getInvasionBossReward() {
return invasionBossReward;
}
public int getInvasionBossTime() {
return invasionBossTime;
}
public int getInvasionBossRefresh() {
return invasionBossRefresh;
}
public int getInvasionBossHolding() {
return invasionBossHolding;
}
}

View File

@ -0,0 +1,109 @@
package com.ljsd.jieling.config;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.Table;
import java.util.Map;
@Table(name ="MainLevelConfig")
public class SMainLevelConfig implements BaseConfig {
private int id;
private int nextLevel;
private int levelLimit;
private int monsterGroup;
private int exp;
private int[] reward;
private int[] randomRewardMin;
private int[] randomReward;
private int recommendFightAbility;
private int rankTime;
private int[][] invasionBoss;
private int[][] invasionBossReward;
private int invasionBossTime;
private int invasionBossRefresh;
private int invasionBossHolding;
public static Map<Integer, SMainLevelConfig> config;
@Override
public void init() throws Exception {
config = STableManager.getConfig(SMainLevelConfig.class);
}
public int getId() {
return id;
}
public int getLevelLimit() {
return levelLimit;
}
public int getMonsterGroup() {
return monsterGroup;
}
public int getExp() {
return exp;
}
public int[] getReward() {
return reward;
}
public int[] getRandomRewardMin() {
return randomRewardMin;
}
public int[] getRandomReward() {
return randomReward;
}
public int getRecommendFightAbility() {
return recommendFightAbility;
}
public int getRankTime() {
return rankTime;
}
public int[][] getInvasionBoss() {
return invasionBoss;
}
public int[][] getInvasionBossReward() {
return invasionBossReward;
}
public int getInvasionBossTime() {
return invasionBossTime;
}
public int getInvasionBossRefresh() {
return invasionBossRefresh;
}
public int getInvasionBossHolding() {
return invasionBossHolding;
}
public int getNextLevel() {
return nextLevel;
}
}

View File

@ -19,7 +19,7 @@ public class STestWelfare implements BaseConfig {
@Override
public void init() throws Exception {
testWelfareMap= STableManager.getConfig(STestWelfare.class);
//testWelfareMap= STableManager.getConfig(STestWelfare.class);
}

View File

@ -41,4 +41,5 @@ public class MongoKey {
public final static String guildMyInfo = "guildMyInfo";
public final static String questionManager = "questionManager";
public final static String bloodyInfo = "bloodyInfo";
public final static String mainLevelManager = "mainLevelManager";
}

View File

@ -84,6 +84,8 @@ public interface BIReason {
int DIRECT_BUY = 52; // 直购
int MAIN_LEVEL_STATE_REWARD = 53; // 关卡挂机奖励
//道具消耗原因 1000开头
int ADVENTURE_UPLEVEL_CONSUME = 1000; //秘境升级
@ -151,4 +153,6 @@ public interface BIReason {
int FAMILY_SET_ICON = 1037;//工会修改图腾
int EXCHANGE_ACTIVITY_CLOSE = 1038;
}

View File

@ -9,9 +9,11 @@ import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.ktbeans.*;
import com.ljsd.jieling.ktbeans.parmsBean.*;
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
import com.ljsd.jieling.logic.dao.UserRecentLoginInfo;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
@ -20,8 +22,12 @@ import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.StringUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.data.mongodb.core.aggregation.ArrayOperators;
import org.springframework.stereotype.Component;
import java.util.List;
import java.util.Map;
@Component
public class LoginRequestHandler extends BaseHandler<PlayerInfoProto.LoginRequest> {
@ -111,10 +117,13 @@ public class LoginRequestHandler extends BaseHandler<PlayerInfoProto.LoginReques
.build();
try {
String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(userId));
RedisUtil.getInstence().del(key);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.LOGIN_RESPONSE_VALUE, loginResponse, true);
MapLogic.getInstance().whenLogin(user);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,0);
KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,0);
} catch (Exception e) {
e.printStackTrace();
}

View File

@ -1,21 +1,21 @@
package com.ljsd.jieling.handler.adventure;
package com.ljsd.jieling.handler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class GetAdventureHandler extends BaseHandler {
public class MainLevelGetInfoHandler extends BaseHandler{
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_INFO_REQUEST;
return MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
CombatLogic.getInstance().getAdventureInfo(iSession);
MapLogic.getInstance().getMainLevelInfo(iSession);
}
}

View File

@ -1,24 +0,0 @@
package com.ljsd.jieling.handler.adventure;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class AdventureChallenegeHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
FightInfoProto.AdventurnChallengeRequest adventurnChallengeRequest = FightInfoProto.AdventurnChallengeRequest.parseFrom(bytes);
CombatLogic.getInstance().adventureChallenge(iSession,adventurnChallengeRequest.getArenaId(),adventurnChallengeRequest.getTeamId(),adventurnChallengeRequest.getSkipFight());
}
}

View File

@ -1,23 +0,0 @@
package com.ljsd.jieling.handler.adventure;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class AdventureLeftHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_LEFT_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
FightInfoProto.AdventureLeftRequest adventureLeftRequest = FightInfoProto.AdventureLeftRequest.parseFrom(netData.parseClientProtoNetData());
CombatLogic.getInstance().leftAdventurePos(iSession,adventureLeftRequest.getType());
}
}

View File

@ -1,23 +0,0 @@
package com.ljsd.jieling.handler.adventure;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.netty.cocdex.PacketNetData;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class AdventureUpLevelHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
CombatLogic.getInstance().adventureUpLevle(iSession,FightInfoProto.AdventureUpLevelRequest.parseFrom(bytes).getArenaId());
}
}

View File

@ -18,6 +18,6 @@ public class TakeAdventureRewardHandler extends BaseHandler {
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
FightInfoProto.TakeAventureRewardRequest takeAventureRewardRequest = FightInfoProto.TakeAventureRewardRequest.parseFrom(netData.parseClientProtoNetData());
CombatLogic.getInstance().takeAdventureReward(iSession,takeAventureRewardRequest.getType(),takeAventureRewardRequest.getPosition());
CombatLogic.getInstance().takeNewAdventureReward(iSession,takeAventureRewardRequest.getType(),takeAventureRewardRequest.getPosition());
}
}

View File

@ -5,7 +5,6 @@ import com.ljsd.jieling.config.*;
import com.ljsd.jieling.core.VipPrivilegeType;
import com.ljsd.jieling.dataReport.reportBeans_37.ChatContentType;
import com.ljsd.jieling.dataReport.reportBeans_37.Repot37EventUtil;
import com.ljsd.jieling.db.mongo.MongoUtil;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.globals.BIReason;
@ -18,7 +17,6 @@ import com.ljsd.jieling.ktbeans.KTGameType;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.StoryEvent;
import com.ljsd.jieling.logic.dao.*;
@ -2297,6 +2295,119 @@ public class MapLogic {
}
/**
*
*/
public void startMainLevelFight(ISession session, int fightId, int teamId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
MainLevelManager mainLevelManager = user.getMainLevelManager();
int mineFightId = mainLevelManager.getFightId();
if (mineFightId != fightId || mainLevelManager.getState()!=1) {
LOGGER.info("startMainLevelFight==> uid={},fightId={}, levelDifficulty is not allow ", uid, fightId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
List<TeamPosHeroInfo> teamPosHeroInfos = user.getTeamPosManager().getTeamPosForHero().get(teamId);
if (teamPosHeroInfos == null || teamPosHeroInfos.size() == 0) {
LOGGER.info("startLevelDifficultyFight==> uid={},fightId={},teamId={}", uid, fightId, teamId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "阵容有误!!");
return;
}
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.STORY.getIndex(),fightId);
user.getTeamPosManager().setCurTeamPosId(teamId);
String fightInfo = fightId + "#" + teamId;
String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid), false);
RedisUtil.getInstence().set(key, fightInfo, sMainLevelConfig.getRankTime() + 100);
//扣除预先道具
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
BehaviorUtil.getLevelDifficultyifficuFightInfo(user, sMainLevelConfig.getMonsterGroup(), teamId, sMainLevelConfig.getRankTime(), fightStartResponse, RedisKey.LEVE_DIFFICULTY_FIGHT);
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
}
public void endMainLevelFight(ISession session, String frames, int fightId, MessageTypeProto.MessageType messageType) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
String fightKey = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_INFO, String.valueOf(uid), false);
String fightInfos = (String) RedisUtil.getInstence().get(fightKey);
if (fightInfos.isEmpty()) {
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey, fightId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
String[] split = fightInfos.split("#");
int checkFightId = Integer.parseInt(split[0]);
if (fightId != checkFightId) {
LOGGER.info("endFight() uid=>{} fightId=>{},checkFightId={}", uid, fightId, checkFightId);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "");
return;
}
String key = RedisKey.getKey(RedisKey.LEVE_DIFFICULTY_FIGHT, Integer.toString(user.getId()), false);
Map<Object, Object> valueMap = RedisUtil.getInstence().hmget(key);
RedisUtil.getInstence().del(key);
if (valueMap == null || valueMap.isEmpty()) {
LOGGER.info("endFight() uid=>{} not start fight", uid);
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "此战斗已结算过 !");
return;
}
int seed = Integer.parseInt((String) valueMap.get(RedisKey.FIGHT_SEED));
CommonProto.FightTeamInfo.Builder builder = CommonProto.FightTeamInfo.newBuilder();
JsonFormat.merge((String) valueMap.get(RedisKey.FIGHT_HEROES), builder);
CommonProto.FightTeamInfo fightTeamInfo = builder.build();
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
int[] checkResult = CheckFight.getInstance().checkFight(seed, sMainLevelConfig.getRankTime(), getFightData, getOptionData,FightType.StoryFight);
//校验结果码 1胜利
int resultCode = checkResult[0];
if (resultCode == -1) {
MessageUtil.sendErrorResponse(session, 0, messageType.getNumber(), "战斗异常!");
return;
} else if (resultCode == 0) {
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
return;
}
//玩家升级
userLevelUp(user, sMainLevelConfig.getExp());
// user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId, 0,1);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sMainLevelConfig.getReward(), 1, 0, BIReason.LEVELDIFFICULTY_FIGHT_REWARD);
openNextMainLevel(user, fightId);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
FightInfoProto.UpdateUserExpIndicaiton updateUserExpIndicaiton = FightInfoProto.UpdateUserExpIndicaiton.newBuilder().setExp(playerInfoManager.getExp()).setLevel(playerInfoManager.getLevel()).build();
FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder();
fightEndResponse.setEnventDrop(drop);
fightEndResponse.setResult(resultCode);
fightEndResponse.build();
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
}
private void openNextMainLevel(User user,int fightId){
int level = user.getPlayerInfoManager().getLevel();
int state = 1;
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
if(sMainLevelConfig.getNextLevel()!=-1){
if(sMainLevelConfig.getLevelLimit()>level){
state =-1;
}
user.getMainLevelManager().updateFight(sMainLevelConfig.getNextLevel(),state);
}
}
public void getMainLevelInfo(ISession session) throws Exception {
User user = UserManager.getUser(session.getUid());
MainLevelManager mainLevelManager = user.getMainLevelManager();
PlayerInfoProto.GetMainLevelInfoResponse mainLevelInfoResponse = CBean2Proto.getMainLevelInfoResponse(mainLevelManager);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_RESPONSE_VALUE,mainLevelInfoResponse,true);
}
/**
*
*
@ -2501,19 +2612,10 @@ public class MapLogic {
Repot37EventUtil.onKtEvent(user, Repot37EventUtil.Report37EventType.ROLE_LEVEUP_EVENT);
}
playerInfoManager.setExp(curExp);
int itemNum = 0;
if (playerInfoManager.getLevel() > oldLevel) {
for (int level = oldLevel + 1; level <= playerInfoManager.getLevel(); level++) {
sPlayerLevelConfig = SPlayerLevelConfig.getsPlayerLevelConfigMap().get(level);
playerInfoManager.setMaxStamina(sPlayerLevelConfig.getMaxEnergy());
itemNum += sPlayerLevelConfig.getAddEnergy();
}
user.getUserMissionManager().onGameEvent(user, GameEvent.USER_LEVELUP,oldLevel+1,playerInfoManager.getLevel());
}
if (itemNum > 0) {
String reward = Global.STAMINA + "#" + itemNum;
ItemUtil.drop(user, StringUtil.parseFiledInt2(reward), BIReason.USER_LEVELUPSTAMINA_REWARD);
}
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
if(sessionByUid!=null){
PlayerInfoProto.UpdateUserExpIndicaiton build = PlayerInfoProto.UpdateUserExpIndicaiton.newBuilder().setExp(playerInfoManager.getExp()).setLevel(playerInfoManager.getLevel()).build();

View File

@ -33,6 +33,8 @@ public class FightEndRequestHandler extends BaseHandler {
MapLogic.getInstance().endSuddlenlyFight(iSession, frames, MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
}else if(type == 5){
MapLogic.getInstance().endMonsterAttackFight(iSession, frames,MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
}else if(type == 6){
MapLogic.getInstance().endMainLevelFight(iSession, frames,fightId,MessageTypeProto.MessageType.FIGHT_END_RESPONSE);
} else {
// MapLogic.getInstance().endFight(iSession, frames, MessageTypeProto.MessageType.FIGHT_END_RESPONSE);

View File

@ -0,0 +1,21 @@
package com.ljsd.jieling.handler.map.mapHandler;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.fight.CombatLogic;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.FightInfoProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class MainLevelTakeStateHandler extends BaseHandler< FightInfoProto.TakeAventureRewardRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.MAIN_LEVEL_TAKE_STATE_REWARD_REQUEST;
}
@Override
public void processWithProto(ISession iSession, FightInfoProto.TakeAventureRewardRequest proto) throws Exception {
CombatLogic.getInstance().takeNewAdventureReward(iSession,proto.getType(),proto.getPosition());
}
}

View File

@ -74,9 +74,9 @@ public class StartFightRequestHandler extends BaseHandler<FightInfoProto.FightSt
MapLogic.getInstance().startSuddlenlyFight(iSession,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
}else if(type == 5){
MapLogic.getInstance().startMonsterAttackFight(iSession,fightId,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
}else if(type == 6){
MapLogic.getInstance().startMainLevelFight(iSession,fightId,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
} else {
// MapLogic.getInstance().startLevelDifficultyFight(iSession,fightId,teamId,type,MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
MessageUtil.sendErrorResponse(iSession, 0, MessageTypeProto.MessageType.FIGHT_START_RESPONSE.getNumber(),"type is wrong:" + type);
}
}

View File

@ -17,8 +17,6 @@ public class OnlineUserManager {
public static Map<Integer, PlayerManager> onlineUserMap = new ConcurrentHashMap<>(10000);
public static Set<Integer> orderAdventureUids= Sets.newConcurrentHashSet();
public static void userOnline(int uid, ISession session) {
sessionMap.put(uid, session);
}
@ -35,7 +33,6 @@ public class OnlineUserManager {
public static void userOffline(int uid) {
sessionMap.remove(uid);
orderAdventureUids.remove(uid);
}

View File

@ -1,11 +1,10 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.config.SErrorCodeEerverConfig;
import com.ljsd.jieling.config.SGlobalActivity;
import com.ljsd.jieling.config.SSevenDaysScore;
import com.ljsd.jieling.config.STreasureTaskConfig;
import com.ljsd.jieling.config.*;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mail.MailLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
@ -53,6 +52,16 @@ public class DefaultEmptyActivity extends AbstractActivity{
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,(int)(System.currentTimeMillis()/1000), Global.MAIL_EFFECTIVE_TIME);
}
}
}else if(sGlobalActivity.getType() == ActivityType.EXCHANGEANDDROP){
int shopId = sGlobalActivity.getShopId();
SStoreConfig sStoreConfig = SStoreConfig.getSstoreConfigBuyStore().get(shopId).get(0);
int removeItemId = sStoreConfig.getCost()[0][1];
Item item = user.getItemManager().getItem(removeItemId);
if(item!=null){
int[][] cost= new int[1][];
cost[0] = new int[]{item.getItemId(),item.getItemNum()};
ItemUtil.itemCost(user,cost, BIReason.EXCHANGE_ACTIVITY_CLOSE,sGlobalActivity.getId());
}
}
}

View File

@ -1,50 +0,0 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.handler.map.TemporaryItems;
import com.ljsd.jieling.logic.dao.root.User;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class AdventureManager extends MongoBase {
private Map<Integer,AdventureStateInfo> adventureStateInfoMap;
private long flushBossTime;
private int takeFirst;
public AdventureManager(){
this.setRootCollection(User._COLLECTION_NAME);
adventureStateInfoMap = new HashMap<>();
}
public Map<Integer, AdventureStateInfo> getAdventureStateInfoMap() {
return adventureStateInfoMap;
}
public void addAdventureStation(AdventureStateInfo adventureStateInfo){
adventureStateInfo.init(getRootId(), getMongoKey() + ".adventureStateInfoMap."+ adventureStateInfo.getPosition());
updateString("adventureStateInfoMap."+adventureStateInfo.getPosition(),adventureStateInfo);
adventureStateInfoMap.put(adventureStateInfo.getPosition(),adventureStateInfo);
}
public void setFlushBossTime(long flushBossTime) {
updateString("flushBossTime",flushBossTime);
this.flushBossTime = flushBossTime;
}
public int getTakeFirst() {
return takeFirst;
}
public void setTakeFirst(int takeFirst) {
updateString("takeFirst",takeFirst);
this.takeFirst = takeFirst;
}
}

View File

@ -1,69 +0,0 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.TimeUtils;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
public class AdventureStateInfo extends MongoBase {
private int position;
private int startTime;
private int level;
private Set<String> bossIds = new HashSet<>();
public AdventureStateInfo(){
this.setRootCollection(User._COLLECTION_NAME);
}
public AdventureStateInfo(int position) {
int now = (int)(TimeUtils.now()/1000);
this.position = position;
this.level=1;
this.startTime = now;
bossIds = new HashSet<>();
}
public int getStartTime() {
return startTime;
}
public int getPosition() {
return position;
}
public Set<String> getBossIds() {
return bossIds;
}
public void setStartTime(int startTime) {
updateString("startTime",startTime);
this.startTime = startTime;
}
public int getLevel() {
return level;
}
public void setLevel(int level) {
updateString("level", level);
this.level = level;
}
public void addBossGroup(String bossId){
bossIds.add(bossId);
updateString("bossIds",bossIds);
}
public void removeBossGroup(String bossId){
bossIds.remove(bossId);
updateString("bossIds",bossIds);
}
public void removeMutBossGroup(Set<String> bossIds){
bossIds.removeAll(bossIds);
updateString("bossIds",bossIds);
}
}

View File

@ -10,7 +10,7 @@ public class LevelDifficulty extends MongoBase {
private int fightId;
private int state; //2 已开启 3:已打过未通过,=4已通过
private int state; //2 已开启 3:已打过未通过,=4已通过.
private int challengeTimes;

View File

@ -1,12 +1,107 @@
package com.ljsd.jieling.logic.dao;
import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.config.SGameSetting;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
public class MainLevelManager extends MongoBase {
public static final String _COLLECTION_NAME = "mainLevelManager";
private int fightId; // 当前关卡id
private int state; //状态
private int state; //状态 -1表示有等级卡
private int startTime;
private int lastTime; //上一个关卡记时时间
private Map<Integer,Integer> fightStateInfo = new HashMap<>();
private Map<Integer,Set<String>> bossIds = new HashMap<>();
public void init(){
this.startTime = (int)(System.currentTimeMillis()/1000);
updateString("startTime",startTime);
updateFight(1011,1);
}
public void updateStateInfo(){
SGameSetting gameSetting = SGameSetting.getGameSetting();
int adventureRefresh = gameSetting.getAdventureRefresh();
int timeDuration = (int)(System.currentTimeMillis()/1000) - lastTime;
int times = timeDuration / adventureRefresh;
if(times<=0){
times = 1;
}
fightStateInfo.put(fightId,times);
updateString("fightStateInfo." + fightId,times);
}
public void updateFight(int fightId,int state){
if(fightId!=1011){
updateStateInfo();
}
this.fightId = fightId;
this.state = state;
this.lastTime = (int)(System.currentTimeMillis()/1000);
updateString("fightId",fightId);
updateString("state",state);
updateString("lastTime",lastTime);
}
public void afterTakeStateReward(){
fightStateInfo.clear();
this.startTime = (int)(System.currentTimeMillis()/1000);
this.lastTime = (int)(System.currentTimeMillis()/1000);
updateString("lastTime",state);
updateString("startTime",startTime);
updateString("lastTime",lastTime);
updateString("fightStateInfo",fightStateInfo);
}
public void addBossGroup(String bossId){
if(!bossIds.containsKey(fightId)){
bossIds.put(fightId,new HashSet<>());
}
bossIds.get(fightId).add(bossId);
updateString("bossIds." + fightId,bossIds);
}
public void removeBossGroup(String bossId){
bossIds.remove(bossId);
updateString("bossIds",bossIds);
}
public void removeMutBossGroup(Set<String> bossIdsTmp){
bossIds.clear();
updateString("bossIds",bossIds);
}
public int getFightId() {
return fightId;
}
public int getState() {
return state;
}
public int getStartTime() {
return startTime;
}
public Map<Integer, Integer> getFightStateInfo() {
return fightStateInfo;
}
public int getLastTime() {
return lastTime;
}
public Map<Integer, Set<String>> getBossIds() {
return bossIds;
}
public void directUpdateDb(){
updateString("bossIds",bossIds);
}
}

View File

@ -129,7 +129,7 @@ public class PlayerManager extends MongoBase {
}
public void setNickName(String nickName) throws Exception {
updateString("nickName", nickName);
// updateString("nickName", nickName);
this.nickName = nickName;
}

View File

@ -86,6 +86,7 @@ public class UserManager {
PlayerLogic.getInstance().vipflushEveryDay(user,null);
ActivityLogic.getInstance().newPlayerOpenActivityMission(user);
PlayerLogic.getInstance().playerInfoUpdate(user);
user.getMainLevelManager().init();
user.getUserMissionManager().onGameEvent(user, GameEvent.USER_LEVELUP,0,1);
user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_REFRESH,0);
user.getUserMissionManager().onGameEvent(user, GameEvent.BLOODY_REFRESH,0);

View File

@ -26,8 +26,6 @@ public class User {
private EquipManager equipManager;
private AdventureManager adventureManager;
private PokemonManager pokemonManager;
private WorkShopController workShopController;
@ -51,6 +49,7 @@ public class User {
private QuestionManager questionManager;
private BloodyInfo bloodyInfo;
private MainLevelManager mainLevelManager;
//构造函数必须要声明否则从mongodb读出来反编译成类不通过
public User(){
@ -65,7 +64,6 @@ public class User {
this.teamPosManager = new TeamPosManager();
this.mailManager = new MailManager();
this.equipManager = new EquipManager();
this.adventureManager = new AdventureManager();
this.pokemonManager = new PokemonManager();
this.workShopController = new WorkShopController();
this.levelDifficultyManager = new LevelDifficultyManager();
@ -78,6 +76,7 @@ public class User {
this.guildMyInfo = new GuildMyInfo();
this.questionManager = new QuestionManager();
this.bloodyInfo = new BloodyInfo();
this.mainLevelManager = new MainLevelManager();
//綁定关系
@ -88,7 +87,6 @@ public class User {
this.teamPosManager.init(id, MongoKey.teamPosManager);
this.mailManager.init(id, MongoKey.mailManager);
this.equipManager.init(id, MongoKey.equipManager);
this.adventureManager.init(id, MongoKey.adventureManager);
this.pokemonManager.init(id, MongoKey.pokemonManager);
this.workShopController.init(id, MongoKey.workShopController);
this.levelDifficultyManager.init(id, MongoKey.levelDifficultyManager);
@ -101,6 +99,7 @@ public class User {
this.guildMyInfo.init(id,MongoKey.guildMyInfo);
this.questionManager.init(id,MongoKey.questionManager);
this.bloodyInfo.init(id,MongoKey.bloodyInfo);
this.mainLevelManager.init(id,MongoKey.mainLevelManager);
}
public int getId() {
@ -167,10 +166,6 @@ public class User {
return equipManager;
}
public AdventureManager getAdventureManager() {
return adventureManager;
}
public PokemonManager getPokemonManager() {
return pokemonManager;
}
@ -234,4 +229,8 @@ public class User {
public BloodyInfo getBloodyInfo() {
return bloodyInfo;
}
public MainLevelManager getMainLevelManager() {
return mainLevelManager;
}
}

View File

@ -8,7 +8,6 @@ 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.handler.map.EndlessHero;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.behavior.BehaviorUtil;
import com.ljsd.jieling.ktbeans.KTGameType;
@ -188,127 +187,12 @@ public class CombatLogic {
/************** 新挂机*****************/
public void getAdventureInfo(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
FightInfoProto.GetAdventureStateInfoResponse adventureStateInfoResponse = CBean2Proto.getAdventureStateInfoResponse(adventureStateInfoMap);
OnlineUserManager.orderAdventureUids.add(uid);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_INFO_RESPONSE_VALUE,adventureStateInfoResponse,true);
}
//挑战首次
public void adventureChallenge(ISession iSession,int arenaId,int teamId,int skipFight) throws Exception {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
if(adventureStateInfoMap.containsKey(arenaId)){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_RESPONSE_VALUE,"already challenge");
return;
}
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
if(sAdventureConfig == null){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_RESPONSE_VALUE,"");
return;
}
if(sAdventureConfig.getOpenLevel()[0]>user.getPlayerInfoManager().getLevel()){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_RESPONSE_VALUE,"level not");
return;
}
int groupId = sAdventureConfig.getSystemBoss();
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user,teamId,true);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(groupId);
List<CommonProto.FightTeamInfo> monsterTeamList = new ArrayList<>(3);
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_1);
monsterTeamList.addAll(monsterGroupList);
List<CommonProto.FightTeamInfo> monsterGroupList1 = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_2);
monsterTeamList.addAll(monsterGroupList1);
List<CommonProto.FightTeamInfo> monsterGroupList2 = BehaviorUtil.getFightTeamInfos(groupId,monsterByGroup, Global.MONSTER_3);
monsterTeamList.addAll(monsterGroupList2);
//设置战斗随机种子
int seed = (int)(System.currentTimeMillis()/1000);
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
LuaValue getOptionData = FightDataUtil.getOptionData("");
int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getSystemBossTime(), getFightData, getOptionData,FightType.AdventureLock);
int fightResult = checkResult[0];
if(fightResult == 1){
adventureManager.addAdventureStation(new AdventureStateInfo(arenaId));
if(arenaId == 1){
int[][] drop= new int[1][];
drop[0] = new int[2];
drop[0][0]=SGameSetting.getGameSetting().getAdventureItem();
drop[0][1] = 1;
ItemUtil.drop(user,drop,BIReason.FIRST_ADVENTURE_REWARD);
}
}
FightInfoProto.AdventurnChallengeResponse.Builder builder = FightInfoProto.AdventurnChallengeResponse.newBuilder().setFightResult(fightResult);
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
.setFightSeed(seed)
.setHeroFightInfos(fightTeamInfo)
.addAllMonsterList(monsterGroupList)
.build();
builder.setFightData(fightData);
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.ADVENTURE_CHALLENGE_RESPONSE_VALUE,builder.build(),true);
}
//升级
public void adventureUpLevle(ISession iSession,int arenaId) throws Exception {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(arenaId);
if(null == adventureStateInfo){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_RESPONSE_VALUE,"");
return;
}
int level = adventureStateInfo.getLevel();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
int[] openLevel = sAdventureConfig.getOpenLevel();
if(level>=openLevel.length){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_RESPONSE_VALUE,"level max");
return;
}
if(sAdventureConfig.getOpenLevel()[level]>user.getPlayerInfoManager().getLevel()){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_RESPONSE_VALUE,"level not");
return;
}
int[] upgradeConsume = sAdventureConfig.getUpgradeConsume()[level-1];
boolean enough = ItemUtil.itemCost(user, new int[][]{upgradeConsume},BIReason.ADVENTURE_UPLEVEL_CONSUME,arenaId);
if(!enough){
MessageUtil.sendErrorResponse(iSession,0, MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_RESPONSE_VALUE,"item not");
return;
}
adventureStateInfo.setLevel(adventureStateInfo.getLevel()+1);
getAdventureReward(user, arenaId, true,1);
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.ADVENTURE_UPLEVEL_RESPONSE_VALUE,null,true);
}
public void takeAdventureReward(ISession session,int type,int position) throws Exception {
public void takeNewAdventureReward(ISession session,int type,int position) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
Map<Integer, CommonProto.Drop> adventureFastReward =null;
if(type == 2){
if(position==-1){
boolean allowed = user.getPlayerInfoManager().checkFunctionIsAllowed(VipPrivilegeType.UNLOCK_ADVENTURE_ONEKEY);
if(!allowed){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,"not allowed");
return;
}
}
if(position == 1 && user.getAdventureManager().getTakeFirst() == 0){
adventureFastReward = getAdventureFastReward(user,SGameSetting.getGameSetting().getAdventureRefresh());
user.getAdventureManager().setTakeFirst(1);
user.getUserMissionManager().onGameEvent(user,GameEvent.ADVENTURE_TAKEREWARD,1);
}else{
adventureFastReward = getAdventureReward(user, position,false,0);
}
adventureFastReward = getNewAdventureReward(user);
}else{
String err ="";
if(position == 0){
@ -320,22 +204,18 @@ public class CombatLogic {
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,err);
return;
}
adventureFastReward = getAdventureFastReward(user, SGameSetting.getGameSetting().getAdventureFastBattle());
adventureFastReward = getNewAdventureFastReward(user, SGameSetting.getGameSetting().getAdventureFastBattle());
user.getUserMissionManager().onGameEvent(user,GameEvent.PlAY_STORY,9999,1);
Poster.getPoster().dispatchEvent(new SecretEvent(user.getId()));
}
FightInfoProto.TakeAventureRewardResponse build = FightInfoProto.TakeAventureRewardResponse.newBuilder().setDrop(adventureFastReward.get(1)).setRandomDrop(adventureFastReward.get(2)).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,build,true);
KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.TAKE_SECURE_REWARD.getIndex(),type*10+position);
KtEventUtils.onKtEvent(user,ParamEventBean.UserGameType,KTGameType.TAKE_SECURE_REWARD.getIndex(),type*10);
}
public Map<Integer,CommonProto.Drop> getAdventureReward(User user, int position,boolean sendMail,int reason) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
if(adventureStateInfoMap.isEmpty()){
return null;
}
int now = (int)(System.currentTimeMillis()/1000);
public Map<Integer,CommonProto.Drop> getNewAdventureReward(User user) throws Exception {
MainLevelManager mainLevelManager = user.getMainLevelManager();
Map<Integer, Integer> fightStateInfo = user.getMainLevelManager().getFightStateInfo();
SGameSetting gameSetting = SGameSetting.getGameSetting();
int adventureRefresh = gameSetting.getAdventureRefresh();
int adventureOffline = gameSetting.getAdventureOffline()*60*60/adventureRefresh;
@ -351,55 +231,36 @@ public class CombatLogic {
CommonProto.Drop.Builder baseBuilder = CommonProto.Drop.newBuilder();
CommonProto.Drop.Builder randomBuilder = CommonProto.Drop.newBuilder();
int takeTimes= 0;
for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()) {
int positionTmp = adventureStateInfoTmp.getPosition();
if (position != -1 && positionTmp != position) {
continue;
for(Map.Entry<Integer,Integer> fightStateInfoItem : fightStateInfo.entrySet()){
Integer fightId = fightStateInfoItem.getKey();
Integer times = fightStateInfoItem.getValue();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
int[] randomRewardMin = sMainLevelConfig.getRandomRewardMin();
ItemUtil.combineReward(user,randomRewardMin, times,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap);
int timesTemp =times;
while (timesTemp-->0){
ItemUtil.combineReward(user,sMainLevelConfig.getRandomReward(), 1f,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap);
}
int startTime = adventureStateInfoTmp.getStartTime();
int times = (now - startTime) / adventureRefresh;
int refreshTimes = times;
times = adventureOffline > times ? times : adventureOffline;
if (times > 0) {
adventureStateInfoTmp.setStartTime(startTime + refreshTimes * adventureRefresh);
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(positionTmp);
int baseRewardGroup[] = sAdventureConfig.getBaseRewardGroup();
int[][] randomRewardGroup = sAdventureConfig.getRandomRewardGroup();
ItemUtil.combineReward(user,new int[]{baseRewardGroup[adventureStateInfoTmp.getLevel()-1]}, times,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap);
takeTimes+=times;
}
if(mainLevelManager.getState()!=-1){
int fightId = mainLevelManager.getFightId();
int lastTime = mainLevelManager.getLastTime();
int times = ((int)(System.currentTimeMillis()/1000) - lastTime)/SGameSetting.getGameSetting().getAdventureRefresh();
int maxTimes = adventureOffline - takeTimes;
if(maxTimes>0){
times = times > maxTimes?maxTimes:times;
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
int[] randomRewardMin = sMainLevelConfig.getRandomRewardMin();
ItemUtil.combineReward(user,randomRewardMin, times,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap);
int timesTemp =times;
while (timesTemp-->0){
ItemUtil.combineReward(user,randomRewardGroup[adventureStateInfoTmp.getLevel()-1], 1f,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap);
ItemUtil.combineReward(user,sMainLevelConfig.getRandomReward(), 1f,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap);
}
takeTimes++;
}
if(sendMail){
adventureStateInfoTmp.setStartTime(now);
}
}
if(sendMail){
if(!baseItemMap.isEmpty()){
String title = "";
String content = "";
if(reason == 1){
String areaName = SAdventureConfig.getConfig().get(position).getAreaName();
title = SErrorCodeEerverConfig.getI18NMessage("adventuren_reward_of_uplevel_title");
content = SErrorCodeEerverConfig.getI18NMessage("adventuren_reward_of_uplevel_content",new Object[]{areaName,adventureStateInfoMap.get(position).getLevel()});
}else if(reason == 2){
int vipLevel = user.getPlayerInfoManager().getVipLevel();
title = SErrorCodeEerverConfig.getI18NMessage("adventuren_reward_of_viplevel_title");
content = SErrorCodeEerverConfig.getI18NMessage("adventuren_reward_of_viplevel_content",new Object[]{vipLevel});
}else {
return null;
}
String reward = ItemUtil.getReward(baseItemMap, baseCardMap, baseEquipMap, baseRandomMap);
String randomReward = ItemUtil.getReward(randomItemMap, randomCardMap, randomEquipMap, randomRandomMap);
if(randomReward.length()!=0){
reward = reward + "|" + randomReward;
}
MailLogic.getInstance().sendMail(user.getId(),title,content,reward,now,Global.MAIL_EFFECTIVE_TIME);
}
return null;
}
mainLevelManager.afterTakeStateReward();
ItemUtil.drop(user,baseBuilder,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap,BIReason.ADVENTURE_BASE_REWARD);
ItemUtil.drop(user,randomBuilder,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap,BIReason.ADVENTURE_RANDOM_REWARDD);
Map<Integer, CommonProto.Drop> result = new HashMap<>(2);
@ -408,10 +269,8 @@ public class CombatLogic {
user.getUserMissionManager().onGameEvent(user,GameEvent.ADVENTURE_TAKEREWARD,takeTimes);
return result;
}
private Map<Integer,CommonProto.Drop> getAdventureFastReward(User user,int timeDuration) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
private Map<Integer,CommonProto.Drop> getNewAdventureFastReward(User user,int timeDuration) throws Exception {
MainLevelManager mainLevelManager = user.getMainLevelManager();
SGameSetting gameSetting = SGameSetting.getGameSetting();
int adventureRefresh = gameSetting.getAdventureRefresh();
int times = timeDuration / adventureRefresh;
@ -426,17 +285,15 @@ public class CombatLogic {
Map<Integer,Integer> randomRandomMap = new HashMap<>();
CommonProto.Drop.Builder baseBuilder = CommonProto.Drop.newBuilder();
CommonProto.Drop.Builder randomBuilder = CommonProto.Drop.newBuilder();
for(AdventureStateInfo adventureStateInfoTmp:adventureStateInfoMap.values()) {
int positionTmp = adventureStateInfoTmp.getPosition();
if (times > 0) {
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(positionTmp);
int baseRewardGroup[] = sAdventureConfig.getBaseRewardGroup();
int[][] randomRewardGroup = sAdventureConfig.getRandomRewardGroup();
ItemUtil.combineReward(user,new int[]{baseRewardGroup[adventureStateInfoTmp.getLevel()-1]}, times,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap);
int timesTemp =times;
while (timesTemp-->0){
ItemUtil.combineReward(user,randomRewardGroup[adventureStateInfoTmp.getLevel()-1], 1f,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap);
}
if(mainLevelManager.getState()!=-1){
int fightId = mainLevelManager.getFightId();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
int[] randomRewardMin = sMainLevelConfig.getRandomRewardMin();
ItemUtil.combineReward(user,randomRewardMin, times,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap);
int timesTemp =times;
while (timesTemp-->0){
ItemUtil.combineReward(user,sMainLevelConfig.getRandomReward(), 1f,randomItemMap,randomCardMap,randomEquipMap,randomRandomMap);
}
}
ItemUtil.drop(user,baseBuilder,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap,BIReason.ADVENTURE_BASE_REWARD);
@ -450,6 +307,8 @@ public class CombatLogic {
public void getInvasionBoss(ISession session,FightInfoProto.AdventureBossInfoResponse.Builder builder) throws Exception {
int uid = session.getUid();
Map<String, Integer> myHurtInfo = RedisUtil.getInstence().getMapValues(RedisKey.ADVENTRUEN_BOSS_OWN, Integer.toString(uid), String.class, Integer.class);
@ -473,8 +332,8 @@ public class CombatLogic {
String bossId = adventureBoss.getBossId();
int arenaId = adventureBoss.getArenaId();
int findTime = adventureBoss.getFindTime();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
int invasionBossHolding = sAdventureConfig.getInvasionBossHolding();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(arenaId);
int invasionBossHolding = sMainLevelConfig.getInvasionBossHolding();
int remainTime = invasionBossHolding - ( now - findTime);
int findUserId = adventureBoss.getFindUserId();
if(remainTime<0){
@ -529,46 +388,24 @@ public class CombatLogic {
public void callInvasionBoss(ISession iSession, boolean isGm) throws Exception {
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
AdventureManager adventureManager = user.getAdventureManager();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
int arenaID = 0;
for(Integer tmpArenaId : adventureStateInfoMap.keySet()){
if(arenaID<tmpArenaId){
arenaID = tmpArenaId;
}
}
MainLevelManager mainLevelManager = user.getMainLevelManager();
int msgId = MessageTypeProto.MessageType.ADVENTURE_CALL_BOSS_RESPONSE_VALUE;
if(arenaID == 0){
if(isGm){
return ;
}
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
return;
}
int[][] cost= new int[1][];
cost[0] = new int[2];
cost[0][0]=SGameSetting.getGameSetting().getAdventureItem();
cost[0][1] = 1;
boolean enough = ItemUtil.itemCost(user, cost, BIReason.ADVENTURE_CALL_BOSS_CONSUME, arenaID);
int fightId = mainLevelManager.getFightId();
boolean enough = ItemUtil.itemCost(user, cost, BIReason.ADVENTURE_CALL_BOSS_CONSUME,fightId);
if(!enough){
MessageUtil.sendErrorResponse(iSession,0,msgId,"次数不足");
return;
}
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaID);
int[][][] invasionBoss = sAdventureConfig.getInvasionBoss();
Set<Integer> arenaIDs = adventureStateInfoMap.keySet();
int arenaIndex = MathUtils.randomInt(arenaIDs.size()+1);
arenaID = arenaIDs.iterator().next();
Iterator<Integer> iterator = arenaIDs.iterator();
int j=arenaIndex;
while (iterator.hasNext() && j-->0){
arenaID = iterator.next();
}
AdventureStateInfo adventureStateInfo = adventureStateInfoMap.get(arenaID);
int bossGroupID =0;
int level = adventureStateInfo.getLevel();
int[][] invasionBossWeightInfo = invasionBoss[level - 1];
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(fightId);
int[][] invasionBossWeightInfo = sMainLevelConfig.getInvasionBoss();
int totalWeight = 0;
for(int[] item :invasionBossWeightInfo){
totalWeight+=item[1];
@ -591,14 +428,14 @@ public class CombatLogic {
for(Integer hp: hps){
totalHp+=hp;
}
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,level,uid,now,totalHp,hps);
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,fightId,1,uid,now,totalHp,hps);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,Integer.toString(uid),bossId,0);
MessageUtil.sendRedIndication(uid,GlobalsDef.SHARE_BOSS_RED_TYPE);
adventureStateInfo.addBossGroup(bossId);
int remainTime =sAdventureConfig.getInvasionBossHolding()-(now - adventureBoss.getFindTime());
mainLevelManager.addBossGroup(bossId);
int remainTime =sMainLevelConfig.getInvasionBossHolding()-(now - adventureBoss.getFindTime());
FightInfoProto.AdventureCallBossResponse build = FightInfoProto.AdventureCallBossResponse.newBuilder().setAdventureBossInfo(CommonProto.AdventureBossSimpleInfo.newBuilder()
.setArenaId(adventureStateInfo.getPosition())
.setArenaId(fightId)
.setBossGroupId(adventureBoss.getBossGroupId())
.setRemainTime(remainTime)
.setBossId(bossId)
@ -606,24 +443,14 @@ public class CombatLogic {
MessageUtil.sendMessage(iSession,1,msgId,build,true);
}
public void leftAdventurePos(ISession session,int type){
if(type == 0){
OnlineUserManager.orderAdventureUids.remove(session.getUid());
}else{
OnlineUserManager.orderAdventureUids.add(session.getUid());
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_LEFT_RESPONSE_VALUE,null,true);
}
public void broadAdventureBoss(AdventureBoss adventureBoss,String findUserName,List<Integer> friends,int findUid){
int arenaId = adventureBoss.getArenaId();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(arenaId);
CommonProto.AdventureBossSimpleInfo build = CommonProto.AdventureBossSimpleInfo.newBuilder()
.setArenaId(arenaId)
.setBossId(adventureBoss.getBossId())
.setBossGroupId(adventureBoss.getBossGroupId())
.setRemainTime(sAdventureConfig.getInvasionBossHolding())
.setRemainTime(sMainLevelConfig.getInvasionBossHolding())
.setFindUserName(findUserName)
.build();
FightInfoProto.AdventureBossFindIndication adventureBossFindIndication = FightInfoProto.AdventureBossFindIndication.newBuilder().setAdventureBossSimpleInfo(build).build();
@ -709,19 +536,19 @@ public class CombatLogic {
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterGroupList);
LuaValue getOptionData = FightDataUtil.getOptionData("");
FightInfoProto.AdventurenBossChallengeResponse.Builder builder = FightInfoProto.AdventurenBossChallengeResponse.newBuilder();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(adventureBoss.getArenaId());
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(adventureBoss.getArenaId());
int totalHurt=0;
int fightResult=0;
int i=0;
for(;i<fightTimes;i++){
CommonProto.FightData build = CommonProto.FightData.newBuilder()
.setFightMaxTime(sAdventureConfig.getInvasionBossTime())
.setFightMaxTime(sMainLevelConfig.getInvasionBossTime())
.setFightSeed(seed)
.setHeroFightInfos(fightTeamInfo)
.addAllMonsterList(monsterGroupList)
.build();
builder.setFightData(build);
int[] checkResult = CheckFight.getInstance().checkFight(seed, sAdventureConfig.getInvasionBossTime(), getFightData, getOptionData,FightType.InvasionBossFight);
int[] checkResult = CheckFight.getInstance().checkFight(seed, sMainLevelConfig.getInvasionBossTime(), getFightData, getOptionData,FightType.InvasionBossFight);
totalHurt+= updateBossAndGetHurtForFight(checkResult, adventureBoss);
fightResult = checkResult[0];
//发送击杀boss奖励和发现者奖励
@ -784,8 +611,8 @@ public class CombatLogic {
private String sendRewardOfBossKilled(int findUserId,int killUid,int killBossGroupId, int arenaId,int arenaLevel) throws Exception {
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(killBossGroupId);
int[] killReward = sMonsterGroup.getRewardgroup();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
int[][] rewaeds = sAdventureConfig.getInvasionBossReward()[arenaLevel - 1];
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(arenaId);
int[][] rewaeds = sMainLevelConfig.getInvasionBossReward();
int[] findRewardgroup=null;
for(int[] rewardBossItem : rewaeds){
if(rewardBossItem[0] == killBossGroupId){

View File

@ -225,7 +225,6 @@ public class PlayerLogic {
int vipLevel = playerInfoManager.getVipLevel();
playerInfoManager.updateVipInfo(user,vipLevel+1);
CombatLogic.getInstance().getAdventureReward(user, -1, true,2);
List<CommonProto.UserMissionInfo> missionList = new ArrayList<>();
MissionLoigc.getVipMission(user,missionList);
CommonProto.VipBaseInfo vipInfoProto = CommonProto.VipBaseInfo.newBuilder()
@ -499,7 +498,7 @@ public class PlayerLogic {
public void sendTestWelfareMail(User user,int sendDay,int duration) throws Exception {
String title = SErrorCodeEerverConfig.getI18NMessage("welfare_activity_daily_title");
/* String title = SErrorCodeEerverConfig.getI18NMessage("welfare_activity_daily_title");
for(;sendDay<=duration;sendDay++){
STestWelfare sTestWelfare = STestWelfare.testWelfareMap.get(sendDay);
if(sTestWelfare == null){
@ -508,7 +507,7 @@ public class PlayerLogic {
String content = SErrorCodeEerverConfig.getI18NMessage("welfare_activity_daily_txt",new String[]{Integer.toString(sendDay)});
String mailReward = ItemUtil.getMailReward(user, sTestWelfare.getReward(), 1.0f);
MailLogic.getInstance().sendMail(user.getId(),title,content,mailReward,(int)(System.currentTimeMillis()/1000),Global.MAIL_EFFECTIVE_TIME);
}
}*/
}

View File

@ -1,7 +1,7 @@
package com.ljsd.jieling.util;
import com.ljsd.jieling.config.SAdventureConfig;
import com.ljsd.jieling.config.SGameSetting;
import com.ljsd.jieling.config.SMainLevelConfig;
import com.ljsd.jieling.config.SMonsterConfig;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
@ -441,26 +441,32 @@ public class CBean2Proto {
.build();
}
public static FightInfoProto.GetAdventureStateInfoResponse getAdventureStateInfoResponse(Map<Integer, AdventureStateInfo> adventureStateInfoMap){
FightInfoProto.GetAdventureStateInfoResponse.Builder builder = FightInfoProto.GetAdventureStateInfoResponse.newBuilder();
public static PlayerInfoProto.GetMainLevelInfoResponse getMainLevelInfoResponse( MainLevelManager mainLevelManager){
long nowMs = TimeUtils.now();
int now = (int)(nowMs/1000);
for(AdventureStateInfo adventureStateInfo : adventureStateInfoMap.values()){
CommonProto.AdventureStateInfo.Builder builder1 = CommonProto.AdventureStateInfo.newBuilder()
.setPositionId(adventureStateInfo.getPosition())
.setLevel(adventureStateInfo.getLevel())
.setStateTime(now-adventureStateInfo.getStartTime());
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(adventureStateInfo.getPosition());
Set<String> bossIds = adventureStateInfo.getBossIds();
int state = mainLevelManager.getState();
int duration = (int)(System.currentTimeMillis()/1000) - mainLevelManager.getStartTime();
PlayerInfoProto.GetMainLevelInfoResponse.Builder builder = PlayerInfoProto.GetMainLevelInfoResponse.newBuilder()
.setFightId(mainLevelManager.getFightId())
.setState(state)
.setDuration(duration);
Map<Integer, Set<String>> bossIds = mainLevelManager.getBossIds();
boolean update =false;
for(Map.Entry<Integer, Set<String>> item : bossIds.entrySet()){
Integer fightId = item.getKey();
Set<String> value = item.getValue();
SMainLevelConfig sMainLevelConfig = SMainLevelConfig.config.get(mainLevelManager.getFightId());
Set<String> removeCache = new HashSet<>();
for(String bossId : bossIds){
for(String bossId : value){
AdventureBoss adventureBoss = RedisUtil.getInstence().getMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO, "", bossId, AdventureBoss.class);
if(adventureBoss != null){
int findBossTime = adventureBoss.getFindTime();
int remainTime =sAdventureConfig.getInvasionBossHolding()-(now - findBossTime);
int remainTime =sMainLevelConfig.getInvasionBossHolding()-(now - findBossTime);
if(remainTime>0){
builder1.addAdventureBossSimpleInfo(
CommonProto.AdventureBossSimpleInfo.newBuilder().setArenaId(adventureStateInfo.getPosition())
builder.addAdventureBossSimpleInfo(
CommonProto.AdventureBossSimpleInfo.newBuilder()
.setArenaId(fightId)
.setBossGroupId(adventureBoss.getBossGroupId())
.setRemainTime(remainTime)
.setBossId(adventureBoss.getBossId())
@ -474,10 +480,12 @@ public class CBean2Proto {
}
}
if(!removeCache.isEmpty()){
adventureStateInfo.removeMutBossGroup(removeCache);
value.removeAll(removeCache);
update =true;
}
builder.addAdventureStateInfoList(builder1);
}
if(update){
mainLevelManager.directUpdateDb();
}
return builder.build();
}