Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
174da1a2db
|
|
@ -17,6 +17,8 @@ public class SPropertyConfig implements BaseConfig {
|
|||
|
||||
private float score;
|
||||
|
||||
private int targetPropertyId;
|
||||
|
||||
|
||||
private static Map<Integer,SPropertyConfig> sPropertyConfigByPIDMap;
|
||||
|
||||
|
|
@ -52,4 +54,8 @@ public class SPropertyConfig implements BaseConfig {
|
|||
public float getScore() {
|
||||
return score;
|
||||
}
|
||||
|
||||
public int getTargetPropertyId() {
|
||||
return targetPropertyId;
|
||||
}
|
||||
}
|
||||
|
|
@ -54,5 +54,7 @@ public interface GlobalsDef {
|
|||
int EXPLORE_MAP_DIGGLE_TYPE =4;
|
||||
int EXPLORE_MAP_ACTION_POWER_RORMULA_TYPE =5;
|
||||
|
||||
int MUST_BE = -1;
|
||||
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.workshop;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.item.WorkShopLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
|
||||
@Component
|
||||
public class RebuildConfirmHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.WORKSHOP_REBUILD_CONFIRM_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
byte[] bytes = netData.parseClientProtoNetData();
|
||||
PlayerInfoProto.WorkShopRebuildConfirmRequest workShopRebuildConfirmRequest = PlayerInfoProto.WorkShopRebuildConfirmRequest.parseFrom(bytes);
|
||||
int state = workShopRebuildConfirmRequest.getState();
|
||||
WorkShopLogic.getInstance().confirmRebuild(iSession,state);
|
||||
}
|
||||
}
|
||||
|
|
@ -12,7 +12,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class Equip extends MongoBase {
|
||||
public class Equip extends MongoBase implements Cloneable{
|
||||
|
||||
private String id;
|
||||
|
||||
|
|
@ -150,13 +150,28 @@ public class Equip extends MongoBase {
|
|||
List<SEquipPropertyPool> sEquipPropertyPoolList = SEquipPropertyPool.getSEquipPropertyPool(poolId);
|
||||
int totalWeight = 0;
|
||||
for(SEquipPropertyPool sEquipPropertyPool : sEquipPropertyPoolList){
|
||||
int weight = sEquipPropertyPool.getWeight();
|
||||
if(weight == GlobalsDef.MUST_BE){
|
||||
Integer propertyPromote = promoteMap.get(sEquipPropertyPool.getPropertyId());
|
||||
if(propertyPromote == null){
|
||||
propertyPromote = 0;
|
||||
}
|
||||
int random = MathUtils.random(sEquipPropertyPool.getMin() * (100 + propertyPromote) / 100, sEquipPropertyPool.getMax()* (100 + propertyPromote) / 100);
|
||||
result.put(sEquipPropertyPool.getPropertyId(),random);
|
||||
nums--;
|
||||
continue;
|
||||
}
|
||||
totalWeight+=sEquipPropertyPool.getWeight();
|
||||
}
|
||||
while (result.size()<nums){
|
||||
int weight = 0;
|
||||
int randomWeight = MathUtils.randomInt(totalWeight) +1;
|
||||
for(SEquipPropertyPool sEquipPropertyPool : sEquipPropertyPoolList){
|
||||
weight+=sEquipPropertyPool.getWeight();
|
||||
int weightTmp= sEquipPropertyPool.getWeight();
|
||||
if(weightTmp<=0){
|
||||
continue;
|
||||
}
|
||||
weight+=weightTmp;
|
||||
if(randomWeight<=weight){
|
||||
Integer propertyPromote = promoteMap.get(sEquipPropertyPool.getPropertyId());
|
||||
if(propertyPromote == null){
|
||||
|
|
@ -267,4 +282,8 @@ public class Equip extends MongoBase {
|
|||
return secondValueByIdMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return (Equip) super.clone();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,8 @@ public class EquipManager extends MongoBase {
|
|||
|
||||
private Map<String,Equip> equipMap;
|
||||
|
||||
private Equip unDetermined;
|
||||
|
||||
public EquipManager() {
|
||||
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
|
|
@ -34,4 +36,12 @@ public class EquipManager extends MongoBase {
|
|||
return equipMap;
|
||||
}
|
||||
|
||||
public Equip getUnDetermined() {
|
||||
return unDetermined;
|
||||
}
|
||||
|
||||
public void setUnDetermined(Equip unDetermined) {
|
||||
updateString("unDetermined", unDetermined);
|
||||
this.unDetermined = unDetermined;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -753,9 +753,40 @@ public class HeroLogic {
|
|||
combinedAttribute(secondValueByIdMap,heroAllAttribute);
|
||||
}
|
||||
heroAllAttribute.put(HeroAttributeEnum.CurHP.getPropertyId(),heroAllAttribute.get(GlobalsDef.HP_TYPE));
|
||||
calInteractAdd(heroAllAttribute);
|
||||
return heroAllAttribute;
|
||||
}
|
||||
|
||||
public void calInteractAdd(Map<Integer, Integer> heroAllAttribute){
|
||||
Map<Integer,Integer> propertyPercentMap = new HashMap<>();
|
||||
Iterator<Map.Entry<Integer, Integer>> iterator = heroAllAttribute.entrySet().iterator();
|
||||
while (iterator.hasNext()){
|
||||
Map.Entry<Integer, Integer> item = iterator.next();
|
||||
Integer propertyId = item.getKey();
|
||||
SPropertyConfig sPropertyConfig = SPropertyConfig.getsPropertyConfigByPID(propertyId);
|
||||
int targetPropertyId = sPropertyConfig.getTargetPropertyId();
|
||||
if(targetPropertyId == 0){
|
||||
continue;
|
||||
}
|
||||
int style = sPropertyConfig.getStyle();
|
||||
Integer effectValue = item.getValue();
|
||||
Integer targetValue = heroAllAttribute.get(targetPropertyId);
|
||||
if(style == GlobalsDef.ABSOLUTE_TYPE){
|
||||
effectValue += targetValue;
|
||||
}else{
|
||||
propertyPercentMap.put(targetPropertyId,100+effectValue);
|
||||
}
|
||||
heroAllAttribute.put(targetPropertyId,effectValue);
|
||||
iterator.remove();
|
||||
}
|
||||
|
||||
for(Map.Entry<Integer,Integer> item : propertyPercentMap.entrySet()){
|
||||
Integer propertyId = item.getKey();
|
||||
Integer propertyValue = heroAllAttribute.get(propertyId);
|
||||
heroAllAttribute.put(propertyId,propertyValue*item.getValue()/100);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取英雄所有属性
|
||||
|
|
@ -764,13 +795,13 @@ public class HeroLogic {
|
|||
//食物buffer加成
|
||||
Map<Integer, Integer> foodAddMap = CombatLogic.getInstance().attributeByEatFood(user,GlobalsDef.FOOD_ADDITION_BATTLE_TYPE, GlobalsDef.FOOD_EAT_AFFECT_PERSON);
|
||||
combinedAttribute(foodAddMap,heroAllAttribute);
|
||||
calInteractAdd(heroAllAttribute);
|
||||
return heroAllAttribute;
|
||||
}
|
||||
|
||||
|
||||
public int calHeoForce(User user, Hero hero){
|
||||
Map<Integer, Integer> heroAllAttribute = calHeroFinalAttributeWhenInMap(user, hero);
|
||||
heroAllAttribute.remove(0);
|
||||
double result = 0;
|
||||
for(Map.Entry<Integer, Integer> item : heroAllAttribute.entrySet()){
|
||||
Integer propertyId = item.getKey();
|
||||
|
|
|
|||
|
|
@ -205,9 +205,13 @@ public class WorkShopLogic {
|
|||
List<CommonProto.WorkShopUnLockInfo> workShopUnLockInfoList = new ArrayList<>(2);
|
||||
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_BASE_TYPE).addAllId(workShopList == null ?new ArrayList<>(1):workShopList).build());
|
||||
workShopUnLockInfoList.add(CommonProto.WorkShopUnLockInfo.newBuilder().setType(GlobalsDef.WORK_CREATE_TYPE).addAllId(cookShopList==null?new ArrayList<>(1):cookShopList).build());
|
||||
|
||||
PlayerInfoProto.GetWorkShopInfoResponse build = PlayerInfoProto.GetWorkShopInfoResponse.newBuilder().addAllWorkShopBaseInfo(workShopBaseInfoList).addAllWorkShopUnLockInfo(workShopUnLockInfoList).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_WORKSHOP_INFO_RESPONSE_VALUE,build,true);
|
||||
Equip unDetermined = user.getEquipManager().getUnDetermined();
|
||||
PlayerInfoProto.GetWorkShopInfoResponse.Builder builder = PlayerInfoProto.GetWorkShopInfoResponse.newBuilder().addAllWorkShopBaseInfo(workShopBaseInfoList).addAllWorkShopUnLockInfo(workShopUnLockInfoList);
|
||||
if(unDetermined !=null){
|
||||
CommonProto.Equip equipProto = CBean2Proto.getEquipProto(unDetermined);
|
||||
builder.setUnDetermined(equipProto);
|
||||
}
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.GET_WORKSHOP_INFO_RESPONSE_VALUE,builder.build(),true);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -324,12 +328,27 @@ public class WorkShopLogic {
|
|||
SWorkShopRebuildConfig sWorkShopRebuildConfig = SWorkShopRebuildConfig.getsWorkShopRebuildConfigByQulity(sEquipConfig.getQuality());
|
||||
int addExp = sWorkShopRebuildConfig.getExp();
|
||||
user.getWorkShopController().addWorkShopExp(addExp);
|
||||
equip.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
|
||||
equipManager.addEquip(equip);
|
||||
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(equip)).build();
|
||||
Equip clone = (Equip)equip.clone();
|
||||
clone.rebuildEquip(user.getWorkShopController().getWorkShopLevel());
|
||||
equipManager.setUnDetermined(clone);
|
||||
PlayerInfoProto.WorkShopRebuildRespoonse build = PlayerInfoProto.WorkShopRebuildRespoonse.newBuilder().setEquip(CBean2Proto.getEquipProto(clone)).build();
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_RESPONSE_VALUE,build,true);
|
||||
}
|
||||
|
||||
|
||||
public void confirmRebuild(ISession session,int state) throws Exception {
|
||||
int uid = session.getUid();
|
||||
User user = UserManager.getUser(uid);
|
||||
EquipManager equipManager = user.getEquipManager();
|
||||
Equip unDetermined = equipManager.getUnDetermined();
|
||||
if(unDetermined == null){
|
||||
MessageUtil.sendErrorResponse(session,0,MessageTypeProto.MessageType.WORKSHOP_REBUILD_CONFIRM_RESONSE_VALUE,"");
|
||||
return;
|
||||
}
|
||||
if(state == 1){
|
||||
equipManager.addEquip(unDetermined);
|
||||
}
|
||||
equipManager.setUnDetermined(null);
|
||||
MessageUtil.sendMessage(session,1, MessageTypeProto.MessageType.WORKSHOP_REBUILD_CONFIRM_RESONSE_VALUE,null,true);
|
||||
}
|
||||
|
||||
private String checkForRebuildEquip( User user,List<String> consumeEquipIds,SEquipConfig sEquipConfig,String excludeEquipId) throws Exception {
|
||||
|
|
|
|||
Loading…
Reference in New Issue