Merge branch 'master_dev' into master_otnew

# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/util/CBean2Proto.java
master_otnew
grimm 2023-12-29 14:50:18 +08:00
commit ecc76d4e87
8 changed files with 111 additions and 63 deletions

View File

@ -220,7 +220,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
.setDailyredpack(playerInfoManager.getDailyWelfareRedPacket())
.setRandomCount(randomCount)
.addAllDrawTimes(CBean2Proto.getRandomTypeNums(user))
.addAllHelpFightList(CBean2Proto.getHelpFightList(user))
.addAllHelpFightList(CBean2Proto.getHelpHeroList(user))
.addAllSixiangInfos(sixiangxinfaInfos)
.setServerOpenTime((int) (openTime / 1000))
.setXiuweiLevel(heroManager.getXiuweiLevel())

View File

@ -87,10 +87,7 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
this.training = new Training();
}
/**
*
* ,
*/
// 大脑天宫 初始化英雄,不入英雄背包
public Hero(Hero hero,int uid,int heroTid,int level) {
this.setRootCollection(User._COLLECTION_NAME);
this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid);
@ -111,9 +108,7 @@ public class Hero extends MongoBase implements Comparable<Hero>,Cloneable {
this.jewelInfo = new HashSet<>(hero.getJewelInfo());
}
/**
*
*/
// 创建默认英雄
public Hero(int uid, int heroTid, int initStar){
this.setRootCollection(User._COLLECTION_NAME);
this.id = KeyGenUtils.produceIdByModule(UUIDEnum.HERO, uid);

View File

@ -4,8 +4,11 @@ import com.ljsd.common.mogodb.MongoBase;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.KeyGenUtils;
import com.ljsd.jieling.util.UUIDEnum;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class PropertyItem extends MongoBase {
private static final Logger LOGGER = LoggerFactory.getLogger(PropertyItem.class);
private String id;// 唯一id
private int equipId;// 道具id
@ -77,7 +80,7 @@ public class PropertyItem extends MongoBase {
clone = (PropertyItem) super.clone();
clone.init(0,"");
} catch (CloneNotSupportedException e) {
e.printStackTrace();
LOGGER.error("强化类型装备克隆失败........",e);
}
return clone;
}

View File

@ -56,6 +56,8 @@ public class HelpHero {
private Baubles baubles;
private List<Baubles> baublesList = new ArrayList<>();
public int getUid() {
return uid;
}
@ -135,4 +137,12 @@ public class HelpHero {
public void setBaubles(Baubles baubles) {
this.baubles = baubles;
}
public List<Baubles> getBaublesList() {
return baublesList;
}
public void setBaublesList(List<Baubles> baublesList) {
this.baublesList = baublesList;
}
}

View File

@ -83,7 +83,7 @@ public class HelpHeroLogic {
// 我的助战
if (typeEnum == Me){
for (Map.Entry<String, HelpHero> data:helpHeroMap.entrySet()){
result.add(CBean2Proto.helpHeroProto(data.getValue()));
result.add(CBean2Proto.buildHelpHeroToProto(data.getValue()));
}
}
// 人佛妖道
@ -113,7 +113,7 @@ public class HelpHeroLogic {
if (friends.contains(Integer.parseInt(data.getKey()))){
// 此处进行助战类型赋值
data.getValue().setHelpType(0);
result.add(CBean2Proto.helpHeroProto(data.getValue()));
result.add(CBean2Proto.buildHelpHeroToProto(data.getValue()));
continue;
}
@ -122,7 +122,7 @@ public class HelpHeroLogic {
if (mem.contains(Integer.parseInt(data.getKey()))){
// 此处进行助战类型赋值
data.getValue().setHelpType(1);
result.add(CBean2Proto.helpHeroProto(data.getValue()));
result.add(CBean2Proto.buildHelpHeroToProto(data.getValue()));
break;
}
}
@ -134,7 +134,7 @@ public class HelpHeroLogic {
HelpHero helpHero = getHelpHero(subKey1, typeEnum.getPropertyId());
// 英雄不存在添加
if (helpHero != null && !strings.contains(helpHero.getHero().getId())){
result.add(CBean2Proto.helpHeroProto(helpHero));
result.add(CBean2Proto.buildHelpHeroToProto(helpHero));
}
}
return result;
@ -157,10 +157,11 @@ public class HelpHeroLogic {
if (helpHero != null){
throw new ErrorCodeException(ErrorCode.SYS_ERROR_CODE,"已选择其他神将!");
}
HelpHero helpHeroForRedis = CBean2Proto.buildHelpHeroToRedis(user, hero);
// 自己的助战列表添加
addHelpHero(subKey,propertyName,CBean2Proto.heroToHelpHero(user,hero));
addHelpHero(subKey,propertyName, helpHeroForRedis);
// 类型助战列表添加,自己的助战列表没有该类型英雄,那么对应类型的助战列表也应该没有对应英雄,所以这里不再循环验证
addHelpHero(String.valueOf(propertyName),user.getId(),CBean2Proto.heroToHelpHero(user,hero));
addHelpHero(String.valueOf(propertyName),user.getId(), helpHeroForRedis);
// 配置表,获取自己设置助战奖励
SCampTowerSetting campTowerSetting = STableManager.getConfig(SCampTowerSetting.class).get(1);

View File

@ -1323,7 +1323,8 @@ public class HeroLogic {
} else {
user.getTeamPosManager().changeTeamInfo(teamId, heroIds);
}
} else if (teamId == TeamEnum.TEAM_ARENA_DEFENSE.getTeamId()) {
}
else if (teamId == TeamEnum.TEAM_ARENA_DEFENSE.getTeamId()) {
long teamForce = calTeamTotalForce(user, teamId);
//更新竞技场防御编队战力
String key = RedisKey.getKey(RedisKey.AREDEF_TEAM_FORCE_RANK, "");

View File

@ -70,9 +70,8 @@ public class CBean2Proto {
/**
*
* @param item
* @param item
* @param itemNum -1
* @return
*/
public static CommonProto.Item getItem(Item item,long itemNum){
if(itemNum == -1){
@ -115,7 +114,6 @@ public class CBean2Proto {
}
/**
<<<<<<< HEAD
*
* @param user
* @return
@ -185,8 +183,6 @@ public class CBean2Proto {
/**
*
* @param user
* @return
*/
public static List<CommonProto.UserMountInfo> getUserMountList(User user) {
List<CommonProto.UserMountInfo> userMountLists = new ArrayList<>();
@ -211,12 +207,11 @@ public class CBean2Proto {
user.getPlayerInfoManager().setUserMountValidTime(validTime);
return userMountLists;
}
/*
* @param user
* @return
* @throws Exception
/**
*
*/
public static List<CommonProto.HelpFightList> getHelpFightList(User user) throws Exception {
public static List<CommonProto.HelpFightList> getHelpHeroList(User user) throws Exception {
List<CommonProto.HelpFightList> lists = new ArrayList<>();
// 助战英雄列表
String subKey = HelpHeroLogic.subKey(user.getId(),HelpHeroLogic.CHOOSE);
@ -225,7 +220,7 @@ public class CBean2Proto {
return lists;
}
for (HelpHero hero : helpHeroMap.values()) {
lists.add(helpHeroProto(hero));
lists.add(buildHelpHeroToProto(hero));
}
return lists;
}
@ -251,32 +246,66 @@ public class CBean2Proto {
/**
* redisproto
*/
public static CommonProto.HelpFightList helpHeroProto(HelpHero helpHero) throws Exception {
public static CommonProto.HelpFightList buildHelpHeroToProto(HelpHero helpHero) throws Exception {
User otherUser = UserManager.getUser(helpHero.getUid());
// 魂宝灵宝
List<CommonProto.Equip> jewels = buildHelpFightEquip(helpHero.getJewels());
// 法相
List<CommonProto.Equip> faxiang = buildHelpFightEquip(helpHero.getFaxiangs());
Hero hero = helpHero.getHero();
// 装备详细信息
List<CommonProto.Equip> equips = new ArrayList<>();
Map<Integer, Integer> equip = helpHero.getHero().getEquipByPositionMap();
equip.values().forEach(v->equips.add(getEquipProto(v)));
hero.getEquipByPositionMap().values().forEach(v->equips.add(getEquipProto(v)));
// 法宝
CommonProto.Equip baublesProto = getBaublesProto(helpHero.getBaublesList(), helpHero.getBaubles());
// 获取英雄信息
return CommonProto.HelpFightList.newBuilder()
.setUid(otherUser.getId())
.setUserName(otherUser.getPlayerInfoManager().getNickName())
.setGuildName(helpHero.getHelpType())
.setTrailType(helpHero.getFunctionType().getPropertyId())
.setHero(getHero(helpHero.getHero()))
.setHero(getHero(hero))
.setState(helpHero.getState())
.addAllJewels(jewels)
.addAllFaxiang(faxiang)
.setFourTotal(helpHero.getFourTotalTier())
.addAllEquips(equips)
.setBaubles(baublesProto)
.build();
}
public static List<PropertyItem> clonePropertyItemList(EquipManager equipManager, Set<String> infoList){
/**
* heroredis
* redis
*/
public static HelpHero buildHelpHeroToRedis(User user, Hero hero) {
// 获取神将类型
HelpTypeEnum type = HelpTypeEnum.getType(hero.getPropertyId());
// 英雄镜像
EquipManager equipManager = user.getEquipManager();
// 魂宝灵宝镜像
List<PropertyItem> jewels = buildPropertyItemList(equipManager, hero.getJewelInfo());
// 法相
List<PropertyItem> faxiangs = buildPropertyItemList(equipManager, hero.getFaxiangList());
// 结果返回,援助类型不在这里写
HelpHero helpHero = new HelpHero();
helpHero.setUid(user.getId());
helpHero.setFunctionType(type);
helpHero.setCreatTime(TimeUtils.now());
helpHero.setHero(hero);
helpHero.setState(0);
helpHero.setJewels(jewels);
helpHero.setFaxiangs(faxiangs);
helpHero.setFourTotalTier(user.getPlayerInfoManager().getFourChallengeTotal());
helpHero.setBaubles(equipManager.getBaubles(hero.getBauBlesId()));
helpHero.setBaublesList(buildBaublesList(equipManager, hero.getBauBlesId()));
return helpHero;
}
/**
*
*/
public static List<PropertyItem> buildPropertyItemList(EquipManager equipManager, Set<String> infoList){
List<PropertyItem> List = new ArrayList<>();
if (infoList == null || infoList.isEmpty()){
return List;
@ -284,38 +313,34 @@ public class CBean2Proto {
for (String id: infoList){
PropertyItem item = equipManager.getEquip(id);
if (item != null){
List.add(item.clone());
List.add(item);
}
}
return List;
}
/**
* heroredis
* redis
*
*/
public static HelpHero heroToHelpHero(User user,Hero hero) {
// 获取神将类型
HelpTypeEnum type = HelpTypeEnum.getType(hero.getPropertyId());
// 英雄镜像
Hero heroVo = hero.clone();
EquipManager equipManager = user.getEquipManager();
// 魂宝灵宝镜像
List<PropertyItem> jewels = clonePropertyItemList(equipManager, heroVo.getJewelInfo());
// 法相
List<PropertyItem> faxiangs = clonePropertyItemList(equipManager, heroVo.getFaxiangList());
// 结果返回,援助类型不在这里写
HelpHero helpHero = new HelpHero();
helpHero.setUid(user.getId());
helpHero.setFunctionType(type);
helpHero.setCreatTime(TimeUtils.now());
helpHero.setHero(heroVo);
helpHero.setState(0);
helpHero.setJewels(jewels);
helpHero.setFaxiangs(faxiangs);
helpHero.setFourTotalTier(user.getPlayerInfoManager().getFourChallengeTotal());
helpHero.setBaubles(equipManager.getBaubles(hero.getBauBlesId()));
return helpHero;
public static List<Baubles> buildBaublesList(EquipManager equipManager, String baublesId){
List<Baubles> list = new ArrayList<>();
// 当前法宝信息
Baubles baublesEquip = equipManager.getBaubles(baublesId);
if (baublesEquip == null){
return list;
}
// 庇佑信息
Set<String> blessList = baublesEquip.getBlessList();
if (blessList != null && !blessList.isEmpty()){
for (String id: blessList){
Baubles item = equipManager.getBaubles(id);
if (item == null){
continue;
}
list.add(item);
}
}
return list;
}
public static CommonProto.UserRank.Builder getOneUserRank(User everyUser, int function, com.ljsd.jieling.logic.dao.root.ArenaRecord arenaRecord){
@ -343,9 +368,8 @@ public class CBean2Proto {
}
/**
* proto
* @param hero
* @return
*
* @param hero
*/
public static CommonProto.Hero getHero(Hero hero){
// 魂印
@ -515,6 +539,20 @@ public class CBean2Proto {
return builder.build();
}
/**
*
*/
public static CommonProto.Equip getBaublesProto(List<Baubles> baublesList, Baubles bauBles){
CommonProto.Equip.Builder builder = getPropertyEquipProto(bauBles).toBuilder();
if (baublesList != null && !baublesList.isEmpty()){
for (Baubles baubles : baublesList) {
CommonProto.Equip equip = getPropertyEquipProto(baubles);
builder.addBless(equip);
}
}
return builder.build();
}
public static CommonProto.PokemonInfo getPokemon(Pokemon pokemon) {
return CommonProto.PokemonInfo.newBuilder()
.setId(pokemon.getId()).setLevel(pokemon.getLevel()).setStar(pokemon.getStar()).setTempId(pokemon.getTmpId())
@ -664,8 +702,8 @@ public class CBean2Proto {
/**
*
* @param tower
* @param indexId
* @param tower
* @param indexId
* @return
*/
@SuppressWarnings("StringBufferReplaceableByString")

View File

@ -226,7 +226,7 @@ public class STableManager {
try {
dealParams(clazz, map, key, type, obj, prarms);
}catch (Exception e){
LOGGER.error("clazz = [" + clazz + "], line = [" + line.substring(0,10) + "]"+prarms.toString() );
LOGGER.warn("clazz = [" + clazz + "], line = [" + line.substring(0,10) + "]"+ Arrays.toString(prarms));
throw e;
}
break;