Merge branch 'dev_dh_xinjiang' into master_test_hw
commit
2ae47522f3
|
@ -48,4 +48,6 @@ public interface VipPrivilegeType {
|
|||
|
||||
int DRAGON_TREASURE_SUPPLY = 1007;//青龙宝藏每周补给
|
||||
|
||||
int NEW_GENERAL_ATTACK_NUM = 3005;
|
||||
|
||||
}
|
||||
|
|
|
@ -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;//新将来袭
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
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.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 com.ljsd.jieling.util.ItemUtil;
|
||||
import config.SMonsterConfig;
|
||||
import config.SMonsterGroup;
|
||||
import config.SNewHeroConfig;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.text.NumberFormat;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/***
|
||||
* @author hj
|
||||
* @date 2020-11-27
|
||||
* 新将来袭
|
||||
*/
|
||||
@Component
|
||||
public class NewGeneralAttackHandler extends BaseHandler<ActivityProto.NewGeneralAttackRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.NewGeneralAttackRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public GeneratedMessage processWithProto(int uid, ActivityProto.NewGeneralAttackRequest proto) throws Exception {
|
||||
|
||||
// 用户信息
|
||||
User user = UserManager.getUser(uid);
|
||||
if (user == 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());
|
||||
|
||||
// 读表
|
||||
int monsterGroupId = newHeroConfig.getMonsterGroup(); //怪物id
|
||||
int bossBlood = 0; //怪物血量
|
||||
int[][] hurtList = newHeroConfig.getDropCell(); //伤害奖励表
|
||||
|
||||
SMonsterGroup sMonsterGroup = SMonsterGroup.getsMonsterGroupMap().get(monsterGroupId);
|
||||
// 获取怪物组
|
||||
int[][] contents = sMonsterGroup.getContents();
|
||||
|
||||
for (int i = 0; i < contents.length; i++) {
|
||||
int[] ints = contents[i];
|
||||
for (int j = 0; j < ints.length; j++) {
|
||||
if (ints[j] == 0){
|
||||
// 怪物不存在
|
||||
continue;
|
||||
}
|
||||
SMonsterConfig monsterConfig = STableManager.getConfig(SMonsterConfig.class).get(ints[j]);
|
||||
// 计算总血量
|
||||
bossBlood+=monsterConfig.getHp();
|
||||
}
|
||||
}
|
||||
|
||||
if (bossBlood == 0){
|
||||
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE);
|
||||
}
|
||||
|
||||
// 战斗逻辑
|
||||
PVEFightEvent pveFightEvent = new PVEFightEvent(user.getId(), GlobalsDef.FORMATION_NORMAL, 1000, "", GameFightType.GuildChallenge, 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();
|
||||
|
||||
// 设置小数点后4位
|
||||
NumberFormat numberFormat = NumberFormat.getInstance();
|
||||
numberFormat.setMaximumFractionDigits(4);
|
||||
// 伤害/血量 ,用float表示
|
||||
String blood = numberFormat.format((float) checkResult[1] / (float)bossBlood);
|
||||
// 表里面配置的伤害是万分比,所以这里的概率乘以10000
|
||||
float b = Float.parseFloat(blood)*10000;
|
||||
|
||||
// 获取奖励id
|
||||
int[] dropList = new int[1];
|
||||
|
||||
// 道具逻辑,封装好的
|
||||
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
|
||||
|
||||
for (int i = 0; i < hurtList.length; i++) {
|
||||
// 当前类型奖励次数
|
||||
float v = b / hurtList[i][0];
|
||||
dropList[0] = hurtList[i][1];
|
||||
ItemUtil.drop(user, dropList,drop,v,0, BIReason.NEW_GENERAL_ATTACK);
|
||||
System.out.println();
|
||||
}
|
||||
// 消耗道具
|
||||
PlayerLogic.getInstance().checkAndUpdate(user, proto.getPrivilageTypeId(),1);
|
||||
|
||||
return ActivityProto.NewGeneralAttackResponse.newBuilder().setFightData(fightData).setDrop(drop).build();
|
||||
}
|
||||
}
|
|
@ -82,5 +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 = 200;//新将来袭
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ 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_ATTACK(ActivityType.NEW_GENERAL_ATTACK,DefaultEmptyActivity::new),
|
||||
;
|
||||
private int type;
|
||||
private Function<Integer, AbstractActivity> toActivityFunction;
|
||||
|
|
|
@ -249,6 +249,27 @@ public class ItemUtil {
|
|||
return dropBuilder;
|
||||
}
|
||||
|
||||
public static CommonProto.Drop.Builder drop(User user, int[] dropGroupIds,CommonProto.Drop.Builder dropBuilder,float dropRatio, int isMapping,int reason) throws Exception {
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
Map<Integer, Integer> cardMap = new HashMap<>();
|
||||
Map<Integer, Integer> equipMap = new HashMap<>();
|
||||
Map<Integer,Integer> randomMap = new HashMap<>();
|
||||
ItemMap itemObj = new ItemMap();
|
||||
|
||||
combineRewardDropGroup(user, dropGroupIds, dropRatio, itemMap, cardMap, equipMap, randomMap,itemObj);
|
||||
useRandomItem(user,randomMap,reason);
|
||||
if (isMapping == 1) {
|
||||
addItemToTemporaryBag(user, itemMap, equipMap, dropBuilder);
|
||||
} else {
|
||||
addItem(user,itemMap,dropBuilder,reason);
|
||||
addEquip(user,equipMap,dropBuilder,reason);
|
||||
addSpecialMonster(user,itemObj,dropBuilder,reason);
|
||||
|
||||
}
|
||||
addCard(user,cardMap,dropBuilder,reason);
|
||||
return dropBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param user
|
||||
* @param dropGroupIds
|
||||
|
|
Loading…
Reference in New Issue