心魔试炼扫荡,一键扫荡
parent
e74314c6c7
commit
202b170cd5
|
@ -11,14 +11,21 @@ import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
|||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.util.ItemUtil;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import com.sun.deploy.util.ArrayUtil;
|
||||
import com.sun.tools.javac.util.ArrayUtils;
|
||||
import config.SFloodConfig;
|
||||
import config.SSpecialConfig;
|
||||
import manager.STableManager;
|
||||
import org.assertj.core.util.Lists;
|
||||
import org.springframework.stereotype.Component;
|
||||
import rpc.protocols.CommonProto;
|
||||
import rpc.protocols.FightInfoProto;
|
||||
import rpc.protocols.MessageTypeProto;
|
||||
import rpc.protocols.PlayerInfoProto;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Component
|
||||
public class SweepBattleRequestHandler extends BaseHandler<FightInfoProto.SweepDemonRequest>{
|
||||
@Override
|
||||
|
@ -30,28 +37,44 @@ public class SweepBattleRequestHandler extends BaseHandler<FightInfoProto.SweepD
|
|||
@Override
|
||||
public void processWithProto(ISession iSession, FightInfoProto.SweepDemonRequest proto) throws Exception {
|
||||
User user = UserManager.getUser(iSession.getUid());
|
||||
|
||||
int id =proto.getId();
|
||||
SFloodConfig sFloodConfig = STableManager.getConfig(SFloodConfig.class).get(id);
|
||||
if(sFloodConfig == null){
|
||||
return;
|
||||
}
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sFloodConfig.getReward(), BIReason.MONSTERATTACK_REWARD);
|
||||
boolean freeCount = PlayerLogic.getInstance().check(user, 2025, 1);
|
||||
if(!freeCount){
|
||||
boolean feeCount = PlayerLogic.getInstance().check(user, 2026, 1);
|
||||
if(!feeCount){
|
||||
return;
|
||||
}else {
|
||||
user.getPlayerInfoManager().updateVipPrivilage(2026,1);
|
||||
List<Integer> dropList = Lists.newArrayList();
|
||||
boolean isOnekey= proto.getOnkeySweep();
|
||||
boolean isSuccess = false;
|
||||
CommonProto.Drop.Builder drop = null;
|
||||
//判断是否挑战过
|
||||
if(user.getMapManager().getLastMonsterAttack()<id){
|
||||
return;
|
||||
}
|
||||
int privilageType = SSpecialConfig.getIntegerValue(SSpecialConfig.SWEEP_ONEKEY);
|
||||
if(isOnekey){
|
||||
int times = PlayerLogic.getInstance().checkAndConsumeAllPrivilegeTimes(user,privilageType);
|
||||
if(times>0){
|
||||
int[][] reward = new int[times*sFloodConfig.getReward().length][2];
|
||||
for(int i =0;i<reward.length;){
|
||||
for (int [] a :sFloodConfig.getReward()) {
|
||||
reward[i] = a;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
drop = ItemUtil.drop(user, reward, BIReason.MONSTERATTACK_REWARD);
|
||||
}
|
||||
}else {
|
||||
user.getPlayerInfoManager().updateVipPrivilage(2025,1);
|
||||
}else{
|
||||
//扫荡一次
|
||||
isSuccess = PlayerLogic.getInstance().checkAndUpdate(user,privilageType,1);
|
||||
if(isSuccess){
|
||||
drop = ItemUtil.drop(user, sFloodConfig.getReward(), BIReason.MONSTERATTACK_REWARD);
|
||||
}
|
||||
}
|
||||
if(drop == null){
|
||||
drop = CommonProto.Drop.newBuilder();
|
||||
}
|
||||
FightInfoProto.SweepDemonResponse.Builder res = FightInfoProto.SweepDemonResponse.newBuilder();
|
||||
res.setDrop(drop);
|
||||
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.SWEEP_DEMON_RESPONSE.getNumber(), res.build(), true);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -846,6 +846,44 @@ public class PlayerLogic {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
//消耗完所有特权次数
|
||||
public int checkAndConsumeAllPrivilegeTimes(User user, int privilageTypeId){
|
||||
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
|
||||
if(privilageTypeId == 0){
|
||||
return 0;
|
||||
}
|
||||
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilageTypeId);
|
||||
List<Integer> typePrivileges = new ArrayList<>();
|
||||
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
|
||||
if(!vipInfo.containsKey(config.getId())){
|
||||
continue;
|
||||
}
|
||||
typePrivileges.add(config.getId());
|
||||
}
|
||||
if(typePrivileges.isEmpty()){
|
||||
return 0;
|
||||
}
|
||||
int levelUpdateCount = 0;
|
||||
for(Integer privilageId:typePrivileges){
|
||||
VipInfo info = vipInfo.get(privilageId);
|
||||
if(info.getEffectTime()!=0&&TimeUtils.now()/1000>info.getEffectTime()){
|
||||
continue;
|
||||
}
|
||||
int mCount = getMaxCountByPrivilege(user,privilageId);
|
||||
if(mCount==-1){
|
||||
return 0;
|
||||
}
|
||||
if(info.getCount()>= mCount){
|
||||
continue;
|
||||
}
|
||||
if(info.getEffectTime()!=0&&TimeUtils.now()/1000>info.getEffectTime()){
|
||||
continue;
|
||||
}
|
||||
levelUpdateCount+=mCount-info.getCount();
|
||||
user.getPlayerInfoManager().updateVipPrivilage(privilageId, mCount-info.getCount());
|
||||
}
|
||||
return levelUpdateCount;
|
||||
}
|
||||
// private boolean priviliageCheck(User user, int privilageTypeId, int checkNum,boolean isUpdate){
|
||||
// Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
|
||||
// if(privilageTypeId == 0){
|
||||
|
|
|
@ -514,7 +514,9 @@ public class StoreLogic implements IEventHandler {
|
|||
if(sStoreConfig.getOpenPrivilege()!=null){
|
||||
PlayerInfoProto.PrivilegeIndication.Builder indication = PlayerInfoProto.PrivilegeIndication.newBuilder();
|
||||
int[] openPrivilege = sStoreConfig.getOpenPrivilege();
|
||||
for(int privilege:openPrivilege){
|
||||
|
||||
for(int i=0;i<itemNum;i++){
|
||||
for(int privilege:openPrivilege){
|
||||
// int privilegeType = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilege).getPrivilegeType();
|
||||
// if(privilegeType== VipPrivilegeType.ADVENTURE_BASE_REWARD||privilegeType==VipPrivilegeType.FAST_MAP_LIMIT){
|
||||
// CombatLogic.getInstance().getNewAdventureReward(user,true);
|
||||
|
@ -522,8 +524,10 @@ public class StoreLogic implements IEventHandler {
|
|||
// user.getPlayerInfoManager().addVipInfo(privilege);
|
||||
// VipInfo vipInfo = user.getPlayerInfoManager().getVipInfo().get(privilege);
|
||||
// indication.addInfos(CommonProto.Privilege.newBuilder().setId(privilege).setUsedTimes(vipInfo.getCount()).setEffectTime(vipInfo.getEffectTime()).build());
|
||||
BuyGoodsNewLogic.addNewPrivilege(user,privilege,indication);
|
||||
}
|
||||
BuyGoodsNewLogic.addNewPrivilege(user,privilege,indication);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ISession sessionByUid = OnlineUserManager.getSessionByUid(uid);
|
||||
MessageUtil.sendIndicationMessage(sessionByUid,1, MessageTypeProto.MessageType.PRIVILLEGE_ADD_INDICATION_VALUE,indication.build(),true);
|
||||
|
|
|
@ -100,6 +100,8 @@ public class SSpecialConfig implements BaseConfig {
|
|||
public static final String FU_XING = "FuXing";//福星高照可购买天数和可领取天数
|
||||
public static final String FU_XING_STORE = "FuXingStore";//福星高照购买解锁奖励
|
||||
public static final String YIJIANGOUMAI = "YiJianGouMai";//一件购买
|
||||
public static final String SWEEP_ONEKEY = "floodprivilegeid";//一键扫荡
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
|
||||
|
|
Loading…
Reference in New Issue