化身之力
parent
b97b400182
commit
d589cfc104
|
@ -405,5 +405,6 @@ public interface BIReason {
|
|||
int TRANSFORMATION_CARD_LEVEL_REWARD = 1245;//身外化身卡片升星奖励
|
||||
int TRANSFORMATION_CARD_STAR_REWARD= 1246;//身外化身卡片升星奖励
|
||||
int TRANSFORMATION_FORCE_STAR_COST= 1247;//身外化身之力消耗
|
||||
int TRANSFORMATION_CARD_ACTIVATION = 1248;//身外化身卡片升星奖励
|
||||
|
||||
}
|
|
@ -12,6 +12,7 @@ import com.ljsd.jieling.util.ItemUtil;
|
|||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChangingCard;
|
||||
import config.SChangingCardLevel;
|
||||
import config.SItem;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
|
@ -55,11 +56,12 @@ public class TransformationUpGradeHandler extends BaseHandler<HeroInfoProto.Tran
|
|||
if (poolConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "该卡片版本错误");
|
||||
}
|
||||
SChangingCardLevel nextConfig = poolConfig.get(info.getLevel() + 1);
|
||||
if (nextConfig == null) {
|
||||
SChangingCardLevel curConfig = poolConfig.get(info.getLevel());
|
||||
SChangingCardLevel nextConfig = poolConfig.get(info.getLevel()+1);
|
||||
if (nextConfig == null||curConfig == null) {
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE, "该卡片版本错误");
|
||||
}
|
||||
int[][] costItem = {{nextConfig.getExp()[0], nextConfig.getExp()[1]}};
|
||||
int[][] costItem = {{curConfig.getExp()[0], curConfig.getExp()[1]}};
|
||||
if (!ItemUtil.itemCost(user, costItem, BIReason.TRANSFORMATION_CARD_LEVEL_COST, 1)) {
|
||||
return;
|
||||
}
|
||||
|
@ -76,12 +78,31 @@ public class TransformationUpGradeHandler extends BaseHandler<HeroInfoProto.Tran
|
|||
Map<Integer, Integer> costMap = new HashMap<>();
|
||||
for (CommonProto.KeyVal keyVal : itemIdList) {
|
||||
if (costMap.containsKey(keyVal.getKey())) {
|
||||
costMap.put(keyVal.getKey(), costMap.get(keyVal.getKey()) + 1);
|
||||
costMap.put(keyVal.getKey(), costMap.get(keyVal.getKey()) + keyVal.getVal());
|
||||
} else {
|
||||
costMap.put(keyVal.getKey(), 1);
|
||||
costMap.put(keyVal.getKey(), keyVal.getVal());
|
||||
}
|
||||
}
|
||||
int num = 0;
|
||||
int quantity = 0;
|
||||
if(changingCard.getStarUpCost().length>= info.getStar() + 1){
|
||||
num = changingCard.getStarUpCost()[info.getStar()][1];
|
||||
quantity = changingCard.getStarUpCost()[info.getStar()][0];
|
||||
}
|
||||
for(Object itemId:costMap.keySet().toArray()){
|
||||
int itemid = (int)itemId;
|
||||
SItem sItem = SItem.getsItemMap().get(itemid);
|
||||
if(sItem == null || sItem.getQuantity() != quantity){
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TransformationUpGradeResponse.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(costMap.values().stream().mapToInt(Integer::intValue).sum() != num ){
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TransformationUpGradeResponse.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
if (!ItemUtil.itemCost(user, costMap, BIReason.TRANSFORMATION_CARD_STAR_COST, 1)) {
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TransformationUpGradeResponse.getNumber(), builder.build(), true);
|
||||
return;
|
||||
}
|
||||
if (info != null) {
|
||||
|
|
|
@ -14,6 +14,7 @@ import com.ljsd.jieling.util.MessageUtil;
|
|||
import config.SChangingCard;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
|
@ -43,7 +44,9 @@ public class UpOrDownTransformationHandler extends BaseHandler<HeroInfoProto.UpO
|
|||
if (changingCard == null || changingCard.getIsOpen() == 0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"该卡片版本错误");
|
||||
}
|
||||
|
||||
// 返回值
|
||||
HeroInfoProto.GetTransformationResponse.Builder builder = HeroInfoProto.GetTransformationResponse.newBuilder()
|
||||
.addAllList(CBean2Proto.getTransformationInfoList(user));
|
||||
Map<Integer, TransformationInfo> infoMap = user.getHeroManager().getTransformationList();
|
||||
TransformationInfo info = infoMap.get(id);
|
||||
if (info != null && info.getStatus() == 0){
|
||||
|
@ -69,15 +72,19 @@ public class UpOrDownTransformationHandler extends BaseHandler<HeroInfoProto.UpO
|
|||
info = new TransformationInfo(id, 0, 0);
|
||||
info.setLevel(1);
|
||||
info.setStar(0);
|
||||
//激活给变身之力
|
||||
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
|
||||
int[][] dropItem = {changingCard.getExp()};
|
||||
|
||||
ItemUtil.drop(user, dropItem, drop, BIReason.TRANSFORMATION_CARD_ACTIVATION);
|
||||
builder.setDrop(drop);
|
||||
}else {
|
||||
info.setStatus(0);
|
||||
info.setIndex(0);
|
||||
}
|
||||
}
|
||||
user.getHeroManager().putTransformationList(info);
|
||||
// 返回值
|
||||
HeroInfoProto.GetTransformationResponse.Builder builder = HeroInfoProto.GetTransformationResponse.newBuilder()
|
||||
.addAllList(CBean2Proto.getTransformationInfoList(user));
|
||||
|
||||
MessageUtil.sendMessage(user.getId(),1, MessageTypeProto.MessageType.GetTransformationResponse_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue