公会副本
parent
588e22626f
commit
1b70b3c73a
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family.guildChallenge;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildChallengeLogic;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/8/21
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetGuildChallengeInfoHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GET_GUILD_CHALLENGE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildChallengeLogic.getInstance().getGuildChallengeInfo(iSession, MessageTypeProto.MessageType.GET_GUILD_CHALLENGE_INFO_RESPONSE);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
package com.ljsd.jieling.handler.family.guildChallenge;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildChallengeLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/8/21
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GuildChallengeHandler extends BaseHandler<Family.GuildChallengeRequest> {
|
||||
|
||||
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GUILD_CHALLENGE_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.GuildChallengeRequest proto) throws Exception {
|
||||
GuildChallengeLogic.getInstance().doGuildChallenge(iSession,proto.getBossId(),proto.getType(), MessageTypeProto.MessageType.GUILD_CHALLENGE_RESPONSE);
|
||||
|
||||
}
|
||||
}
|
|
@ -39,6 +39,8 @@ public class GuildMyInfo extends MongoBase {
|
|||
private int carPlayProgress; // 车迟玩的阶段
|
||||
|
||||
private int joinTime;//加入公会时间
|
||||
//公会副本
|
||||
private int guildChallengeDamage;
|
||||
|
||||
|
||||
|
||||
|
@ -294,4 +296,13 @@ public class GuildMyInfo extends MongoBase {
|
|||
updateString("joinTime",joinTime);
|
||||
}
|
||||
|
||||
public int getGuildChallengeDamage() {
|
||||
return guildChallengeDamage;
|
||||
}
|
||||
|
||||
public void setGuildChallengeDamage(int guildChallengeDamage) {
|
||||
this.guildChallengeDamage = guildChallengeDamage;
|
||||
updateString("guildChallengeDamage",guildChallengeDamage);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -56,6 +56,10 @@ public class GuildInfo extends MongoBase {
|
|||
|
||||
public List<GuildHelpLog> guildHelpLogInfoMap = new LinkedList<>();
|
||||
|
||||
private int currBossId;
|
||||
|
||||
private long bossHpRemain;
|
||||
|
||||
public GuildInfo() {
|
||||
setRootCollection(_COLLECTION_NAME);
|
||||
}
|
||||
|
@ -77,6 +81,8 @@ public class GuildInfo extends MongoBase {
|
|||
totalMembers=1;
|
||||
icon = MathUtils.randomInt(SGuildSetting.sGuildSetting.getTotemItem().length)+1;
|
||||
defendInfo = new ConcurrentHashMap<>();
|
||||
currBossId = 1;
|
||||
bossHpRemain = 10000;
|
||||
}
|
||||
|
||||
public void addMembers(int type,int uid){
|
||||
|
@ -265,4 +271,22 @@ public class GuildInfo extends MongoBase {
|
|||
public List<GuildHelpLog> getGuildHelpLogInfoMap() {
|
||||
return guildHelpLogInfoMap;
|
||||
}
|
||||
|
||||
public int getCurrBossId() {
|
||||
return currBossId;
|
||||
}
|
||||
|
||||
public void setCurrBossId(int currBossId) {
|
||||
this.currBossId = currBossId;
|
||||
updateString("currBossId",currBossId);
|
||||
}
|
||||
|
||||
public long getBossHpRemain() {
|
||||
return bossHpRemain;
|
||||
}
|
||||
|
||||
public void setBossHpRemain(long bossHpRemain) {
|
||||
this.bossHpRemain = bossHpRemain;
|
||||
updateString("bossHpRemain",bossHpRemain);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,136 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.GuildInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightDispatcher;
|
||||
import com.ljsd.jieling.logic.fight.GameFightType;
|
||||
import com.ljsd.jieling.logic.fight.PVEFightEvent;
|
||||
import com.ljsd.jieling.logic.fight.result.FightResult;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SGuildCheckpointConfig;
|
||||
import manager.STableManager;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/8/21
|
||||
* @discribe
|
||||
*/
|
||||
public class GuildChallengeLogic {
|
||||
|
||||
public static GuildChallengeLogic getInstance() {
|
||||
return Instance.instance;
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static GuildChallengeLogic instance = new GuildChallengeLogic();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Map<Integer,Object> lockMap = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
|
||||
|
||||
//获取信息
|
||||
public void getGuildChallengeInfo(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
if(guildId==0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
|
||||
int currBossId = guildInfo.getCurrBossId();
|
||||
SGuildCheckpointConfig config = STableManager.getConfig(SGuildCheckpointConfig.class).get(currBossId);
|
||||
Family.GetGuildChallengeInfoResponse response = Family.GetGuildChallengeInfoResponse.newBuilder()
|
||||
.setCurBoss(currBossId)
|
||||
.setBlood((int)(guildInfo.getBossHpRemain()*10000/config.getOpenRules())).build();
|
||||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response,true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 挑战
|
||||
* @param session
|
||||
*/
|
||||
public void doGuildChallenge(ISession session,int bossId,int type,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
if(guildId==0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
if(lockMap.containsKey(guildId)){
|
||||
lockMap.put(guildId,new Object());
|
||||
}
|
||||
String error = "";
|
||||
/**
|
||||
* 挑战加锁
|
||||
*/
|
||||
CommonProto.Drop.Builder drop = null;
|
||||
CommonProto.FightData fightData = null;
|
||||
int kill = 0;
|
||||
synchronized (lockMap.get(guildId)){
|
||||
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
|
||||
if(guildInfo.getCurrBossId()!=bossId||guildInfo.getBossHpRemain()<=0){
|
||||
error = "已被击杀";
|
||||
}else{
|
||||
SGuildCheckpointConfig config = STableManager.getConfig(SGuildCheckpointConfig.class).get(bossId);
|
||||
|
||||
|
||||
if(type==0){
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(uid, 1, 10, "", GameFightType.DailyChallenge, config.getMonsterId(), 3);
|
||||
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
fightData = fightResult.getFightData();
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
int damage = checkResult[1];
|
||||
|
||||
if(checkResult[0]==1){
|
||||
kill = 1;
|
||||
guildInfo.setCurrBossId(guildInfo.getCurrBossId()+1);
|
||||
}
|
||||
user.getGuildMyInfo().setGuildChallengeDamage(damage);
|
||||
//记录血量
|
||||
guildInfo.setBossHpRemain(guildInfo.getBossHpRemain()-damage);
|
||||
}else{
|
||||
//扫荡
|
||||
guildInfo.setBossHpRemain(guildInfo.getBossHpRemain()-user.getGuildMyInfo().getGuildChallengeDamage());
|
||||
}
|
||||
|
||||
|
||||
|
||||
drop = ItemUtil.drop(user, new int[]{config.getReward()}, 1, 0, 1);
|
||||
|
||||
}
|
||||
}
|
||||
if(!error.isEmpty()){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Family.GuildChallengeResponse.Builder response = Family.GuildChallengeResponse.newBuilder();
|
||||
response.setDrop(drop);
|
||||
if(fightData!=null){
|
||||
response.setFightData(fightData);
|
||||
}
|
||||
response.setKill(kill);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,91 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="GuildCheckpointConfig")
|
||||
public class SGuildCheckpointConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private String remarks;
|
||||
|
||||
private int openRules;
|
||||
|
||||
private int reward;
|
||||
|
||||
private int killReward;
|
||||
|
||||
private int legionExp;
|
||||
|
||||
private int monsterId;
|
||||
|
||||
private int[][] attributePromote;
|
||||
|
||||
private int[][] attributePromotePrice;
|
||||
|
||||
private int[] privilege;
|
||||
|
||||
private int[][] rankingReward;
|
||||
|
||||
private int[][] rewardNumber;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public String getRemarks() {
|
||||
return remarks;
|
||||
}
|
||||
|
||||
public int getOpenRules() {
|
||||
return openRules;
|
||||
}
|
||||
|
||||
public int getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int getKillReward() {
|
||||
return killReward;
|
||||
}
|
||||
|
||||
public int getLegionExp() {
|
||||
return legionExp;
|
||||
}
|
||||
|
||||
public int getMonsterId() {
|
||||
return monsterId;
|
||||
}
|
||||
|
||||
public int[][] getAttributePromote() {
|
||||
return attributePromote;
|
||||
}
|
||||
|
||||
public int[][] getAttributePromotePrice() {
|
||||
return attributePromotePrice;
|
||||
}
|
||||
|
||||
public int[] getPrivilege() {
|
||||
return privilege;
|
||||
}
|
||||
|
||||
public int[][] getRankingReward() {
|
||||
return rankingReward;
|
||||
}
|
||||
|
||||
public int[][] getRewardNumber() {
|
||||
return rewardNumber;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue