boss
parent
48be1a6fe6
commit
69d72692df
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler;
|
||||
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
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;
|
||||
|
|
@ -18,5 +19,6 @@ public class FunctionOfTimeHandler extends BaseHandler{
|
|||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
iSession.setFiveReady(1);
|
||||
GlobalDataManaager.getInstance().getTimeOfControl(iSession);
|
||||
CombatLogic.getInstance().getInvasionBoss(iSession,null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ 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;
|
||||
|
||||
|
|
@ -16,6 +17,6 @@ public class GetAdventureBossHurtHandler extends BaseHandler {
|
|||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
CombatLogic.getInstance().getInvasionBoss(iSession);
|
||||
CombatLogic.getInstance().getInvasionBoss(iSession, FightInfoProto.AdventureBossInfoResponse.newBuilder());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package com.ljsd.jieling.logic.dao;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
public class AdventureBoss {
|
||||
public class AdventureBoss implements Comparable<AdventureBoss> {
|
||||
private String bossId;
|
||||
private int bossGroupId;
|
||||
private int arenaId;
|
||||
|
|
@ -11,6 +11,7 @@ public class AdventureBoss {
|
|||
private int findTime; //发现时间
|
||||
private int totalHp;// 总血量
|
||||
private int remainHp;
|
||||
private int shareTime; //分享时间
|
||||
private List<Integer> remainHps; //剩余血量
|
||||
|
||||
public AdventureBoss() {
|
||||
|
|
@ -100,4 +101,19 @@ public class AdventureBoss {
|
|||
public void setRemainHps(List<Integer> remainHps) {
|
||||
this.remainHps = remainHps;
|
||||
}
|
||||
|
||||
public int getShareTime() {
|
||||
return shareTime;
|
||||
}
|
||||
|
||||
public void setShareTime(int shareTime) {
|
||||
this.shareTime = shareTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(AdventureBoss o) {
|
||||
Integer shareTimeA = this.getShareTime();
|
||||
Integer shareTimeB = o.getShareTime();
|
||||
return shareTimeA.compareTo(shareTimeB);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -417,15 +417,22 @@ public class CombatLogic {
|
|||
|
||||
|
||||
|
||||
public void getInvasionBoss(ISession session) throws Exception {
|
||||
|
||||
public void getInvasionBoss(ISession session,FightInfoProto.AdventureBossInfoResponse.Builder builder) throws Exception {
|
||||
int uid = session.getUid();
|
||||
FightInfoProto.AdventureBossInfoResponse.Builder builder = FightInfoProto.AdventureBossInfoResponse.newBuilder();
|
||||
Map<String, Integer> myHurtInfo = RedisUtil.getInstence().getMapValues(RedisKey.ADVENTRUEN_BOSS_OWN, Integer.toString(uid), String.class, Integer.class);
|
||||
int now = (int)(TimeUtils.now()/1000);
|
||||
int count = 0;
|
||||
if(myHurtInfo!=null&&!myHurtInfo.isEmpty()){
|
||||
int now = (int)(TimeUtils.now()/1000);
|
||||
int count = 0;
|
||||
User user = UserManager.getUser(uid);
|
||||
List<Integer> sendIds = new ArrayList<>(1);
|
||||
sendIds.add(uid);
|
||||
List<Integer> friends = user.getFriendManager().getFriends();
|
||||
List<Object> kes = new ArrayList<>(myHurtInfo.keySet());
|
||||
List<AdventureBoss> adventureBosseInfo = RedisUtil.getInstence().getMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO, "", kes, AdventureBoss.class);
|
||||
if(builder == null){
|
||||
Collections.sort(adventureBosseInfo);
|
||||
}
|
||||
List<String> removeAdventureBosseInfo = new ArrayList<>();
|
||||
for(AdventureBoss adventureBoss : adventureBosseInfo){
|
||||
if(adventureBoss == null){
|
||||
|
|
@ -446,20 +453,27 @@ public class CombatLogic {
|
|||
myHurtInfo.remove(bossId);
|
||||
break;
|
||||
}
|
||||
if(uid!=findUserId && !friends.contains(findUserId)){
|
||||
continue;
|
||||
}
|
||||
count++;
|
||||
User findUsser = UserManager.getUser(findUserId);
|
||||
builder.addAdventureBossInfo(CommonProto.AdventureBossInfo.newBuilder()
|
||||
.setArenaId(adventureBoss.getArenaId())
|
||||
.setFindUid(adventureBoss.getFindUserId())
|
||||
.setFindName(findUsser.getPlayerInfoManager().getNickName())
|
||||
.setBossId(bossId)
|
||||
.setBossGroupId(adventureBoss.getBossGroupId())
|
||||
.setMyHurt(myHurtInfo.get(bossId))
|
||||
.setRemainTime(remainTime)
|
||||
.setTotalHp(adventureBoss.getTotalHp())
|
||||
.setArenaLevel(adventureBoss.getArenaLevel())
|
||||
.setBossRemainlHp(adventureBoss.getRemainHp())
|
||||
.build());
|
||||
if(builder == null){
|
||||
broadAdventureBoss(adventureBoss,findUsser.getPlayerInfoManager().getNickName(),sendIds,uid);
|
||||
}else{
|
||||
builder.addAdventureBossInfo(CommonProto.AdventureBossInfo.newBuilder()
|
||||
.setArenaId(adventureBoss.getArenaId())
|
||||
.setFindUid(adventureBoss.getFindUserId())
|
||||
.setFindName(findUsser.getPlayerInfoManager().getNickName())
|
||||
.setBossId(bossId)
|
||||
.setBossGroupId(adventureBoss.getBossGroupId())
|
||||
.setMyHurt(myHurtInfo.get(bossId))
|
||||
.setRemainTime(remainTime)
|
||||
.setTotalHp(adventureBoss.getTotalHp())
|
||||
.setArenaLevel(adventureBoss.getArenaLevel())
|
||||
.setBossRemainlHp(adventureBoss.getRemainHp())
|
||||
.build());
|
||||
}
|
||||
myHurtInfo.remove(bossId);
|
||||
}
|
||||
if(!myHurtInfo.isEmpty()){
|
||||
|
|
@ -469,10 +483,15 @@ public class CombatLogic {
|
|||
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO,"",removeAdventureBosseInfo.toArray());
|
||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_OWN,"",removeAdventureBosseInfo.toArray());
|
||||
}
|
||||
User user = UserManager.getUser(uid);
|
||||
user.getPlayerInfoManager().removeRed(GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||
if(builder!=null){
|
||||
user.getPlayerInfoManager().removeRed(GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_RESPONSE_VALUE,builder.build(),true);
|
||||
if(builder!=null){
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_RESPONSE_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void callInvasionBoss(ISession iSession, boolean isGm) throws Exception {
|
||||
|
|
@ -565,7 +584,7 @@ public class CombatLogic {
|
|||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_LEFT_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
public void broadAdventureBoss(AdventureBoss adventureBoss,String findUserName){
|
||||
public void broadAdventureBoss(AdventureBoss adventureBoss,String findUserName,List<Integer> friends,int findUid){
|
||||
int arenaId = adventureBoss.getArenaId();
|
||||
SAdventureConfig sAdventureConfig = SAdventureConfig.getConfig().get(arenaId);
|
||||
CommonProto.AdventureBossSimpleInfo build = CommonProto.AdventureBossSimpleInfo.newBuilder()
|
||||
|
|
@ -577,8 +596,18 @@ public class CombatLogic {
|
|||
.build();
|
||||
FightInfoProto.AdventureBossFindIndication adventureBossFindIndication = FightInfoProto.AdventureBossFindIndication.newBuilder().setAdventureBossSimpleInfo(build).build();
|
||||
|
||||
for(Integer uid:OnlineUserManager.orderAdventureUids){
|
||||
boolean isMine = false;
|
||||
for(Integer uid:friends){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
if(uid == findUid){
|
||||
isMine = true;
|
||||
}
|
||||
if(sessionByUid!=null){
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_FIND_INDICATION_VALUE,adventureBossFindIndication,true);
|
||||
}
|
||||
}
|
||||
if(!isMine){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(findUid);
|
||||
if(sessionByUid!=null){
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_FIND_INDICATION_VALUE,adventureBossFindIndication,true);
|
||||
}
|
||||
|
|
@ -592,12 +621,14 @@ public class CombatLogic {
|
|||
return;
|
||||
}
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
broadAdventureBoss(adventureBoss,user.getPlayerInfoManager().getNickName());
|
||||
List<Integer> friends = user.getFriendManager().getFriends();
|
||||
for(Integer friendId :friends){
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_OWN,Integer.toString(friendId),bossId,0);
|
||||
MessageUtil.sendRedIndication(friendId, GlobalsDef.SHARE_BOSS_RED_TYPE);
|
||||
}
|
||||
adventureBoss.setShareTime((int)(TimeUtils.now()));
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId,adventureBoss);
|
||||
broadAdventureBoss(adventureBoss,user.getPlayerInfoManager().getNickName(),friends,session.getUid());
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_SHARE_RESPONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
|
|
@ -664,13 +695,20 @@ public class CombatLogic {
|
|||
//发送击杀boss奖励和发现者奖励
|
||||
if(fightResult == 1){
|
||||
i = i+1;
|
||||
String killReward = sendRewardOfBossKilled(adventureBoss.getFindUserId(), uid, bossGroupId, adventureBoss.getArenaId(), adventureBoss.getArenaLevel());
|
||||
String killReward = sendRewardOfBossKilled(adventureBoss.getFindUserId(), uid, bossGroupId, adventureBoss.getArenaId(), adventureBoss.getA renaLevel());
|
||||
builder.setKillRewards(killReward);
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.KILLINVASIONBOSS);
|
||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.ADVENTRUEN_BOSS_INFO,"",bossId);
|
||||
int findUserId = adventureBoss.getFindUserId();
|
||||
User findUser = UserManager.getUser(findUserId);
|
||||
List<Integer> friends = findUser.getFriendManager().getFriends();
|
||||
ISession findSession = OnlineUserManager.getSessionByUid(adventureBoss.getFindUserId());
|
||||
FightInfoProto.AdventureBossKillIndication bossKilled = FightInfoProto.AdventureBossKillIndication.newBuilder().setBossId(adventureBoss.getBossId()).setPos(adventureBoss.getArenaId()).build();
|
||||
for(Integer sendID : friends){
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(sendID);
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_KILL_INDICATION_VALUE,bossKilled,true);
|
||||
}
|
||||
if(findSession!=null){
|
||||
FightInfoProto.AdventureBossKillIndication bossKilled = FightInfoProto.AdventureBossKillIndication.newBuilder().setBossId(adventureBoss.getBossId()).setPos(adventureBoss.getArenaId()).build();
|
||||
MessageUtil.sendIndicationMessage(findSession,1, MessageTypeProto.MessageType.ADVENTURE_BOSS_KILL_INDICATION_VALUE,bossKilled,true);
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
Loading…
Reference in New Issue