gm修改器购买礼包验证流程优化修改

back_recharge
duhui 2022-11-04 16:29:52 +08:00
parent 6b72172fe8
commit b45efced66
4 changed files with 75 additions and 53 deletions

View File

@ -71,8 +71,8 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
if (master == null){
return false;
}
boolean goodStatus = checkGoodStatus(user, id);
if (goodStatus){
boolean goodStatus = checkGoodStatus(user, id, 0);
if (!goodStatus){
throw new ErrorCodeException(ErrorCode.BLOOD_BUY_SCORE_YET);
}
boolean result = true;
@ -96,7 +96,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
break;
}
for (SGMMaster sgmMaster : masters) {
boolean status = checkGoodStatus(user, sgmMaster.getPackID());
boolean status = checkGoodStatus(user, sgmMaster.getPackID(), 1);
if (!status){
throw new ErrorCodeException(ErrorCode.BEFORE_CONDITION_NOT);
}
@ -109,7 +109,7 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
}
break;
case 5:// 购买了其他礼包rechargeID开启
boolean status = checkGoodStatus(user, value[1]);
boolean status = checkGoodStatus(user, value[1], 1);
if (!status){
throw new ErrorCodeException(ErrorCode.BEFORE_CONDITION_NOT);
}
@ -125,14 +125,22 @@ public class GmBuyGoodHandler extends BaseHandler<PlayerInfoProto.GmBuyGoodReque
*
* @param user
* @param goodId
* @param state 0: 1
* @return
*/
private static boolean checkGoodStatus(User user, int goodId){
private static boolean checkGoodStatus(User user, int goodId, int state){
SRechargeCommodityNewConfig recharge = SRechargeCommodityNewConfig.getConfigById(goodId);
RechargeHandler rechargeHandler = BuyGoodsNewLogic.getRechargeHandler(recharge.getOtype());
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(goodId);
if (bag == null){
return false;
}
// 是否可买
if (bag != null && bag.checkBuy()){
if (state == 0 && bag.checkBuy()){
return true;
}
// 是否购买过
if (state == 1 && bag.buyAgo()){
return true;
}
return false;

View File

@ -623,7 +623,7 @@ public class BuyGoodsNewLogic {
if (bag.getType() == RechargeType.receive.getType()){
for (String[] strings : bag.getCondition()) {
if (strings[0].equals("9")){
if(!judgeOpen(strings,user)){
if(judgeOpen(strings, user)){
bag.setOpen(false);
}
}
@ -633,7 +633,7 @@ public class BuyGoodsNewLogic {
if (bag.getType() == RechargeType.perpetual.getType()){
for (String[] strings : bag.getCondition()){
if (strings[0].equals("1")){
if(!judgeOpen(strings,user)){
if(judgeOpen(strings, user)){
bag.setOpen(false);
}
}
@ -663,7 +663,7 @@ public class BuyGoodsNewLogic {
if (bag.getTimeType() == 9) {
boolean init = true;
for(String[] con : bag.getCondition()){
if(!judgeOpen(con,user)){
if(judgeOpen(con, user)){
init = false;
break;
}
@ -686,7 +686,7 @@ public class BuyGoodsNewLogic {
boolean open = true;
if(now > bag.getStartTime()){
for(String[] con : bag.getCondition()){
if(!judgeOpen(con,user)){
if(judgeOpen(con, user)){
open = false;
break;
}
@ -741,48 +741,54 @@ public class BuyGoodsNewLogic {
* ()
*/
public static boolean judgeOpen(String[] con,User user) {
if(con[0].equals("1")){//玩家等级
int level = user.getPlayerInfoManager().getLevel();
if(Integer.parseInt(con[1]) <= level && level <= Integer.parseInt(con[2])){
return true;
}
}else if(con[0].equals("2")){//功能开启
if(GlobalDataManaager.getInstance().checkIsOpen(Integer.parseInt(con[1]))){
SGlobalSystemConfig config = SGlobalSystemConfig.getConfigById(Integer.parseInt(con[1]));
if(config == null){
return false;
boolean result = false;
int level = user.getPlayerInfoManager().getLevel();
switch (con[0]){
case "1"://玩家等级
if(Integer.parseInt(con[1]) <= level && level <= Integer.parseInt(con[2])){
result = true;
}
int[] rule = config.getOpenRules();
if(rule[0] == 2){
int level = user.getPlayerInfoManager().getLevel();
if(level < rule[1]){
return false;
break;
case "2"://功能开启
if(GlobalDataManaager.getInstance().checkIsOpen(Integer.parseInt(con[1]))){
SGlobalSystemConfig config = SGlobalSystemConfig.getConfigById(Integer.parseInt(con[1]));
if(config == null){
break;
}
int[] rule = config.getOpenRules();
if(rule[0] == 2 && level < rule[1]){
break;
}
result = true;
}
return true;
}
return false;
}else if(con[0].equals("3")){//活动开启
return ActivityLogic.checkActivityOpen(user,Integer.parseInt(con[1]));
}else if(con[0].equals("4")){//时间类全部true
return true;
}else if(con[0].equals("5")){//激活高级月卡
return user.getPlayerInfoManager().getMonthCard().get(Global.LMONTHCARDID) != null;
}else if(con[0].equals("7")){
return true;
}else if (con[0].equals("9")){
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(Integer.parseInt(con[1]));
if (config == null){
return true;
}
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(config.getId());
if (bag == null){
return true;
}
return bag.buyAgo();
break;
case "3"://活动开启
result = ActivityLogic.checkActivityOpen(user,Integer.parseInt(con[1]));
break;
case "5"://激活高级月卡
result = user.getPlayerInfoManager().getMonthCard().get(Global.LMONTHCARDID) != null;
break;
case "4"://时间类全部true
case "7":
result = true;
break;
case "9":
SRechargeCommodityNewConfig config = SRechargeCommodityNewConfig.getConfigById(Integer.parseInt(con[1]));
if (config == null){
result = true;
break;
}
RechargeHandler rechargeHandler = getRechargeHandler(config.getOtype());
AbstractWelfareBag bag = rechargeHandler.getRechargeMap(user).get(config.getId());
if (bag == null){
result = true;
break;
}
result = bag.buyAgo();
break;
default:break;
}
return false;
return !result;
}
public static boolean isNumeric(String str) {

View File

@ -68,7 +68,7 @@ public class ReceiveWelfareBag extends AbstractWelfareBag {
@Override
public boolean buy() {
if (bought) {
LOGGER.error("礼包:{}已经购买", getModId());
LOGGER.error("================>礼包:{}已经购买", getModId());
return false;
}
setBought(true);
@ -79,6 +79,14 @@ public class ReceiveWelfareBag extends AbstractWelfareBag {
return true;
}
public boolean checkBuy() {
if (bought) {
LOGGER.error("================>>礼包:{}已经购买", getModId());
return false;
}
return true;
}
@Override
public boolean buyAgo(){
return bought;

View File

@ -1973,14 +1973,14 @@ public class ItemUtil {
private static long parseTheValueByPrivilegeMap(User user,long sourceNum,int privigeId){
int privigeValue = PlayerLogic.getInstance().getMaxCountByPrivilegeType(user,privigeId);
if(privigeValue!=0){
int privilegeValue = PlayerLogic.getInstance().getMaxCountByPrivilegeType(user,privigeId);
if(privilegeValue!=0){
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privigeId);
int dataType = sPrivilegeTypeConfig.getIfFloat();
if(dataType == GlobalsDef.PERCENT_TYPE){
sourceNum=(long)(privigeValue / 10000f * sourceNum);
sourceNum=(long)(privilegeValue / 10000f * sourceNum);
}else{
sourceNum+=privigeValue;
sourceNum+=privilegeValue;
}
}
return sourceNum;