身外化身
parent
9a48f5e62f
commit
699836479c
|
@ -0,0 +1,56 @@
|
|||
package com.ljsd.jieling.handler.transformation;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.TransformationInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChangingCard;
|
||||
import config.SChangingCardLevel;
|
||||
import config.SChangingForce;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Date 2021/11/11 17:06:42
|
||||
* @Description: 化身之力升级
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class TransformationForceUpHandler extends BaseHandler<HeroInfoProto.TransformationForceUpRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.TransformationForceUpRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.TransformationForceUpRequest proto) throws Exception {
|
||||
int id = proto.getId();
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
Map<Integer, SChangingForce> cardMap = STableManager.getConfig(SChangingForce.class);
|
||||
SChangingForce config = cardMap.get(id);
|
||||
if(config == null){
|
||||
return;
|
||||
}
|
||||
int[][] costItem = {{config.getExpCost()[0],config.getExpCost()[1]}};
|
||||
if(!ItemUtil.itemCost(user,costItem, BIReason.TRANSFORMATION_CARD_COST,1)){
|
||||
return;
|
||||
}
|
||||
user.getHeroManager().addTransformationForce(1);
|
||||
HeroInfoProto.TransformationForceUpResponse.Builder builder = HeroInfoProto.TransformationForceUpResponse.newBuilder();
|
||||
builder.setId(user.getHeroManager().getTransformationForce());
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TransformationForceUpResponse.getNumber(), builder.build(), true);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,92 @@
|
|||
package com.ljsd.jieling.handler.transformation;
|
||||
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.globals.BIReason;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.dao.TransformationInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import config.SChangingCard;
|
||||
import config.SChangingCardLevel;
|
||||
import manager.STableManager;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.HeroInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @Author hj
|
||||
* @Date 2021/11/11 17:06:42
|
||||
* @Description: 上阵或卸下变身卡信息
|
||||
* @Version 1.0
|
||||
*/
|
||||
@Component
|
||||
public class TransformationUpGradeHandler extends BaseHandler<HeroInfoProto.TransformationUpGradeRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.TransformationUpGradeRequest;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, HeroInfoProto.TransformationUpGradeRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
int id = proto.getId();
|
||||
int type = proto.getType();
|
||||
Map<Integer, SChangingCard> cardMap = STableManager.getConfig(SChangingCard.class);
|
||||
SChangingCard changingCard = cardMap.get(id);
|
||||
if (changingCard == null || changingCard.getIsOpen() == 0){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"该卡片版本错误");
|
||||
}
|
||||
Map<Integer, TransformationInfo> infoMap = user.getHeroManager().getTransformationList();
|
||||
TransformationInfo info = infoMap.get(id);
|
||||
HeroInfoProto.TransformationUpGradeResponse.Builder builder = HeroInfoProto.TransformationUpGradeResponse.newBuilder();
|
||||
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();
|
||||
if(type == 1){
|
||||
//升级
|
||||
int pool = changingCard.getLevelUpPool();
|
||||
Map<Integer, SChangingCardLevel> poolConfig = SChangingCardLevel.getConfigByPoolId(pool);
|
||||
if(poolConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"该卡片版本错误");
|
||||
}
|
||||
SChangingCardLevel nextConfig = poolConfig.get(info.getLevel()+1);
|
||||
if(nextConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"该卡片版本错误");
|
||||
}
|
||||
int[][] costItem = {{nextConfig.getExp()[0],nextConfig.getExp()[1]}};
|
||||
if(!ItemUtil.itemCost(user,costItem, BIReason.TRANSFORMATION_CARD_COST,1)){
|
||||
return;
|
||||
}
|
||||
info.setLevel(info.getLevel()+1);
|
||||
user.getHeroManager().putTransformationList(info);
|
||||
int[][] dropItem = {nextConfig.getChangingForceExp()};
|
||||
|
||||
ItemUtil.drop(user, dropItem, drop, BIReason.SEVEN_WORLD_TREASURE);
|
||||
builder.setDrop(drop);
|
||||
|
||||
}else if(type == 2 ){
|
||||
//升星
|
||||
if(!ItemUtil.itemCost(user, changingCard.getStarUpCost(), BIReason.TRANSFORMATION_CARD_COST,1)){
|
||||
return;
|
||||
}
|
||||
if (info != null){
|
||||
info.setStar(info.getStar()+ 1);
|
||||
user.getHeroManager().putTransformationList(info);
|
||||
Map<Integer,Long> itemMap = new HashMap<>(1);
|
||||
int [] item = changingCard.getStarUpExp()[info.getStar()-1];
|
||||
itemMap.put(item[0],Long.valueOf(item[1]));
|
||||
ItemUtil.addItem(user,itemMap,drop, BIReason.VIP_DAY_REWARD);
|
||||
builder.setDrop(drop);
|
||||
//user.getHeroManager().addTransformationForce(changingCard.getStarUpExp()[info.getStar()-1][1]);
|
||||
}
|
||||
}
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.TransformationUpGradeResponse.getNumber(), builder.build(), true);
|
||||
}
|
||||
}
|
|
@ -198,6 +198,19 @@ public class HeroManager extends MongoBase {
|
|||
public Map<Integer,TransformationInfo> getTransformationList() {
|
||||
return transformationList;
|
||||
}
|
||||
/**
|
||||
* 变身卡变身之力
|
||||
*/
|
||||
private int transformationForce;
|
||||
|
||||
public int getTransformationForce() {
|
||||
return transformationForce;
|
||||
}
|
||||
|
||||
public void addTransformationForce(int transformationForce) {
|
||||
this.transformationForce+=transformationForce;
|
||||
updateString("transformationForce", this.transformationForce);
|
||||
}
|
||||
|
||||
public void putTransformationList(TransformationInfo info) {
|
||||
this.transformationList.put(info.getCardId(),info);
|
||||
|
|
|
@ -13,6 +13,10 @@ public class TransformationInfo {
|
|||
private int index;
|
||||
private int status;
|
||||
|
||||
private int level;//升级
|
||||
private int star;//升星
|
||||
|
||||
|
||||
public TransformationInfo(int cardId, int index, int status) {
|
||||
this.cardId = cardId;
|
||||
this.index = index;
|
||||
|
@ -43,6 +47,23 @@ public class TransformationInfo {
|
|||
this.status = status;
|
||||
}
|
||||
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) {
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getStar() {
|
||||
return star;
|
||||
}
|
||||
|
||||
public void setStar(int star) {
|
||||
this.star = star;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
|
|
|
@ -2467,8 +2467,10 @@ public class HeroLogic {
|
|||
Map<Integer, SChangingCard> cardMap = STableManager.getConfig(SChangingCard.class);
|
||||
for (int cardId : tfInfoList) {
|
||||
SChangingCard card = cardMap.get(cardId);
|
||||
if (card != null){
|
||||
skillStr.append(card.getSkill()).append("#");
|
||||
if (card != null){ //TODO
|
||||
for(int skill:card.getSkill()){
|
||||
skillStr.append(skill).append("#");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2852,8 +2854,28 @@ public class HeroLogic {
|
|||
combinedAttribute(card.getPropList(), heroAllAttribute);
|
||||
// 每张变身卡提供得额外属性
|
||||
combinedAttribute(arrayValue, heroAllAttribute);
|
||||
//变身卡升星属性
|
||||
if(info.getStar() == 1){
|
||||
combinedAttribute(card.getStar1UpProps(), heroAllAttribute);
|
||||
}else if(info.getStar() == 2){
|
||||
combinedAttribute(card.getStar2UpProps(), heroAllAttribute);
|
||||
}else if(info.getStar() == 3){
|
||||
combinedAttribute(card.getStar3UpProps(), heroAllAttribute);
|
||||
}
|
||||
//变身卡升级属性
|
||||
int pool = card.getLevelUpPool();
|
||||
Map<Integer, SChangingCardLevel> poolConfig = SChangingCardLevel.getConfigByPoolId(pool);
|
||||
if(poolConfig.get(info.getLevel()) == null){
|
||||
continue;
|
||||
}
|
||||
combinedAttribute(poolConfig.get(info.getLevel()).getPropList(), heroAllAttribute);
|
||||
}
|
||||
}
|
||||
//化身之力提供的属性
|
||||
Map<Integer, SChangingForce> SChangingForce = STableManager.getConfig(SChangingForce.class);
|
||||
if(SChangingForce.get(user.getHeroManager().getTransformationForce()) != null){
|
||||
combinedAttribute(SChangingForce.get(user.getHeroManager().getTransformationForce()).getPropList(), heroAllAttribute);
|
||||
}
|
||||
|
||||
//装备总战力评分
|
||||
int equipForce = 0;
|
||||
|
|
|
@ -11,7 +11,19 @@ public class SChangingCard implements BaseConfig {
|
|||
|
||||
private int[][] propList;
|
||||
|
||||
private int skill;
|
||||
private int[][] starUpCost;
|
||||
|
||||
private int[][] star1UpProps;
|
||||
|
||||
private int[][] star2UpProps;
|
||||
|
||||
private int[][] star3UpProps;
|
||||
|
||||
private int[][] starUpExp;
|
||||
|
||||
private int[] exp;
|
||||
private int levelUpPool;
|
||||
private int[] skill;
|
||||
|
||||
private int isOpen;
|
||||
|
||||
|
@ -34,7 +46,7 @@ public class SChangingCard implements BaseConfig {
|
|||
return propList;
|
||||
}
|
||||
|
||||
public int getSkill() {
|
||||
public int[] getSkill() {
|
||||
return skill;
|
||||
}
|
||||
|
||||
|
@ -42,5 +54,31 @@ public class SChangingCard implements BaseConfig {
|
|||
return isOpen;
|
||||
}
|
||||
|
||||
public int[][] getStarUpCost() {
|
||||
return starUpCost;
|
||||
}
|
||||
|
||||
public int[][] getStar1UpProps() {
|
||||
return star1UpProps;
|
||||
}
|
||||
|
||||
public int[][] getStar2UpProps() {
|
||||
return star2UpProps;
|
||||
}
|
||||
|
||||
public int[][] getStar3UpProps() {
|
||||
return star3UpProps;
|
||||
}
|
||||
|
||||
public int[][] getStarUpExp() {
|
||||
return starUpExp;
|
||||
}
|
||||
|
||||
public int[] getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public int getLevelUpPool() {
|
||||
return levelUpPool;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ChangingCardLevel")
|
||||
public class SChangingCardLevel implements BaseConfig {
|
||||
|
||||
private int iD;
|
||||
|
||||
private int level;
|
||||
|
||||
private int poolId;
|
||||
|
||||
private int[][] propList;
|
||||
|
||||
private int[] exp;
|
||||
|
||||
private int[] changingForceExp;
|
||||
|
||||
public static Map<Integer, Map<Integer, SChangingCardLevel>> sChallengeConfigs;
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SChangingCardLevel> sChangingCardLevel = STableManager.getConfig(SChangingCardLevel.class);
|
||||
for(SChangingCardLevel config: sChangingCardLevel.values()){
|
||||
if(!sChallengeConfigs.containsKey(config.getPoolId())){
|
||||
sChallengeConfigs.put(config.getPoolId(),new HashMap<Integer, SChangingCardLevel>());
|
||||
}
|
||||
if(!sChallengeConfigs.get(config.getPoolId()).containsKey(config.getLevel())){
|
||||
sChallengeConfigs.get(config.getPoolId()).put(config.getLevel(),config);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static Map<Integer, SChangingCardLevel> getConfigByPoolId(int poolId){
|
||||
|
||||
if(sChallengeConfigs.containsKey(poolId)){
|
||||
return sChallengeConfigs.get(poolId);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public int getID() {
|
||||
return iD;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int getPoolId() {
|
||||
return poolId;
|
||||
}
|
||||
|
||||
public int[][] getPropList() {
|
||||
return propList;
|
||||
}
|
||||
|
||||
public int[] getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public int[] getChangingForceExp() {
|
||||
return changingForceExp;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
package config;
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="ChangingForce")
|
||||
public class SChangingForce implements BaseConfig {
|
||||
|
||||
private int iD;
|
||||
|
||||
private int level;
|
||||
|
||||
private int[][] propList;
|
||||
|
||||
private int[] expCost;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
}
|
||||
|
||||
|
||||
public int getID() {
|
||||
return iD;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public int[][] getPropList() {
|
||||
return propList;
|
||||
}
|
||||
|
||||
public int[] getExpCost() {
|
||||
return expCost;
|
||||
}
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue