装备优化修改

back_recharge
lvxinran 2020-07-06 18:08:37 +08:00
parent 3934507fe8
commit 4109833298
13 changed files with 265 additions and 272 deletions

View File

@ -32,72 +32,72 @@ import java.util.concurrent.ConcurrentLinkedQueue;
//todo 对用户频繁访问加限流处理。
public class HandlerLogicThread extends Thread{
private static final Logger LOGGER = LoggerFactory.getLogger(HandlerLogicThread.class);
private static Set<Integer> whiteMsg = new HashSet<>();
// private static Set<Integer> whiteMsg = new HashSet<>();
static {
whiteMsg.add(MessageTypeProto.MessageType.MAP_ENTER_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_START_EXPLORE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_UDPATE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.EVENT_UPDATE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_FAST_FIGHT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FIGHT_START_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FIGHT_END_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_OUT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_USEBOMB_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_USEBUFF_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_RESET_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_SIGN_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_EXECUTION_REFRESH_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_OUT_CONSUME_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_HERO_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_PLAYERINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ITEMINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_EQUIP_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_POKEMON_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_TEAMPOS_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_WORKSHOP_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_MAIL_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_LEVE_DIFFICULTT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_ACTIVITY_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_SECRETBOX_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ADVENTURE_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_FRIEND_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_STARE_INFOS_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ARENA_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_RINGFIRE_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.BUY_STORE_ITEM_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_MISSION_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.REFRESH_ITEM_NUM_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.STORE_GOODS_REFRESH_REQUEST_VALUE);
//日后删除
whiteMsg.add(MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.BLESS_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.SERVER_FIVE_REQEUST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.SERVER_ZERO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FAMILY_FIGHT_ROUND_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_MEMBER_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_APPLY_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_REQEUST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.USER_FORCE_CHANGE_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_SET_SKIPFIGHT_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.GET_QUESTION_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_REQUEST_VALUE);
whiteMsg.add(MessageTypeProto.MessageType.EXPEDITION_GET_EXPEDITION_REQUEST_VALUE);
}
// static {
// whiteMsg.add(MessageTypeProto.MessageType.MAP_ENTER_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_START_EXPLORE_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_UDPATE_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.EVENT_UPDATE_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_FAST_FIGHT_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FIGHT_START_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FIGHT_END_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_OUT_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_CALL_CHIEF_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_USEBOMB_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAP_TOWER_USEBUFF_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_RESET_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_SIGN_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_EXECUTION_REFRESH_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_OUT_CONSUME_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_MAP_HERO_INFO_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_PLAYERINFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ITEMINFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_EQUIP_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_POKEMON_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_HEROINFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_TEAMPOS_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_WORKSHOP_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_MAIL_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_LEVE_DIFFICULTT_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_ALL_ACTIVITY_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_FUNCTIONOFTIME_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_SECRETBOX_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ADVENTURE_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_FRIEND_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_STARE_INFOS_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ARENA_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_RINGFIRE_INFO_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.BUY_STORE_ITEM_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.GET_MISSION_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.REFRESH_ITEM_NUM_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.STORE_GOODS_REFRESH_REQUEST_VALUE);
// //日后删除
// whiteMsg.add(MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.BLESS_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.SERVER_FIVE_REQEUST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.SERVER_ZERO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FAMILY_FIGHT_ROUND_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_MEMBER_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.FAMILY_GET_APPLY_REQUEST_VALUE);
//
// whiteMsg.add(MessageTypeProto.MessageType.ADVENTURE_BOSSHURT_REQEUST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.USER_FORCE_CHANGE_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.ENDLESS_SET_SKIPFIGHT_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.GET_QUESTION_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.MAIN_LEVEL_GET_INFO_REQUEST_VALUE);
// whiteMsg.add(MessageTypeProto.MessageType.EXPEDITION_GET_EXPEDITION_REQUEST_VALUE);
//
//
//
// }
public ConcurrentLinkedQueue<PacketNetData> handlerLinkedQueue = new ConcurrentLinkedQueue();
public ConcurrentLinkedQueue<AyyncWorker> ayyncWorkerConcurrentLinkedQueue = new ConcurrentLinkedQueue();
@ -146,11 +146,11 @@ public class HandlerLogicThread extends Thread{
MessageUtil.sendErrorResponse(session,-1,msgId+1,"funciton not");
return;
}
b = checkIsPermit(msgId, session);
if(!b){
MessageUtil.sendErrorResponse(session,-1,msgId+1,"在地图探索中,不可以操作");
return;
}
// b = checkIsPermit(msgId, session);
// if(!b){
// MessageUtil.sendErrorResponse(session,-1,msgId+1,"在地图探索中,不可以操作");
// return;
// }
}
if (msgId != MessageTypeProto.MessageType.GET_CHAT_MESSAGE_REQUEST_VALUE) {
@ -212,24 +212,15 @@ public class HandlerLogicThread extends Thread{
}
private boolean checkIsPermit(int msgId, ISession session) throws Exception {
int uid = session.getUid();
User user = UserManager.getUser(uid);
int curMapId = 0;
//todo 暂时删除
// int curMapId = user.getMapManager().getCurMapId();
if(curMapId!=0 && msgId == MessageTypeProto.MessageType.TEAM_POS_SAVE_REQUEST_VALUE){
SChallengeConfig sChallengeConfig = SChallengeConfig.sChallengeConfigs.get(curMapId);
if(sChallengeConfig.getType()==4){
return true;
}
}
if(curMapId!=0 && !whiteMsg.contains(msgId)){
return false;
}
return true;
}
// private boolean checkIsPermit(int msgId, ISession session) throws Exception {
// int uid = session.getUid();
// User user = UserManager.getUser(uid);
// int curMapId = 0;
// //todo 暂时删除
//// int curMapId = user.getMapManager().getCurMapId();
//
// return true;
// }
private boolean checkFunctionIsOpen(int msgId, ISession session ) {

View File

@ -141,6 +141,7 @@ public interface BIReason {
int EXCEPTION_TREASURE_REWARD = 77;//天空密境积分奖励
int PROUD_REWARD = 78;//膜拜获得金币奖励
int EQUIP_UNLOAD_REWARD = 79;
int ADVENTURE_UPLEVEL_CONSUME = 1000;//秘境升级
int SECRETBOX_CONSUME = 1001;//秘盒抽卡
@ -258,6 +259,8 @@ public interface BIReason {
int TRIAL_ADD_HP_CONSUME = 1062;//试炼回春散消耗
int DAILY_SCORE_CONSUME = 1063;//删除日常任务积分
int EQUIP_WEAR_CONSUME = 1064;
}

View File

@ -102,9 +102,8 @@ public class HeroNodeGetInfoRequestHandler extends BaseHandler<Expedition.HeroNo
for(Map.Entry<Integer,Integer> item : heroNotBufferAttribute.entrySet()){
inner.addSpecialEffects(CommonProto.SpecialEffects.newBuilder().setPropertyId(item.getKey()).setPropertyValue(item.getValue()).build());
}
Map<String, PropertyItem> equipMap = user.getExpeditionManager().getEquipMap();
for(String equipId : hero.getEquipByPositionMap().values()){
inner.addEquip(CBean2Proto.getEquipProto(equipMap.get(equipId)));
for(Integer equipId : hero.getEquipByPositionMap().values()){
inner.addEquip(CBean2Proto.getEquipProto(equipId));
}
inner.setForce(HeroLogic.getInstance().calForce(heroNotBufferAttribute));
inner.setHero(CBean2Proto.getHero(hero));

View File

@ -6,6 +6,7 @@ import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.dao.Equip;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
@ -58,8 +59,6 @@ public class ComplexEquipHandler extends BaseHandler<HeroInfoProto.ComplexEquipR
if (equipId == 0) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
Set<String> equipByIDs = ItemLogic.getEquipByID(user, equipId);
SEquipStarsConfig sEquipStarsConfig = STableManager.getConfig(SEquipStarsConfig.class).get(needStar);
if (null == sEquipStarsConfig) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
@ -68,58 +67,43 @@ public class ComplexEquipHandler extends BaseHandler<HeroInfoProto.ComplexEquipR
if (null == sTargetEquipStarsConfig) {
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int needcount = sEquipStarsConfig.getRankupCount();
if (equipByIDs.size() / needcount < proto.getNum()) {
//数据不够
throw new ErrorCodeException(ErrorCode.UNKNOWN);
}
//check cost
int needCount = sEquipStarsConfig.getRankupCount();
// //check cost
Map<Integer, Integer> consumeMap = new HashMap<>();
for (int i = 0; i < proto.getNum(); i++) {
int[][] sumConsume = sTargetEquipStarsConfig.getRankupResources();
HeroLogic.getInstance().combinedAttribute(sumConsume, consumeMap);
int[][] sumConsume = sEquipStarsConfig.getRankupResources();
for(int[] consumeArray:sumConsume){
consumeMap.put(consumeArray[0],consumeArray[1]*proto.getNum());
}
consumeMap.put(equipId,needCount*proto.getNum());
boolean enough = ItemUtil.itemCost(user, consumeMap, BIReason.COMPLEX_EQUIP_CONSUME, 0);
if (!enough) {
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
//drop
//
// //drop
int[][] dropItems = new int[1][];
dropItems[0] = new int[2];
dropItems[0][0] = targetEquip;
dropItems[0][1] = proto.getNum();
CommonProto.Drop.Builder drop = ItemUtil.drop(user, dropItems, BIReason.COMPLEX_EQUIP);
HeroInfoProto.ComplexEquipResponse.Builder response = HeroInfoProto.ComplexEquipResponse.newBuilder();
//remove hero
int i = 1;
for (String id : equipByIDs) {
if (i > proto.getNum() * needcount) {
break;
}
response.addEquipIds(id);
user.getEquipManager().remove(id);
i++;
}
response.setDrop(drop);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EQUIP_COMPLEX_RESPONSE_VALUE, response.build(), true);
} else {
Map<Integer, Map<Integer, Integer>> euipTppes = STableManager.getFigureConfig(ItemStaticConfig.class).getEuipTppes();
Map<Integer, Integer> integerIntegerMap = new TreeMap<>(euipTppes.getOrDefault(proto.getType(), new HashMap<>()));
Set<String> equipadds =new HashSet<>();
Map<Integer, Integer> consumeMap = new HashMap<>();
List< CommonProto.Equip> equips = new LinkedList<>();
Set<String> newids = new HashSet<>();
Map<Integer, Integer> consumeMapTem = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : integerIntegerMap.entrySet()) {
Map<Integer, Map<Integer, Integer>> equipComplexConfig = STableManager.getFigureConfig(ItemStaticConfig.class).getEuipTppes();
Map<Integer, Integer> typeComplexMap = new TreeMap<>(equipComplexConfig.getOrDefault(proto.getType(), new HashMap<>()));
Map<Integer,Integer> consumeMap = new HashMap<>();
Map<Integer,Integer> countMap = new HashMap<>();
for (Map.Entry<Integer, Integer> entry : typeComplexMap.entrySet()) {
//star conf
int targetstar = entry.getKey()+1;
SEquipStarsConfig sTargetEquipStarsConfig = STableManager.getConfig(SEquipStarsConfig.class).get(targetstar);
int targetStar = entry.getKey()+1;
SEquipStarsConfig sTargetEquipStarsConfig = STableManager.getConfig(SEquipStarsConfig.class).get(targetStar);
if (null == sTargetEquipStarsConfig) {
break;
}
@ -128,7 +112,7 @@ public class ComplexEquipHandler extends BaseHandler<HeroInfoProto.ComplexEquipR
throw new ErrorCodeException(ErrorCode.CFG_NULL);
}
int targetEquipId = STableManager.getFigureConfig(ItemStaticConfig.class).getEquipByStar(proto.getType(), targetstar);
int targetEquipId = STableManager.getFigureConfig(ItemStaticConfig.class).getEquipByStar(proto.getType(), targetStar);
if (targetEquipId == 0) {
break;
}
@ -138,54 +122,67 @@ public class ComplexEquipHandler extends BaseHandler<HeroInfoProto.ComplexEquipR
}
TreeSet<String> equipByIDs = ItemLogic.getEquipByID(user, equipId);
int canConNum =equipByIDs.size()/sEquipStarsConfig.getRankupCount();
int equipByIDs = ItemLogic.getEquipByID(user, equipId);
int canConNum =(countMap.getOrDefault(equipId,0)+equipByIDs)/sEquipStarsConfig.getRankupCount();
if(canConNum<=0){
continue;
}
//check cost
boolean enough;
int needcount=0;
int equipNeedCount=0;
//进行合成
Map<Integer, Integer> consumeMapTem = new HashMap<>();
for (int i = 0; i < canConNum; i++) {
int[][] sumConsume = sEquipStarsConfig.getRankupResources();
HeroLogic.getInstance().combinedAttribute(sumConsume, consumeMapTem);
enough = ItemUtil.checkCost(user, consumeMapTem);
//数组变map
Map<Integer, Integer> consumeOnce = new HashMap<>();
for(int[] item : sumConsume){
consumeOnce.put(item[0],consumeMapTem.getOrDefault(item[0],0)+item[1]+consumeMap.getOrDefault(item[0],0));
}
enough = ItemUtil.checkCost(user, consumeOnce);
if (!enough) {
break;
}
//生成装备 混合消耗
Equip equip = new Equip(user.getId(),targetEquipId);
user.getEquipManager().addEquip(user,equip);
newids.add(equip.getId());//后面合成可能会被删除
needcount += sEquipStarsConfig.getRankupCount();
HeroLogic.getInstance().combinedAttribute(sumConsume, consumeMap);
for(int[] consume:sumConsume){
consumeMapTem.put(consume[0],consumeMapTem.getOrDefault(consume[0],0)+consume[1]);
}
countMap.put(targetEquipId,countMap.getOrDefault(targetEquipId,0)+1);
equipNeedCount += sEquipStarsConfig.getRankupCount();
// HeroLogic.getInstance().combinedAttribute(sumConsume, consumeMap);
}
//消耗装备
int i = 1;
for (String id : equipByIDs.descendingSet()) {
if (i > needcount) {
break;
int needEquipMax = countMap.getOrDefault(equipId,0)+equipByIDs;
if(equipNeedCount>needEquipMax){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}else if(equipNeedCount<=countMap.getOrDefault(equipId,0)){
int less = countMap.getOrDefault(equipId, 0) - equipNeedCount;
if(less==0){
countMap.remove(equipId);
}else{
countMap.put(equipId,less);
}
if(!newids.contains(id)){
equipadds.add(id);
}else {
newids.remove(id);
}else{
consumeMapTem.put(equipId,consumeMapTem.getOrDefault(equipId,0)+equipNeedCount-countMap.getOrDefault(equipId,0));
countMap.remove(equipId);
}
user.getEquipManager().remove(id);
i++;
for(Map.Entry<Integer, Integer> consumeEntry:consumeMapTem.entrySet()){
consumeMap.put(consumeEntry.getKey(),consumeMap.getOrDefault(consumeEntry.getKey(),0)+consumeEntry.getValue());
}
}
for (String id:newids) {
equips.add(CBean2Proto.getEquipProto( user.getEquipManager().getEquipMap().get(id)));
int[][] createArray = new int[countMap.size()][];
int index = 0 ;
for(Map.Entry<Integer, Integer> createEntry:countMap.entrySet()){
createArray[index] = new int[]{createEntry.getKey(),createEntry.getValue()};
index++;
}
ItemUtil.itemCost(user, consumeMap, BIReason.COMPLEX_EQUIP_CONSUME, 0);
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder().addAllEquipId(equips);
CommonProto.Drop.Builder drop = ItemUtil.drop(user,createArray,BIReason.COMPLEX_EQUIP);
HeroInfoProto.ComplexEquipResponse.Builder response = HeroInfoProto.ComplexEquipResponse.newBuilder();
response.addAllEquipIds(equipadds);
response.setDrop(drop);
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.EQUIP_COMPLEX_RESPONSE_VALUE, response.build(), true);
}

View File

@ -19,9 +19,9 @@ public class Cmd_fixequip extends GmAbstract{
user.getEquipManager().getEquipMap().values().forEach(equip -> equip.setHeroId(""));
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
user.getHeroManager().getHeroMap().values().forEach(hero -> {
Map<Integer, String> equipByPositionMap = hero.getEquipByPositionMap();
Map<Integer, Integer> equipByPositionMap = hero.getEquipByPositionMap();
Set<Integer> removeHeroEquip = new HashSet<>();
for(Map.Entry<Integer,String> item : equipByPositionMap.entrySet()){
for(Map.Entry<Integer,Integer> item : equipByPositionMap.entrySet()){
if(!equipMap.containsKey(item.getValue())){
removeHeroEquip.add(item.getKey());
}

View File

@ -13,6 +13,7 @@ import org.slf4j.LoggerFactory;
import java.util.*;
@Deprecated
public class Equip extends PropertyItem implements Cloneable{
private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(Equip.class);

View File

@ -28,7 +28,7 @@ public class Hero extends MongoBase {
private int star;
private Map<Integer,String> equipByPositionMap;
private Map<Integer,Integer> equipByPositionMap;
private Map<Integer,Integer> soulEquipByPositionMap;
@ -144,32 +144,32 @@ public class Hero extends MongoBase {
return star;
}
public Map<Integer, String> getEquipByPositionMap() {
public Map<Integer, Integer> getEquipByPositionMap() {
return equipByPositionMap==null?new HashMap<>():equipByPositionMap;
}
public void setEquipByPositionMap(Map<Integer, String> equipByPositionMap) throws Exception {
public void setEquipByPositionMap(Map<Integer, Integer> equipByPositionMap) throws Exception {
updateString("equipByPositionMap",equipByPositionMap);
this.equipByPositionMap = equipByPositionMap;
}
public void updateEquipPositionMap(int position,String equipId) throws Exception {
public void updateEquipPositionMap(int position,int equipId) throws Exception {
updateString("equipByPositionMap." + position ,equipId);
this.equipByPositionMap.put(position,equipId);
}
public void updateMutliEquipPositionMap(Map<Integer,String> equipByPositionMapTmp) throws Exception {
public void updateMutliEquipPositionMap(Map<Integer,Integer> equipByPositionMapTmp) throws Exception {
this.equipByPositionMap.putAll(equipByPositionMapTmp);
updateString("equipByPositionMap" ,equipByPositionMap);
}
public void removeEquip(int position){
String value = this.equipByPositionMap.get(position);
if (value!=null){
if (!equipByPositionMap.containsKey(position)){
return;
}
removeString(getMongoKey()+".equipByPositionMap." + position);
this.equipByPositionMap.remove(position);
}
}
public Map<Integer, Integer> getSoulEquipByPositionMap() {

View File

@ -864,20 +864,19 @@ public class ExpeditionLogic {
Hero newHero = new Hero(uid,tempid,finalstar,hero);
EquipManager equipManager = user.getEquipManager();
for (Map.Entry<Integer, String> next : hero.getEquipByPositionMap().entrySet()) {
String equipId = next.getValue();
for (Map.Entry<Integer, Integer> next : hero.getEquipByPositionMap().entrySet()) {
Integer equipId = next.getValue();
PropertyItem equip = equipManager.getEquipMap().get(equipId);
if (equip == null) {
continue;
}
Equip newequip = new Equip(uid, equip.getEquipId());
// if(isTemp){
// user.getExpeditionManager().addEquipToTemp(user, newequip);
// }else {
user.getExpeditionManager().addEquip(user, newequip);
// }
newHero.updateEquipPositionMap(next.getKey(), newequip.getId());
newHero.updateEquipPositionMap(next.getKey(), equipId);
}

View File

@ -128,13 +128,13 @@ public class HeroLogic{
int uid = iSession.getUid();
User user = UserManager.getUser(uid);
List<CommonProto.Equip> equipList = new ArrayList<>();
if(type==1){
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
for(PropertyItem equipInfo: equipMap.values()){
if(equipInfo instanceof Equip)
equipList.add(CBean2Proto.getEquipProto(equipInfo));
}
}
// if(type==1){
// Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
// for(PropertyItem equipInfo: equipMap.values()){
// if(equipInfo instanceof Equip)
// equipList.add(CBean2Proto.getEquipProto(equipInfo));
// }
// }
//宝器
if(type==4){
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
@ -142,6 +142,8 @@ public class HeroLogic{
if(equipInfo instanceof Jewel)
equipList.add(CBean2Proto.getEquipProto(equipInfo));
}
}else {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
@ -1066,20 +1068,21 @@ public class HeroLogic{
skillList.addAll( tempHero.getPassiveSkills(1,hero.getBreakId()));
skillList.addAll( tempHero.getPassiveSkills(2,hero.getStarBreakId()));
Map<Integer, String> equipByPositionMap = hero.getEquipByPositionMap();
if(!equipByPositionMap.isEmpty()){
Map<String, PropertyItem> equipMap = hero.getCreateType()==1?user.getExpeditionManager().getEquipMap():user.getEquipManager().getEquipMap();
for(Integer position : equipSkillPositionTemaplge){
String equipId = equipByPositionMap.get(position);
if(StringUtil.isEmpty(equipId)){
continue;
}
int skillId = equipMap.get(equipId).getSkill();
if(skillId!=0){
skillList.add(skillId);
}
}
}
//装备没有技能不用计算
// Map<Integer, Integer> equipByPositionMap = hero.getEquipByPositionMap();
// if(!equipByPositionMap.isEmpty()){
// Map<String, PropertyItem> equipMap = hero.getCreateType()==1?user.getExpeditionManager().getEquipMap():user.getEquipManager().getEquipMap();
// for(Integer position : equipSkillPositionTemaplge){
// Integer equipId = equipByPositionMap.get(position);
// if(equipId==null){
// continue;
// }
// int skillId = equipMap.get(equipId).getSkill();
// if(skillId!=0){
// skillList.add(skillId);
// }
// }
// }
//魂印
Map<Integer, Integer> soulEquipByPositionMap = hero.getSoulEquipByPositionMap();
Map<Integer, SEquipConfig> config = STableManager.getConfig(SEquipConfig.class);
@ -1306,22 +1309,17 @@ public class HeroLogic{
//装备总战力评分
int equipForce=0;
boolean needRemove = false;
Iterator<Map.Entry<Integer, String>> iterator = hero.getEquipByPositionMap().entrySet().iterator();
Iterator<Map.Entry<Integer, Integer>> iterator = hero.getEquipByPositionMap().entrySet().iterator();
Map<Integer,Integer> suiteNumByIdMap = new HashMap<>();
while (iterator.hasNext()){
Map.Entry<Integer, String> next = iterator.next();
String equipId = next.getValue();
PropertyItem equip = equipMap.get(equipId);
if(equip == null){
needRemove = true;
continue;
Map.Entry<Integer, Integer> next = iterator.next();
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(next.getValue());
int[][] property = sEquipConfig.getProperty();
Map<Integer,Integer> propertyValueByIdMap = new HashMap<>();
for(int[] prop:property){
propertyValueByIdMap.put(prop[0],prop[1]);
}
Map<Integer, Integer> propertyValueByIdMap = equip.getPropertyValueByIdMap();
Map<Integer, Integer> secondValueByIdMap = equip.getSecondValueByIdMap();
// LOGGER.info("cal equip = {}",equip.getEquipId());
combinedAttribute(propertyValueByIdMap,heroAllAttribute);
combinedAttribute(secondValueByIdMap,heroAllAttribute);
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equip.getEquipId());
equipForce+=sEquipConfig.getScore();
suiteNumByIdMap.put(sEquipConfig.getSuiteID(),suiteNumByIdMap.getOrDefault(sEquipConfig.getSuiteID(),0)+1);
}
@ -1340,11 +1338,11 @@ public class HeroLogic{
AyyncWorker ayyncWorker = new AyyncWorker(user,true,user1 -> {
Map<String, Hero> heroMap = user1.getHeroManager().getHeroMap();
for(Hero heroTmp : heroMap.values()){
Iterator<Map.Entry<Integer, String>> iterator1 = heroTmp.getEquipByPositionMap().entrySet().iterator();
Iterator<Map.Entry<Integer, Integer>> iterator1 = heroTmp.getEquipByPositionMap().entrySet().iterator();
boolean isUpate = false;
while (iterator1.hasNext()){
Map.Entry<Integer, String> next = iterator1.next();
String equipId = next.getValue();
Map.Entry<Integer, Integer> next = iterator1.next();
Integer equipId = next.getValue();
PropertyItem equip = equipMap.get(equipId);
if(equip == null){
iterator1.remove();
@ -1735,31 +1733,31 @@ public class HeroLogic{
}
}
public boolean checkEquipForWear(Hero hero,EquipManager equipManager,List<String> equipIds, Map<Integer,String> equipInfos ){
//新版穿装备
private boolean checkEquipForWear(Hero hero,User user,List<String> equipIds, Map<Integer,Integer> equipInfos ) throws Exception {
if(equipIds == null || equipIds.isEmpty()){
return false;
}
Map<String, PropertyItem> equipMap = equipManager.getEquipMap();
if(hero==null){
return false;
}
for(String equipId : equipIds){
PropertyItem equip =equipMap.get(equipId);
if( null == equip || null == hero ){
return false;
}
if(!StringUtil.isEmpty(equip.getHeroId()) && !equip.getHeroId().equals(hero.getId())){
return false;
}
int equipIdTid = equip.getEquipId();
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equipIdTid);
int equip = Integer.parseInt(equipId);
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equip);
int position = sEquipConfig.getPosition();
boolean itemCost = ItemUtil.itemCost(user, new int[][]{{equip, 1}}, BIReason.EQUIP_WEAR_CONSUME, 1);
if(!itemCost){
return false;
}
int professionLimit = sEquipConfig.getProfessionLimit();
SCHero scHero = SCHero.getsCHero().get(hero.getTemplateId());
if(professionLimit!=0 && scHero.getProfession()!= professionLimit){
return false;
}
equipInfos.put(position,equipId);
}
if(equipInfos.size()!=equipIds.size()){
return false;
equipInfos.put(position,equip);
}
return true;
@ -1774,18 +1772,26 @@ public class HeroLogic{
Hero hero = user.getHeroManager().getHeroMap().get(heroId);
EquipManager equipManager = user.getEquipManager();
if(type==1){
Map<Integer,String> equipInfoTmp = new HashMap<>(6);
if(!checkEquipForWear(hero,user.getEquipManager(),equipIds,equipInfoTmp)){
Map<Integer,Integer> equipInfoTmp = new HashMap<>(4);
if(!checkEquipForWear(hero,user,equipIds,equipInfoTmp)){
throw new ErrorCodeException(ErrorCode.HERO_EQUIP_ERR);
}
hero.getEquipByPositionMap().forEach((Integer position,String equipId) -> {
if(equipInfoTmp.containsKey(position) && !equipId.equals(equipInfoTmp.get(position))){
equipManager.getEquipMap().get(equipId).setHeroId("");
List<Integer> equipUnload = new ArrayList<>(4);
for(Map.Entry<Integer,Integer> entry :hero.getEquipByPositionMap().entrySet()){
if(!equipInfoTmp.containsKey(entry.getKey()) ) {
continue;
}
equipUnload.add(entry.getValue());
}
int[][] unloadArray = new int[equipUnload.size()][];
for(int i = 0 ; i <unloadArray.length;i++){
unloadArray[i] = new int[]{equipUnload.get(i),1};
}
if(unloadArray.length!=0){
ItemUtil.drop(user, unloadArray, BIReason.EQUIP_UNLOAD_REWARD);
}
});
hero.updateMutliEquipPositionMap(equipInfoTmp);
user.getUserMissionManager().onGameEvent(user,GameEvent.WEAR_EQUIP,equipInfoTmp.size());
equipIds.forEach(equipId->equipManager.getEquipMap().get(equipId).setHeroId(heroId));
}else if(type ==2){
for(String jId:equipIds){
wearJewel(hero,equipManager,jId);
@ -1842,25 +1848,32 @@ public class HeroLogic{
if( hero == null || equipIds.isEmpty()){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
if(type==1){
List<Integer> positions = new ArrayList<>();
for(String equipId : equipIds){
PropertyItem equip = equipMap.get(equipId);
if(null == equip || StringUtil.isEmpty(equip.getHeroId())){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int equipIdTid = equip.getEquipId();
//
int equipIdTid =Integer.parseInt(equipId);
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(equipIdTid);
int position = sEquipConfig.getPosition();
Integer currEquip = hero.getEquipByPositionMap().get(position);
if(currEquip == null || currEquip != equipIdTid){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
positions.add(position);
}
equipIds.forEach(equidId->equipMap.get(equidId).setHeroId(""));
for(Integer position : positions){
hero.removeEquip(position);
if(positions.size()==0){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
int[][] dropEquip = new int[positions.size()][];
for(int i = 0 ; i <dropEquip.length;i++){
int currEquip= hero.getEquipByPositionMap().get(positions.get(i));
dropEquip[i] = new int[]{currEquip,1};
hero.removeEquip(positions.get(i));
}
ItemUtil.drop(user,dropEquip,BIReason.EQUIP_UNLOAD_REWARD);
}else if(type==2){
Map<String, PropertyItem> equipMap = user.getEquipManager().getEquipMap();
for(String equipId:equipIds){
if(!hero.getJewelInfo().contains(equipId)||equipMap.get(equipId)==null){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);

View File

@ -581,17 +581,23 @@ public class ItemLogic {
}
/**
* 穿
* 穿
* @param user
* @param equipid
* @return
*/
public static TreeSet<String> getEquipByID(User user, int equipid) {
TreeSet<String> equiplist = new TreeSet<>();
user.getEquipManager().getEquipMap().entrySet().stream().filter(stringEquipEntry ->
StringUtil.isEmpty(stringEquipEntry.getValue().getHeroId()) && stringEquipEntry.getValue().getEquipId() == equipid
).forEach(stringEquipEntry -> equiplist.add(stringEquipEntry.getKey()));
return equiplist;
public static int getEquipByID(User user, int equipId) throws Exception {
Item item = user.getItemManager().getItemMap().get(equipId);
if(item==null){
return 0;
}
// TreeSet<String> equiplist = new TreeSet<>();
// user.getEquipManager().getEquipMap().entrySet().stream().filter(stringEquipEntry ->
// StringUtil.isEmpty(stringEquipEntry.getValue().getHeroId()) && stringEquipEntry.getValue().getEquipId() == equipid
// ).forEach(stringEquipEntry -> equiplist.add(stringEquipEntry.getKey()));
return item.getItemNum();
}

View File

@ -246,7 +246,7 @@ public class PlayerLogic {
int vipLevel = playerInfoManager.getVipLevel();
playerInfoManager.setVipLevel(vipLevel+1);
user.getUserMissionManager().onGameEvent(user,GameEvent.VIP_LEVLUP,playerInfoManager.getVipLevel());
// CombatLogic.getInstance().getNewAdventureReward(user, true);
// CombatLogic.getInstance().getNewAdventureReward(user, true,TimeUtils.nowInt());
List<CommonProto.UserMissionInfo> missionList = new ArrayList<>();
MissionLoigc.getVipMission(user,missionList);
CommonProto.VipBaseInfo vipInfoProto = CommonProto.VipBaseInfo.newBuilder()
@ -654,8 +654,8 @@ public class PlayerLogic {
for(String equipId : hero.getJewelInfo()){
builder.addEquip(CBean2Proto.getEquipProto(equipMap.get(equipId)));
}
for(String equipId : hero.getEquipByPositionMap().values()){
builder.addEquip(CBean2Proto.getEquipProto(equipMap.get(equipId)));
for(Integer equipId : hero.getEquipByPositionMap().values()){
builder.addEquip(CBean2Proto.getEquipProto(equipId));
}
builder.setForce(HeroLogic.getInstance().calForce(heroNotBufferAttribute));
builder.setHero(CBean2Proto.getHero(hero));

View File

@ -79,11 +79,7 @@ public class CBean2Proto {
return itemProto;
}
public static CommonProto.Hero getHero(Hero hero){ Map<Integer, String> equipByPositionMap = hero.getEquipByPositionMap();
List<String> equipList = new ArrayList<>();
if(equipByPositionMap!=null && !equipByPositionMap.isEmpty()){
equipList.addAll(equipByPositionMap.values());
}
public static CommonProto.Hero getHero(Hero hero){
List<CommonProto.SoulPos> soulPoss = new ArrayList<>();
Map<Integer, Integer> soulEquipMap = hero.getSoulEquipByPositionMap();
if(soulEquipMap!=null&&!soulEquipMap.isEmpty()){
@ -103,7 +99,7 @@ public class CBean2Proto {
.setBreakId(hero.getBreakId())
.setStarBreakId(hero.getStarBreakId())
.setCreateTime(hero.getCreateTime())
.addAllEquipIdList(equipList)
.addAllEquipIdList(hero.getEquipByPositionMap().values())
.setEspecialEquipLevel(hero.getEspecialEquipLevel())
.addAllSoulPos(soulPoss)
.setLockState(hero.getIsLock())
@ -165,6 +161,9 @@ public class CBean2Proto {
return equipProto.build();
}
public static CommonProto.Equip getEquipProto(int equipId) {
return CommonProto.Equip.newBuilder().setEquipId(equipId).build();
}
public static CommonProto.Drop getDrop(TemporaryItems temporaryItems) {
CommonProto.Drop.Builder drop = CommonProto.Drop.newBuilder();

View File

@ -493,10 +493,10 @@ public class ItemUtil {
switch (itemType) {
case GlobalItemType.SOUL_MARK:
case GlobalItemType.ITEM:
case GlobalItemType.EQUIP:
return itemMap;
case GlobalItemType.CARD:
return cardMap;
case GlobalItemType.EQUIP:
case GlobalItemType.ESPECIAL_EQUIP:
case GlobalItemType.JEWEL:
return equipMap;
@ -738,22 +738,6 @@ public class ItemUtil {
sendToFront.add(CBean2Proto.getItem(item,-1));
LOGGER.info("the uid={},the curMapId={},add item={},addItemNum={},totalItemNum={}",user.getId(),user.getMapManager().getCurMapId(),entry.getKey(),entry.getValue(),item.getItemNum());
}
Set<PropertyItem> equips = temporaryItems.equips;
for (Map.Entry<Integer, Integer> entry : equipMap.entrySet()) {
SEquipConfig sEquipConfig = STableManager.getConfig(SEquipConfig.class).get(entry.getKey());
if (sEquipConfig == null) {
continue;
}
Integer nums = entry.getValue();
for(int i=0;i<nums;i++){
Equip equip = new Equip(user.getId(), entry.getKey());
equips.add(equip);
equipProtoList.add(CBean2Proto.getEquipProto(equip));
}
LOGGER.info("the uid={},the curMapId={},add equip={},equipNum={},totalEquipNum={}",user.getId(),user.getMapManager().getCurMapId(),entry.getKey(),nums,equips.size());
}
mapManager.setTemporaryItems(temporaryItems);
if (dropBuilder != null) {
dropBuilder.addAllItemlist(itemProtoList);
@ -1232,6 +1216,7 @@ public class ItemUtil {
switch (itemType) {
case GlobalItemType.ITEM:
case GlobalItemType.SOUL_MARK:
case GlobalItemType.EQUIP:
putcountMap(itemId,itemNum,itemMap);
break;
default: