back_recharge
wangyuan 2019-05-16 17:50:40 +08:00
parent 48375cd38f
commit 544ba36938
15 changed files with 358 additions and 73 deletions

View File

@ -85,6 +85,8 @@ public class RedisKey {
public static final String ARENA_RANK = "ARENA_RANK";
public static final String ADVENTRUEN_BOSS_OWN = "ADVENTRUEN_BOSS_OWN";
public static final String ADVENTRUEN_BOSS_INFO = "ADVENTRUEN_BOSS_INFO";
public static final String ADVENTRUEN_BOSS_RANK = "ADVENTRUEN_BOSS_RANK";

View File

@ -22,6 +22,6 @@ public class AdventureBossChallengeHandler extends BaseHandler{
int teamId = adventurenBossChallengeRequest.getTeamId();
int fightTimes = adventurenBossChallengeRequest.getFightTimes();
int skipFight = adventurenBossChallengeRequest.getSkipFight();
//CombatLogic.getInstance().challengeInvasionBoss(iSession,);
CombatLogic.getInstance().challengeInvasionBoss(iSession,bossId,teamId,fightTimes,skipFight);
}
}

View File

@ -0,0 +1,23 @@
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 AdventureBossShareHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
FightInfoProto.AdventureBossShareRequest adventureBossShareRequest = FightInfoProto.AdventureBossShareRequest.parseFrom(netData.parseClientProtoNetData());
CombatLogic.getInstance().shareAdventureBoss(iSession,adventureBossShareRequest.getBossId());
}
}

View File

@ -0,0 +1,21 @@
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.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class AdventureFlushBossHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_FLUSH_BOSS_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
CombatLogic.getInstance().flushArenaBoss(iSession);
}
}

View File

@ -1,20 +1,21 @@
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.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class GetAdventureBossHurtHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
return MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_REQEUST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
CombatLogic.getInstance().getInvasionBoss(iSession);
}
}

View File

@ -1,20 +1,23 @@
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 GetAdventureBossRankHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return null;
return MessageTypeProto.MessageType.ADVENTURE_BOSS_RANK_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
FightInfoProto.AdventurnRankRequest adventurnRankRequest = FightInfoProto.AdventurnRankRequest.parseFrom(netData.parseClientProtoNetData());
CombatLogic.getInstance().getWorldRankByPage(iSession,adventurnRankRequest.getPage());
}
}

View File

@ -0,0 +1,23 @@
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 TakeAdventureRewardHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.ADVENTURE_REWARD_REQUEST;
}
@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());
}
}

View File

@ -6,18 +6,23 @@ public class AdventureBoss {
private String bossId;
private int bossGroupId;
private int arenaId;
private int arenaLevel;
private int findUserId; //发现者
private int findTime; //发现时间
private int totalHp;// 总血量
private List<Integer> remainHp; //剩余血量
public AdventureBoss(String bossId,int bossGroupId, int arenaId,int findUserId, int findTime, int totalHp, List<Integer> remainHp) {
public AdventureBoss() {
}
public AdventureBoss(String bossId, int bossGroupId, int arenaId, int arenaLevel, int findUserId, int findTime, int totalHp, List<Integer> remainHp) {
this.bossId = bossId;
this.findUserId = findUserId;
this.findTime = findTime;
this.totalHp = totalHp;
this.remainHp = remainHp;
this.bossGroupId = bossGroupId;
this.arenaLevel = arenaLevel;
}
public String getBossId() {
@ -71,4 +76,16 @@ public class AdventureBoss {
public int getArenaId() {
return arenaId;
}
public void setArenaId(int arenaId) {
this.arenaId = arenaId;
}
public int getArenaLevel() {
return arenaLevel;
}
public void setArenaLevel(int arenaLevel) {
this.arenaLevel = arenaLevel;
}
}

View File

@ -18,7 +18,8 @@ public class AdventureManager extends MongoBase {
private int dayChallengeTimes;
private List<TempDropInfo> tempDropRatio = new ArrayList<>();
private long flushBossTime;
@ -34,20 +35,6 @@ public class AdventureManager extends MongoBase {
adventureStateInfoMap.put(position,adventureStateInfo);
}
public List<TempDropInfo> getTempDropRatio() {
return tempDropRatio;
}
public void updateTemp(int dropIds[], float ratio){
tempDropRatio.add(new TempDropInfo(dropIds,ratio));
updateString("tempDropRatio",tempDropRatio);
}
public void clearTemp(){
tempDropRatio.clear();
updateString("tempDropRatio", new ArrayList<>());
}
public Map<Integer, AdventureStateInfo> getAdventureStateInfoMap() {
return adventureStateInfoMap;
}
@ -79,4 +66,13 @@ public class AdventureManager extends MongoBase {
updateString("buyTimsPerDay",buyTimsPerDay);
this.buyTimsPerDay = buyTimsPerDay;
}
public long getFlushBossTime() {
return flushBossTime;
}
public void setFlushBossTime(long flushBossTime) {
updateString("flushBossTime",flushBossTime);
this.flushBossTime = flushBossTime;
}
}

View File

@ -2,6 +2,7 @@ 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.List;
@ -17,8 +18,12 @@ public class AdventureStateInfo extends MongoBase {
}
public AdventureStateInfo(int position) {
int now = (int)(TimeUtils.now()/1000);
this.position = position;
this.level=1;
this.startTime = now;
this.findBossTime = now;
}
public int getStartTime() {

View File

@ -22,7 +22,7 @@ public class Equip extends MongoBase implements Cloneable{
private int level;
private int rebuildLevel;
private int rebuildLevel;
@ -239,7 +239,10 @@ public class Equip extends MongoBase implements Cloneable{
int value = MathUtils.random(sEquipPropertyPool.getMin() * (100 + secondPropertyPromote) / 100, sEquipPropertyPool.getMax()* (100 + secondPropertyPromote) / 100);
secondValueByIdMap.put(secondPropertyId,value);
}
rebuildLevel = workShopLevle;
setRebuildLevel(workShopLevle);
setSecondValueByIdMap(secondValueByIdMap);
setPropertyValueByIdMap(propertyValueByIdMap);
}
@ -286,6 +289,22 @@ public class Equip extends MongoBase implements Cloneable{
return secondValueByIdMap;
}
public void setRebuildLevel(int rebuildLevel) {
updateString("rebuildLevel",rebuildLevel);
this.rebuildLevel = rebuildLevel;
}
public void setPropertyValueByIdMap(Map<Integer, Integer> propertyValueByIdMap) {
updateString("propertyValueByIdMap",propertyValueByIdMap);
this.propertyValueByIdMap = propertyValueByIdMap;
}
public void setSecondValueByIdMap(Map<Integer, Integer> secondValueByIdMap) {
updateString("secondValueByIdMap",secondValueByIdMap);
this.secondValueByIdMap = secondValueByIdMap;
}
@Override
public Object clone() throws CloneNotSupportedException {
return (Equip) super.clone();

View File

@ -127,33 +127,116 @@ public class CombatLogic {
AdventureManager adventureManager = user.getAdventureManager();
FightInfoProto.GetAdventureStateInfoResponse.Builder builder = FightInfoProto.GetAdventureStateInfoResponse.newBuilder();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
int flushBossNextTime = -1;
if(!adventureStateInfoMap.isEmpty()){
int now = (int)(TimeUtils.now()/1000);
long nowMs = TimeUtils.now();
int now = (int)(nowMs/1000);
for(AdventureStateInfo adventureStateInfo : adventureStateInfoMap.values()){
CommonProto.AdventureStateInfo.Builder builder1 = CommonProto.AdventureStateInfo.newBuilder()
.setPositionId(adventureStateInfo.getPosition())
.setBossId(adventureStateInfo.getBossId())
.setLevel(adventureStateInfo.getLevel())
.setStateTime(now-adventureStateInfo.getStartTime());
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(adventureStateInfo.getPosition());
int findBossNextTime = sAdventureConfig.getInvasionBossRefresh();
if(!StringUtil.isEmpty(adventureStateInfo.getBossId())){
int findBossTime = adventureStateInfo.getFindBossTime();
int remainTime =sAdventureConfig.getInvasionBossHolding()-(now - findBossTime);
int nextFlushTime = sAdventureConfig.getInvasionBossRefresh();
int findBossTime = adventureStateInfo.getFindBossTime();
int remainTime =sAdventureConfig.getInvasionBossHolding()-(now - findBossTime);
boolean needRandom = false;
boolean need = false;
if(StringUtil.isEmpty(adventureStateInfo.getBossId())){
if(now-adventureStateInfo.getStartTime()>nextFlushTime){
needRandom = true;
}
}else{
if(remainTime>0){
builder1.setBossRemainTime(remainTime).setBossId(adventureStateInfo.getBossId());
}else {
//删除boss 刷新boss
need= true;
}
if(remainTime+nextFlushTime<0){
needRandom = true;
}
}
builder1.setBossFindNextTime(findBossNextTime);
if(needRandom){
int bossGroupId = randomInvasionBoss(uid, adventureStateInfo.getPosition());
if(bossGroupId>0){
nextFlushTime+=remainTime;
need=true;
}
}
if(need){
builder1.setAdventureBossSimpleInfo( CommonProto.AdventureBossSimpleInfo.newBuilder().setArenaId(adventureStateInfo.getPosition())
.setBossGroupId(adventureStateInfo.getBossGroupId())
.setRemainTime(remainTime)
.build());
}
if(flushBossNextTime == -1 || flushBossNextTime>nextFlushTime){
flushBossNextTime = nextFlushTime;
}
builder.addAdventureStateInfoList(builder1);
}
if(flushBossNextTime!=-1){
adventureManager.setFlushBossTime(nowMs + flushBossNextTime *1000);
}
}
builder.setBuyTimsPerDay(adventureManager.getBuyTimsPerDay()).setDayChallengeTimes(adventureManager.getDayChallengeTimes());
builder.setNextBossFlushTime(flushBossNextTime).setBuyTimsPerDay(adventureManager.getBuyTimsPerDay()).setDayChallengeTimes(adventureManager.getDayChallengeTimes());
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_INFO_RESPONSE_VALUE,builder.build(),true);
}
public void flushArenaBoss(ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
long nowMs = TimeUtils.now();
AdventureManager adventureManager = user.getAdventureManager();
if(adventureManager.getFlushBossTime()>nowMs){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_FLUSH_BOSS_RESPONSE_VALUE,"cold time");
return;
}
int now = (int)(nowMs/1000);
int flushBossNextTime = -1;
FightInfoProto.AdventureBossFlushResponse.Builder builder = FightInfoProto.AdventureBossFlushResponse.newBuilder();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
if(!adventureStateInfoMap.isEmpty()){
for(AdventureStateInfo adventureStateInfo : adventureStateInfoMap.values()){
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(adventureStateInfo.getPosition());
int nextFlushTime = sAdventureConfig.getInvasionBossRefresh();
int findBossTime = adventureStateInfo.getFindBossTime();
int remainTime =sAdventureConfig.getInvasionBossHolding()-(now - findBossTime);
boolean needRandom = false;
boolean need = false;
if(StringUtil.isEmpty(adventureStateInfo.getBossId())){
if(now-adventureStateInfo.getStartTime()>nextFlushTime){
needRandom = true;
}
}else{
if(remainTime>0){
need= true;
}
if(remainTime+nextFlushTime<0){
needRandom = true;
}
}
if(needRandom){
int bossGroupId = randomInvasionBoss(uid, adventureStateInfo.getPosition());
if(bossGroupId>0){
nextFlushTime+=remainTime;
need=true;
}
}
if(need){
builder.setAdventureBossSimpleInfo( CommonProto.AdventureBossSimpleInfo.newBuilder().setArenaId(adventureStateInfo.getPosition())
.setBossGroupId(adventureStateInfo.getBossGroupId())
.setRemainTime(remainTime)
.build());
}
if(flushBossNextTime == -1 || flushBossNextTime>nextFlushTime){
flushBossNextTime = nextFlushTime;
}
}
}
builder.setNextFlushTime(flushBossNextTime);
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_FLUSH_BOSS_RESPONSE_VALUE,builder.build(),true);
}
//挑战首次
public void adventureChallenge(ISession iSession,int arenaId,int teamId,int skipFight) throws Exception {
int uid = iSession.getUid();
@ -173,7 +256,6 @@ public class CombatLogic {
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);
@ -212,7 +294,6 @@ public class CombatLogic {
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,"");
@ -244,16 +325,15 @@ public class CombatLogic {
User user = UserManager.getUser(uid);
CommonProto.Drop.Builder advetureReward=null;
if(type == 2){
advetureReward = getAdvetureReward(user, position);
advetureReward = getAdventureReward(user, position);
}else{
advetureReward = getAdventureFastReward(user,SGameSetting.getGameSetting().getAdventureFastBattle());
}
FightInfoProto.TakeAventureRewardResponse build = FightInfoProto.TakeAventureRewardResponse.newBuilder().setDrop(advetureReward).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_REWARD_RESPONSE_VALUE,build,true);
}
private CommonProto.Drop.Builder getAdvetureReward(User user, int position) throws Exception {
private CommonProto.Drop.Builder getAdventureReward(User user, int position) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
@ -279,10 +359,35 @@ public class CombatLogic {
}
}
return dropBuilder;
}
private CommonProto.Drop.Builder getAdventureFastReward(User user,int timeDuration) throws Exception {
AdventureManager adventureManager = user.getAdventureManager();
CommonProto.Drop.Builder dropBuilder = CommonProto.Drop.newBuilder();
Map<Integer, AdventureStateInfo> adventureStateInfoMap = adventureManager.getAdventureStateInfoMap();
int now = (int)(System.currentTimeMillis()/1000);
SGameSetting gameSetting = SGameSetting.getGameSetting();
int adventureRefresh = gameSetting.getAdventureRefresh();
int times = (now - timeDuration) / adventureRefresh;
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.activityDrop(user, dropBuilder, new int[]{baseRewardGroup[adventureStateInfoTmp.getLevel()-1]}, times);
ItemUtil.activityDrop(user, dropBuilder, randomRewardGroup[adventureStateInfoTmp.getLevel()-1], times);
}
}
return dropBuilder;
}
public void getInvasionBoss(ISession session){
int uid = session.getUid();
Map<String, Integer> mapValues = RedisUtil.getInstence().getMapValues(RedisKey.ADVENTRUEN_BOSS_OWN, Integer.toString(uid), String.class, Integer.class);
}
@ -310,23 +415,31 @@ public class CombatLogic {
totalWeight+=item[1];
}
int now = (int)(System.currentTimeMillis()/1000);
String bossId = KeyGenUtils.produceIdByModule(UUIDEnum.ADVENTUREBOSS, user.getId());
Map<Integer, List<Integer>> monsterHpByGroup = MonsterUtil.getMonsterHpByGroup(bossGroupID);
List<Integer> hps = monsterHpByGroup.get(0);
int totalHp = 0;
for(Integer hp: hps){
totalHp+=hp;
String bossId="";
if(bossGroupID != 0){
bossId = KeyGenUtils.produceIdByModule(UUIDEnum.ADVENTUREBOSS, user.getId());
Map<Integer, List<Integer>> monsterHpByGroup = MonsterUtil.getMonsterHpByGroup(bossGroupID);
List<Integer> hps = monsterHpByGroup.get(0);
int totalHp = 0;
for(Integer hp: hps){
totalHp+=hp;
}
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,levle,uid,now,totalHp,hps);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
}
AdventureBoss adventureBoss = new AdventureBoss(bossId,bossGroupID,arenaID,uid,now,totalHp,hps);
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
adventureStateInfo.setBossId(bossId);
adventureStateInfo.setBossGroupId(bossGroupID);
adventureStateInfo.setFindBossTime(now);
return bossGroupID;
}
public void shareAdventureBoss(ISession session,String bossId){
public void shareAdventureBoss(ISession session,String bossId) throws Exception {
AdventureBoss adventureBoss = RedisUtil.getInstence().getMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO, "", bossId, AdventureBoss.class);
if(adventureBoss == null || adventureBoss.getFindUserId() !=session.getUid()){
MessageUtil.sendErrorResponse(session,0, MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_RESPONSE_VALUE,"data wrong");
return;
}
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_RESPONSE_VALUE,null,true);
}
public void challengeInvasionBoss(ISession session,String bossId,int teamId,int fightTimes,int skipFight) throws Exception {
@ -346,15 +459,17 @@ public class CombatLogic {
}
AdventureBoss adventureBoss = RedisUtil.getInstence().getMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO, "", bossId, AdventureBoss.class);
int bossGroupId = adventureBoss.getBossGroupId();
Map<Integer,List<Integer>> hps = new HashMap<>(1);
hps.put(0,adventureBoss.getRemainHp());
CommonProto.FightTeamInfo fightTeamInfo = BehaviorUtil.getFightTeamInfo(user, teamId,true);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(bossGroupId);
Map<Integer, List<CommonProto.FightUnitInfo>> monsterByGroup = MonsterUtil.getMonsterByGroup(bossGroupId,hps);
List<CommonProto.FightTeamInfo> monsterGroupList = BehaviorUtil.getFightTeamInfos(bossGroupId,monsterByGroup, Global.MONSTER_1);
//设置战斗随机种子
int seed = (int)(System.currentTimeMillis()/1000);
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterGroupList);
LuaValue getOptionData = FightDataUtil.getOptionData("");
FightInfoProto.AdventurenBossChallengeResponse.Builder builder = FightInfoProto.AdventurenBossChallengeResponse.newBuilder();
if(skipFight == 0){
if(fightTimes == 1 && skipFight == 0){
CommonProto.FightData build = CommonProto.FightData.newBuilder()
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
.setFightSeed(seed)
@ -370,7 +485,7 @@ public class CombatLogic {
int fightResult = checkResult[0];
//发送击杀boss奖励和发现者奖励
if(fightResult == 1){
sendRewardOfBossKilled();
sendRewardOfBossKilled(adventureBoss.getFindUserId(),uid,bossGroupId,adventureBoss.getArenaId(),adventureBoss.getArenaLevel());
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId);
}else{
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",Integer.toString(uid),adventureBoss);
@ -380,7 +495,28 @@ public class CombatLogic {
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_CHALLENGE_RESPONSE_VALUE,build,true);
}
private void sendRewardOfBossKilled() {
private void sendRewardOfBossKilled(int findUserId,int killUid,int killBossGroupId, int arenaId,int arenaLevel) throws Exception {
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(killBossGroupId);
int[] findRewardgroup = sMonsterGroup.getRewardgroup();
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
int[][] rewaeds = sAdventureConfig.getInvasionBossReward()[arenaLevel - 1];
int[] killReward=null;
for(int[] rewardBossItem : rewaeds){
if(rewardBossItem[0] == killBossGroupId){
killReward = new int[]{rewardBossItem[1]};
break;
}
}
int nowTime = (int)(TimeUtils.now()/1000);
String findRewardMail = ItemUtil.getMailReward(findRewardgroup, 1.0f);
String title = SErrorCodeEerverConfig.getI18NMessage("adventuren_boss_find_reward_title");
String content = SErrorCodeEerverConfig.getI18NMessage("adventuren_boss_find_reward__txt");
MailLogic.getInstance().sendMail(findUserId,title,content,findRewardMail,nowTime, Global.MAIL_EFFECTIVE_TIME);
String killRewardMail = ItemUtil.getMailReward(killReward, 1.0f);
title = SErrorCodeEerverConfig.getI18NMessage("adventuren_boss_kill_reward_title");
content = SErrorCodeEerverConfig.getI18NMessage("adventuren_boss_kill_reward__txt");
MailLogic.getInstance().sendMail(killUid,title,content,killRewardMail,nowTime, Global.MAIL_EFFECTIVE_TIME);
}
@ -404,37 +540,40 @@ public class CombatLogic {
}
public List<Integer> parseToList(int checkResult[]){
List<Integer> result =new ArrayList<>(5);
for(int i=1;i<checkResult.length;i++){
result.add(checkResult[1]);
}
return result;
}
public void getWorldRankByPage(ISession session,int page) throws Exception {
if (page == 0) {
page = 1;
}
int start = (page - 1) * 20, end = page * 20 - 1;
List<CommonProto.AdventureRankItemInfo> adventureRankItemInfos = new ArrayList<>(20);
Set<ZSetOperations.TypedTuple<String>> adventureBossRankInfo= RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ADVENTRUEN_BOSS_RANK,"", start, end);
for(ZSetOperations.TypedTuple<String> item : adventureBossRankInfo){
String value = item.getValue();
int score =item.getScore().intValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUser(uid);
adventureRankItemInfos.add(CBean2Proto.getAdventureRankItemInfo(uid,user,score,++start));
}
int uid = session.getUid();
int score = RedisUtil.getInstence().getZSetScore(RedisKey.ADVENTRUEN_BOSS_RANK,"", Integer.toString(uid)).intValue();
int myRank =-1;
if(score == -1){
score = 0;
}else{
myRank= RedisUtil.getInstence().getZSetreverseRank(RedisKey.ADVENTRUEN_BOSS_RANK,"",Integer.toString(uid)).intValue();
}
User user = UserManager.getUser(uid);
CommonProto.AdventureRankItemInfo myinfo = CBean2Proto.getAdventureRankItemInfo(session.getUid(), user, score, myRank);
FightInfoProto.AdventurnRankResponse build = FightInfoProto.AdventurnRankResponse.newBuilder().addAllAdventureRankItemInfo(adventureRankItemInfos).setMyInfo(myinfo).build();
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_RANK_RESPONSE_VALUE,build,true);
}
/**
*
* @param type
* @throws Exception
*/
public void sendReward(int type) throws Exception {
public void sendReward() throws Exception {
String title=SErrorCodeEerverConfig.getI18NMessage("adventure_boss_reward_title");
String content=SErrorCodeEerverConfig.getI18NMessage("adventure_boss_reward_txt");
Set<ZSetOperations.TypedTuple<String>> adventureBossRankInfo= RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.ADVENTRUEN_BOSS_RANK,"", 0,-1);
@ -444,7 +583,7 @@ public class CombatLogic {
String value = item.getValue();
int uid = Integer.parseInt(value);
User user = UserManager.getUser(uid);
String rewardByRank = getRewardByRank(rank++, type);
String rewardByRank = getRewardByRank(rank++);
if("".equals(rewardByRank)){
break;
}
@ -452,7 +591,7 @@ public class CombatLogic {
}
}
public String getRewardByRank(int rank,int type){
public String getRewardByRank(int rank){
Map<Integer, SAdventureReward> config = SAdventureReward.getAdventureRewardMap();
for(SAdventureReward sAdventureReward : config.values()){
int minRank = sAdventureReward.getMinRank();

View File

@ -4,6 +4,7 @@ import com.ljsd.jieling.config.SMonsterConfig;
import com.ljsd.jieling.handler.map.MapManager;
import com.ljsd.jieling.handler.map.TemporaryItems;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.protocols.CommonProto;
import java.util.ArrayList;
@ -199,4 +200,16 @@ public class CBean2Proto {
.setLeftStep(leftStep)
.build();
}
public static CommonProto.AdventureRankItemInfo getAdventureRankItemInfo(int uid, User user, int hurtNum, int rank){
PlayerManager playerInfoManager = user.getPlayerInfoManager();
return CommonProto.AdventureRankItemInfo.newBuilder()
.setUid(uid)
.setLevel(playerInfoManager.getLevel())
.setName(playerInfoManager.getNickName())
.setHurt(hurtNum)
.setHead(0)
.setRank(rank)
.build();
}
}

View File

@ -115,11 +115,9 @@ public class ItemUtil {
}
/**
*
* @param user
* @param dropGroupIds
* @param dropRatio
* @param isMapping
* @return
* @throws Exception
*/

View File

@ -30,6 +30,31 @@ public class MonsterUtil {
return map;
}
public static Map<Integer, List<CommonProto.FightUnitInfo>> getMonsterByGroup(int groupId, Map<Integer,List<Integer>> hps){
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(groupId);
int[][] groupIds = sMonsterGroup.getContents();
Map<Integer, List<CommonProto.FightUnitInfo>> map = new ConcurrentHashMap<>();
Map<Integer, CommonProto.FightUnitInfo> monsterMap = SMonsterConfig.getMonsterMap();
for (int i = 0; i < groupIds.length; i++) {
int[] monsterIds = groupIds[i];
List<CommonProto.FightUnitInfo> monsterList = new ArrayList<>();
List<Integer> hpInfo = hps.get(i);
if(hpInfo!=null && !hpInfo.isEmpty()){
int index=0;
for (int monsterId : monsterIds) {
SMonsterConfig sMonsterConfig = SMonsterConfig.getsMonsterConfigMap().get(monsterId);
monsterList.add(CBean2Proto.getMonster(sMonsterConfig,hpInfo.get(index)));
}
}else{
for (int monsterId : monsterIds) {
monsterList.add(monsterMap.get(monsterId));
}
}
map.put(i,monsterList);
}
return map;
}
public static Map<Integer,List<Integer>> getMonsterHpByGroup(int groupId){
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(groupId);