新增礼物升星功能
parent
2421d26bc5
commit
27bf841cb6
|
@ -452,5 +452,7 @@ public interface BIReason {
|
|||
int TRAINING_ARCH_UP_COST = 1338;//特训建筑升级消耗
|
||||
int TRAINING_ARCH_UP_QUICK_COST = 1339;//特训建筑快速升级消耗
|
||||
int TRAINING_UP_LV_COST = 1340;//特训进阶消耗
|
||||
int TRAINING_UNLOCK_SKILL_COST = 1340;//特训解锁技能消耗
|
||||
int TRAINING_UNLOCK_SKILL_COST = 1341;//特训解锁技能消耗
|
||||
int GIFT_UP_STAR_COST = 1342;//礼物装备升星
|
||||
int GIFT_UP_STAR_GET = 1343;//礼物装备获得
|
||||
}
|
|
@ -0,0 +1,24 @@
|
|||
package com.ljsd.jieling.handler.equip;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.equip.EquipLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
/**
|
||||
* 礼物装备升星
|
||||
*/
|
||||
@Component
|
||||
public class GiftUpStarEquipHandler extends BaseHandler<HeroInfoProto.GiftEquipUpStarRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.GiftEquipUpStarRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.GiftEquipUpStarRequest proto) throws Exception {
|
||||
EquipLogic.getInstance().giftUpStar(iSession, proto);
|
||||
}
|
||||
}
|
|
@ -12,7 +12,6 @@ import com.ljsd.jieling.logic.activity.event.Poster;
|
|||
import com.ljsd.jieling.logic.activity.event.SaveHeroForceEvent;
|
||||
import com.ljsd.jieling.logic.dao.*;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.hero.TrainingLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.tools.Utils;
|
||||
|
@ -515,11 +514,11 @@ public class EquipLogic {
|
|||
String format = MessageFormat.format("礼物穿戴报错, 英雄礼物已穿戴,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, heroGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
int boxNum = getHeroGiftBoxNum(user);
|
||||
if (heroGifts.size() + set.size() > boxNum){
|
||||
String format = MessageFormat.format("礼物穿戴报错, 英雄礼物超出格子数量,uid:{0},wear:{1}, allow:{2}", user.getId(), heroGifts.size() + set.size(), boxNum);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
// int boxNum = getHeroGiftBoxNum(user);
|
||||
// if (heroGifts.size() + set.size() > boxNum){
|
||||
// String format = MessageFormat.format("礼物穿戴报错, 英雄礼物超出格子数量,uid:{0},wear:{1}, allow:{2}", user.getId(), heroGifts.size() + set.size(), boxNum);
|
||||
// throw new ErrorCodeException(format);
|
||||
// }
|
||||
int templateId = hero.getTemplateId();
|
||||
SCHero scHero = SCHero.getsCHero().get(templateId);
|
||||
if (scHero == null){
|
||||
|
@ -547,25 +546,32 @@ public class EquipLogic {
|
|||
}
|
||||
ItemUtil.itemCost(user, items, BIReason.GIFT_EQUIP_UP_COST ,1);
|
||||
}
|
||||
else {
|
||||
// 脱下
|
||||
else {// 脱下
|
||||
// 主角礼物
|
||||
if (role.equals("0")){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 主角礼物无法脱卸,uid:{0}", user.getId());
|
||||
throw new ErrorCodeException(format);
|
||||
Set<Integer> playerGifts = playerManager.getPlayerGiftEquipList();
|
||||
if (!playerGifts.containsAll(set)){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 主角礼物不存在,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, playerGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
playerGifts.removeAll(set);
|
||||
playerManager.setPlayerGiftEquipList(playerGifts);
|
||||
}
|
||||
// 英雄礼物
|
||||
Hero hero = heroManager.getHero(role);
|
||||
if (hero == null){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 英雄不存在,uid:{0},role:{1}", user.getId(), role);
|
||||
throw new ErrorCodeException(format);
|
||||
else {
|
||||
// 英雄礼物
|
||||
Hero hero = heroManager.getHero(role);
|
||||
if (hero == null){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 英雄不存在,uid:{0},role:{1}", user.getId(), role);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
Set<Integer> heroGifts = hero.getHeroGiftEquipList();
|
||||
if (!heroGifts.containsAll(set)){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 英雄礼物不存在,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, heroGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
heroGifts.removeAll(set);
|
||||
hero.setHeroGiftEquipList(heroGifts);
|
||||
}
|
||||
Set<Integer> heroGifts = hero.getHeroGiftEquipList();
|
||||
if (!heroGifts.containsAll(set)){
|
||||
String format = MessageFormat.format("礼物脱卸报错, 英雄礼物不存在,uid:{0},list:{1}, roleList:{2}", user.getId(), giftIds, heroGifts);
|
||||
throw new ErrorCodeException(format);
|
||||
}
|
||||
heroGifts.removeAll(set);
|
||||
hero.setHeroGiftEquipList(heroGifts);
|
||||
|
||||
ItemUtil.drop(user, items, BIReason.GIFT_EQUIP_DOWN_REWARD);
|
||||
}
|
||||
|
@ -581,6 +587,29 @@ public class EquipLogic {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 礼物升星
|
||||
*/
|
||||
public void giftUpStar(ISession iSession, HeroInfoProto.GiftEquipUpStarRequest proto) throws Exception{
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int giftId = proto.getGiftId();
|
||||
SEquipConfig config = SEquipConfig.equipConfigMap.get(giftId);
|
||||
if (config == null){
|
||||
throw new ErrorCodeException(ErrorCode.CFG_NULL);
|
||||
}
|
||||
ArrayList<int[][]> costList = new ArrayList<>();
|
||||
costList.add(config.getFormula());
|
||||
costList.add(config.getResource());
|
||||
|
||||
boolean cost = ItemUtil.itemCost(user, costList, BIReason.GIFT_UP_STAR_COST, 1);
|
||||
if (!cost){
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, new int[][]{{giftId, 1}}, BIReason.GIFT_UP_STAR_GET);
|
||||
HeroInfoProto.GiftEquipUpStarResponse.Builder builder = HeroInfoProto.GiftEquipUpStarResponse.newBuilder().setDrop(drop);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.GiftEquipUpStarResponse_VALUE, builder.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 装备验证职业条件
|
||||
*/
|
||||
|
@ -646,44 +675,44 @@ public class EquipLogic {
|
|||
* @param user 玩家
|
||||
* @return 收集值
|
||||
*/
|
||||
public int getGiftProsperityNum(User user){
|
||||
Set<Integer> giftEquipList = user.getPlayerInfoManager().getPlayerGiftEquipList();
|
||||
Map<Integer, SEquipConfig> configMap = SEquipConfig.equipConfigMap;
|
||||
int num = 0;
|
||||
for (Integer id : giftEquipList) {
|
||||
SEquipConfig config = configMap.get(id);
|
||||
if (config == null){
|
||||
continue;
|
||||
}
|
||||
num += config.getGift();
|
||||
}
|
||||
// 特训增加的额外收集值
|
||||
int maxHeroNum = TrainingLogic.getInstance().getTrainingMaxHeroNum(user);
|
||||
int value = SSpecialConfig.getIntegerValue("Train_Gift_shouji");
|
||||
num += (maxHeroNum * value);
|
||||
|
||||
return num;
|
||||
}
|
||||
// public int getGiftProsperityNum(User user){
|
||||
// Set<Integer> giftEquipList = user.getPlayerInfoManager().getPlayerGiftEquipList();
|
||||
// Map<Integer, SEquipConfig> configMap = SEquipConfig.equipConfigMap;
|
||||
// int num = 0;
|
||||
// for (Integer id : giftEquipList) {
|
||||
// SEquipConfig config = configMap.get(id);
|
||||
// if (config == null){
|
||||
// continue;
|
||||
// }
|
||||
// num += config.getGift();
|
||||
// }
|
||||
// // 特训增加的额外收集值
|
||||
// int maxHeroNum = TrainingLogic.getInstance().getTrainingMaxHeroNum(user);
|
||||
// int value = SSpecialConfig.getIntegerValue("Train_Gift_shouji");
|
||||
// num += (maxHeroNum * value);
|
||||
//
|
||||
// return num;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取英雄礼物各自数量
|
||||
* @param user 玩家
|
||||
* @return 格子数
|
||||
*/
|
||||
public int getHeroGiftBoxNum(User user){
|
||||
int prosperityNum = getGiftProsperityNum(user);
|
||||
int resultBox = 0;
|
||||
|
||||
// 英雄礼物基础格子
|
||||
for (SGiftConfig value : SGiftConfig.map.values()) {
|
||||
if (prosperityNum >= value.getGift()){
|
||||
resultBox = value.getBox();
|
||||
}else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return resultBox;
|
||||
}
|
||||
// public int getHeroGiftBoxNum(User user){
|
||||
// int prosperityNum = getGiftProsperityNum(user);
|
||||
// int resultBox = 0;
|
||||
//
|
||||
// // 英雄礼物基础格子
|
||||
// for (SGiftConfig value : SGiftConfig.map.values()) {
|
||||
// if (prosperityNum >= value.getGift()){
|
||||
// resultBox = value.getBox();
|
||||
// }else {
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return resultBox;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 查询全部法宝
|
||||
|
|
|
@ -55,6 +55,10 @@ public class SItem implements BaseConfig {
|
|||
return sItemMap;
|
||||
}
|
||||
|
||||
public static SItem getItem(int id) {
|
||||
return sItemMap.get(id);
|
||||
}
|
||||
|
||||
public static Map<Integer, List<SItem>> getItemMapByRecycle() {
|
||||
return itemMapByRecycle;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue