back_recharge
parent
16c7e11fb8
commit
60de80b53b
|
@ -23,7 +23,6 @@ import rpc.protocols.MessageTypeProto;
|
||||||
import rpc.protocols.PlayerInfoProto;
|
import rpc.protocols.PlayerInfoProto;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class EquipLogic {
|
public class EquipLogic {
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(EquipLogic.class);
|
private static final Logger LOGGER = LoggerFactory.getLogger(EquipLogic.class);
|
||||||
|
@ -114,7 +113,7 @@ public class EquipLogic {
|
||||||
/**
|
/**
|
||||||
* 强化法相,或法相升星
|
* 强化法相,或法相升星
|
||||||
*/
|
*/
|
||||||
public void strongthenFaxiangEquip(ISession session, String faxiangID, int targetLv, int action) throws Exception {
|
public void strongthenFaxiangEquip(ISession session, String faxiangID, int targetLv, int action, List<String> costID) throws Exception {
|
||||||
User user = UserManager.getUser(session.getUid());
|
User user = UserManager.getUser(session.getUid());
|
||||||
EquipManager equipManager = user.getEquipManager();
|
EquipManager equipManager = user.getEquipManager();
|
||||||
Faxiang faxiang = equipManager.getFaxiang(faxiangID);
|
Faxiang faxiang = equipManager.getFaxiang(faxiangID);
|
||||||
|
@ -174,7 +173,7 @@ public class EquipLogic {
|
||||||
}
|
}
|
||||||
|
|
||||||
HashMap<Integer, Long> costMap = new HashMap<>();
|
HashMap<Integer, Long> costMap = new HashMap<>();
|
||||||
StringBuilder equipCostStr = new StringBuilder();
|
int count = 0;
|
||||||
int num = faxiang.getStar();
|
int num = faxiang.getStar();
|
||||||
while (num < targetLv){
|
while (num < targetLv){
|
||||||
SFaxiangStarConfig starConfig = starConfigMap.get(num);
|
SFaxiangStarConfig starConfig = starConfigMap.get(num);
|
||||||
|
@ -183,9 +182,9 @@ public class EquipLogic {
|
||||||
}
|
}
|
||||||
// 整合道具
|
// 整合道具
|
||||||
for (int[] prop : starConfig.getPropList()) {
|
for (int[] prop : starConfig.getPropList()) {
|
||||||
|
// 法相消耗本体
|
||||||
if (prop[0] == 0){
|
if (prop[0] == 0){
|
||||||
// 法相
|
count = prop[1];
|
||||||
equipCostStr.append(faxiang.getItemId()).append("#").append(num).append("#").append(prop[1]).append("|");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
// 道具
|
// 道具
|
||||||
|
@ -196,13 +195,13 @@ public class EquipLogic {
|
||||||
|
|
||||||
// 先校验,后消耗
|
// 先校验,后消耗
|
||||||
boolean checkCost = ItemUtil.checkCostLong(user,costMap);
|
boolean checkCost = ItemUtil.checkCostLong(user,costMap);
|
||||||
boolean costFaxiang = costFaxiang(user, equipCostStr.toString(), false);
|
boolean costFaxiang = costFaxiang(user, costID, count, false);
|
||||||
if (!checkCost || !costFaxiang){
|
if (!checkCost || !costFaxiang){
|
||||||
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH,"SFaxiangLevelConfig 升级道具数量不足:"+faxiang.getStrongLv());
|
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH,"SFaxiangLevelConfig 升级道具数量不足:"+faxiang.getStrongLv());
|
||||||
}
|
}
|
||||||
faxiang.setStar(targetLv);
|
faxiang.setStar(targetLv);
|
||||||
ItemUtil.itemCostLong(user,costMap, BIReason.UP_FAXIANG_EQUIP_STAR_COST,0);
|
ItemUtil.itemCostLong(user,costMap, BIReason.UP_FAXIANG_EQUIP_STAR_COST,0);
|
||||||
costFaxiang(user, equipCostStr.toString(), true);
|
costFaxiang(user, costID, count, true);
|
||||||
}
|
}
|
||||||
equipManager.putFaxiang(faxiang);
|
equipManager.putFaxiang(faxiang);
|
||||||
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.STRONGTHEN_FAXIANG_EQUIP_RESPONSE_VALUE, null, true);
|
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.STRONGTHEN_FAXIANG_EQUIP_RESPONSE_VALUE, null, true);
|
||||||
|
@ -211,40 +210,27 @@ public class EquipLogic {
|
||||||
/**
|
/**
|
||||||
* 消耗法相道具
|
* 消耗法相道具
|
||||||
*/
|
*/
|
||||||
private boolean costFaxiang(User user, String costStr, boolean cost){
|
private boolean costFaxiang(User user, List<String> costID, int num, boolean cost){
|
||||||
if (costStr == null || costStr.isEmpty()){
|
if (costID == null){
|
||||||
return true;
|
costID = new ArrayList<>();
|
||||||
}
|
}
|
||||||
LOGGER.info("验证消耗法相道具,uid:{}, prop:{}, bol:{}",user.getId(),costStr,cost);
|
LOGGER.info("验证消耗法相道具,uid:{}, prop:{}, num:{}, bol:{}",user.getId(),costID,num,cost);
|
||||||
EquipManager equipManager = user.getEquipManager();
|
if (costID.size() != num){
|
||||||
HashSet<String> set = new HashSet<>();
|
|
||||||
Map<Integer, Map<Integer, List<Faxiang>>> map = equipManager.getFaxiangCostMap();
|
|
||||||
int total = 0;
|
|
||||||
String[] oneSplit = costStr.split("\\|");
|
|
||||||
for (String one : oneSplit) {
|
|
||||||
String[] value = one.split("#");
|
|
||||||
// 每条有三个数据
|
|
||||||
if (value.length != 3){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
// 根据 法相道具id#法相星级#法相数量 验证
|
|
||||||
List<Faxiang> list = map.getOrDefault(Integer.parseInt(value[0]), new HashMap<>()).getOrDefault(Integer.parseInt(value[1]), new ArrayList<>());
|
|
||||||
int num = Integer.parseInt(value[2]);
|
|
||||||
if (list.size() < num){
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
List<Faxiang> faxiangList = list.subList(0, num);
|
|
||||||
set.addAll(faxiangList.stream().map(Faxiang::getId).collect(Collectors.toList()));
|
|
||||||
total+=num;
|
|
||||||
}
|
|
||||||
if (total < set.size()){
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
EquipManager equipManager = user.getEquipManager();
|
||||||
|
for (String id : costID) {
|
||||||
|
Faxiang faxiang = equipManager.getFaxiang(id);
|
||||||
|
if (faxiang == null || faxiang.getStrongLv() > 0 || faxiang.getStar() > 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (cost){
|
if (cost){
|
||||||
for (String key : set) {
|
for (String key : costID) {
|
||||||
equipManager.removeFaxiang(key);
|
equipManager.removeFaxiang(key);
|
||||||
}
|
}
|
||||||
LOGGER.info("验证消耗了法相道具,uid:{}, prop:{}",user.getId(),costStr);
|
LOGGER.info("升星消耗了法相道具,uid:{}, prop:{}",user.getId(),costID);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue