Merge branch 'master_test_hw' of http://60.1.1.230/backend/jieling_server into master_test_hw
commit
e1bae5947d
|
@ -39,7 +39,8 @@ import java.util.stream.Collectors;
|
|||
public class ItemLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(ItemLogic.class);
|
||||
|
||||
private ItemLogic(){}
|
||||
private ItemLogic() {
|
||||
}
|
||||
|
||||
public static class Instance {
|
||||
public final static ItemLogic instance = new ItemLogic();
|
||||
|
@ -51,44 +52,45 @@ public class ItemLogic {
|
|||
|
||||
/**
|
||||
* 分解道具
|
||||
*
|
||||
* @param iSession
|
||||
* @param itemList
|
||||
* @throws Exception
|
||||
*/
|
||||
public void priceItem(ISession iSession,List<CommonProto.Item> itemList) throws Exception {
|
||||
public void priceItem(ISession iSession, List<CommonProto.Item> itemList) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE;
|
||||
if (!checkItemResolve(itemList)){
|
||||
if (!checkItemResolve(itemList)) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_UNPRICE);
|
||||
}
|
||||
StringBuilder cost = new StringBuilder();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
for (CommonProto.Item item :itemList){
|
||||
if (cost.length() == 0){
|
||||
for (CommonProto.Item item : itemList) {
|
||||
if (cost.length() == 0) {
|
||||
cost = new StringBuilder(item.getItemId() + "#" + item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward = getStringBuilder(reward, item.getItemNum(), sItem.getResolveReward());
|
||||
}else{
|
||||
} else {
|
||||
cost.append("|").append(item.getItemId()).append("#").append(item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward = getStringBuilder(reward, item.getItemNum(), sItem.getResolveReward());
|
||||
}
|
||||
}
|
||||
int[][] costItemArr = StringUtil.parseFiledInt2(cost.toString());
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr,BIReason.DECOMPOSE_ITEM_CONSUME,0);
|
||||
if (!result){
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr, BIReason.DECOMPOSE_ITEM_CONSUME, 0);
|
||||
if (!result) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0,BIReason.DECOMPOS_ITEM_REWARD);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0, BIReason.DECOMPOS_ITEM_REWARD);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
private StringBuilder getStringBuilder(StringBuilder reward, int itemNum, String itemReward) {
|
||||
for (int i =0; i < itemNum; i++){
|
||||
if (reward.length() == 0){
|
||||
for (int i = 0; i < itemNum; i++) {
|
||||
if (reward.length() == 0) {
|
||||
reward = new StringBuilder(itemReward);
|
||||
}else{
|
||||
} else {
|
||||
reward.append("#").append(itemReward);
|
||||
}
|
||||
}
|
||||
|
@ -96,12 +98,12 @@ public class ItemLogic {
|
|||
}
|
||||
|
||||
private StringBuilder getStringBuilder(StringBuilder reward, int itemNum, int[] itemReward) {
|
||||
for (int i =0; i < itemNum; i++){
|
||||
for (int j = 0; j <itemReward.length ; j++) {
|
||||
if (reward.length() == 0){
|
||||
for (int i = 0; i < itemNum; i++) {
|
||||
for (int j = 0; j < itemReward.length; j++) {
|
||||
if (reward.length() == 0) {
|
||||
reward = new StringBuilder();
|
||||
reward.append(itemReward[j]);
|
||||
}else{
|
||||
} else {
|
||||
reward.append("#").append(itemReward[j]);
|
||||
}
|
||||
|
||||
|
@ -111,136 +113,136 @@ public class ItemLogic {
|
|||
}
|
||||
|
||||
|
||||
|
||||
private boolean checkItemResolve(List<CommonProto.Item> itemList) {
|
||||
for (CommonProto.Item item :itemList){
|
||||
for (CommonProto.Item item : itemList) {
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
if (sItem.getIfResolve() ==0){
|
||||
if (sItem.getIfResolve() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static void sendUseAndPriceItemMessage(ISession iSession, int msgId, CommonProto.Drop.Builder drop) {
|
||||
public static void sendUseAndPriceItemMessage(ISession iSession, int msgId, CommonProto.Drop.Builder drop) {
|
||||
PlayerInfoProto.UseAndPriceItemResponse.Builder useAndPriceItemResponse = PlayerInfoProto.UseAndPriceItemResponse.newBuilder();
|
||||
if(drop!=null){
|
||||
if (drop != null) {
|
||||
useAndPriceItemResponse.setDrop(drop);
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, useAndPriceItemResponse.build(), true);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, useAndPriceItemResponse.build(), true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用道具
|
||||
*
|
||||
* @param iSession
|
||||
* @param itemList
|
||||
*/
|
||||
public void useItem(ISession iSession,List<CommonProto.Item> itemList) throws Exception {
|
||||
public void useItem(ISession iSession, List<CommonProto.Item> itemList) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (itemList.size() == 0 ){
|
||||
if (itemList.size() == 0) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(itemList.size()==1){
|
||||
if (itemList.size() == 1) {
|
||||
CommonProto.Item item = itemList.iterator().next();
|
||||
//如果是使用皮肤
|
||||
if(SItem.getsItemMap().get(item.getItemId()).getItemType()== GlobalItemType.DECORATION){
|
||||
useHeroSkin(iSession,user,item);
|
||||
MessageUtil.sendMessage(iSession, 1,msgId, PlayerInfoProto.UseAndPriceItemResponse.newBuilder().build(), true);
|
||||
if (SItem.getsItemMap().get(item.getItemId()).getItemType() == GlobalItemType.DECORATION) {
|
||||
useHeroSkin(iSession, user, item);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, PlayerInfoProto.UseAndPriceItemResponse.newBuilder().build(), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
int openBoxLimits = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getOpenBoxLimits();
|
||||
for (CommonProto.Item item :itemList){
|
||||
for (CommonProto.Item item : itemList) {
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
if (item.getItemNum() > openBoxLimits){
|
||||
LOGGER.info("useItem ==>uid={},itemNum={},openBoxLimits={}",uid,item.getItemNum(),openBoxLimits);
|
||||
if (item.getItemNum() > openBoxLimits) {
|
||||
LOGGER.info("useItem ==>uid={},itemNum={},openBoxLimits={}", uid, item.getItemNum(), openBoxLimits);
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_USE_ONE_MAX);
|
||||
}
|
||||
if (sItem.getUseType() ==2){ //n 选1
|
||||
if (sItem.getUseType() == 2) { //n 选1
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if (sItem.getUseType() ==0){
|
||||
if (sItem.getUseType() == 0) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_USE_NOT);
|
||||
}
|
||||
}
|
||||
StringBuilder cost = new StringBuilder();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
for (CommonProto.Item item :itemList){
|
||||
if (cost.length() == 0){
|
||||
for (CommonProto.Item item : itemList) {
|
||||
if (cost.length() == 0) {
|
||||
cost = new StringBuilder(item.getItemId() + "#" + item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward = getStringBuilder(reward, item.getItemNum(), sItem.getRewardGroup());
|
||||
}else{
|
||||
} else {
|
||||
cost.append("|").append(item.getItemId()).append("#").append(item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward = getStringBuilder(reward, item.getItemNum(), sItem.getRewardGroup());
|
||||
}
|
||||
}
|
||||
int[][] costItemArr = StringUtil.parseFiledInt2(cost.toString());
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr,BIReason.USER_ITEM,0);
|
||||
if (!result){
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr, BIReason.USER_ITEM, 0);
|
||||
if (!result) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user,StringUtil.parseFiledInt(reward.toString()),1,0,BIReason.USER_ITEM);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0, BIReason.USER_ITEM);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
private void useHeroSkin(ISession session,User user,CommonProto.Item item) throws Exception {
|
||||
private void useHeroSkin(ISession session, User user, CommonProto.Item item) throws Exception {
|
||||
Map<Integer, Integer> skinInfo = user.getHeroManager().getSkinInfo();
|
||||
SHeroSkin sHeroSkin = STableManager.getConfig(SHeroSkin.class).get(item.getItemId());
|
||||
if(sHeroSkin==null){
|
||||
if (sHeroSkin == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(skinInfo.containsKey(sHeroSkin.getType())){
|
||||
if(skinInfo.get(sHeroSkin.getType())==-1||skinInfo.get(sHeroSkin.getType())> TimeUtils.nowInt()){
|
||||
if (skinInfo.containsKey(sHeroSkin.getType())) {
|
||||
if (skinInfo.get(sHeroSkin.getType()) == -1 || skinInfo.get(sHeroSkin.getType()) > TimeUtils.nowInt()) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
int time;
|
||||
if(sHeroSkin.getTime()==0){
|
||||
if (sHeroSkin.getTime() == 0) {
|
||||
time = -1;
|
||||
}else{
|
||||
} else {
|
||||
// time =TimeUtils.nowInt()+120;
|
||||
time =(int)(sHeroSkin.getTime()*TimeUtils.DAY/1000+TimeUtils.nowInt());
|
||||
time = (int) (sHeroSkin.getTime() * TimeUtils.DAY / 1000 + TimeUtils.nowInt());
|
||||
|
||||
}
|
||||
|
||||
boolean use = ItemUtil.itemCost(user,new int[][]{{item.getItemId(),item.getItemNum()}},BIReason.SKIN_USE_CONSUME,1);
|
||||
if(!use){
|
||||
boolean use = ItemUtil.itemCost(user, new int[][]{{item.getItemId(), item.getItemNum()}}, BIReason.SKIN_USE_CONSUME, 1);
|
||||
if (!use) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
user.getHeroManager().addSkin(sHeroSkin.getType(),time);
|
||||
if(sHeroSkin.getHeadIcon()!=null&&sHeroSkin.getHeadIcon().length>0){
|
||||
ItemUtil.drop(user,new int[][]{sHeroSkin.getHeadIcon()},BIReason.SKIN_USE_REWARD);
|
||||
user.getHeroManager().addSkin(sHeroSkin.getType(), time);
|
||||
if (sHeroSkin.getHeadIcon() != null && sHeroSkin.getHeadIcon().length > 0) {
|
||||
ItemUtil.drop(user, new int[][]{sHeroSkin.getHeadIcon()}, BIReason.SKIN_USE_REWARD);
|
||||
}
|
||||
HeroInfoProto.GetSkinIndication indication = HeroInfoProto.GetSkinIndication.newBuilder()
|
||||
.setSkinInfo(CommonProto.SkinInfo.newBuilder().setSkinId(sHeroSkin.getType()).setOverTime(time))
|
||||
.build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.HERO_SKIN_USE_INDICATION_VALUE,indication,true);
|
||||
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.HERO_SKIN_USE_INDICATION_VALUE, indication, true);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用选择宝箱道具
|
||||
*/
|
||||
public void useItem(ISession iSession,List<CommonProto.Item> itemList,int itemId) throws Exception {
|
||||
public void useItem(ISession iSession, List<CommonProto.Item> itemList, int itemId) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
if (itemList.size() == 0 ){
|
||||
if (itemList.size() == 0) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int openBoxLimits = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getOpenBoxLimits();
|
||||
for (CommonProto.Item item :itemList){
|
||||
for (CommonProto.Item item : itemList) {
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
if (item.getItemNum() > openBoxLimits){
|
||||
LOGGER.info("useItem ==>uid={},itemNum={},openBoxLimits={}",uid,item.getItemNum(),openBoxLimits);
|
||||
if (item.getItemNum() > openBoxLimits) {
|
||||
LOGGER.info("useItem ==>uid={},itemNum={},openBoxLimits={}", uid, item.getItemNum(), openBoxLimits);
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_USE_ONE_MAX);
|
||||
}
|
||||
if (sItem.getUseType() !=2){ //n 选1
|
||||
LOGGER.info("Exception::useItem ==>uid={},itemNum={},openBoxLimits={}",uid,item.getItemNum(),openBoxLimits);
|
||||
if (sItem.getUseType() != 2) { //n 选1
|
||||
LOGGER.info("Exception::useItem ==>uid={},itemNum={},openBoxLimits={}", uid, item.getItemNum(), openBoxLimits);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -248,31 +250,31 @@ public class ItemLogic {
|
|||
|
||||
Map<Integer, Integer> itemMap = new HashMap<>();
|
||||
Map<Integer, Integer> cardMap = new HashMap<>();
|
||||
Map<Integer,Integer> equipMap = new HashMap<>();
|
||||
Map<Integer,Integer> randomMap = new HashMap<>();
|
||||
Map<Integer, Integer> equipMap = new HashMap<>();
|
||||
Map<Integer, Integer> randomMap = new HashMap<>();
|
||||
ItemMap itemObj = new ItemMap();
|
||||
|
||||
int num=0;
|
||||
for (CommonProto.Item item :itemList){
|
||||
if (cost.length() == 0){
|
||||
int num = 0;
|
||||
for (CommonProto.Item item : itemList) {
|
||||
if (cost.length() == 0) {
|
||||
cost = new StringBuilder(item.getItemId() + "#" + item.getItemNum());
|
||||
}else{
|
||||
} else {
|
||||
cost.append("|").append(item.getItemId()).append("#").append(item.getItemNum());
|
||||
}
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
num+=item.getItemNum();
|
||||
ItemUtil.combineReward(user,true,sItem.getRewardGroup(), 1f,itemMap,cardMap,equipMap,randomMap,itemObj,0);
|
||||
num += item.getItemNum();
|
||||
ItemUtil.combineReward(user, true, sItem.getRewardGroup(), 1f, itemMap, cardMap, equipMap, randomMap, itemObj, 0);
|
||||
|
||||
}
|
||||
int[][] costItemArr = StringUtil.parseFiledInt2(cost.toString());
|
||||
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr,BIReason.USER_ITEM,0);
|
||||
if (!result){
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr, BIReason.USER_ITEM, 0);
|
||||
if (!result) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
Map<Integer, Integer> mapRe = ItemUtil.getMapRe(itemId, itemMap, cardMap, equipMap, randomMap,itemObj);
|
||||
if(!mapRe.containsKey(itemId)){
|
||||
Map<Integer, Integer> mapRe = ItemUtil.getMapRe(itemId, itemMap, cardMap, equipMap, randomMap, itemObj);
|
||||
if (!mapRe.containsKey(itemId)) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE);
|
||||
}
|
||||
|
||||
|
@ -280,7 +282,7 @@ public class ItemLogic {
|
|||
int[][] dropItems = new int[1][];
|
||||
dropItems[0] = new int[2];
|
||||
dropItems[0][0] = itemId;
|
||||
dropItems[0][1] = num*mapRe.get(itemId);
|
||||
dropItems[0][1] = num * mapRe.get(itemId);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropItems, BIReason.USER_ITEM);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
@ -288,6 +290,7 @@ public class ItemLogic {
|
|||
|
||||
/**
|
||||
* 分解装备
|
||||
*
|
||||
* @param iSession
|
||||
* @param equipIdsList
|
||||
*/
|
||||
|
@ -311,104 +314,105 @@ public class ItemLogic {
|
|||
reward.append("#").append(sItem.getResolveReward());
|
||||
}
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user,StringUtil.parseFiledInt(reward.toString()),1,0,BIReason.DECOMPOS_EQUIP_REWARD);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0, BIReason.DECOMPOS_EQUIP_REWARD);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
//宝器分解
|
||||
public void decomposeJewel(ISession session,List<String> jewelList) throws Exception {
|
||||
public void decomposeJewel(ISession session, List<String> jewelList) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
|
||||
List<int[]> items = new ArrayList<>();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
StringBuilder reportIdLevelQuality = new StringBuilder();
|
||||
for (String jewelId : jewelList) {
|
||||
if(!equipMap.containsKey(jewelId))
|
||||
if (!equipMap.containsKey(jewelId))
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_NO_EQUIP);
|
||||
PropertyItem propertyItem = equipMap.get(jewelId);
|
||||
if(!StringUtil.isEmpty(propertyItem.getHeroId()))
|
||||
if (!StringUtil.isEmpty(propertyItem.getHeroId()))
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_DECOMPOSE_SOULE_CANT);
|
||||
Jewel jewel = (Jewel)propertyItem;
|
||||
Jewel jewel = (Jewel) propertyItem;
|
||||
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(propertyItem.getEquipId());
|
||||
if(jewel.getLevel()==0&&jewel.getBuildLevel()==0){
|
||||
if (jewel.getLevel() == 0 && jewel.getBuildLevel() == 0) {
|
||||
SItem sItem = SItem.getsItemMap().get(propertyItem.getEquipId());
|
||||
reward = getStringBuilder(reward, 1, sItem.getResolveReward());
|
||||
continue;
|
||||
}
|
||||
if(reportIdLevelQuality.length()!=0){
|
||||
if (reportIdLevelQuality.length() != 0) {
|
||||
reportIdLevelQuality.append("|");
|
||||
}
|
||||
reportIdLevelQuality.append(jewel.getEquipId()).append("-").append(jewel.getLevel()).append("-").append(jewel.getBuildLevel());
|
||||
if(jewel.getLevel()!=0){
|
||||
if (jewel.getLevel() != 0) {
|
||||
Map<Integer, SJewelRankupConfig> rankupConfigMap = SJewelRankupConfig.rankupMap.get(config.getLevelupPool()).get(1);
|
||||
for(SJewelRankupConfig value:rankupConfigMap.values()){
|
||||
if(value.getLevel()<propertyItem.getLevel()){
|
||||
for (SJewelRankupConfig value : rankupConfigMap.values()) {
|
||||
if (value.getLevel() < propertyItem.getLevel()) {
|
||||
items.addAll(Arrays.asList(value.getUpExpend()));
|
||||
if(value.getJewelExpend().length<1){
|
||||
if (value.getJewelExpend().length < 1) {
|
||||
continue;
|
||||
}
|
||||
for(int[] count:value.getJewelExpend()){
|
||||
if(count[0]==1){
|
||||
items.add(new int[]{jewel.getEquipId(),count[1]});
|
||||
}else{
|
||||
for (int[] count : value.getJewelExpend()) {
|
||||
if (count[0] == 1) {
|
||||
items.add(new int[]{jewel.getEquipId(), count[1]});
|
||||
} else {
|
||||
items.add(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if(jewel.getBuildLevel()!=0){
|
||||
if (jewel.getBuildLevel() != 0) {
|
||||
Map<Integer, SJewelRankupConfig> buildUpConfigMap = SJewelRankupConfig.rankupMap.get(config.getRankupPool()).get(2);
|
||||
for(SJewelRankupConfig value:buildUpConfigMap.values()){
|
||||
if(value.getLevel()<jewel.getBuildLevel()){
|
||||
for (SJewelRankupConfig value : buildUpConfigMap.values()) {
|
||||
if (value.getLevel() < jewel.getBuildLevel()) {
|
||||
items.addAll(Arrays.asList(value.getUpExpend()));
|
||||
if(value.getJewelExpend().length<1){
|
||||
if (value.getJewelExpend().length < 1) {
|
||||
continue;
|
||||
}
|
||||
for(int[] count:value.getJewelExpend()){
|
||||
if(count[0]==1){
|
||||
items.add(new int[]{jewel.getEquipId(),count[1]});
|
||||
}else{
|
||||
for (int[] count : value.getJewelExpend()) {
|
||||
if (count[0] == 1) {
|
||||
items.add(new int[]{jewel.getEquipId(), count[1]});
|
||||
} else {
|
||||
items.add(count);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
items.add(new int[]{propertyItem.getEquipId(),1});
|
||||
items.add(new int[]{propertyItem.getEquipId(), 1});
|
||||
}
|
||||
for (String jewelId : jewelList) {
|
||||
user.getEquipManager().remove(jewelId);
|
||||
}
|
||||
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0,BIReason.JEWEL_DECOMPOSE);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0, BIReason.JEWEL_DECOMPOSE);
|
||||
|
||||
Map<Integer, Integer> baseItemMap = new HashMap<>();
|
||||
Map<Integer, Integer> baseCardMap = new HashMap<>();
|
||||
Map<Integer, Integer> baseEquipMap = new HashMap<>();
|
||||
Map<Integer,Integer> baseRandomMap = new HashMap<>();
|
||||
Map<Integer, Integer> baseRandomMap = new HashMap<>();
|
||||
ItemMap itemObj = new ItemMap();
|
||||
for (int[] ints:items) {
|
||||
Map<Integer, Integer> mapRe = ItemUtil.getMapRe(ints[0], baseItemMap, baseCardMap, baseEquipMap, baseRandomMap,itemObj);
|
||||
if(mapRe.containsKey(ints[0])){
|
||||
mapRe.put(ints[0],mapRe.get(ints[0])+ints[1]);
|
||||
}else {
|
||||
mapRe.put(ints[0],ints[1]);
|
||||
for (int[] ints : items) {
|
||||
Map<Integer, Integer> mapRe = ItemUtil.getMapRe(ints[0], baseItemMap, baseCardMap, baseEquipMap, baseRandomMap, itemObj);
|
||||
if (mapRe.containsKey(ints[0])) {
|
||||
mapRe.put(ints[0], mapRe.get(ints[0]) + ints[1]);
|
||||
} else {
|
||||
mapRe.put(ints[0], ints[1]);
|
||||
}
|
||||
}
|
||||
ItemUtil.drop(user,drop,baseItemMap,baseCardMap,baseEquipMap,baseRandomMap,itemObj,BIReason.JEWEL_DECOMPOSE);
|
||||
ItemUtil.drop(user, drop, baseItemMap, baseCardMap, baseEquipMap, baseRandomMap, itemObj, BIReason.JEWEL_DECOMPOSE);
|
||||
List<CommonProto.Item> reportMap = drop.getItemlistList();
|
||||
List<Integer> itemId = new ArrayList<>(reportMap.size());
|
||||
List<Integer> itemNum = new ArrayList<>(reportMap.size());
|
||||
reportMap.forEach(item->{
|
||||
reportMap.forEach(item -> {
|
||||
itemId.add(item.getItemId());
|
||||
itemNum.add(item.getItemNum());
|
||||
});
|
||||
ReportUtil.onReportEvent(user,ReportEventEnum.TREASURE_DECOMPOSITION.getType(),reportIdLevelQuality.toString(),itemId,itemNum);
|
||||
sendUseAndPriceItemMessage(session,MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE,drop);
|
||||
ReportUtil.onReportEvent(user, ReportEventEnum.TREASURE_DECOMPOSITION.getType(), reportIdLevelQuality.toString(), itemId, itemNum);
|
||||
sendUseAndPriceItemMessage(session, MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE, drop);
|
||||
}
|
||||
|
||||
private ErrorCode checkEquipResolve(List<String> equipIdsList,EquipManager equipManager) {
|
||||
private ErrorCode checkEquipResolve(List<String> equipIdsList, EquipManager equipManager) {
|
||||
if (equipIdsList.size() == 0) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_EQUIP_NO;
|
||||
}
|
||||
|
@ -428,7 +432,7 @@ public class ItemLogic {
|
|||
return null;
|
||||
}
|
||||
|
||||
private ErrorCode checkSoulEquipResolve(List<String> equipIdsList,EquipManager equipManager) {
|
||||
private ErrorCode checkSoulEquipResolve(List<String> equipIdsList, EquipManager equipManager) {
|
||||
|
||||
if (equipIdsList.size() == 0) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_SOULE_EQUIP_NO;
|
||||
|
@ -438,24 +442,25 @@ public class ItemLogic {
|
|||
|
||||
/**
|
||||
* 分解卡牌|进阶消耗
|
||||
*
|
||||
* @param iSession
|
||||
* @param heroIdsList
|
||||
*/
|
||||
public CommonProto.Drop.Builder decomposeHero(ISession iSession, List<String> heroIdsList,Set<Integer> filterItem,int msgId) throws Exception {
|
||||
public CommonProto.Drop.Builder decomposeHero(ISession iSession, List<String> heroIdsList, Set<Integer> filterItem, int msgId) throws Exception {
|
||||
int uid = iSession.getUid();
|
||||
CommonProto.Drop.Builder baseBuilder = CommonProto.Drop.newBuilder();
|
||||
User user = UserManager.getUser(uid);
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
ErrorCode erroMags = checkHeroResolve(heroIdsList,user);
|
||||
if (null!=erroMags){
|
||||
ErrorCode erroMags = checkHeroResolve(heroIdsList, user);
|
||||
if (null != erroMags) {
|
||||
throw new ErrorCodeException(erroMags);
|
||||
//MessageUtil.sendErrorResponse(iSession,0,msgId,erroMags);
|
||||
// return baseBuilder;
|
||||
// return baseBuilder;
|
||||
}
|
||||
//1裸角色卡(没有突破过的角色卡)熔炼后返还的材料=当前等级返还升级材料+item表返还材料
|
||||
//2有过突破的卡 =当前等级返还升级材料+突破表返还材料
|
||||
Map<Integer, Integer> baseItemMap = new HashMap<>();
|
||||
int rankUpReturnPercent= SSpecialConfig.getIntegerValue(SSpecialConfig.HERO_SACRIFICE_PERCENT);
|
||||
int rankUpReturnPercent = SSpecialConfig.getIntegerValue(SSpecialConfig.HERO_SACRIFICE_PERCENT);
|
||||
List<Integer> heroIdReport = new ArrayList<>();
|
||||
List<Integer> heroLevelReport = new ArrayList<>();
|
||||
List<Integer> heroStarReport = new ArrayList<>();
|
||||
|
@ -466,16 +471,16 @@ public class ItemLogic {
|
|||
//卸下魂印装备
|
||||
Map<Integer, Integer> equipByPositionMap = hero.getEquipByPositionMap();
|
||||
Map<Integer, Integer> soulEquipByPositionMap = hero.getSoulEquipByPositionMap();
|
||||
if(equipByPositionMap!=null&&equipByPositionMap.size()>0){
|
||||
equipByPositionMap.forEach((k,v)->baseItemMap.put(v,baseItemMap.getOrDefault(v,0)+1));
|
||||
if (equipByPositionMap != null && equipByPositionMap.size() > 0) {
|
||||
equipByPositionMap.forEach((k, v) -> baseItemMap.put(v, baseItemMap.getOrDefault(v, 0) + 1));
|
||||
}
|
||||
if(soulEquipByPositionMap!=null&&soulEquipByPositionMap.size()>0){
|
||||
soulEquipByPositionMap.forEach((k,v)->baseItemMap.put(v,baseItemMap.getOrDefault(v,0)+1));
|
||||
if (soulEquipByPositionMap != null && soulEquipByPositionMap.size() > 0) {
|
||||
soulEquipByPositionMap.forEach((k, v) -> baseItemMap.put(v, baseItemMap.getOrDefault(v, 0) + 1));
|
||||
}
|
||||
//卸下宝物
|
||||
Set<String> jewelInfo = hero.getJewelInfo();
|
||||
for(String equipId:jewelInfo){
|
||||
if(!equipMap.containsKey(equipId)){
|
||||
for (String equipId : jewelInfo) {
|
||||
if (!equipMap.containsKey(equipId)) {
|
||||
continue;
|
||||
}
|
||||
//这里保证两个是一致的
|
||||
|
@ -487,20 +492,20 @@ public class ItemLogic {
|
|||
heroLevelReport.add(hero.getLevel());
|
||||
heroStarReport.add(hero.getStar());
|
||||
|
||||
heroManager.removeHero(uid,heroId);
|
||||
heroManager.removeHero(uid, heroId);
|
||||
int[][] sumConsume = SHeroLevlConfig.getsHeroLevlConfigMap().get(hero.getLevel()).getSumConsume();
|
||||
SHeroSacrifice starSHeroSacrifice = STableManager.getFigureConfig(HeroStaticConfig.class).getsHeroSacrificeMap(1, hero.getStar());
|
||||
int breakFloor = hero.getBreakId()==0?0:STableManager.getConfig(SCHeroRankUpConfig.class).get(hero.getBreakId()).getPhase()[1];
|
||||
int breakFloor = hero.getBreakId() == 0 ? 0 : STableManager.getConfig(SCHeroRankUpConfig.class).get(hero.getBreakId()).getPhase()[1];
|
||||
|
||||
SHeroSacrifice breakSHeroSacrifice = STableManager.getFigureConfig(HeroStaticConfig.class).getsHeroSacrificeMap(2, breakFloor);
|
||||
for(int[] item:sumConsume){
|
||||
baseItemMap.put(item[0],baseItemMap.getOrDefault(item[0],0)+item[1]);
|
||||
for (int[] item : sumConsume) {
|
||||
baseItemMap.put(item[0], baseItemMap.getOrDefault(item[0], 0) + item[1]);
|
||||
}
|
||||
for(int[] item:starSHeroSacrifice.getValue()){
|
||||
baseItemMap.put(item[0],baseItemMap.getOrDefault(item[0],0)+item[1]);
|
||||
for (int[] item : starSHeroSacrifice.getValue()) {
|
||||
baseItemMap.put(item[0], baseItemMap.getOrDefault(item[0], 0) + item[1]);
|
||||
}
|
||||
for(int[] item:breakSHeroSacrifice.getValue()){
|
||||
baseItemMap.put(item[0],baseItemMap.getOrDefault(item[0],0)+item[1]);
|
||||
for (int[] item : breakSHeroSacrifice.getValue()) {
|
||||
baseItemMap.put(item[0], baseItemMap.getOrDefault(item[0], 0) + item[1]);
|
||||
}
|
||||
//// 返还法宝修炼材料
|
||||
// int especialEquipLevel = hero.getEspecialEquipLevel();
|
||||
|
@ -522,49 +527,49 @@ public class ItemLogic {
|
|||
// }
|
||||
//法宝获得
|
||||
Map<Integer, Integer> especialReturn = heroEspecialEquipReturnItem(hero);
|
||||
if(especialReturn!=null){
|
||||
especialReturn.forEach((k,v)->baseItemMap.put(k,baseItemMap.getOrDefault(k,0)+v));
|
||||
if (especialReturn != null) {
|
||||
especialReturn.forEach((k, v) -> baseItemMap.put(k, baseItemMap.getOrDefault(k, 0) + v));
|
||||
}
|
||||
}
|
||||
|
||||
int[][] itemArray = ItemUtil.mapToArray(baseItemMap);
|
||||
int reson = BIReason.DECOMPOS_HERO_REWARD;
|
||||
if(null!=filterItem){
|
||||
reson= BIReason.UPHERO_DECOMPOS_HERO_REWARD;
|
||||
for (Integer id:filterItem){
|
||||
if(baseItemMap.containsKey(id)){
|
||||
if (null != filterItem) {
|
||||
reson = BIReason.UPHERO_DECOMPOS_HERO_REWARD;
|
||||
for (Integer id : filterItem) {
|
||||
if (baseItemMap.containsKey(id)) {
|
||||
baseItemMap.remove(id);
|
||||
}
|
||||
}
|
||||
}else {
|
||||
user.getUserMissionManager().onGameEvent(user,GameEvent.DESPOSE_HERO,heroIdsList.size());
|
||||
} else {
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.DESPOSE_HERO, heroIdsList.size());
|
||||
}
|
||||
if(reson== BIReason.DECOMPOS_HERO_REWARD){
|
||||
ReportUtil.onReportEvent(user, ReportEventEnum.SEND_HERO.getType(),heroIdReport,heroLevelReport,heroStarReport,new ArrayList<>(baseItemMap.keySet()),new ArrayList<>(baseItemMap.values()));
|
||||
if (reson == BIReason.DECOMPOS_HERO_REWARD) {
|
||||
ReportUtil.onReportEvent(user, ReportEventEnum.SEND_HERO.getType(), heroIdReport, heroLevelReport, heroStarReport, new ArrayList<>(baseItemMap.keySet()), new ArrayList<>(baseItemMap.values()));
|
||||
}
|
||||
return ItemUtil.drop(user,itemReturnPercent(itemArray,rankUpReturnPercent),reson);
|
||||
return ItemUtil.drop(user, itemReturnPercent(itemArray, rankUpReturnPercent), reson);
|
||||
}
|
||||
|
||||
/**
|
||||
* 法宝归元所得
|
||||
*/
|
||||
public Map<Integer,Integer> heroEspecialEquipReturnItem(Hero hero){
|
||||
public Map<Integer, Integer> heroEspecialEquipReturnItem(Hero hero) {
|
||||
int especialEquipLevel = hero.getEspecialEquipLevel();
|
||||
if(especialEquipLevel==1||especialEquipLevel==0){
|
||||
if (especialEquipLevel == 1 || especialEquipLevel == 0) {
|
||||
return null;
|
||||
}
|
||||
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
|
||||
int[] equipTalismana = scHero.getEquipTalismana();
|
||||
if(equipTalismana==null||equipTalismana.length<2){
|
||||
if (equipTalismana == null || equipTalismana.length < 2) {
|
||||
return null;
|
||||
}
|
||||
Map<Integer,Integer> baseItemMap = new HashMap<>();
|
||||
Map<Integer, Integer> baseItemMap = new HashMap<>();
|
||||
TreeMap<Integer, SEquipTalismana> levelMap = (TreeMap<Integer, SEquipTalismana>) (SEquipTalismana.equipTalismanaStarMap.get(equipTalismana[1]));
|
||||
Map<Integer, SEquipTalismana> returnMap = levelMap.subMap(1, hero.getEspecialEquipLevel());
|
||||
for(Map.Entry<Integer, SEquipTalismana> entry:returnMap.entrySet()){
|
||||
for (Map.Entry<Integer, SEquipTalismana> entry : returnMap.entrySet()) {
|
||||
int[][] rankupBasicMaterial = entry.getValue().getRankupBasicMaterial();
|
||||
for(int[] rankUpConsume:rankupBasicMaterial){
|
||||
baseItemMap.put(rankUpConsume[0],baseItemMap.getOrDefault(rankUpConsume[0],0)+rankUpConsume[1]);
|
||||
for (int[] rankUpConsume : rankupBasicMaterial) {
|
||||
baseItemMap.put(rankUpConsume[0], baseItemMap.getOrDefault(rankUpConsume[0], 0) + rankUpConsume[1]);
|
||||
}
|
||||
}
|
||||
return baseItemMap;
|
||||
|
@ -572,36 +577,38 @@ public class ItemLogic {
|
|||
|
||||
/**
|
||||
* 返回数量乘比值
|
||||
*
|
||||
* @param sumConsume
|
||||
* @param rankUpReturnPercent 注:这需要乘万分比(如果为90%,此处填9000)
|
||||
*/
|
||||
public int[][] itemReturnPercent(int[][] sumConsume,int rankUpReturnPercent){
|
||||
public int[][] itemReturnPercent(int[][] sumConsume, int rankUpReturnPercent) {
|
||||
int[][] tempReturn = new int[sumConsume.length][];
|
||||
for(int i = 0 ; i < sumConsume.length;i++){
|
||||
tempReturn[i] = new int[]{sumConsume[i][0],Double.valueOf(sumConsume[i][1]*(double)rankUpReturnPercent/10000).intValue()};
|
||||
for (int i = 0; i < sumConsume.length; i++) {
|
||||
tempReturn[i] = new int[]{sumConsume[i][0], Double.valueOf(sumConsume[i][1] * (double) rankUpReturnPercent / 10000).intValue()};
|
||||
}
|
||||
return tempReturn;
|
||||
}
|
||||
public ErrorCode checkHeroResolve(List<String> heroIdsList,User user){
|
||||
|
||||
public ErrorCode checkHeroResolve(List<String> heroIdsList, User user) {
|
||||
HeroManager heroManager = user.getHeroManager();
|
||||
if (heroIdsList.size() == 0){
|
||||
if (heroIdsList.size() == 0) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_HERO_NO;
|
||||
}
|
||||
for (String heroId :heroIdsList){
|
||||
for (String heroId : heroIdsList) {
|
||||
Hero hero = heroManager.getHeroMap().get(heroId);
|
||||
if (hero == null){
|
||||
if (hero == null) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_NO_HERO;
|
||||
}
|
||||
if(hero.getIsLock() == 1){
|
||||
if (hero.getIsLock() == 1) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_HERO_LOCK;
|
||||
}
|
||||
int[] teamId = SSpecialConfig.getOnceArrayValue(SSpecialConfig.HERO_RESOLVE_LICENCE);
|
||||
boolean battleArray = HeroLogic.getInstance().isBattleArray(user, heroId,teamId);
|
||||
if (!battleArray){
|
||||
boolean battleArray = HeroLogic.getInstance().isBattleArray(user, heroId, teamId);
|
||||
if (!battleArray) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_HERO_TEAM;
|
||||
}
|
||||
SItem sItem = SItem.getsItemMap().get(hero.getTemplateId());
|
||||
if (sItem.getIfResolve() ==0){
|
||||
if (sItem.getIfResolve() == 0) {
|
||||
return ErrorCode.ITEM_DECOMPOSE_HERO_CANT;
|
||||
}
|
||||
}
|
||||
|
@ -611,6 +618,7 @@ public class ItemLogic {
|
|||
|
||||
/**
|
||||
* 同步刷新道具数量
|
||||
*
|
||||
* @param iSession
|
||||
* @param itemIdList
|
||||
*/
|
||||
|
@ -620,57 +628,58 @@ public class ItemLogic {
|
|||
User user = UserManager.getUser(uid);
|
||||
Map<Integer, Item> itemMap = user.getItemManager().getItemMap();
|
||||
List<Item> itemList = new ArrayList<>();
|
||||
for (Integer itemId :itemIdList){
|
||||
for (Integer itemId : itemIdList) {
|
||||
SItem sItem = SItem.getsItemMap().get(itemId);
|
||||
if (sItem == null){
|
||||
if (sItem == null) {
|
||||
continue;
|
||||
}
|
||||
LOGGER.info("the item ={} will flush",itemId);
|
||||
if (itemId == Global.STAMINA){
|
||||
LOGGER.info("the item ={} will flush", itemId);
|
||||
if (itemId == Global.STAMINA) {
|
||||
MapManager.getEnergy(user);
|
||||
itemList.add(itemMap.get(itemId));
|
||||
}
|
||||
if (STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getItemRecoveryMap().containsKey(itemId) ){
|
||||
MapManager.getTimesRecoveryTicket(user,itemId);
|
||||
if (STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getItemRecoveryMap().containsKey(itemId)) {
|
||||
MapManager.getTimesRecoveryTicket(user, itemId);
|
||||
itemList.add(itemMap.get(itemId));
|
||||
}
|
||||
}
|
||||
PlayerInfoProto.RefreshItemNumResponse.Builder builder = PlayerInfoProto.RefreshItemNumResponse.newBuilder();
|
||||
PlayerInfoProto.RefreshItemNumResponse.Builder builder = PlayerInfoProto.RefreshItemNumResponse.newBuilder();
|
||||
List<CommonProto.ItemInfo> itemInfos = new ArrayList<>();
|
||||
if (itemList.size() != 0){
|
||||
for (Item item : itemList){
|
||||
if (itemList.size() != 0) {
|
||||
for (Item item : itemList) {
|
||||
itemInfos.add(CBean2Proto.getItemInfo(item));
|
||||
}
|
||||
}
|
||||
builder.addAllItemInfo(itemInfos);
|
||||
MessageUtil.sendMessage(iSession,1, msgId,builder.build(),true);
|
||||
MessageUtil.sendMessage(iSession, 1, msgId, builder.build(), true);
|
||||
}
|
||||
|
||||
public void equipLock(ISession session, int type, List<String> equips, MessageTypeProto.MessageType messageType) throws Exception{
|
||||
public void equipLock(ISession session, int type, List<String> equips, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
EquipManager equipManager = UserManager.getUser(session.getUid()).getEquipManager();
|
||||
//锁定
|
||||
if(type==1){
|
||||
for (String equipId:equips) {
|
||||
if(equipManager.getEquipMap().get(equipId).getIsLocked()!=0){
|
||||
if (type == 1) {
|
||||
for (String equipId : equips) {
|
||||
if (equipManager.getEquipMap().get(equipId).getIsLocked() != 0) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("所选装备有的已上锁"));
|
||||
}
|
||||
equipManager.getEquipMap().get(equipId).updateIsLocked(1);
|
||||
}
|
||||
}
|
||||
//解锁
|
||||
if(type==2){
|
||||
for (String equipId:equips) {
|
||||
if(equipManager.getEquipMap().get(equipId).getIsLocked()!=1){
|
||||
if (type == 2) {
|
||||
for (String equipId : equips) {
|
||||
if (equipManager.getEquipMap().get(equipId).getIsLocked() != 1) {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("所选装备有的未上锁"));
|
||||
}
|
||||
equipManager.getEquipMap().get(equipId).updateIsLocked(0);
|
||||
}
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), null, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 法宝进阶
|
||||
*
|
||||
* @param session
|
||||
* @param heroId
|
||||
* @param materials
|
||||
|
@ -697,11 +706,16 @@ public class ItemLogic {
|
|||
Poster.getPoster().dispatchEvent(new EspecialEquipUpEvent(user.getId(), especialEquipId, hero.getEspecialEquipLevel()));
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.ESPECIAL_EQUIP, hero.getEspecialEquipLevel(), heroId);
|
||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.UP_HERO_STAR_RESPONSE_VALUE, null, true);
|
||||
if (hero.getEspecialEquipLevel() >= SSpecialConfig.getIntegerValue(SSpecialConfig.lamp_rankup_equiptalisman_content_parm)) {
|
||||
int[] value = SSpecialConfig.getOnceArrayValue(SSpecialConfig.lamp_rankup_equiptalisman_content_parm);
|
||||
if (hero.getEspecialEquipLevel() >= value[0]) {
|
||||
SItem sItem = SItem.getsItemMap().get(especialEquipId);
|
||||
if (sItem.getQuantity() < 5) {
|
||||
return;
|
||||
}
|
||||
// 每5级发送一次公告
|
||||
if (hero.getEspecialEquipLevel() % value[1] != 0) {
|
||||
return;
|
||||
}
|
||||
String message = SErrorCodeEerverConfig.getI18NMessage("lamp_rankup_equiptalisman_content", new Object[]{user.getPlayerInfoManager().getNickName(), sItem.getName(), hero.getEspecialEquipLevel()});
|
||||
ChatLogic.getInstance().sendSysChatMessage(message, Global.DILIGENT, sItem.getId(), 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
@ -713,19 +727,20 @@ public class ItemLogic {
|
|||
}
|
||||
}
|
||||
|
||||
public void addItemLog(ItemLog itemLog){
|
||||
public void addItemLog(ItemLog itemLog) {
|
||||
ItemLogUtil.addLogQueue(itemLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取指定装备的数量 过滤掉已穿戴
|
||||
*
|
||||
* @param user
|
||||
* @param equipid
|
||||
* @return
|
||||
*/
|
||||
public static int getEquipByID(User user, int equipId){
|
||||
public static int getEquipByID(User user, int equipId) {
|
||||
Item item = user.getItemManager().getItemMap().get(equipId);
|
||||
if(item==null){
|
||||
if (item == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -753,52 +768,53 @@ public class ItemLogic {
|
|||
}).map(Map.Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
public static TreeSet<String> getJewelEquipWithLeve(User user, int type, int rance,int leve) {
|
||||
public static TreeSet<String> getJewelEquipWithLeve(User user, int type, int rance, int leve) {
|
||||
return user.getEquipManager().getEquipMap().entrySet().stream().filter(stringEquipEntry ->
|
||||
StringUtil.isEmpty(stringEquipEntry.getValue().getHeroId())
|
||||
).filter(stringPropertyItemEntry -> stringPropertyItemEntry.getValue() instanceof Jewel).filter(stringPropertyItemEntry -> {
|
||||
if(((Jewel)stringPropertyItemEntry.getValue()).getBuildLevel()!=0||stringPropertyItemEntry.getValue().getLevel()!=0){
|
||||
if (((Jewel) stringPropertyItemEntry.getValue()).getBuildLevel() != 0 || stringPropertyItemEntry.getValue().getLevel() != 0) {
|
||||
return false;
|
||||
}
|
||||
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(stringPropertyItemEntry.getValue().getEquipId());
|
||||
if (config == null) {
|
||||
return false;
|
||||
}
|
||||
return config.getLocation() == type && config.getRace() == rance&&config.getLevel()==leve;
|
||||
return config.getLocation() == type && config.getRace() == rance && config.getLevel() == leve;
|
||||
}).map(Map.Entry::getKey).collect(Collectors.toCollection(TreeSet::new));
|
||||
}
|
||||
|
||||
/**
|
||||
* 宝器强化 精炼
|
||||
*
|
||||
* @param iSession
|
||||
* @param type
|
||||
* @param jId
|
||||
* @param items
|
||||
* @throws Exception
|
||||
*/
|
||||
public void jewelBuild(ISession iSession,int type,String jId,List<String> items) throws Exception {
|
||||
public void jewelBuild(ISession iSession, int type, String jId, List<String> items) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
PropertyItem propertyItem = user.getEquipManager().getEquipMap().get(jId);
|
||||
if(!(propertyItem instanceof Jewel)){
|
||||
if (!(propertyItem instanceof Jewel)) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
||||
Jewel jewel = (Jewel) propertyItem;
|
||||
int equipId = jewel.getEquipId();
|
||||
SJewelConfig config = STableManager.getConfig(SJewelConfig.class).get(equipId);
|
||||
if(config==null){
|
||||
if (config == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
int level;
|
||||
int poolType;
|
||||
if(type==1){//强化
|
||||
if(jewel.getLevel()>=config.getMax()[0]){
|
||||
if (type == 1) {//强化
|
||||
if (jewel.getLevel() >= config.getMax()[0]) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
level = jewel.getLevel();
|
||||
poolType = config.getLevelupPool();
|
||||
}else{//精炼
|
||||
if(jewel.getBuildLevel()>=config.getMax()[1]){
|
||||
} else {//精炼
|
||||
if (jewel.getBuildLevel() >= config.getMax()[1]) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
level = jewel.getBuildLevel();
|
||||
|
@ -806,60 +822,60 @@ public class ItemLogic {
|
|||
|
||||
}
|
||||
SJewelRankupConfig sJewelRankupConfig = SJewelRankupConfig.rankupMap.get(poolType).get(type).get(level);
|
||||
if(sJewelRankupConfig==null){
|
||||
if (sJewelRankupConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
if(items!=null&&items.size()>0){
|
||||
if (items != null && items.size() > 0) {
|
||||
int[][] jewelExpend = sJewelRankupConfig.getJewelExpend();
|
||||
Map<Integer,Integer> expendMap = new HashMap<>();
|
||||
for(int[] expend:jewelExpend){
|
||||
expendMap.put(expend[0]==1?jewel.getEquipId():expend[0],expend[1]);
|
||||
Map<Integer, Integer> expendMap = new HashMap<>();
|
||||
for (int[] expend : jewelExpend) {
|
||||
expendMap.put(expend[0] == 1 ? jewel.getEquipId() : expend[0], expend[1]);
|
||||
}
|
||||
for(String item:items){
|
||||
for (String item : items) {
|
||||
PropertyItem proItem = user.getEquipManager().getEquipMap().get(item);
|
||||
if(proItem==null){
|
||||
if (proItem == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Hero hero = user.getHeroManager().getHero(proItem.getHeroId());
|
||||
if(!StringUtil.isEmpty(proItem.getHeroId())&&hero!=null&&hero.getJewelInfo().contains(item)){
|
||||
if (!StringUtil.isEmpty(proItem.getHeroId()) && hero != null && hero.getJewelInfo().contains(item)) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
Integer count= expendMap.get(proItem.getEquipId());
|
||||
if(count==null) {
|
||||
Integer count = expendMap.get(proItem.getEquipId());
|
||||
if (count == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
expendMap.put(proItem.getEquipId(),count-1);
|
||||
expendMap.put(proItem.getEquipId(), count - 1);
|
||||
}
|
||||
for(Integer values:expendMap.values()){
|
||||
if(values!=0)
|
||||
for (Integer values : expendMap.values()) {
|
||||
if (values != 0)
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}else{
|
||||
if (sJewelRankupConfig.getJewelExpend().length>0){
|
||||
} else {
|
||||
if (sJewelRankupConfig.getJewelExpend().length > 0) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(items!=null&&items.size()>0){
|
||||
for(String item:items){
|
||||
if (items != null && items.size() > 0) {
|
||||
for (String item : items) {
|
||||
user.getEquipManager().remove(item);
|
||||
}
|
||||
}
|
||||
boolean itemCost = ItemUtil.itemCost(user, sJewelRankupConfig.getUpExpend(), BIReason.JEWEL_BUILD_OR_UP_CONSUME, 1);
|
||||
if(!itemCost){
|
||||
if (!itemCost) {
|
||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
|
||||
}
|
||||
|
||||
if(type==1){//强化
|
||||
jewel.setLevel(jewel.getLevel()+1);
|
||||
}else{//精炼
|
||||
jewel.setBuildLevel(jewel.getBuildLevel()+1);
|
||||
if (type == 1) {//强化
|
||||
jewel.setLevel(jewel.getLevel() + 1);
|
||||
} else {//精炼
|
||||
jewel.setBuildLevel(jewel.getBuildLevel() + 1);
|
||||
}
|
||||
if(HeroLogic.getInstance().isInTeam(user,jewel.getHeroId(),1)){
|
||||
if (HeroLogic.getInstance().isInTeam(user, jewel.getHeroId(), 1)) {
|
||||
Poster.getPoster().dispatchEvent(new UserMainTeamForceEvent(user.getId()));
|
||||
}
|
||||
MessageUtil.sendMessage(iSession,1, MessageTypeProto.MessageType.JEWEL_BUILD_RESPONSE_VALUE,null,true);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.JEWEL_BUILD_RESPONSE_VALUE, null, true);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue