gm转盘优化2:特权相关内容

back_recharge
duhui 2022-10-27 10:00:08 +08:00
parent 731bcc0292
commit 9c459dc23d
16 changed files with 278 additions and 196 deletions

View File

@ -73,12 +73,9 @@ public class GetPlayerInfoHandler extends BaseHandler{
int token = netData.getToken();
int msgId = netData.getMsgId();
int msgIndex = netData.getIndex();
PlayerInfoProto.GetPlayerInfoRequest getPlayerInfoRequest
= PlayerInfoProto.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
PlayerInfoProto.GetPlayerInfoRequest getPlayerInfoRequest = PlayerInfoProto.GetPlayerInfoRequest.parseFrom(netData.parseClientProtoNetData());
LOGGER.info("processMessage->uid={},token={},msgId={},msgIndex={},messageNum={},messageStr={}",
userId, token,msgId,msgIndex,getPlayerInfoRequest.getNum(),getPlayerInfoRequest.getStr());
User user = UserManager.getUser(userId);
QuestionLogic.getInstence().onLogin(user);
PlayerManager playerInfoManager = user.getPlayerInfoManager();
@ -199,8 +196,7 @@ public class GetPlayerInfoHandler extends BaseHandler{
}
// 开服时间戳
long openTime = TimeUtils.stringToTimeLong2(GameApplication.serverConfig.getOpenTime());
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse
= PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
PlayerInfoProto.GetPlayerInfoResponse getPlayerInfoResponse = PlayerInfoProto.GetPlayerInfoResponse.newBuilder()
.setPlayer(player)
.addAllNewPlayerGuidePoint(list)
.addAllPrivilege(privilegeList)

View File

@ -9,10 +9,7 @@ import com.ljsd.jieling.globals.Global;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.jbean.LuckWheelMission;
import com.ljsd.jieling.jbean.LuckWheelPosInfo;
import com.ljsd.jieling.logic.activity.AbstractActivity;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.ActivityTypeEnum;
import com.ljsd.jieling.logic.activity.LuckWheelActivity;
import com.ljsd.jieling.logic.activity.*;
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.UserManager;
@ -48,20 +45,19 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.GetLuckWheelRandRewardRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityById(proto.getActivityId());
int activityId = proto.getActivityId();
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityById(activityId);
if (null == abstractActivity) {
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
}
if (!(abstractActivity instanceof LuckWheelActivity)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("activity err"));
}
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(proto.getActivityId());
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(sGlobalActivity.getType());
int reson = getCostBIReason(sGlobalActivity.getId());
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(activityId);
int reson = getCostBIReason(activityId);
//checkAndUpdate cost
LuckWheelMission luckWheelMission = ActivityLogic.getInstance().getLuckWheel(user.getActivityManager(),sGlobalActivity.getType());
LuckWheelMission luckWheelMission = ActivityLogic.getInstance().getLuckWheel(user.getActivityManager(), activityId);
int[][] costmap = proto.getRepeated() ? sDialRewardSetting.getMultipleCostItem() : sDialRewardSetting.getCostItem();
int[][] realCost = LuckWheelActivity.getCost(luckWheelMission.getRefreshTime(), costmap);
@ -74,7 +70,7 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
int cfgTime = SSpecialConfig.getIntegerValue(SSpecialConfig.LUCKYTURNDAILYLIMIT);
// 普通探宝
if(sGlobalActivity.getId() == 30){
if(activityId == 30){
int luckWheelLimitTime = user.getPlayerInfoManager().getLuckWheelLimitTime();
if(luckWheelLimitTime+time>cfgTime){
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF,"不可超出每日探宝上限次数!");
@ -82,7 +78,7 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
user.getPlayerInfoManager().setLuckWheelLimitTime(luckWheelLimitTime+time);
}
// 高级探宝
if(sGlobalActivity.getId() == 31) {
if(activityId == 31) {
int luckWheelLimitTime = user.getPlayerInfoManager().getLuckAdvanceWheelLimitTime();
if(luckWheelLimitTime+time>cfgTime){
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF,"不可超出每日探宝上限次数!");
@ -90,10 +86,11 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
user.getPlayerInfoManager().setLuckAdvanceWheelLimitTime(luckWheelLimitTime+time);
}
// gm转盘
if(sGlobalActivity.getId() == 10701 || sGlobalActivity.getId() == 10702 || sGlobalActivity.getId() == 10703) {
boolean checkAndUpdate = PlayerLogic.getInstance().checkAndUpdate(user, VipPrivilegeType.SUPER_GM_TURNTABLE_ADD_NUM, time);
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
if(activity.getType() == ActivityType.GM_DIAL) {
boolean checkAndUpdate = PlayerLogic.getInstance().checkOrUpPrivilegeId(user, proto.getPrivilegeId(), time, 1);
if(!checkAndUpdate){
throw new ErrorCodeException(ErrorCode.LEVE_MAX, "不可超出每日gm转盘上限次数");
throw new ErrorCodeException(ErrorCode.SERVER_DEFINE_SELF, "不可超出每日gm转盘上限次数");
}
}
@ -121,11 +118,11 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
String message = SErrorCodeEerverConfig.getI18NMessageNeedConvert("Dial_Reward_txt",
new Object[]{nameColor, nickName, sItem.getName()},
new int[]{0,0,1});
int sysType = getMsgType(sGlobalActivity.getId());
int sysType = getMsgType(activityId);
ChatLogic.getInstance().sendSysChatMessage(message, sysType, "0", 0, 0, 0, 0, 0);
}
}
int dropReson = getRewardBIReason(sGlobalActivity.getId());
int dropReson = getRewardBIReason(activityId);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, drops, dropReson);
CommonProto.DialInfo.Builder dialInfo = CommonProto.DialInfo.newBuilder();
@ -138,12 +135,12 @@ public class GetLuckWheelRandHandler extends BaseHandler<PlayerInfoProto.GetLuck
builder.setLuckTimes(luckWheelPosInfo.getProgrss());
rewardPosInfoList.add(builder.build());
}
dialInfo.setActivityId(sGlobalActivity.getId());
dialInfo.setActivityId(activityId);
Poster.getPoster().dispatchEvent(new LuckWheelEvent(user.getId(),sGlobalActivity.getId(),time));
Poster.getPoster().dispatchEvent(new LuckWheelEvent(user.getId(),activityId,time));
PlayerInfoProto.GetLuckWheelRandRewardResponse.Builder builder = PlayerInfoProto.GetLuckWheelRandRewardResponse.newBuilder();
builder.setActivityId(proto.getActivityId());
builder.setActivityId(activityId);
builder.setDrop(drop);
builder.setDialInfo(dialInfo);
user.getUserMissionManager().onGameEvent(user, GameEvent.LUCK_WHEEL_TIMES,reson,time);

View File

@ -34,18 +34,17 @@ public class RefreshLuckWheelRequestHandler extends BaseHandler<PlayerInfoProto.
@Override
public void processWithProto(ISession iSession, PlayerInfoProto.RefreshLuckWheelRequest proto) throws Exception {
User user = UserManager.getUser(iSession.getUid());
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityById(proto.getActivityId());
int activityId = proto.getActivityId();
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityById(activityId);
if (null == abstractActivity) {
throw new ErrorCodeException(ErrorCode.ACTIVITY_NOT_OPEN);
}
if (!(abstractActivity instanceof LuckWheelActivity)) {
throw new ErrorCodeException(ErrorCode.newDefineCode("activity err"));
}
//checkAndUpdate cost
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(proto.getActivityId());
int reson = GetLuckWheelRandHandler.getCostBIReason(sGlobalActivity.getId());
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(sGlobalActivity.getType());
int reson = GetLuckWheelRandHandler.getCostBIReason(activityId);
SDialRewardSetting sDialRewardSetting = SDialRewardSetting.getsDialRewardSettingMapByType().get(activityId);
if(proto.getIsFree()){
int[][] cost= new int[1][];
cost[0] = new int[2];
@ -56,7 +55,7 @@ public class RefreshLuckWheelRequestHandler extends BaseHandler<PlayerInfoProto.
throw new ErrorCodeException(ErrorCode.REFRESH_WHEL_TIME_NOT);
}
}else {
LuckWheelMission luckWheelMission = ActivityLogic.getInstance().getLuckWheel(user.getActivityManager(),sGlobalActivity.getType());
LuckWheelMission luckWheelMission = ActivityLogic.getInstance().getLuckWheel(user.getActivityManager(),activityId);
int[][] cost = LuckWheelActivity.getCost(luckWheelMission.getRefreshTime(), sDialRewardSetting.getCost());
boolean enough = ItemUtil.itemCost(user, cost, reson, 0);
if(!enough){
@ -65,11 +64,11 @@ public class RefreshLuckWheelRequestHandler extends BaseHandler<PlayerInfoProto.
}
// 清理次数
user.getPlayerInfoManager().putGmDialNum(sGlobalActivity.getId(),0);
user.getPlayerInfoManager().putGmDialNum(activityId,0);
//random
((LuckWheelActivity) abstractActivity).randomReward(user);
PlayerInfoProto.RefreshLuckWheelResponse.Builder builder = PlayerInfoProto.RefreshLuckWheelResponse.newBuilder();
builder.setDialInfo(LuckWheelActivity.getLuckWheelReward(user,sGlobalActivity.getId()));
builder.setDialInfo(LuckWheelActivity.getLuckWheelReward(user,activityId));
MessageUtil.sendMessage(iSession, 1, MessageTypeProto.MessageType.REFRESH_LUCKWHEEL_RESPONSE_VALUE, builder.build(), true);
}
}

View File

@ -102,11 +102,10 @@ public class GetWorldArenaChallengeRequestHandler extends BaseHandler<WorldProto
return;
}
//战斗
CommonProto.FightTeamInfo teamInfo ;
CommonProto.ArenaEnemy arenaEnemys ;
CommonProto.ArenaEnemy arenaAttack ;
CommonProto.FightTeamInfo teamInfo;
CommonProto.ArenaEnemy arenaEnemys;
CommonProto.ArenaEnemy arenaAttack;
//当前分组
int crossGroup = GlobleSystemLogic.getInstence().getCrossGroup();

View File

@ -0,0 +1,15 @@
package com.ljsd.jieling.jbean;
import com.ljsd.common.mogodb.MongoBase;
import java.util.HashMap;
/**
* gm
*
* @author ascend
* 2022/10/26 11:42:48
*/
public class GmActivityManager extends MongoBase {
private HashMap<String, ActivityProgressInfo> map = new HashMap<>();
}

View File

@ -116,7 +116,7 @@ public enum ActivityTypeEnum {
INFINITE_RESOURCES_PAVILION(ActivityType.INFINITE_RESOURCES_PAVILION, InfiniteResourcesPavilionActivity::new),//无限资源阁
ALL_PEOPLE_WELFARE(ActivityType.ALL_PEOPLE_WELFARE, AllPeopleWelfareActivity::new),//全民福利
GIVE_ENDLESS_DRAW(ActivityType.GIVE_ENDLESS_DRAW, GiveEndlessDrawActivity::new),//送无限抽
GM_DIAL(ActivityType.GM_DIAL, LuckWheelNormalActivity::new),//gm转盘
GM_DIAL(ActivityType.GM_DIAL, GmDialActivity::new),//gm转盘
RECHARGE_FIRST(ActivityType.RECHARGE_FIRST, RechargeFirstActivity::new),//直充购买礼包活动
FREE_RECHARGE(ActivityType.FREE_RECHARGE, DefaultEmptyActivity::new),//免费充值,仙充
OPEN_SERVER_COMPETE_RANK(ActivityType.OPEN_SERVER_COMPETE_RANK, OpenServerCompeteRankActivity::new),//开服冲榜

View File

@ -0,0 +1,30 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.root.User;
import config.SGlobalActivity;
/**
* gm
*
* @author ascend
* 2022/10/26 15:22:27
*/
public class GmDialActivity extends LuckWheelNormalActivity{
GmDialActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, LuckWheelEvent.class);
}
@Override
public void initActivity(User user) throws Exception {
super.initActivity(user);
SGlobalActivity activity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (activity.getPrivilege() != 0){
user.getPlayerInfoManager().addVipInfo(activity.getPrivilege());
}
}
}

View File

@ -1,9 +1,6 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.jbean.ActivityMission;
import com.ljsd.jieling.jbean.ActivityProgressInfo;
import com.ljsd.jieling.jbean.LuckWheelMission;
import com.ljsd.jieling.jbean.LuckWheelPosInfo;
import com.ljsd.jieling.jbean.*;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.LuckWheelEvent;
import com.ljsd.jieling.logic.dao.UserManager;
@ -72,8 +69,8 @@ public abstract class LuckWheelActivity extends AbstractActivity {
*
*/
public void randomReward(User user) {
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
LuckWheelMission luckWheelMission =ActivityLogic.getInstance().getLuckWheel(user.getActivityManager(),sGlobalActivity.getId());
ActivityManager activityManager = user.getActivityManager();
LuckWheelMission luckWheelMission =ActivityLogic.getInstance().getLuckWheel(activityManager,id);
Map<Integer, Set<Integer>> posPools = SDialRewardConfig.getsRandPosMap().get(id);
for (int i = 1; i <= posPools.size(); i++) {
LuckWheelPosInfo luckWheelPosInfo = new LuckWheelPosInfo();
@ -90,6 +87,7 @@ public abstract class LuckWheelActivity extends AbstractActivity {
luckWheelPosInfo.setLuckId(luckId);
luckWheelMission.getPosInfoMap().put(i, luckWheelPosInfo);
}
activityManager.putDialRewardInfo(id,luckWheelMission);
}
public static CommonProto.DialInfo getLuckWheelReward(User user, int activityId) {

View File

@ -8,6 +8,7 @@ import com.ljsd.jieling.logic.activity.event.Poster;
* Author: zsx
* CreateDate: 2019/9/23 15:13
*/
@Deprecated
public class LuckWheelAdvancedActivity extends LuckWheelActivity {
public LuckWheelAdvancedActivity(int id) {

View File

@ -598,37 +598,38 @@ public class PlayerManager extends MongoBase {
}
public void addVipInfo(int privilageId){
SPrivilegeTypeConfig config = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilageId);
public void addVipInfo(int privilegeId){
SPrivilegeTypeConfig config = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilegeId);
if (config==null){
return;
}
long maxTime;
VipInfo newVipInfo = new VipInfo();
if(config.getContinueTime()!=null&&config.getContinueTime().length>0){
if(vipInfo.containsKey(privilageId)){
if(config.getContinueTime()[1]==1&&TimeUtils.nowInt()<vipInfo.get(privilageId).getEffectTime()){
if(config.getCondition().length==1&&config.getCondition()[0][0]==0){
return;
}else{
newVipInfo.setCount(vipInfo.get(privilageId).getCount()-config.getCondition()[0][1]);
newVipInfo.setEffectTime(vipInfo.get(privilageId).getEffectTime());
vipInfo.put(privilageId,newVipInfo);
if(config.getContinueTime()!=null && config.getContinueTime().length>0){
if(vipInfo.containsKey(privilegeId)){
VipInfo info = vipInfo.get(privilegeId);
if(config.getContinueTime()[1]==1 && TimeUtils.nowInt()< info.getEffectTime()){
boolean aBool = config.getCondition().length == 1 && config.getCondition()[0][0] == 0;
if(!aBool){
newVipInfo.setCount(info.getCount()-config.getCondition()[0][1]);
newVipInfo.setEffectTime(info.getEffectTime());
vipInfo.put(privilegeId,newVipInfo);
updateString("vipInfo", this.vipInfo);
return;
}
return;
}
maxTime = TimeUtils.now()/1000>vipInfo.get(privilageId).getEffectTime()?(TimeUtils.now()/1000):vipInfo.get(privilageId).getEffectTime();
maxTime = Math.max(TimeUtils.nowInt(), info.getEffectTime());
maxTime = maxTime+config.getContinueTime()[0];
}else {
maxTime = TimeUtils.now()/1000+config.getContinueTime()[0];
maxTime = TimeUtils.nowInt()+config.getContinueTime()[0];
}
maxTime = (int)(TimeUtils.getLastOrUnderHour(maxTime*1000,0,0,true)/1000);
newVipInfo.setEffectTime((int)maxTime);
}
this.vipInfo.put(privilageId,newVipInfo);
this.vipInfo.put(privilegeId,newVipInfo);
updateString("vipInfo", this.vipInfo);
}

View File

@ -146,6 +146,8 @@ public class UserManager {
playerManager.updateVipInfo(GlobalsDef.VIP_UNLOCK_PRIVILEGE,0);
playerManager.updateVipInfo(GlobalsDef.GOD_LV_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.RENOWN_LV_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.BRUSHING_LV_UNLOCK,0);
playerManager.updateVipInfo(GlobalsDef.THE_ABSOLUTE_BEGINNING_LV_UNLOCK,0);
playerManager.setNewRechargeInfo(new NewRechargeInfo());
playerManager.setPhoneBindInfo(new PhoneBindInfo(""));
playerManager.setChannel(channel);

View File

@ -1,10 +1,13 @@
package com.ljsd.jieling.logic.item;
import com.ljsd.jieling.logic.dao.Item;
import com.ljsd.jieling.logic.dao.root.User;
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.index.CompoundIndex;
import org.springframework.data.mongodb.core.index.CompoundIndexes;
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
import util.TimeUtils;
@Document(collection="itemLog")
@CompoundIndexes({@CompoundIndex(name = "uid_time_index", def = "{'uid': 1, 'time': 1}")})
@ -43,6 +46,17 @@ public class ItemLog {
this.itemTotalNum = itemTotalNum;
}
public ItemLog(User user, int type, int reason, Item item, long itemNum) {
this.uid = user.getId();
this.type = type;
this.level = user.getPlayerInfoManager().getLevel();
this.time = String.valueOf(TimeUtils.now());
this.reason = reason;
this.itemId = item.getItemId();
this.itemTotalNum = item.getItemNum();
this.itemNum = itemNum;
}
public String getId() {
return id;
}

View File

@ -711,13 +711,7 @@ public class PlayerLogic {
CommonProto.TeamOneInfo.Builder oneInfo = null;
if(sArenaRobotConfig!=null){
oneInfo = getYuxuRobotOneInfo(sArenaRobotConfig,info,crossTeamId);
}else{
/*oneInfo = getUserTeamOneInfo(id, crossTeamId);
if(UserManager.getUser(id).getFriendManager().getMyApplyFriends().contains(id)){
oneInfo.setIsApplyed(1);
}*/
}
//PlayerInfoProto.GetPlayerCrossYxldOneTeamInfoResponse.Builder playerTeamInfo = PlayerInfoProto.GetPlayerCrossYxldOneTeamInfoResponse.newBuilder().setTeamInfo(oneInfo);
if (oneInfo != null) {
return oneInfo.build();
}
@ -737,22 +731,10 @@ public class PlayerLogic {
if (crossGroup == -1) {
return CommonProto.TeamOneInfo.newBuilder();
}
//TODO
/*Map<Integer, Integer> groupValues = RedisUtil.getInstence().getMapValues(RedisKey.SERVER_SPLIT_INFO, "", Integer.class, Integer.class);
List<Integer> groupList = groupValues.entrySet().stream().filter(n -> n.getValue() == crossGroup).map(keyVal -> keyVal.getKey()).collect(Collectors.toList());
int server = new Random().nextInt(groupList.size());*/
CommonProto.TeamOneInfo.Builder oneInfo = CommonProto.TeamOneInfo.newBuilder()
.setLevel(sArenaRobotConfig.getRobotLevel())
.setName(sArenaRobotConfig.getRobotName())
.setUid(sArenaRobotConfig.getId()).setCrossTeamScore(sArenaRobotConfig.getMsScroe()).setServerName("");
//CommonProto.TeamOneTeamInfo.Builder teamInfo = CommonProto.TeamOneTeamInfo.newBuilder();
if(sArenaRobotConfig.getDifferDemonsId()!=null){
// for(int pokenId:sArenaRobotConfig.getDifferDemonsId()){
// teamInfo.addPokemonInfos(null);
// }
}
//玉虚论道三队伍
for(int id :crossTeamId){
int position = 1;
@ -1438,119 +1420,166 @@ public class PlayerLogic {
user.getPlayerInfoManager().setRideLevel(rideLevel+1);
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
/**
*
* @param user
* @param privilegeTypeId
* @param checkNum
* @return
*/
public boolean check(User user, int privilegeTypeId, int checkNum){
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
return originCheck(user,privilegeTypeId,checkNum,0);
}
/**
*
* @param user
* @param privilegeTypeId
* @param updateNum
* @return
*/
public boolean checkAndUpdate(User user, int privilegeTypeId, int updateNum){
return originCheck(user,privilegeTypeId,updateNum,1);
}
/**
*
* @param user
* @param privilegeTypeId
* @param updateNum
* @param operate 0 1
* @return
*/
private boolean originCheck(User user, int privilegeTypeId, int updateNum, int operate){
if(privilegeTypeId == 0){
return true;
}
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilegeTypeId);
List<Integer> typePrivileges = new ArrayList<>();
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
if(!vipInfo.containsKey(config.getId())){
int privilegeId = config.getId();
VipInfo info = vipInfo.get(privilegeId);
if (info == null){
continue;
}
typePrivileges.add(config.getId());
}
if(typePrivileges.isEmpty()){
return false;
}
for(Integer privilegeId:typePrivileges){
VipInfo info = vipInfo.get(privilegeId);
if(info.getEffectTime()!=0&&TimeUtils.now()/1000>info.getEffectTime()){
if(info.getEffectTime()!=0 && TimeUtils.nowInt()>info.getEffectTime()){
continue;
}
int mCount = getMaxCountByPrivilege(user,privilegeId);
if(mCount==-1){
return true;
}
if((info.getCount()+checkNum>mCount)|| (info.getEffectTime()!=0&&TimeUtils.nowInt()>info.getEffectTime())){
if(info.getCount()+updateNum > mCount){
continue;
}
if (operate == 1){
user.getPlayerInfoManager().updateVipPrivilage(privilegeId, updateNum);
}
return true;
}
return false;
}
public boolean checkAndUpdate(User user, int privilegeTypeId, int updateNum){
boolean check = check(user, privilegeTypeId, updateNum);
if (!check){
/**
* id
* @param user
* @param privilegeId
* @param updateNum
* @param operate 0 1
* @return
*/
public boolean checkOrUpPrivilegeId(User user, int privilegeId, int updateNum, int operate){
if(privilegeId == 0){
return false;
}
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
VipInfo info = vipInfo.get(privilegeId);
if (info == null){
return false;
}
if(info.getEffectTime()!=0 && TimeUtils.nowInt()>info.getEffectTime()){
return false;
}
int mCount = getMaxCountByPrivilege(user,privilegeId);
if(mCount == -1){
return true;
}
if(info.getCount()+updateNum > mCount){
return false;
}
if (operate == 1){
user.getPlayerInfoManager().updateVipPrivilage(privilegeId, updateNum);
}
return true;
}
/**
*
* @param user
* @param privilegeTypeId
* @return
*/
public int checkAndConsumeAllPrivilegeTimes(User user, int privilegeTypeId){
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
if(privilegeTypeId == 0){
return true;
return 0;
}
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilegeTypeId);
List<Integer> typePrivileges = new ArrayList<>();
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
if(!vipInfo.containsKey(config.getId())){
continue;
}
typePrivileges.add(config.getId());
}
if(typePrivileges.isEmpty()){
return false;
}
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 true;
}
if((info.getCount()+updateNum>mCount)|| (info.getEffectTime()!=0&&TimeUtils.now()/1000>info.getEffectTime())){
continue;
}
user.getPlayerInfoManager().updateVipPrivilage(privilageId, updateNum);
return true;
}
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()){
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
int privilegeId = config.getId();
VipInfo info = vipInfo.get(privilegeId);
if (info == null){
continue;
}
int mCount = getMaxCountByPrivilege(user,privilageId);
if(mCount==-1){
if(info.getEffectTime()!=0 && TimeUtils.nowInt()>info.getEffectTime()){
continue;
}
int mCount = getMaxCountByPrivilege(user,privilegeId);
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());
int num = mCount - info.getCount();
user.getPlayerInfoManager().updateVipPrivilage(privilegeId, num);
levelUpdateCount+=num;
}
return levelUpdateCount;
}
/**
*
* @param user
* @param privilegeType
* @return
*/
public int getMaxCountByPrivilegeType(User user ,int privilegeType){
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilegeType);
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
int maxCount = 0;
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
int id = config.getId();
if(!vipInfo.containsKey(id)){
continue;
}
maxCount += getMaxCountByPrivilege(user,id);
}
return maxCount;
}
/**
* id
* @param user
* @param privilegeId
* @return
*/
private int getMaxCountByPrivilege(User user,int privilegeId){
SPrivilegeTypeConfig sPrivilegeTypeConfig = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilegeId);
Map<Integer, Map<Integer, Integer>> conditionMap = SPrivilegeTypeConfig.conditionMap.get(sPrivilegeTypeConfig.getUnlockType());
int mCount;
int cond = 0;
switch (sPrivilegeTypeConfig.getUnlockType()){
case GlobalsDef.LEVEL_UNLOCK_PRIVILEGE:
@ -1582,41 +1611,29 @@ public class PlayerLogic {
break;
}
}
TreeMap<Integer, Integer> condition = (TreeMap)conditionMap.get(privilegeId);
if(sPrivilegeTypeConfig.getUnlockType()==GlobalsDef.RECHARGE_UNLOCK_PRIVILEGE){
mCount = condition.get(0);
}
else if(sPrivilegeTypeConfig.getUnlockType()==GlobalsDef.WEEKCARD_UNLOCK){
if (cond == -1){
mCount = 0;
}else {
Map<Integer, Map<Integer, Integer>> conditionMap = SPrivilegeTypeConfig.conditionMap.get(sPrivilegeTypeConfig.getUnlockType());
TreeMap<Integer, Integer> condition = new TreeMap<>(conditionMap.get(privilegeId));
int mCount;
switch (sPrivilegeTypeConfig.getUnlockType()){
case GlobalsDef.RECHARGE_UNLOCK_PRIVILEGE:
mCount = condition.get(0);
}
}else {
mCount = condition.floorEntry(cond).getValue();
break;
case GlobalsDef.WEEKCARD_UNLOCK:
mCount = cond==-1?0:condition.get(0);
break;
default:
mCount = condition.floorEntry(cond).getValue();
break;
}
return mCount;
}
public int getMaxCountByPrivilegeType(User user ,int privilegeType){
List<SPrivilegeTypeConfig> sPrivilegeTypeConfigs = SPrivilegeTypeConfig.privilegeByType.get(privilegeType);
List<Integer> typePrivileges = new ArrayList<>();
Map<Integer, VipInfo> vipInfo = user.getPlayerInfoManager().getVipInfo();
for(SPrivilegeTypeConfig config:sPrivilegeTypeConfigs){
if(!vipInfo.containsKey(config.getId())){
continue;
}
typePrivileges.add(config.getId());
}
if(typePrivileges.isEmpty()){
return 0;
}
int maxCount = 0;
for(Integer privilageId:typePrivileges){
maxCount+=getMaxCountByPrivilege(user,privilageId);
}
return maxCount;
}
/**
*
* @param user
* @return
*/
public List<CommonProto.MonthCardInfo> getMonthCardInfo(User user) {
List<CommonProto.MonthCardInfo> cardInfos = new LinkedList<>();
PlayerManager playerInfoManager = user.getPlayerInfoManager();
@ -1642,6 +1659,11 @@ public class PlayerLogic {
return cardInfos;
}
/**
*
* @param user
* @throws Exception
*/
public void checkOldMonthCard(User user) throws Exception {
PlayerManager playerInfoManager = user.getPlayerInfoManager();
if (playerInfoManager.getOldMonthCardMark() == 1){

View File

@ -774,7 +774,7 @@ public class ItemUtil {
user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_TASK_TYPE,(int)itemNum,user);
}
//日志记录
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),0,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,sItem.getId(),itemNum,item.getItemNum()));
ItemLogic.getInstance().addItemLog(new ItemLog(user,0,reason,item,itemNum));
}
//发送装备图鉴修改推送
SendEquipBookIndication(user.getId(),itemManager,changeEquipList);
@ -821,7 +821,7 @@ public class ItemUtil {
Map<Integer,Integer> extraItem = new HashMap<>(itemMap.size());
List<Integer>changeEquipList=null;
for (Map.Entry<Integer, Long> entry : itemMap.entrySet()) {
SItem sItem = SItem.getsItemMap().get (entry.getKey());
SItem sItem = SItem.getsItemMap().get(entry.getKey());
if (sItem.getItemBaseType()==6){
equipManager.addEquipList(entry.getKey());
}
@ -907,7 +907,7 @@ public class ItemUtil {
user.getUserMissionManager().onGameEvent(user,GameEvent.DAILY_TASK_TYPE,itemNum,user);
}
//日志记录
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),0,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,sItem.getId(),itemNum,item.getItemNum()));
ItemLogic.getInstance().addItemLog(new ItemLog(user,0,reason,item,itemNum));
}
//发送装备图鉴修改推送
@ -1170,7 +1170,7 @@ public class ItemUtil {
myItem.setItemNum(myItem.getItemNum() - needCount);
KtEventUtils.onKtEvent(user, eventType,reason,GlobalsDef.subReason,myItem.getItemId(),needCount,myItem.getItemNum());
}
ItemLogic.getInstance().addItemLog(new ItemLog(user.getId(),1,user.getPlayerInfoManager().getLevel(),String.valueOf(TimeUtils.now()),reason,myItem.getItemId(),needCount,myItem.getItemNum()));
ItemLogic.getInstance().addItemLog(new ItemLog(user,1,reason,myItem,needCount));
sendToFront.add(CBean2Proto.getItem(myItem,-1));
}

View File

@ -49,6 +49,8 @@ public class SGlobalActivity implements BaseConfig {
private int isOpen;
private int privilege;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByType;
public static Map<Integer, List<SGlobalActivity>> sGlobalActivityMapByOpenRules;
@ -235,4 +237,8 @@ public class SGlobalActivity implements BaseConfig {
public int getIsOpen() {
return isOpen;
}
public int getPrivilege() {
return privilege;
}
}

View File

@ -24,27 +24,29 @@ public class SPrivilegeTypeConfig implements BaseConfig {
private int[] continueTime;
private static Map<Integer,SPrivilegeTypeConfig> sPrivilegeTypeConfigMap;
private static Map<Integer,SPrivilegeTypeConfig> sPrivilegeTypeConfigMap = new HashMap<>();
public static Map<Integer,Map<Integer,Map<Integer,Integer>>> conditionMap;
public static Map<Integer,Map<Integer,Map<Integer,Integer>>> conditionMap = new HashMap<>();
public static Map<Integer, List<SPrivilegeTypeConfig>> privilegeByType;
public static Map<Integer, List<SPrivilegeTypeConfig>> privilegeByType = new HashMap<>();
@Override
public void init() throws Exception {
sPrivilegeTypeConfigMap = STableManager.getConfig(SPrivilegeTypeConfig.class);
conditionMap = new HashMap<>();
conditionMap = new HashMap<>();
privilegeByType = new HashMap<>();
for (Map.Entry<Integer,SPrivilegeTypeConfig> entry:sPrivilegeTypeConfigMap.entrySet()){
privilegeByType.computeIfAbsent(entry.getValue().getPrivilegeType(),n->new ArrayList<>()).add(entry.getValue());
conditionMap.computeIfAbsent(entry.getValue().getUnlockType(),n->new HashMap<>()).computeIfAbsent(entry.getKey(),n->new TreeMap<>());
if(entry.getValue().getCondition()!=null){
for(int[] cond:entry.getValue().getCondition()){
if(entry.getValue().getUnlockType()==2) {
cond[0] = 10_000_000 * (cond[0] % 10) + cond[0];
}
conditionMap.get(entry.getValue().getUnlockType()).get(entry.getKey()).put(cond[0],cond[1]);
SPrivilegeTypeConfig value = entry.getValue();
privilegeByType.computeIfAbsent(value.getPrivilegeType(), n->new ArrayList<>()).add(value);
conditionMap.computeIfAbsent(value.getUnlockType(), n->new HashMap<>()).computeIfAbsent(entry.getKey(), n->new TreeMap<>());
if(value.getCondition() == null){
continue;
}
for(int[] cond: value.getCondition()){
if(value.getUnlockType()==2) {
cond[0] = 10_000_000 * (cond[0] % 10) + cond[0];
}
conditionMap.get(value.getUnlockType()).get(entry.getKey()).put(cond[0],cond[1]);
}
}
}