神印合成bug修改2

back_recharge
duhui 2022-04-29 18:05:36 +08:00
parent 25b4abd436
commit 9c0af37bcf
3 changed files with 51 additions and 39 deletions

View File

@ -32,6 +32,10 @@ public class SaveHeroForceEventHandler implements IEventHandler {
// 参数获取
int uid = ((SaveHeroForceEvent) event).getUid();
String heroId = ((SaveHeroForceEvent) event).getHeroId();
// null兼容
if (heroId == null){
heroId = "";
}
// user
User user = UserManager.getUser(uid);
// 需要存储战力的编队
@ -41,7 +45,7 @@ public class SaveHeroForceEventHandler implements IEventHandler {
if (!HeroLogic.getInstance().isInTeam(user,heroId,teamId) && !"".equals(heroId)){
continue;
}
// 主线标对需要更新排行榜信息
// 主线编队需要更新排行榜信息
if (teamId == TeamEnum.FORMATION_NORMAL.getTeamId()){
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(uid));
}

View File

@ -6344,59 +6344,48 @@ public class HeroLogic {
/**
*
* @param iSession
* @param ItemId id
* @param itemId id
* @param heroId
* @return
* @throws Exception
*/
public void upGodSeal(ISession iSession, int ItemId, String heroId) throws Exception {
public void upGodSeal(ISession iSession, int itemId, String heroId) throws Exception {
// 获取玩家参数
User user = UserManager.getUser(iSession.getUid());
// 升品神印参数
Map<Integer, SEquipConfig> config = STableManager.getConfig(SEquipConfig.class);
SEquipConfig sEquipConfig = config.get(ItemId);
// 升品消耗
int[][] resource = sEquipConfig.getResource();
SEquipConfig sEquipConfig = config.get(itemId);
// 一些需要记录的参数
int position = 0;
int targetId = sEquipConfig.getFormula()[0][0];
Hero hero = null;
// 英雄身上的神印升品
if (!"".equals(heroId)){
ArrayList<int[][]> list = new ArrayList<>();
// hero信息
hero = user.getHeroManager().getHero(heroId);
// hero godseal 信息
HashMap<Integer, Integer> map = new HashMap<>(hero.getGodSealByPositionMap());
for (Map.Entry<Integer, Integer> next : map.entrySet()) {
if (next.getValue() == ItemId){
// 删除英雄身上的神印信息
hero.removeGodSeal(next.getKey());
// 入背包
list.add(new int[][]{{next.getValue(),1}});
// 记录神印位置
position = next.getKey();
}
}
// 卸下的神印需要放回物品背包
ItemUtil.drop(user,list,BIReason.MARGE_GOD_SEAL);
// 基础消耗
ArrayList<int[][]> list = new ArrayList<>();
list.add(sEquipConfig.getResource());
// 背包中的需要增加一个英雄装备的直接覆盖id即可
if ("".equals(heroId)) {
list.add(new int[][]{{itemId, 1}});
}
// 验证道具消耗
boolean b = ItemUtil.itemCost(user, resource, BIReason.MARGE_GOD_SEAL, 0);
boolean b = ItemUtil.itemCost(user, list, BIReason.MARGE_GOD_SEAL, 0);
if (!b) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
// 合成奖励放入背包
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sEquipConfig.getFormula(), BIReason.MARGE_GOD_SEAL);
// 原本是英雄身上的需要重新装备,并删除背包中的
if (position != 0 && hero != null){
// 给英雄重新装备上改id
hero.putGodSealByPositionMap(position,targetId);
// 删除背包里的神印
ItemUtil.itemCost(user, sEquipConfig.getFormula(), BIReason.MARGE_GOD_SEAL,0);
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
// 背包合成,走掉落
if ("".equals(heroId)){
drop = ItemUtil.drop(user, sEquipConfig.getFormula(), BIReason.MARGE_GOD_SEAL);
}
// 英雄装备合成,修改英雄信息,不走掉落
else {
// hero信息
Hero hero = user.getHeroManager().getHero(heroId);
// hero godseal 信息
for (Map.Entry<Integer, Integer> next : hero.getGodSealByPositionMap().entrySet()) {
if (next.getValue() == itemId){
hero.putGodSealByPositionMap(next.getKey(),sEquipConfig.getFormula()[0][0]);
break;
}
}
}
// 更新战力

View File

@ -1514,6 +1514,25 @@ public class ItemUtil {
return true;
}
/**
*
* @param user
* @return
* @throws Exception
*/
public static boolean itemCost(User user,List<int[][]> itemArrs,int reason,int subReson) throws Exception {
Map<Integer, Integer> itemMap = new HashMap<>();
for(int[][] itemArr : itemArrs){
selectCost(itemArr,itemMap);
}
boolean result = checkCost(user, itemMap);
if (!result) {
return false;
}
useItem(user, itemMap,reason,subReson);
return true;
}
public static boolean itemCost(User user,Map<Integer, Integer> costItems,int reason,int subReson) throws Exception {
boolean result = checkCost(user, costItems);
if (!result) {