物品分解
parent
986c064908
commit
9e00bc05f9
|
@ -1,5 +1,5 @@
|
|||
Id BackpackOrNot ItemType ItemBaseType Quantity Isopen Price UseType RewardGroup UsePerCount IsSave HeroStar Ifopen
|
||||
int bool int int int bool mut,int#int,1 int int int int mut,int#int,1 int
|
||||
int bool int int int bool string int int int int mut,int#int,1 int
|
||||
1 false 0 0 1 false null 0 0 0 0 null 1
|
||||
2 false 0 0 2 false null 0 0 0 0 null 1
|
||||
3 false 0 0 3 false null 0 0 0 1 null 1
|
||||
|
@ -19,9 +19,9 @@ int bool int int int bool mut,int#int,1 int int int int mut,int#int,1 int
|
|||
1004 true 0 2 4 false null 0 0 0 0 null 1
|
||||
1005 true 0 2 5 false null 0 0 0 0 null 1
|
||||
1006 true 0 2 1 false null 0 0 0 0 null 1
|
||||
1007 true 0 2 3 false null 0 0 0 0 null 1
|
||||
1008 true 0 2 4 false null 0 0 0 0 null 1
|
||||
1009 true 0 2 5 false null 0 0 0 0 null 1
|
||||
1007 true 0 2 3 false 0 0 0 0 null 1
|
||||
1008 true 0 2 4 false 0 0 0 0 null 1
|
||||
1009 true 0 2 5 false 0 0 0 0 null 1
|
||||
1010 true 0 4 1 false null 0 0 0 0 null 1
|
||||
1011 true 0 4 2 false null 0 0 0 0 null 1
|
||||
1012 true 0 4 3 false null 0 0 0 0 null 1
|
||||
|
@ -380,58 +380,58 @@ int bool int int int bool mut,int#int,1 int int int int mut,int#int,1 int
|
|||
10050 false 1 0 3 false null 0 0 0 0 10050#3 1
|
||||
10051 false 1 0 3 false null 0 0 0 0 10051#3 1
|
||||
10052 false 1 0 3 false null 0 0 0 0 10052#3 1
|
||||
11001 true 2 5 5 false 14#1000 1 701 50 0 null 1
|
||||
11002 true 2 5 5 false 14#1001 1 702 50 0 null 1
|
||||
11003 true 2 5 5 false 14#1002 1 703 50 0 null 1
|
||||
11004 true 2 5 5 false 14#1003 1 704 50 0 null 1
|
||||
11005 true 2 5 5 false 14#1004 1 705 50 0 null 1
|
||||
11006 true 2 5 5 false 14#1005 1 706 50 0 null 1
|
||||
11007 true 2 5 5 false 14#1006 1 707 50 0 null 1
|
||||
11008 true 2 5 5 false 14#1007 1 708 50 0 null 1
|
||||
11009 true 2 5 5 false 14#1008 1 709 50 0 null 1
|
||||
11010 true 2 5 5 false 14#1009 1 710 50 0 null 1
|
||||
11011 true 2 5 5 false 14#1010 1 711 50 0 null 1
|
||||
11012 true 2 5 5 false 14#1011 1 712 50 0 null 1
|
||||
11013 true 2 5 5 false 14#1012 1 713 50 0 null 1
|
||||
11014 true 2 5 5 false 14#1013 1 714 50 0 null 1
|
||||
11015 true 2 5 5 false 14#1014 1 715 50 0 null 1
|
||||
11016 true 2 5 5 false 14#1015 1 716 50 0 null 1
|
||||
11017 true 2 5 5 false 14#1016 1 717 50 0 null 1
|
||||
11018 true 2 5 5 false 14#1017 1 718 50 0 null 1
|
||||
11019 true 2 5 5 false 14#1018 1 719 50 0 null 1
|
||||
11020 true 2 5 5 false 14#1019 1 720 50 0 null 1
|
||||
11021 true 2 5 5 false 14#1020 1 721 50 0 null 1
|
||||
11022 true 2 5 5 false 14#1021 1 722 50 0 null 1
|
||||
11023 true 2 5 5 false 14#1022 1 723 50 0 null 1
|
||||
11024 true 2 5 4 false 14#1023 1 724 40 0 null 1
|
||||
11025 true 2 5 4 false 14#1024 1 725 40 0 null 1
|
||||
11026 true 2 5 4 false 14#1025 1 726 40 0 null 1
|
||||
11027 true 2 5 4 false 14#1026 1 727 40 0 null 1
|
||||
11028 true 2 5 4 false 14#1027 1 728 40 0 null 1
|
||||
11029 true 2 5 4 false 14#1028 1 729 40 0 null 1
|
||||
11030 true 2 5 4 false 14#1029 1 730 40 0 null 1
|
||||
11031 true 2 5 4 false 14#1030 1 731 40 0 null 1
|
||||
11032 true 2 5 4 false 14#1031 1 732 40 0 null 1
|
||||
11033 true 2 5 4 false 14#1032 1 733 40 0 null 1
|
||||
11034 true 2 5 4 false 14#1033 1 734 40 0 null 1
|
||||
11035 true 2 5 4 false 14#1034 1 735 40 0 null 1
|
||||
11036 true 2 5 4 false 14#1035 1 736 40 0 null 1
|
||||
11037 true 2 5 4 false 14#1036 1 737 40 0 null 1
|
||||
11038 true 2 5 4 false 14#1037 1 738 40 0 null 1
|
||||
11039 true 2 5 4 false 14#1038 1 739 40 0 null 1
|
||||
11040 true 2 5 4 false 14#1039 1 740 40 0 null 1
|
||||
11041 true 2 5 4 false 14#1040 1 741 40 0 null 1
|
||||
11042 true 2 5 4 false 14#1041 1 742 40 0 null 1
|
||||
11043 true 2 5 4 false 14#1042 1 743 40 0 null 1
|
||||
11044 true 2 5 4 false 14#1043 1 744 40 0 null 1
|
||||
11045 true 2 5 4 false 14#1044 1 745 40 0 null 1
|
||||
11046 true 2 5 4 false 14#1045 1 746 40 0 null 1
|
||||
11047 true 2 5 3 false 14#1046 1 747 30 0 null 1
|
||||
11048 true 2 5 3 false 14#1047 1 748 30 0 null 1
|
||||
11049 true 2 5 3 false 14#1048 1 749 30 0 null 1
|
||||
11050 true 2 5 3 false 14#1049 1 750 30 0 null 1
|
||||
11051 true 2 5 3 false 14#1050 1 751 30 0 null 1
|
||||
11052 true 2 5 3 false 14#1051 1 752 30 0 null 1
|
||||
11001 true 2 5 5 false 100001 1 701 50 0 null 1
|
||||
11002 true 2 5 5 false 100001 1 702 50 0 null 1
|
||||
11003 true 2 5 5 false 100001 1 703 50 0 null 1
|
||||
11004 true 2 5 5 false 100001 1 704 50 0 null 1
|
||||
11005 true 2 5 5 false 100001 1 705 50 0 null 1
|
||||
11006 true 2 5 5 false 100001 1 706 50 0 null 1
|
||||
11007 true 2 5 5 false 100001 1 707 50 0 null 1
|
||||
11008 true 2 5 5 false 100001 1 708 50 0 null 1
|
||||
11009 true 2 5 5 false 100001 1 709 50 0 null 1
|
||||
11010 true 2 5 5 false 100001 1 710 50 0 null 1
|
||||
11011 true 2 5 5 false 100001 1 711 50 0 null 1
|
||||
11012 true 2 5 5 false 100001 1 712 50 0 null 1
|
||||
11013 true 2 5 5 false 100001 1 713 50 0 null 1
|
||||
11014 true 2 5 5 false 100001 1 714 50 0 null 1
|
||||
11015 true 2 5 5 false 100001 1 715 50 0 null 1
|
||||
11016 true 2 5 5 false 100001 1 716 50 0 null 1
|
||||
11017 true 2 5 5 false 100001 1 717 50 0 null 1
|
||||
11018 true 2 5 5 false 100001 1 718 50 0 null 1
|
||||
11019 true 2 5 5 false 100001 1 719 50 0 null 1
|
||||
11020 true 2 5 5 false 100001 1 720 50 0 null 1
|
||||
11021 true 2 5 5 false 100001 1 721 50 0 null 1
|
||||
11022 true 2 5 5 false 100001 1 722 50 0 null 1
|
||||
11023 true 2 5 5 false 100001 1 723 50 0 null 1
|
||||
11024 true 2 5 4 false 100001 1 724 40 0 null 1
|
||||
11025 true 2 5 4 false 100001 1 725 40 0 null 1
|
||||
11026 true 2 5 4 false 100001 1 726 40 0 null 1
|
||||
11027 true 2 5 4 false 100001 1 727 40 0 null 1
|
||||
11028 true 2 5 4 false 100001 1 728 40 0 null 1
|
||||
11029 true 2 5 4 false 100001 1 729 40 0 null 1
|
||||
11030 true 2 5 4 false 100001 1 730 40 0 null 1
|
||||
11031 true 2 5 4 false 100001 1 731 40 0 null 1
|
||||
11032 true 2 5 4 false 100001 1 732 40 0 null 1
|
||||
11033 true 2 5 4 false 100001 1 733 40 0 null 1
|
||||
11034 true 2 5 4 false 100001 1 734 40 0 null 1
|
||||
11035 true 2 5 4 false 100001 1 735 40 0 null 1
|
||||
11036 true 2 5 4 false 100001 1 736 40 0 null 1
|
||||
11037 true 2 5 4 false 100001 1 737 40 0 null 1
|
||||
11038 true 2 5 4 false 100001 1 738 40 0 null 1
|
||||
11039 true 2 5 4 false 100001 1 739 40 0 null 1
|
||||
11040 true 2 5 4 false 100001 1 740 40 0 null 1
|
||||
11041 true 2 5 4 false 100001 1 741 40 0 null 1
|
||||
11042 true 2 5 4 false 100001 1 742 40 0 null 1
|
||||
11043 true 2 5 4 false 100001 1 743 40 0 null 1
|
||||
11044 true 2 5 4 false 100001 1 744 40 0 null 1
|
||||
11045 true 2 5 4 false 100001 1 745 40 0 null 1
|
||||
11046 true 2 5 4 false 100001 1 746 40 0 null 1
|
||||
11047 true 2 5 3 false 100001 1 747 30 0 null 1
|
||||
11048 true 2 5 3 false 100001 1 748 30 0 null 1
|
||||
11049 true 2 5 3 false 100001 1 749 30 0 null 1
|
||||
11050 true 2 5 3 false 100001 1 750 30 0 null 1
|
||||
11051 true 2 5 3 false 100001 1 751 30 0 null 1
|
||||
11052 true 2 5 3 false 100001 1 752 30 0 null 1
|
||||
12001 true 2 5 3 false null 1 501 30 0 null 0
|
||||
12002 true 2 5 4 false null 1 502 40 0 null 0
|
||||
12003 true 2 5 4 false null 1 503 40 0 null 0
|
||||
|
@ -468,4 +468,4 @@ int bool int int int bool mut,int#int,1 int int int int mut,int#int,1 int
|
|||
13044 false 1 0 5 false null 0 0 0 0 10044#5 1
|
||||
13045 false 1 0 5 false null 0 0 0 0 10045#5 1
|
||||
13046 false 1 0 5 false null 0 0 0 0 10046#5 1
|
||||
400001 true 5 3 5 false 14#1000 1 2 1 0 null 0
|
||||
400001 true 5 3 5 false 100001 1 2 1 0 null 0
|
||||
|
|
|
@ -14,7 +14,7 @@ public class SItem implements BaseConfig {
|
|||
private int itemType;
|
||||
private int itemBaseType; //道具类型(该道具在哪个背包显示)
|
||||
private int quantity;
|
||||
private int[] price;
|
||||
private String price;
|
||||
private int useType; //使用类型0不使用 1掉落组 2N选1
|
||||
private int rewardGroup;
|
||||
private int usePerCount;
|
||||
|
@ -52,7 +52,7 @@ public class SItem implements BaseConfig {
|
|||
return quantity;
|
||||
}
|
||||
|
||||
public int[] getPrice() {
|
||||
public String getPrice() {
|
||||
return price;
|
||||
}
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@ import org.slf4j.Logger;
|
|||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Component
|
||||
public class UseAndPriceItemHandler extends BaseHandler {
|
||||
|
||||
|
@ -25,13 +27,16 @@ public class UseAndPriceItemHandler extends BaseHandler {
|
|||
PlayerInfoProto.UseAndPriceItemRequest useAndPriceItemRequest
|
||||
= PlayerInfoProto.UseAndPriceItemRequest.parseFrom(netData.parseClientProtoNetData());
|
||||
int type = useAndPriceItemRequest.getType();
|
||||
CommonProto.Item item = useAndPriceItemRequest.getItem();
|
||||
if (type == 0){
|
||||
ItemLogic.getInstance().useItem(iSession,item);
|
||||
}else{
|
||||
ItemLogic.getInstance().priceItem(iSession,item);
|
||||
}
|
||||
List<CommonProto.Item> itemList = useAndPriceItemRequest.getItemList();
|
||||
List<String> equipIdsList = useAndPriceItemRequest.getEquipIdsList();
|
||||
if (type == 0){ //使用
|
||||
ItemLogic.getInstance().useItem(iSession,itemList);
|
||||
}else if (type == 2){ //分解装备
|
||||
ItemLogic.getInstance().decomposeEquip(iSession,equipIdsList);
|
||||
}else{// 分解道具
|
||||
ItemLogic.getInstance().priceItem(iSession,itemList);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -892,7 +892,7 @@ public class HeroLogic {
|
|||
}
|
||||
Map<Integer,Integer> randomMap = new ConcurrentHashMap<>();
|
||||
randomMap.put(itemId,itemNum);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap );
|
||||
CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap);
|
||||
HeroInfoProto.HeroComposeResponse heroComposeResponse = HeroInfoProto.HeroComposeResponse
|
||||
.newBuilder()
|
||||
.setDrop(drop)
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.ljsd.jieling.logic.item;
|
||||
|
||||
import com.ljsd.jieling.config.*;
|
||||
import com.ljsd.jieling.logic.dao.Equip;
|
||||
import com.ljsd.jieling.logic.dao.EquipManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
|
@ -8,9 +10,11 @@ import com.ljsd.jieling.protocols.CommonProto;
|
|||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import com.ljsd.jieling.util.*;
|
||||
import com.sun.org.apache.regexp.internal.RE;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
|
@ -28,35 +32,35 @@ public class ItemLogic {
|
|||
}
|
||||
|
||||
/**
|
||||
* 出售道具
|
||||
* 分解道具
|
||||
* @param iSession
|
||||
* @param item
|
||||
* @param itemList
|
||||
* @throws Exception
|
||||
*/
|
||||
public void priceItem(ISession iSession,CommonProto.Item item) 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;
|
||||
int itemId = item.getItemId();
|
||||
int itemNum = item.getItemNum();
|
||||
SItem sItem = SItem.getsItemMap().get(itemId);
|
||||
if (sItem == null){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
StringBuilder cost = new StringBuilder();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
for (CommonProto.Item item :itemList){
|
||||
if (cost.length() == 0){
|
||||
cost = new StringBuilder(item.getItemId() + "#" + item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward = new StringBuilder(sItem.getPrice());
|
||||
}else{
|
||||
cost.append("|").append(item.getItemId()).append("#").append(item.getItemNum());
|
||||
SItem sItem = SItem.getsItemMap().get(item.getItemId());
|
||||
reward.append("#").append(sItem.getPrice());
|
||||
}
|
||||
}
|
||||
String costItem = itemId + "#"+ itemNum;
|
||||
int[][] costItemArr = StringUtil.parseFiledInt2(costItem);
|
||||
int[][] costItemArr = StringUtil.parseFiledInt2(cost.toString());
|
||||
boolean result = ItemUtil.itemCost(user, costItemArr);
|
||||
if (!result){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
int[] prices = sItem.getPrice();
|
||||
int priceItemId = prices[0];
|
||||
int priceItemNum = prices[1] * itemNum;
|
||||
String priceReward = priceItemId+"#"+priceItemNum;
|
||||
int[][] ints = StringUtil.parseFiledInt2(priceReward);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, ints);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, StringUtil.parseFiledInt(reward.toString()), 1, 0);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
|
@ -70,22 +74,54 @@ public class ItemLogic {
|
|||
/**
|
||||
* 使用道具
|
||||
* @param iSession
|
||||
* @param item
|
||||
* @param itemList
|
||||
*/
|
||||
public void useItem(ISession iSession, CommonProto.Item item) 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);
|
||||
// int itemId = item.getItemId();
|
||||
// int itemNum = item.getItemNum();
|
||||
// SItem sItem = SItem.getsItemMap().get(itemId);
|
||||
// boolean result = ItemUtil.checkCost(user, sItem, itemNum);
|
||||
// if (!result){
|
||||
// MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
// }
|
||||
// Map<Integer,Integer> randomMap = new ConcurrentHashMap<>();
|
||||
// randomMap.put(itemId,itemNum);
|
||||
// CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap);
|
||||
// sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 分解装备
|
||||
* @param iSession
|
||||
* @param equipIdsList
|
||||
*/
|
||||
public void decomposeEquip(ISession iSession, List<String> equipIdsList) throws Exception {
|
||||
int msgId = MessageTypeProto.MessageType.USER_AND_PRICE_ITEM_RESPONSE_VALUE;
|
||||
int uid = iSession.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
int itemId = item.getItemId();
|
||||
int itemNum = item.getItemNum();
|
||||
SItem sItem = SItem.getsItemMap().get(itemId);
|
||||
boolean result = ItemUtil.checkCost(user, sItem, itemNum);
|
||||
if (!result){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
EquipManager equipManager = user.getEquipManager();
|
||||
StringBuilder reward = new StringBuilder();
|
||||
if (equipIdsList.size() == 0){
|
||||
for (String equipId :equipIdsList){
|
||||
Equip equip = equipManager.getEquipMap().get(equipId);
|
||||
if (equip == null){
|
||||
MessageUtil.sendErrorResponse(iSession,0,msgId,"");
|
||||
return;
|
||||
}
|
||||
SItem sItem = SItem.getsItemMap().get(equip.getEquipId());
|
||||
equipManager.remove(equipId);
|
||||
if (reward.length() == 0){
|
||||
reward = new StringBuilder(sItem.getPrice());
|
||||
}else{
|
||||
reward.append("#").append(sItem.getPrice());
|
||||
}
|
||||
}
|
||||
}
|
||||
Map<Integer,Integer> randomMap = new ConcurrentHashMap<>();
|
||||
randomMap.put(itemId,itemNum);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.useRandomItem(user,randomMap);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user,StringUtil.parseFiledInt(reward.toString()),1,0);
|
||||
sendUseAndPriceItemMessage(iSession, msgId, drop);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue