公会副本提交

lvxinran 2020-08-27 19:49:57 +08:00
parent ec758ee011
commit 95375eab26
4 changed files with 29 additions and 14 deletions

View File

@ -17,7 +17,7 @@ public enum FightType {
CarPersonFight(12), // 车迟斗法抢夺
EXPEDITION(13), // 远征
GuildChallenge(14), //公会副本
;

View File

@ -58,7 +58,7 @@ public class GuildInfo extends MongoBase {
private int currBossId;
private long bossHpRemain;
private int bossHpRemain;
public GuildInfo() {
setRootCollection(_COLLECTION_NAME);
@ -82,7 +82,6 @@ public class GuildInfo extends MongoBase {
icon = MathUtils.randomInt(SGuildSetting.sGuildSetting.getTotemItem().length)+1;
defendInfo = new ConcurrentHashMap<>();
currBossId = 1;
bossHpRemain = 10000;
}
public void addMembers(int type,int uid){
@ -281,11 +280,11 @@ public class GuildInfo extends MongoBase {
updateString("currBossId",currBossId);
}
public long getBossHpRemain() {
public int getBossHpRemain() {
return bossHpRemain;
}
public void setBossHpRemain(long bossHpRemain) {
public void setBossHpRemain(int bossHpRemain) {
this.bossHpRemain = bossHpRemain;
updateString("bossHpRemain",bossHpRemain);
}

View File

@ -23,7 +23,9 @@ import com.ljsd.jieling.util.MessageUtil;
import config.SGuildCheckpointConfig;
import manager.STableManager;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ -60,17 +62,21 @@ public class GuildChallengeLogic {
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
int currBossId = guildInfo.getCurrBossId();
SGuildCheckpointConfig config = STableManager.getConfig(SGuildCheckpointConfig.class).get(currBossId);
double bossHpRemain = guildInfo.getBossHpRemain();
Family.GetGuildChallengeInfoResponse response = Family.GetGuildChallengeInfoResponse.newBuilder()
.setCurBoss(currBossId)
.setBlood((int)(guildInfo.getBossHpRemain()*10000/config.getOpenRules())).build();
.setBlood(bossHpRemain==0?10000:(int)(bossHpRemain*10000/999999)).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 {
@ -81,7 +87,7 @@ public class GuildChallengeLogic {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
if(lockMap.containsKey(guildId)){
if(!lockMap.containsKey(guildId)){
lockMap.put(guildId,new Object());
}
String error = "";
@ -94,26 +100,35 @@ public class GuildChallengeLogic {
long damage = 0;
synchronized (lockMap.get(guildId)){
GuildInfo guildInfo = GuilidManager.guildInfoMap.get(guildId);
if(guildInfo.getCurrBossId()!=bossId||guildInfo.getBossHpRemain()<=0){
if(guildInfo.getCurrBossId()!=bossId){
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);
PVEFightEvent pveFightEvent = new PVEFightEvent(uid, 1, 10, "", GameFightType.GuildChallenge, config.getMonsterId(), 3);
if(guildInfo.getBossHpRemain()!=0){
List<Integer> hp = new ArrayList<>();
hp.add(guildInfo.getBossHpRemain());
pveFightEvent.setMonsterRemainHp(hp);
}
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
fightData = fightResult.getFightData();
int[] checkResult = fightResult.getCheckResult();
int damageInt = checkResult[1];
if(checkResult[0]==1){
if(checkResult[0]==1) {
kill = 1;
guildInfo.setCurrBossId(guildInfo.getCurrBossId()+1);
//重置boss血量
guildInfo.setCurrBossId(guildInfo.getCurrBossId() + 1);
guildInfo.setBossHpRemain(0);
}else if(checkResult[0]==0){
guildInfo.setBossHpRemain(guildInfo.getBossHpRemain()==0?999999-damageInt:guildInfo.getBossHpRemain()-damageInt);
}else{
error = "战斗异常!";
}
user.getGuildMyInfo().setGuildChallengeDamage(damageInt);
//记录血量
guildInfo.setBossHpRemain(guildInfo.getBossHpRemain()-damageInt);
damage = damageInt;
}else{
//扫荡

View File

@ -47,6 +47,7 @@ public enum GameFightType {
CarBossChallenge(FightType.CarBossFight,new DefaultWithoutHandFightHandler(),null),
CarPersonChallenge(FightType.CarBossFight,new PVPFightHandler(),null),
GuildChallenge(FightType.GuildChallenge,new DefaultWithoutHandFightHandler(),null),
;