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),//宝物战斗
;
private int type;
private final int type;
public int getType() {
return type;

View File

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

View File

@ -14,6 +14,6 @@ public class WearFaxiangEquipHandler extends BaseHandler<PlayerInfoProto.WearFax
@Override
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 {
private Map<String,PropertyItem> equipMap;
private Map<String,Faxiang> faxiangMap = new HashMap<>();
private Set<Integer> equipBookEnabled = new HashSet<>();
private Set<Integer> equipList = new HashSet<>();
private final Map<String,PropertyItem> equipMap;
private final Map<String,Faxiang> faxiangMap = new HashMap<>();
private final Set<Integer> equipBookEnabled = new HashSet<>();
private final Set<Integer> equipList = new HashSet<>();
// private Equip unDetermined;
private Map<Integer,Integer> equipHandBook;
private final Map<Integer,Integer> equipHandBook;
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 {
private String id;
private String bindHeroId;
private int itemId;
private int strongLv;
private int star;
@ -53,4 +55,12 @@ public class Faxiang {
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.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.tools.Utils;
import com.ljsd.jieling.util.CBean2Proto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
@ -21,6 +22,7 @@ import org.slf4j.LoggerFactory;
import rpc.protocols.CommonProto;
import rpc.protocols.MessageTypeProto;
import rpc.protocols.PlayerInfoProto;
import util.StringUtil;
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());
Hero hero = user.getHeroManager().getHero(heroID);
if (hero == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"英雄不存在:"+heroID);
}
if (Utils.isEmptyList(wearID)){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"客户端参数异常");
}
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){
Set<String> faxiangList = hero.getFaxiangList();
if (faxiangList.contains(faxiangID)){
LOGGER.error("法相已装备hero:{}, faxiang:{}",heroID,faxiangID);
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备");
}
// 检测是否装备同类型的法相
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;
HashSet<String> removeList = new HashSet<>();
for (String id : wearID) {
Faxiang faxiang = equipManager.getFaxiang(id);
if (faxiang == null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"法相装备不存在:"+id);
}
SFaxiangConfig faxiangConfig1 = faxiangMap.get(faxiang1.getItemId());
if (faxiangConfig1 == null){
hero.uninstallFaxiang(faxiangId);
LOGGER.error("法相不存在配置表中已卸载uid:{}, hero:{}, faxiang:{}",user.getId(),heroID,faxiangID);
continue;
SFaxiangConfig faxiangConfig = SFaxiangConfig.faxiangMap.get(faxiang.getItemId());
if (faxiangConfig == null || faxiangConfig.getIsOpen() == 0){
throw new ErrorCodeException(ErrorCode.CFG_NULL,"法相配置表不存在,或未进入版本:"+faxiang.getItemId());
}
if (faxiangConfig.getType() == faxiangConfig1.getType()){
if (action == 3 && removeId == null){
removeId = faxiang1.getId();
}else {
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"法相已装备同类型的法相");
if (!StringUtil.isEmpty(faxiang.getBindHeroId())){
LOGGER.error("法相已被其他英雄装备hero:{}, faxiang:{}",faxiang.getBindHeroId(),id);
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());
if (scHero == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL,"英雄不存在配置表中");
}
// 职业是否吻合
if (faxiangConfig.getProfession() != 0 && faxiangConfig.getProfession() != scHero.getProfession()){
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄职业不符合");
}
if (faxiangConfig.getJob() != 0 && faxiangConfig.getJob() != scHero.getJob()){
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄细分职业不符合");
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
if (scHero == null){
throw new ErrorCodeException(ErrorCode.CFG_NULL,"英雄不存在配置表中");
}
// 职业是否吻合
if (faxiangConfig.getProfession() != 0 && faxiangConfig.getProfession() != scHero.getProfession()){
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄职业不符合");
}
if (faxiangConfig.getJob() != 0 && faxiangConfig.getJob() != scHero.getJob()){
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR,"英雄细分职业不符合");
}
}
hero.addFaxiang(faxiangID);
if (removeId != null){
hero.uninstallFaxiang(removeId);
for (String key : wearID) {
hero.addFaxiang(key);
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 (!hero.getFaxiangList().contains(faxiangID)){
LOGGER.error("法相未装备hero:{}, faxiang:{}",heroID,faxiangID);
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE,"法相未装备");
for (String key : wearID) {
hero.uninstallFaxiang(key);
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);
}

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 propertySb = new StringBuilder();
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();
CommonProto.FightUnitInfo heroFightInfo = CommonProto.FightUnitInfo
.newBuilder()

View File

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

View File

@ -4414,6 +4414,15 @@ public class HeroLogic {
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 templateId = hero.getTemplateId();

View File

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

View File

@ -578,6 +578,16 @@ public class ItemLogic {
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());
heroLevelReport.add(hero.getOriginalLevel());

View File

@ -1288,6 +1288,10 @@ public class PlayerLogic {
for(int equipId : hero.getEquipByHongmengPositionMap(userInMem.getHeroManager()).values()){
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.setHero(CBean2Proto.getHeroByHongMeng(hero,userInMem.getHeroManager()));
Map<Integer, Integer> guildSkill = userInMem.getGuildMyInfo().getGuildSkill();

View File

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