back_recharge
duhui 2023-02-19 19:40:52 +08:00
parent 9eff8bfd28
commit 17c2291269
15 changed files with 127 additions and 92 deletions

View File

@ -35,7 +35,7 @@ public enum FightType {
TREASURE_TEAM(29),//宝物战斗 TREASURE_TEAM(29),//宝物战斗
; ;
private int type; private final int type;
public int getType() { public int getType() {
return type; return type;

View File

@ -171,11 +171,7 @@ public class TimeUtils {
return false; return false;
} }
if (_second < 0 || _second > 59) { return _second >= 0 && _second <= 59;
return false;
}
return true;
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("isValidDayTime->msg={}", e.getMessage(), e); LOGGER.error("isValidDayTime->msg={}", e.getMessage(), e);
return false; return false;
@ -197,11 +193,7 @@ public class TimeUtils {
return false; return false;
} }
if (_minute < 0 || _minute > 59) { return _minute >= 0 && _minute <= 59;
return false;
}
return true;
} catch (Exception e) { } catch (Exception e) {
LOGGER.error("isValidHhMmTime->msg={}", e.getMessage(), e); LOGGER.error("isValidHhMmTime->msg={}", e.getMessage(), e);
return false; return false;
@ -451,9 +443,7 @@ public class TimeUtils {
// 设置Monday为一周的开始 // 设置Monday为一周的开始
st.setFirstDayOfWeek(Calendar.MONDAY); st.setFirstDayOfWeek(Calendar.MONDAY);
et.setFirstDayOfWeek(Calendar.MONDAY); et.setFirstDayOfWeek(Calendar.MONDAY);
if (st.get(Calendar.WEEK_OF_YEAR) == et.get(Calendar.WEEK_OF_YEAR)) { return st.get(Calendar.WEEK_OF_YEAR) == et.get(Calendar.WEEK_OF_YEAR);
return true;
}
} }
return false; return false;
} }
@ -560,10 +550,7 @@ public class TimeUtils {
* @return * @return
*/ */
private static boolean hasSpecTimeBetween(long st, long now, long specTime) { private static boolean hasSpecTimeBetween(long st, long now, long specTime) {
if (st <= specTime && specTime <= now) { return st <= specTime && specTime <= now;
return true;
}
return false;
} }
/** /**
@ -813,10 +800,7 @@ public class TimeUtils {
public static boolean isSameWeek7(long src) { public static boolean isSameWeek7(long src) {
long weekStart = getCurWeekdayStartTime(1, 0); long weekStart = getCurWeekdayStartTime(1, 0);
long weekEnd = TimeUtils.getCurWeekdayStartTime(1, 0) + TimeUtils.WEEK; long weekEnd = TimeUtils.getCurWeekdayStartTime(1, 0) + TimeUtils.WEEK;
if (src >= weekStart && src <= weekEnd) { return src >= weekStart && src <= weekEnd;
return true;
}
return false;
} }
/** /**
@ -1666,16 +1650,12 @@ public class TimeUtils {
return true; return true;
} else { } else {
curWeekdayStartTime = curWeekdayStartTime - WEEK; curWeekdayStartTime = curWeekdayStartTime - WEEK;
if (lastTime < curWeekdayStartTime) { return lastTime < curWeekdayStartTime;
return true;
} else {
return false;
}
} }
} }
public static long getNextTimeByDay(long time, int day) { public static long getNextTimeByDay(long time, int day) {
return time + day * 24 * 60 * 60 * 1000; return time + (long) day * 24 * 60 * 60 * 1000;
} }

View File

@ -44,6 +44,14 @@ public class Utils {
return b; return b;
} }
public static boolean isEmptyList(List<String> list){
return list == null || list.isEmpty();
}
public static boolean isEmptyMap(Map<Object,Object> map){
return map == null || map.isEmpty();
}
/** /**
* MD5 * MD5
* */ * */

View File

@ -14,6 +14,6 @@ public class WearFaxiangEquipHandler extends BaseHandler<PlayerInfoProto.WearFax
@Override @Override
public void processWithProto(ISession iSession, PlayerInfoProto.WearFaxiangEquipRequest proto) throws Exception { public void processWithProto(ISession iSession, PlayerInfoProto.WearFaxiangEquipRequest proto) throws Exception {
EquipLogic.getInstance().wearFaxiangEquip(iSession,proto.getHeroID(),proto.getFaxiangID(),proto.getAction()); EquipLogic.getInstance().wearFaxiangEquip(iSession,proto.getHeroID(),proto.getWearIDList(),proto.getAction());
} }
} }

View File

@ -7,21 +7,21 @@ import java.util.*;
public class EquipManager extends MongoBase { public class EquipManager extends MongoBase {
private Map<String,PropertyItem> equipMap; private final Map<String,PropertyItem> equipMap;
private Map<String,Faxiang> faxiangMap = new HashMap<>(); private final Map<String,Faxiang> faxiangMap = new HashMap<>();
private Set<Integer> equipBookEnabled = new HashSet<>(); private final Set<Integer> equipBookEnabled = new HashSet<>();
private Set<Integer> equipList = new HashSet<>(); private final Set<Integer> equipList = new HashSet<>();
// private Equip unDetermined; // private Equip unDetermined;
private Map<Integer,Integer> equipHandBook; private final Map<Integer,Integer> equipHandBook;
private int soulEquipPool;//占星装备卡池 private int soulEquipPool;//占星装备卡池
/** /**
* *
*/ */
private Map<Integer,Integer> equipIntensifyMap = new HashMap<>(4); private final Map<Integer,Integer> equipIntensifyMap = new HashMap<>(4);
/** /**
* *
*/ */

View File

@ -5,6 +5,8 @@ import com.ljsd.jieling.util.UUIDEnum;
public class Faxiang { public class Faxiang {
private String id; private String id;
private String bindHeroId;
private int itemId; private int itemId;
private int strongLv; private int strongLv;
private int star; private int star;
@ -53,4 +55,12 @@ public class Faxiang {
this.star = star; this.star = star;
} }
public String getBindHeroId() {
return bindHeroId;
}
public void setBindHeroId(String bindHeroId) {
this.bindHeroId = bindHeroId;
}
} }

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.logic.dao.Hero;
import com.ljsd.jieling.logic.dao.UserManager; import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User; import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession; import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.tools.Utils;
import com.ljsd.jieling.util.CBean2Proto; import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil; import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil; import com.ljsd.jieling.util.MessageUtil;
@ -21,6 +22,7 @@ import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto; import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto; import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto; import rpc.protocols.PlayerInfoProto;
import util.StringUtil;
import java.util.*; import java.util.*;
@ -36,76 +38,89 @@ public class EquipLogic {
/** /**
* 穿 * 穿
*/ */
public void wearFaxiangEquip(ISession session, String heroID, String faxiangID, int action) throws Exception { public void wearFaxiangEquip(ISession session, String heroID, List<String> wearID, int action) throws Exception {
User user = UserManager.getUser(session.getUid()); User user = UserManager.getUser(session.getUid());
Hero hero = user.getHeroManager().getHero(heroID); Hero hero = user.getHeroManager().getHero(heroID);
if (hero == null){ if (hero == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"英雄不存在:"+heroID); throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"英雄不存在:"+heroID);
} }
if (Utils.isEmptyList(wearID)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"客户端参数异常");
}
EquipManager equipManager = user.getEquipManager(); EquipManager equipManager = user.getEquipManager();
Faxiang faxiang = equipManager.getFaxiang(faxiangID); // 穿戴和替换
if (faxiang == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"法相装备不存在:"+faxiangID);
}
Map<Integer, SFaxiangConfig> faxiangMap = SFaxiangConfig.faxiangMap;
SFaxiangConfig faxiangConfig = faxiangMap.get(faxiang.getItemId());
if (faxiangConfig == null || faxiangConfig.getIsOpen() == 0){
throw new ErrorCodeException(ErrorCode.CFG_NULL,"法相配置表不存在,或未进入版本:"+faxiang.getItemId());
}
// 穿戴
if (action == 1 || action == 3){ if (action == 1 || action == 3){
Set<String> faxiangList = hero.getFaxiangList(); HashSet<String> removeList = new HashSet<>();
if (faxiangList.contains(faxiangID)){ for (String id : wearID) {
LOGGER.error("法相已装备hero:{}, faxiang:{}",heroID,faxiangID); Faxiang faxiang = equipManager.getFaxiang(id);
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备"); if (faxiang == null){
} throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"法相装备不存在:"+id);
// 检测是否装备同类型的法相
String removeId = null;
for (String faxiangId : faxiangList) {
Faxiang faxiang1 = equipManager.getFaxiang(faxiangId);
if (faxiang1 == null){
hero.uninstallFaxiang(faxiangId);
LOGGER.error("法相不存在装备库中已卸载uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangID);
continue;
} }
SFaxiangConfig faxiangConfig1 = faxiangMap.get(faxiang1.getItemId()); SFaxiangConfig faxiangConfig = SFaxiangConfig.faxiangMap.get(faxiang.getItemId());
if (faxiangConfig1 == null){ if (faxiangConfig == null || faxiangConfig.getIsOpen() == 0){
hero.uninstallFaxiang(faxiangId); throw new ErrorCodeException(ErrorCode.CFG_NULL,"法相配置表不存在,或未进入版本:"+faxiang.getItemId());
LOGGER.error("法相不存在配置表中已卸载uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangID);
continue;
} }
if (faxiangConfig.getType() == faxiangConfig1.getType()){ if (!StringUtil.isEmpty(faxiang.getBindHeroId())){
if (action == 3 && removeId == null){ LOGGER.error("法相已被其他英雄装备hero:{}, faxiang:{}",faxiang.getBindHeroId(),id);
removeId = faxiang1.getId(); throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已被其他英雄装备");
}else { }
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备同类型的法相");
// 检测是否装备同类型的法相
Set<String> heroFaxiangList = hero.getFaxiangList();
for (String faxiangId : heroFaxiangList) {
Faxiang heroFaxiang = equipManager.getFaxiang(faxiangId);
if (heroFaxiang == null){
hero.uninstallFaxiang(faxiangId);
LOGGER.error("法相不存在装备库中已卸载uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangId);
continue;
}
SFaxiangConfig heroFaxiangConfig = SFaxiangConfig.faxiangMap.get(heroFaxiang.getItemId());
if (heroFaxiangConfig == null){
hero.uninstallFaxiang(faxiangId);
LOGGER.error("法相不存在配置表中已卸载uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangId);
continue;
}
if (faxiangConfig.getType() == heroFaxiangConfig.getType()){
removeList.add(faxiangId);
} }
} }
} SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId()); if (scHero == null){
if (scHero == null){ throw new ErrorCodeException(ErrorCode.CFG_NULL,"英雄不存在配置表中");
throw new ErrorCodeException(ErrorCode.CFG_NULL,"英雄不存在配置表中"); }
} // 职业是否吻合
// 职业是否吻合 if (faxiangConfig.getProfession() != 0 && faxiangConfig.getProfession() != scHero.getProfession()){
if (faxiangConfig.getProfession() != 0 && faxiangConfig.getProfession() != scHero.getProfession()){ throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄职业不符合");
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄职业不符合"); }
} if (faxiangConfig.getJob() != 0 && faxiangConfig.getJob() != scHero.getJob()){
if (faxiangConfig.getJob() != 0 && faxiangConfig.getJob() != scHero.getJob()){ throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄细分职业不符合");
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄细分职业不符合"); }
} }
hero.addFaxiang(faxiangID); for (String key : wearID) {
if (removeId != null){ hero.addFaxiang(key);
hero.uninstallFaxiang(removeId); Faxiang faxiang = equipManager.getFaxiang(key);
faxiang.setBindHeroId(heroID);
equipManager.putFaxiang(faxiang);
}
if (!removeList.isEmpty()){
for (String key : removeList) {
hero.uninstallFaxiang(key);
Faxiang faxiang = equipManager.getFaxiang(key);
faxiang.setBindHeroId("");
equipManager.putFaxiang(faxiang);
}
} }
} }
// 脱下 // 脱下
if (action == 2){ if (action == 2){
if (!hero.getFaxiangList().contains(faxiangID)){ for (String key : wearID) {
LOGGER.error("法相未装备hero:{}, faxiang:{}",heroID,faxiangID); hero.uninstallFaxiang(key);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"法相未装备"); Faxiang faxiang = equipManager.getFaxiang(key);
faxiang.setBindHeroId("");
equipManager.putFaxiang(faxiang);
} }
hero.uninstallFaxiang(faxiangID);
} }
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WEAR_FAXIANG_EQUIP_RESPONSE_VALUE, null, true); MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.WEAR_FAXIANG_EQUIP_RESPONSE_VALUE, null, true);
} }

View File

@ -34,7 +34,7 @@ public class FightRecordLogic {
/** /**
* *
*/ */
private static BlockingQueue<String> queue = new LinkedBlockingQueue<>(QUEUE_LENGTH); private static final BlockingQueue<String> queue = new LinkedBlockingQueue<>(QUEUE_LENGTH);
/** /**
* *

View File

@ -436,7 +436,7 @@ public class FightUtil {
StringBuilder skillSb = new StringBuilder(); StringBuilder skillSb = new StringBuilder();
StringBuilder propertySb = new StringBuilder(); StringBuilder propertySb = new StringBuilder();
String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString(); String heroSkill = HeroLogic.getInstance().getHeroSkills(user, hero, skillSb).toString();
heroSkill = heroSkill + moraleSkillBuilder.toString(); heroSkill = heroSkill + moraleSkillBuilder;
String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero.getPropertyId(), hero.getLevel(user.getHeroManager()), heroAttributeMap).toString(); String property = HeroLogic.getInstance().getHeroPropertyBuilder(propertySb, hero.getPropertyId(), hero.getLevel(user.getHeroManager()), heroAttributeMap).toString();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder() .newBuilder()

View File

@ -193,7 +193,7 @@ public class FightResult {
", fightTeamInfo=" + fightTeam + ", fightTeamInfo=" + fightTeam +
", defFightTeamInfo=" + defFightTeam + ", defFightTeamInfo=" + defFightTeam +
", fightData=" + fightDataS + ", fightData=" + fightDataS +
", monsterTeamList=" + list.toString() + ", monsterTeamList=" + list +
'}'; '}';
} }
} }

View File

@ -4414,6 +4414,15 @@ public class HeroLogic {
returnItemMap.put(integer,1); returnItemMap.put(integer,1);
} }
} }
// 法相
Set<String> faxiangList = hero.getFaxiangList();
if (faxiangList != null && !faxiangList.isEmpty()){
for (String key : faxiangList) {
Faxiang faxiang = user.getEquipManager().getFaxiang(key);
faxiang.setBindHeroId("");
user.getEquipManager().putFaxiang(faxiang);
}
}
} }
int breakId = hero.getBreakId(); int breakId = hero.getBreakId();
int templateId = hero.getTemplateId(); int templateId = hero.getTemplateId();

View File

@ -34,7 +34,6 @@ public class ItemLogUtil {
}else{ }else{
try { try {
Thread.sleep(100); Thread.sleep(100);
return;
} catch (InterruptedException e) { } catch (InterruptedException e) {
e.printStackTrace(); e.printStackTrace();
} }

View File

@ -578,6 +578,16 @@ public class ItemLogic {
baseItemMap.put(integer,1L); baseItemMap.put(integer,1L);
} }
} }
// 法相
Set<String> faxiangList = hero.getFaxiangList();
if (faxiangList != null && !faxiangList.isEmpty()){
for (String key : faxiangList) {
Faxiang faxiang = user.getEquipManager().getFaxiang(key);
faxiang.setBindHeroId("");
user.getEquipManager().putFaxiang(faxiang);
}
}
heroIdReport.add(hero.getTemplateId()); heroIdReport.add(hero.getTemplateId());
heroLevelReport.add(hero.getOriginalLevel()); heroLevelReport.add(hero.getOriginalLevel());

View File

@ -1288,6 +1288,10 @@ public class PlayerLogic {
for(int equipId : hero.getEquipByHongmengPositionMap(userInMem.getHeroManager()).values()){ for(int equipId : hero.getEquipByHongmengPositionMap(userInMem.getHeroManager()).values()){
builder.addEquip(CBean2Proto.getEquipProto(equipId)); builder.addEquip(CBean2Proto.getEquipProto(equipId));
} }
for(String key : hero.getFaxiangList()){
Faxiang faxiang = equipManager.getFaxiang(key);
builder.addEquip(CBean2Proto.getFaxiangEquipProto(faxiang));
}
builder.setForce(HeroLogic.getInstance().calForce(heroNotBufferAttribute)); builder.setForce(HeroLogic.getInstance().calForce(heroNotBufferAttribute));
builder.setHero(CBean2Proto.getHeroByHongMeng(hero,userInMem.getHeroManager())); builder.setHero(CBean2Proto.getHeroByHongMeng(hero,userInMem.getHeroManager()));
Map<Integer, Integer> guildSkill = userInMem.getGuildMyInfo().getGuildSkill(); Map<Integer, Integer> guildSkill = userInMem.getGuildMyInfo().getGuildSkill();

View File

@ -20,7 +20,7 @@ public enum UUIDEnum {
Faxiang(17) Faxiang(17)
; ;
private int value; private final int value;
UUIDEnum( int value ){ UUIDEnum( int value ){
this.value = value; this.value = value;
} }