临时提交2
parent
249580edf7
commit
ed7d883cce
|
@ -298,4 +298,6 @@ public interface BIReason {
|
|||
int SKIN_USE_CONSUME = 1073;//激活皮肤消耗
|
||||
int SUB_ACTIVITY_CONSUME = 1074;//易经宝库
|
||||
int SUB_ACTIVITY_CONSUME_FINISH = 1075;//易经宝库活动结束补发消耗
|
||||
|
||||
int NEW_GENERAL_ATTACK = 1076;//新将来袭
|
||||
}
|
|
@ -1,16 +1,32 @@
|
|||
package com.ljsd.jieling.handler.activity;
|
||||
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.VipInfo;
|
||||
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.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.protocols.ActivityProto;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import config.SPrivilegeTypeConfig;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SMonsterConfig;
|
||||
import config.SMonsterGroup;
|
||||
import config.SNewHeroConfig;
|
||||
import manager.STableManager;
|
||||
|
||||
/***
|
||||
* @author hj
|
||||
* @date 2020-11-27
|
||||
* 新将来袭
|
||||
*/
|
||||
public class NewGeneralAttackHandler extends BaseHandler<ActivityProto.NewGeneralAttackRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
|
@ -20,18 +36,62 @@ public class NewGeneralAttackHandler extends BaseHandler<ActivityProto.NewGenera
|
|||
@Override
|
||||
public GeneratedMessage processWithProto(int uid, ActivityProto.NewGeneralAttackRequest proto) throws Exception {
|
||||
|
||||
// 用户信息
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == null) {
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||
}
|
||||
|
||||
VipInfo vipInfo = user.getPlayerInfoManager().getVipInfo().get(proto.getActivityId());
|
||||
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(proto.getCountId());
|
||||
if (sPrivilegeTypeConfig == null || vipInfo == null){
|
||||
throw new ErrorCodeException(ErrorCode.UNKNOWN);
|
||||
// 查询,挑战次数是否满足
|
||||
boolean countBol = PlayerLogic.getInstance().check(user, proto.getPrivilageTypeId(),1);
|
||||
if (!countBol){
|
||||
throw new ErrorCodeException(ErrorCode.REFRESH_WHEL_TIME_NOT);
|
||||
}
|
||||
|
||||
SNewHeroConfig newHeroConfig = STableManager.getConfig(SNewHeroConfig.class).get(proto.getActivityId());
|
||||
|
||||
return null;
|
||||
// 读表
|
||||
int monsterGroupId = newHeroConfig.getMonsterGroup(); //怪物id
|
||||
int bossBlood = 0; //怪物血量
|
||||
int[][] hurt = newHeroConfig.getDropList(); //伤害奖励表
|
||||
|
||||
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(monsterGroupId);
|
||||
int[][] contents = sMonsterGroup.getContents();
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
if (contents[i][0] == 0){
|
||||
break;
|
||||
}
|
||||
SMonsterConfig monsterConfig = STableManager.getConfig(SMonsterConfig.class).get(contents[i][1]);
|
||||
bossBlood+=monsterConfig.getHp();
|
||||
}
|
||||
|
||||
// 战斗逻辑
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.DailyChallenge, monsterGroupId, 3);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(pveFightEvent);
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
|
||||
.setFightMaxTime(20)
|
||||
.setFightSeed(fightResult.getSeed())
|
||||
.setHeroFightInfos(fightResult.getFightTeamInfo())
|
||||
.addAllMonsterList(fightResult.getMonsterTeamList())
|
||||
.setFightType(GameFightType.DailyChallenge.getFightType().getType())
|
||||
.build();
|
||||
|
||||
// 战斗结果,第二位是伤害
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
// 伤害对比血量,百分比
|
||||
int blood = checkResult[1] / bossBlood;
|
||||
// 获取奖励id
|
||||
int[] dropList = new int[hurt.length];
|
||||
for (int i=0;i<hurt.length;i++){
|
||||
if (blood > hurt[i][0]/100){
|
||||
dropList[i] = hurt[i][1];
|
||||
}
|
||||
}
|
||||
// 道具逻辑,封装好的
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropList,1,0, BIReason.NEW_GENERAL_ATTACK);
|
||||
// 消耗道具
|
||||
PlayerLogic.getInstance().checkAndUpdate(user, proto.getPrivilageTypeId(),1);
|
||||
|
||||
return ActivityProto.NewGeneralAttackResponse.newBuilder().setFightData(fightData).setDrop(drop).build();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -82,6 +82,6 @@ public interface ActivityType {
|
|||
int SKIN_RECHARGE_ACTIVITY = 71;
|
||||
int SPECIAL_MONSTER_RANDOM_ACTIVITY = 100;//灵兽限时抽卡
|
||||
int SPECIAL_MONSTER_GIFT_ACTIVITY = 101;//灵兽礼包
|
||||
int NEW_GENERAL_RECRUITING = 102;//新将招募
|
||||
int NEW_GENERAL_ATTACK = 103;//新将来袭
|
||||
// int NEW_GENERAL_RECRUITING = 102;//新将招募
|
||||
int NEW_GENERAL_ATTACK = 200;//新将来袭
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ public enum ActivityTypeEnum {
|
|||
SKIN_RECHARGE_ACTIVITY(ActivityType.SKIN_RECHARGE_ACTIVITY, DefaultEmptyActivity::new),
|
||||
SPECIAL_MONSTER_RANDOM_ACTIVITY(ActivityType.SPECIAL_MONSTER_RANDOM_ACTIVITY,LimitRandomSpecialMonsterActivity::new),
|
||||
SPECIAL_MONSTER_GIFT_ACTIVITY(ActivityType.SPECIAL_MONSTER_GIFT_ACTIVITY,DefaultEmptyActivity::new),
|
||||
NEW_GENERAL_RECRUITING(ActivityType.NEW_GENERAL_RECRUITING,LimitRandomCardActivity::new),
|
||||
// NEW_GENERAL_RECRUITING(ActivityType.NEW_GENERAL_RECRUITING,LimitRandomCardActivity::new),
|
||||
NEW_GENERAL_ATTACK(ActivityType.NEW_GENERAL_ATTACK,DefaultEmptyActivity::new),
|
||||
;
|
||||
private int type;
|
||||
|
|
Loading…
Reference in New Issue