阵容 装备
parent
a60edcf3dd
commit
ae84d45e79
|
|
@ -4,6 +4,7 @@ package com.ljsd.common.mogodb;
|
||||||
import com.mongodb.BasicDBList;
|
import com.mongodb.BasicDBList;
|
||||||
import com.mongodb.BasicDBObject;
|
import com.mongodb.BasicDBObject;
|
||||||
import com.mongodb.DBObject;
|
import com.mongodb.DBObject;
|
||||||
|
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||||
|
|
||||||
import java.lang.reflect.*;
|
import java.lang.reflect.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
@ -234,7 +235,24 @@ public class BeanUtil {
|
||||||
Map map = new HashMap<K, V>();
|
Map map = new HashMap<K, V>();
|
||||||
BasicDBObject dbObj = (BasicDBObject)dbObject;
|
BasicDBObject dbObj = (BasicDBObject)dbObject;
|
||||||
for (Map.Entry<String, Object> entry : dbObj.entrySet()) {
|
for (Map.Entry<String, Object> entry : dbObj.entrySet()) {
|
||||||
Object obj = getObj(entry.getValue(), (Class)types[1], root);
|
Type type = types[1];
|
||||||
|
if(type.getClass()== ParameterizedTypeImpl.class){
|
||||||
|
Class actualTypeArgument = (Class) (((ParameterizedTypeImpl) type).getActualTypeArguments()[0]);
|
||||||
|
|
||||||
|
ArrayList<Object> objects = new ArrayList<>();
|
||||||
|
BasicDBList values = (BasicDBList)entry.getValue();
|
||||||
|
Iterator<Object> iterator = values.iterator();
|
||||||
|
while (iterator.hasNext()){
|
||||||
|
Object next = iterator.next();
|
||||||
|
Object obj = getObj(next,actualTypeArgument, root);
|
||||||
|
objects.add(obj);
|
||||||
|
}
|
||||||
|
Object key = getKey(entry.getKey(), (Class)types[0]);
|
||||||
|
map.put(key,objects);
|
||||||
|
return map;
|
||||||
|
}
|
||||||
|
|
||||||
|
Object obj = getObj(entry.getValue(), (Class)type, root);
|
||||||
// Object value = ((Class)types[1]).newInstance();
|
// Object value = ((Class)types[1]).newInstance();
|
||||||
// Object obj = dbObject2Bean((DBObject) entry.getValue(), value, root);
|
// Object obj = dbObject2Bean((DBObject) entry.getValue(), value, root);
|
||||||
Object key = getKey(entry.getKey(), (Class)types[0]);
|
Object key = getKey(entry.getKey(), (Class)types[0]);
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package com.ljsd.jieling.handler;
|
||||||
|
|
||||||
|
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||||
|
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||||
|
import com.ljsd.jieling.network.session.ISession;
|
||||||
|
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||||
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
@Component
|
||||||
|
public class GetAllEquipHandler extends BaseHandler{
|
||||||
|
@Override
|
||||||
|
public MessageTypeProto.MessageType getMessageCode() {
|
||||||
|
return MessageTypeProto.MessageType.GET_ALL_EQUIP_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||||
|
HeroLogic.getInstance().getAllEquipInfo(iSession);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -22,8 +22,8 @@ public class SaveTeamPosHandler extends BaseHandler{
|
||||||
HeroInfoProto.TeamposSaveRequest teamposSaveRequest = HeroInfoProto.TeamposSaveRequest.parseFrom(netData.parseClientProtoNetData());
|
HeroInfoProto.TeamposSaveRequest teamposSaveRequest = HeroInfoProto.TeamposSaveRequest.parseFrom(netData.parseClientProtoNetData());
|
||||||
CommonProto.TeamPosInfo teamPosInfo = teamposSaveRequest.getTeamPosInfo();
|
CommonProto.TeamPosInfo teamPosInfo = teamposSaveRequest.getTeamPosInfo();
|
||||||
int teamId = teamPosInfo.getTeamId();
|
int teamId = teamPosInfo.getTeamId();
|
||||||
List<String> heroIdsList = teamPosInfo.getHeroIdsList();
|
List<CommonProto.TeamHeroInfo> teamHeroInfosList = teamPosInfo.getTeamHeroInfosList();
|
||||||
List<Integer> pokemonIdsList = teamPosInfo.getPokemonIdsList();
|
List<CommonProto.TeamPokemonInfo> teamPokemonInfosList = teamPosInfo.getTeamPokemonInfosList();
|
||||||
HeroLogic.getInstance().saveTeamPos(iSession,teamId,heroIdsList,pokemonIdsList);
|
HeroLogic.getInstance().saveTeamPos(iSession,teamId,teamHeroInfosList,teamPokemonInfosList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
public class TeamPosForPokenInfo {
|
||||||
|
private int position;
|
||||||
|
private int pokenId;
|
||||||
|
|
||||||
|
public TeamPosForPokenInfo(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public TeamPosForPokenInfo(int position, int pokenId) {
|
||||||
|
this.position = position;
|
||||||
|
this.pokenId = pokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPokenId() {
|
||||||
|
return pokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPokenId(int pokenId) {
|
||||||
|
this.pokenId = pokenId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
|
public class TeamPosHeroInfo {
|
||||||
|
private String heroId;
|
||||||
|
private int position;
|
||||||
|
|
||||||
|
public TeamPosHeroInfo(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public TeamPosHeroInfo(String heroId, int position) {
|
||||||
|
this.heroId = heroId;
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHeroId() {
|
||||||
|
return heroId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeroId(String heroId) {
|
||||||
|
this.heroId = heroId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPosition() {
|
||||||
|
return position;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPosition(int position) {
|
||||||
|
this.position = position;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
package com.ljsd.jieling.logic.dao;
|
package com.ljsd.jieling.logic.dao;
|
||||||
|
|
||||||
import com.ljsd.common.mogodb.MongoBase;
|
import com.ljsd.common.mogodb.MongoBase;
|
||||||
|
import com.ljsd.jieling.protocols.CommonProto;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TeamPosManager extends MongoBase {
|
public class TeamPosManager extends MongoBase {
|
||||||
|
|
||||||
private Map<Integer, List<String>> teamPosForHero;
|
private Map<Integer, List<TeamPosHeroInfo>> teamPosForHero;
|
||||||
private Map<Integer,String> teamNames;
|
private Map<Integer,String> teamNames;
|
||||||
private Map<Integer,List<Integer>> teamPosForPoken;
|
private Map<Integer,List<TeamPosForPokenInfo>> teamPosForPoken;
|
||||||
|
|
||||||
public TeamPosManager(){
|
public TeamPosManager(){
|
||||||
teamNames = new HashMap<>(3);
|
teamNames = new HashMap<>(3);
|
||||||
|
|
@ -23,23 +25,34 @@ public class TeamPosManager extends MongoBase {
|
||||||
updateString("teamNames",teamNames);
|
updateString("teamNames",teamNames);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeTeamInfo(int teamId,List<String> heroIds,List<Integer> pokemonoIds) throws Exception {
|
public void changeTeamInfo(int teamId, List<CommonProto.TeamHeroInfo> heroIds, List<CommonProto.TeamPokemonInfo> pokemonoIds) throws Exception {
|
||||||
teamPosForHero.put(teamId,heroIds);
|
List<TeamPosHeroInfo> teamPosHeroInfoList = new ArrayList<>(5);
|
||||||
teamPosForPoken.put(teamId,pokemonoIds);
|
for(CommonProto.TeamHeroInfo teamHeroInfo : heroIds){
|
||||||
|
TeamPosHeroInfo teamPosHeroInfo = new TeamPosHeroInfo(teamHeroInfo.getHeroId(), teamHeroInfo.getPosition());
|
||||||
|
teamPosHeroInfoList.add(teamPosHeroInfo);
|
||||||
|
}
|
||||||
|
List<TeamPosForPokenInfo> teamPosForPokenInfos = new ArrayList<>(5);
|
||||||
|
for(CommonProto.TeamPokemonInfo teamPokemonInfo : pokemonoIds){
|
||||||
|
teamPosForPokenInfos.add(new TeamPosForPokenInfo(teamPokemonInfo.getPosition(),teamPokemonInfo.getPokemonId()));
|
||||||
|
|
||||||
|
}
|
||||||
|
teamPosForHero.put(teamId,teamPosHeroInfoList);
|
||||||
|
teamPosForPoken.put(teamId,teamPosForPokenInfos);
|
||||||
updateString("teamPosForHero",teamPosForHero);
|
updateString("teamPosForHero",teamPosForHero);
|
||||||
updateString("teamPosForPoken",teamPosForPoken);
|
updateString("teamPosForPoken",teamPosForPoken);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, List<String>> getTeamPosForHero() {
|
|
||||||
return teamPosForHero;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Map<Integer, String> getTeamNames() {
|
public Map<Integer, String> getTeamNames() {
|
||||||
return teamNames;
|
return teamNames;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<Integer, List<Integer>> getTeamPosForPoken() {
|
public Map<Integer, List<TeamPosHeroInfo>> getTeamPosForHero() {
|
||||||
|
return teamPosForHero;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Integer, List<TeamPosForPokenInfo>> getTeamPosForPoken() {
|
||||||
return teamPosForPoken;
|
return teamPosForPoken;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,17 @@ public class HeroLogic {
|
||||||
|
|
||||||
private HeroLogic(){}
|
private HeroLogic(){}
|
||||||
|
|
||||||
|
public void getAllEquipInfo(ISession iSession) throws Exception {
|
||||||
|
int uid = iSession.getUid();
|
||||||
|
User user = UserManager.getUser(uid);
|
||||||
|
Map<String, Equip> equipMap = user.getEquipManager().getEquipMap();
|
||||||
|
List<CommonProto.Equip> equipList = new ArrayList<>();
|
||||||
|
for(Equip equipInfo: equipMap.values()){
|
||||||
|
equipList.add(CBean2Proto.getEquipProto(equipInfo));
|
||||||
|
}
|
||||||
|
HeroInfoProto.GetAllEquipResponse build = HeroInfoProto.GetAllEquipResponse.newBuilder().addAllEquip(equipList).build();
|
||||||
|
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.GET_ALL_EQUIP_RESPONSE_VALUE,build,true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public static class Instance {
|
public static class Instance {
|
||||||
|
|
@ -178,24 +189,37 @@ public class HeroLogic {
|
||||||
User user = UserManager.getUser(session.getUid());
|
User user = UserManager.getUser(session.getUid());
|
||||||
List<CommonProto.TeamPosInfo> teamPosInfoList = new ArrayList<>();
|
List<CommonProto.TeamPosInfo> teamPosInfoList = new ArrayList<>();
|
||||||
TeamPosManager teamPosManager = user.getTeamPosManager();
|
TeamPosManager teamPosManager = user.getTeamPosManager();
|
||||||
Map<Integer, List<String>> teamPosForHero = teamPosManager.getTeamPosForHero();
|
Map<Integer, List<TeamPosHeroInfo>> teamPosForHero = teamPosManager.getTeamPosForHero();
|
||||||
Map<Integer, String> teamNames = teamPosManager.getTeamNames();
|
Map<Integer, String> teamNames = teamPosManager.getTeamNames();
|
||||||
Map<Integer, List<Integer>> teamPosForPoken = teamPosManager.getTeamPosForPoken();
|
Map<Integer, List<TeamPosForPokenInfo>> teamPosForPoken = teamPosManager.getTeamPosForPoken();
|
||||||
for(Integer teamId:teamPosForHero.keySet()){
|
for(Integer teamId:teamPosForHero.keySet()){
|
||||||
List<String> heroIds = teamPosForHero.get(teamId);
|
List<TeamPosHeroInfo> teamPosHeroInfoList = teamPosForHero.get(teamId);
|
||||||
List<Integer> pokenIds = teamPosForPoken.get(teamId);
|
List<TeamPosForPokenInfo> teamPosForPokenInfos = teamPosForPoken.get(teamId);
|
||||||
if(null == pokenIds){
|
if(null == teamPosForPokenInfos){
|
||||||
pokenIds = new ArrayList<>(1);
|
teamPosForPokenInfos = new ArrayList<>(1);
|
||||||
}
|
}
|
||||||
String teamName = teamNames.get(teamId);
|
String teamName = teamNames.get(teamId);
|
||||||
if(StringUtil.isEmpty(teamName)){
|
if(StringUtil.isEmpty(teamName)){
|
||||||
teamName="";
|
teamName="";
|
||||||
}
|
}
|
||||||
|
List<CommonProto.TeamHeroInfo> teamHeroInfoList = new ArrayList<>();
|
||||||
|
for(TeamPosHeroInfo teamPosHeroInfo :teamPosHeroInfoList ){
|
||||||
|
teamHeroInfoList.add(
|
||||||
|
CommonProto.TeamHeroInfo.newBuilder().setPosition(teamPosHeroInfo.getPosition()).setHeroId(teamPosHeroInfo.getHeroId()).build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
List<CommonProto.TeamPokemonInfo> pokemonInfoList = new ArrayList<>();
|
||||||
|
for(TeamPosForPokenInfo teamPokemonInfo : teamPosForPokenInfos){
|
||||||
|
pokemonInfoList.add(
|
||||||
|
CommonProto.TeamPokemonInfo.newBuilder().setPokemonId(teamPokemonInfo.getPokenId()).setPosition(teamPokemonInfo.getPosition()).build()
|
||||||
|
);
|
||||||
|
}
|
||||||
teamPosInfoList.add(
|
teamPosInfoList.add(
|
||||||
CommonProto.TeamPosInfo.newBuilder()
|
CommonProto.TeamPosInfo.newBuilder()
|
||||||
.addAllHeroIds(heroIds)
|
.addAllTeamHeroInfos(teamHeroInfoList)
|
||||||
.addAllPokemonIds(pokenIds)
|
.addAllTeamPokemonInfos(pokemonInfoList)
|
||||||
.setTeamName(teamName)
|
.setTeamName(teamName)
|
||||||
|
.setTeamId(teamId)
|
||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
@ -203,9 +227,9 @@ public class HeroLogic {
|
||||||
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.GET_TEAMPOS_INFO_RESPONSE_VALUE,build,true);
|
MessageUtil.sendMessage(session,1,MessageTypeProto.MessageType.GET_TEAMPOS_INFO_RESPONSE_VALUE,build,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveTeamPos(ISession iSession,int teamId,List<String> heroIds ,List<Integer> pokemonoIds) throws Exception {
|
public void saveTeamPos(ISession iSession, int teamId, List<CommonProto.TeamHeroInfo> heroIds , List<CommonProto.TeamPokemonInfo> pokemonoIds) throws Exception {
|
||||||
User user = UserManager.getUser(iSession.getUid());
|
User user = UserManager.getUser(iSession.getUid());
|
||||||
String err = checkTeamPos(user, heroIds,pokemonoIds);
|
String err = checkTeamPos(user, teamId,heroIds,pokemonoIds);
|
||||||
if(!"".equals(err)){
|
if(!"".equals(err)){
|
||||||
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,err);
|
MessageUtil.sendErrorResponse(iSession,0,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,err);
|
||||||
return;
|
return;
|
||||||
|
|
@ -214,31 +238,43 @@ public class HeroLogic {
|
||||||
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,null,true);
|
MessageUtil.sendMessage(iSession,1,MessageTypeProto.MessageType.TEAM_POS_SAVE_RESPONSE_VALUE,null,true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String checkTeamPos(User user,List<String> heroIds,List<Integer> pokemonoIds ){
|
public String checkTeamPos(User user, int teamId,List<CommonProto.TeamHeroInfo> heroIds, List<CommonProto.TeamPokemonInfo> pokemonoIds ){
|
||||||
if(heroIds ==null || heroIds.isEmpty()){
|
if(heroIds ==null || heroIds.isEmpty()){
|
||||||
return "队伍信息错误";
|
return "队伍信息错误";
|
||||||
}
|
}
|
||||||
|
|
||||||
Set<String> cacheHeroIds = new HashSet<>();
|
Set<String> cacheHeroIds = new HashSet<>();
|
||||||
Collection<List<String>> values = user.getTeamPosManager().getTeamPosForHero().values();
|
Set<String> alreadyHeroIds = new HashSet<>();
|
||||||
for(String heroId : heroIds){
|
Map<Integer, List<TeamPosHeroInfo>> teamPosForHero = user.getTeamPosManager().getTeamPosForHero();
|
||||||
|
for(Integer teamIdTmp : teamPosForHero.keySet()){
|
||||||
|
if(teamIdTmp == teamId){
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
List<TeamPosHeroInfo> teamPosHeroInfoList = teamPosForHero.get(teamIdTmp);
|
||||||
|
for(TeamPosHeroInfo teamPosHeroInfo : teamPosHeroInfoList){
|
||||||
|
alreadyHeroIds.add(teamPosHeroInfo.getHeroId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(CommonProto.TeamHeroInfo teamHeroInfo: heroIds){
|
||||||
|
String heroId = teamHeroInfo.getHeroId();
|
||||||
if(user.getHeroManager().getHero(heroId) == null) {
|
if(user.getHeroManager().getHero(heroId) == null) {
|
||||||
// 卡牌不存在
|
// 卡牌不存在
|
||||||
return "card not exists";
|
return "card not exists";
|
||||||
}
|
}
|
||||||
// 卡牌重复
|
// 卡牌重复 卡牌已上阵
|
||||||
if(cacheHeroIds.contains(heroId)){
|
if(cacheHeroIds.contains(heroId)){
|
||||||
return "card repeated";
|
return "card repeated";
|
||||||
}
|
}
|
||||||
// 卡牌已上阵
|
if(alreadyHeroIds.contains(heroId)){
|
||||||
if(values.contains(heroId)){
|
return "card repeated";
|
||||||
return "card has already in teampos";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cacheHeroIds.add(heroId);
|
cacheHeroIds.add(heroId);
|
||||||
}
|
}
|
||||||
Map<Integer, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
|
Map<Integer, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
|
||||||
for(Integer pokemonoId : pokemonoIds){
|
for(CommonProto.TeamPokemonInfo pokemonInfo : pokemonoIds){
|
||||||
if( !pokemonMap.containsKey(pokemonoId)){
|
int pokemonId = pokemonInfo.getPokemonId();
|
||||||
|
if( !pokemonMap.containsKey(pokemonId)){
|
||||||
return "pokemono not exists";
|
return "pokemono not exists";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -602,8 +638,10 @@ public class HeroLogic {
|
||||||
int equipIdTid = equip.getEquipId();
|
int equipIdTid = equip.getEquipId();
|
||||||
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(equipIdTid);
|
SEquipConfig sEquipConfig = SEquipConfig.getsEquipConfigById(equipIdTid);
|
||||||
int position = sEquipConfig.getPosition();
|
int position = sEquipConfig.getPosition();
|
||||||
Map<Integer, String> equipByPositionMap = hero.getEquipByPositionMap();
|
int professionLimit = sEquipConfig.getProfessionLimit();
|
||||||
if( equipByPositionMap!=null && equipByPositionMap.get(position)!= null){
|
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
|
||||||
|
if(professionLimit!=0 && scHero.getProfession()!= professionLimit){
|
||||||
|
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.EQUIP_WEAR_REQUEST_VALUE,"");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import com.ljsd.jieling.protocols.CommonProto;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
public class CBean2Proto {
|
public class CBean2Proto {
|
||||||
|
|
||||||
|
|
@ -75,18 +76,26 @@ public class CBean2Proto {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static List<String> getHeroEquip(List<Equip> equipList) {
|
|
||||||
List<String> equips = new ArrayList<>();
|
|
||||||
return equips;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static CommonProto.Equip getEquipProto(Equip equip){
|
public static CommonProto.Equip getEquipProto(Equip equip){
|
||||||
|
Map<Integer, Integer> propertyValueByIdMap = equip.getPropertyValueByIdMap();
|
||||||
|
Map<Integer, Integer> secondValueByIdMap = equip.getSecondValueByIdMap();
|
||||||
CommonProto.Equip equipProto =CommonProto.Equip.newBuilder()
|
CommonProto.Equip equipProto =CommonProto.Equip.newBuilder()
|
||||||
.setEquipId(equip.getEquipId())
|
.setEquipId(equip.getEquipId())
|
||||||
|
.setId(equip.getId())
|
||||||
|
.setMainAttribute(parseFromMap(propertyValueByIdMap).get(0))
|
||||||
|
.addAllSecondAttribute(parseFromMap(secondValueByIdMap))
|
||||||
.build();
|
.build();
|
||||||
return equipProto;
|
return equipProto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static List<CommonProto.SpecialEffects> parseFromMap(Map<Integer,Integer> propertyValueByIdMap){
|
||||||
|
List<CommonProto.SpecialEffects> result = new ArrayList<>();
|
||||||
|
for(Integer propertyId:propertyValueByIdMap.keySet()){
|
||||||
|
result.add(CommonProto.SpecialEffects.newBuilder().setPropertyId(propertyId).setPropertyValue(propertyValueByIdMap.get(propertyId)).build());
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue