# Conflicts:
#	serverlogic/src/main/java/com/ljsd/jieling/network/server/ProtocolsManager.java
back_recharge
zhangshanxue 2019-11-23 14:20:13 +08:00
commit 85eae5a303
36 changed files with 746 additions and 128 deletions

View File

@ -14,8 +14,6 @@ repositories {
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile("com.fasterxml.jackson.core:jackson-core:2.3.1")
compile("com.fasterxml.jackson.core:jackson-databind:2.3.3")
}
jar {
baseName = 'gamecommon'

View File

@ -91,7 +91,9 @@ public class ChatLogic {
* @param message
*/
public void sendChatMessage(ISession iSession, int chatType, String message,int friendId) throws Exception {
System.out.println("the uid=" + iSession.getUid() + "send msg =" +message);
if(message.length()>140){
throw new ErrorCodeException("over length");
}
int msgId = MessageTypeProto.MessageType.SEND_CHAT_INFO_RESPONSE_VALUE;
int uid = iSession.getUid();
User user = UserManager.getUser(uid);

View File

@ -20,6 +20,7 @@ public class HeroStaticConfig extends AbstractClassStaticConfig {
private Map<Integer, Map<Integer, Map<Integer, SCHeroRankUpConfig>>> scHeroRankUpConfigByType;
private Set<Integer> randomHeroIds;
private Map<Integer,Integer> randomPoolByType;
@Override
public void registConfigs(Set<String> registConfigs) {
@ -75,12 +76,15 @@ public class HeroStaticConfig extends AbstractClassStaticConfig {
try {
Set<Integer> randomHeroIdTmp = new HashSet<>();
Map<Integer, SLotterySetting> config = STableManager.getConfig(SLotterySetting.class);
Map<Integer,Integer> randomPoolByType = new HashMap<>();
for(SLotterySetting sLotterySetting : config.values()){
if(sLotterySetting.getLotteryType() == GlobalsDef.RANDOM_LOTTERY_TYPE){
randomHeroIdTmp.add(sLotterySetting.getId());
}
randomPoolByType.put(sLotterySetting.getId(),sLotterySetting.getMergePool());
}
randomHeroIds = randomHeroIdTmp;
randomPoolByType = randomPoolByType;
} catch (Exception e) {
LOGGER.error("SLotterySetting init fail");
}
@ -97,4 +101,8 @@ public class HeroStaticConfig extends AbstractClassStaticConfig {
public Set<Integer> getRandomHeroIds() {
return randomHeroIds;
}
public Map<Integer, Integer> getRandomPoolByType() {
return randomPoolByType;
}
}

View File

@ -139,7 +139,11 @@ public enum ErrorCode implements IErrorCode {
MAP_IN(105,"在地图探索中,不可以操作"),
HERO_LIVE_AGAIN(106,"英雄{0}秒后复活"),
REWARD_COLLECTING(107,"奖励正在积攒中!"),
IN_BLACK(108,"对方已被您加入黑名单,无法添加好友")
IN_BLACK(108,"对方已被您加入黑名单,无法添加好友"),
NULL_NAME(109,"名字不能为空"),
NAME_LENGTH_ERROR(110,"公会名长度不符"),
EXIST_NAME(111,"此名已存在");
;
private static final Set<Integer> CodeSet = new HashSet<>();

View File

@ -179,5 +179,7 @@ public interface BIReason {
int RIDE_LEVEL_UP_CONSUME = 1045;//坐骑升级消耗
int FAMILY_RENAME = 1045;//公会改名
}

View File

@ -9,16 +9,14 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
import org.springframework.stereotype.Component;
@Component
public class FamilyChangeNoticHandler extends BaseHandler {
public class FamilyChangeNoticHandler extends BaseHandler<Family.FamilyChangeRequest> {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.FAMILY_CHANGE_NOTICE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
byte[] bytes = netData.parseClientProtoNetData();
Family.FamilyChangeRequest familyChangeRequest = Family.FamilyChangeRequest.parseFrom(bytes);
GuildLogic.changeNotice(iSession,familyChangeRequest.getContent());
public void processWithProto(ISession iSession, Family.FamilyChangeRequest proto) throws Exception {
GuildLogic.changeNotice(iSession,proto.getType(),proto.getContent());
}
}

View File

@ -21,9 +21,7 @@ import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.GlobalDataManaager;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.StoryEvent;
import com.ljsd.jieling.logic.activity.event.*;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.CheckFight;
@ -199,7 +197,6 @@ public class MapLogic {
mapEnterResponse.setCurXY(mapManager.getCurXY());
}
if(type ==4){
mapEnterResponse.setCurXY(mapManager.getCurXY());
List<TeamPosHeroInfo> teamPosForHero = user.getTeamPosManager().getTeamPosForHero().get(teamId);
@ -210,6 +207,8 @@ public class MapLogic {
}
EndlessMapInfo endlessMapInfo = mapManager.getEndlessMapInfo();
if(endlessMapInfo.getSeason()!=endlessSeason){
//切换赛季清除信息
clearEndlessItem(user);
TimeControllerOfFunction openTimeOfFuntionCacheByType = GlobalDataManaager.getInstance().getOpenTimeOfFuntionCacheByType(FunctionIdEnum.Endless);
StoreLogic.initOnsStoereWithTime(user,SEndlessMapConfig.sEndlessMapConfigMap.get(endlessMapId).getMapStoreId(),openTimeOfFuntionCacheByType.getStartTime(),openTimeOfFuntionCacheByType.getEndTime());
mapManager.updateEndlessSeason(endlessSeason);
@ -1121,10 +1120,6 @@ public class MapLogic {
onlyLevelMap(user, false);
}
if(user.getMapManager().getCurMapId()!=0&&SChallengeConfig.sChallengeConfigs.get(user.getMapManager().getCurMapId()).getType()==4){
if(endlessSeason==0){
onlyLevelMap(user,false);
user.getMapManager().setEndlessMapInfo(new EndlessMapInfo());
}
if(user.getMapManager().getEndlessMapInfo().getSeason()!=endlessSeason){
onlyLevelMap(user,false);
user.getMapManager().setEndlessMapInfo(new EndlessMapInfo());
@ -1318,6 +1313,9 @@ public class MapLogic {
Hero hero = user.getHeroManager().getHero(team.get(i).getHeroId());
Map<Integer, Integer> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,teamId);
int per = (int)(checkResult[i+2] / (double) heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+2]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
mapManager.updateHeroOneAttribute(team.get(i).getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[i+2]);
}
@ -1573,6 +1571,9 @@ public class MapLogic {
Hero hero = user.getHeroManager().getHero(team.get(i).getHeroId());
Map<Integer, Integer> heroAllAttribute = HeroLogic.getInstance().calHeroNotBufferAttribute(user, hero,false,teamId);
int per =(int) (checkResult[i+2] / (double) heroAllAttribute.get(HeroAttributeEnum.Hp.getPropertyId())*10000);
if(checkResult[i+2]>0&&per<=0){
per = 1;
}
mapManager.updateEndlessHeroHp(team.get(i).getHeroId(),per);
mapManager.updateHeroOneAttribute(team.get(i).getHeroId(), HeroAttributeEnum.CurHP.getPropertyId(), checkResult[i+2]);
}
@ -2243,8 +2244,8 @@ public class MapLogic {
}else{
state =2;
}
user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId,0,1);
Poster.getPoster().dispatchEvent(new FightMainEvent(user.getId(),fightId));
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.LEVEL_FIGHT.getType(),fightId));
user.getMainLevelManager().updateFight(updateFightId,state);
if(state == -1){
//删除为0的
@ -2259,6 +2260,7 @@ public class MapLogic {
user.getMainLevelManager().removeFightStateInfo(removeId);
}
}
user.getUserMissionManager().onGameEvent(user, GameEvent.STORY_FIGHT, fightId,0,1);
}
public void getMainLevelInfo(ISession session) throws Exception {
@ -3252,34 +3254,42 @@ public class MapLogic {
*/
public void resetEndlessInfo() throws Exception {
Map<Integer, ISession> onlineUserMap = OnlineUserManager.sessionMap;
SEndlessMapConfig config = SEndlessMapConfig.sEndlessMapConfigMap.get(MapLogic.getEndlessMapId());
int[] mapItem = config.getMapItem();
for(Map.Entry<Integer, ISession> entry:onlineUserMap.entrySet()){
User user = UserManager.getUser(entry.getValue().getUid());
MapManager mapManager = user.getMapManager();
mapManager.setEndlessMapInfo(new EndlessMapInfo());
if(mapManager.getCurMapId()!=0&&SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4){
MessageUtil.sendIndicationMessage(entry.getValue(),1,MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE,null,true);
resetMapInfo(user,false);
}
ItemManager itemManager = user.getItemManager();
int [][] costItem = new int[mapItem.length][2];
for(int i = 0 ; i <mapItem.length;i++){
Item item = itemManager.getItem(mapItem[i]);
int[] it = new int[2];
it[0] = mapItem[i];
if(item!=null){
it[1] = item.getItemNum();
}else{
it[1] = 0;
}
costItem[i] = it;
}
ItemUtil.itemCost(user,costItem, BIReason.ENDLESS_REASON_CHANGE,1);
endLessClear(entry.getValue());
}
updateEndlessSeason(0);
}
public void endLessClear(ISession session) throws Exception {
User user = UserManager.getUser(session.getUid());
MapManager mapManager = user.getMapManager();
mapManager.setEndlessMapInfo(new EndlessMapInfo());
if(mapManager.getCurMapId()!=0&&SChallengeConfig.sChallengeConfigs.get(mapManager.getCurMapId()).getType()==4){
MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.MAP_OUT_INDICATION_VALUE,null,true);
// resetMapInfo(user,false);
}
}
public void clearEndlessItem(User user) throws Exception {
SEndlessMapConfig config = SEndlessMapConfig.sEndlessMapConfigMap.get(MapLogic.getEndlessMapId());
int[] mapItem = config.getMapItem();
ItemManager itemManager = user.getItemManager();
int [][] costItem = new int[mapItem.length][2];
for(int i = 0 ; i <mapItem.length;i++){
Item item = itemManager.getItem(mapItem[i]);
int[] it = new int[2];
it[0] = mapItem[i];
if(item!=null){
it[1] = item.getItemNum();
}else{
it[1] = 0;
}
costItem[i] = it;
}
ItemUtil.itemCost(user,costItem, BIReason.ENDLESS_REASON_CHANGE,1);
}
/**
*
* @param session
@ -3337,4 +3347,8 @@ public class MapLogic {
UserManager.getUser(session.getUid()).getMapManager().updateEndlessSkipFight(type);
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
}
public static int getEndlessSeason() {
return endlessSeason;
}
}

View File

@ -56,7 +56,8 @@ public class FourtyTwoBehavior extends BaseBehavior {
mapManager.setStartExporeTime(0);
mapManager.setMapIntoFlag(2);
STrialConfig sTrialConfig = STrialConfig.sTrialConfigMap.get(mapManager.getTower());
mapManager.setCurMapId(sTrialConfig.getMapId());
MapLogic.getInstance().initTrialMap(mapManager, user);
return true;
}

View File

@ -320,4 +320,13 @@ public abstract class AbstractActivity implements IActivity, IEventHandler {
}
}
void setOpenState(User user,int openState){
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
if(activityMission != null){
activityMission.updateActivityState(openState);
}
}
}

View File

@ -10,6 +10,9 @@ import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.handler.activity.BlessInfoConfig;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.NewWelfareEvent;
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
@ -61,6 +64,7 @@ public class ActivityLogic {
ActivityLogic.getInstance().resumeActivity(user, ActivityType.RECHARGE_SUM_DAY);
user.getPlayerInfoManager().setRechargedaily(0);
updateActivityMissionProgress(user, ActivityType.SevenLogin, 1);
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.LOGIN_TIMES.getType(),1));
//幸运转盘活动刷新
ActivityLogic.getInstance().resumeActivity(user, ActivityType.LUCK_WHEEL);
@ -207,14 +211,19 @@ public class ActivityLogic {
if (activityMission != null) {
continue;
}
// if(!initOtherActivity(user, sGlobalActivity)){
activityManager.initAllActivityMission(openActivityId);
// }
AbstractActivity abstractActivity = ActivityTypeEnum.getActicityType(openActivityId);
if (null==abstractActivity) {
continue;
}
abstractActivity.initActivity(user);
int activityOpenState = getActivityOpenState(user, openActivityId);
abstractActivity.setOpenState(user,activityOpenState);
//非角色活动开启通知
openNewActivityIds.add(openActivityId);
if(sGlobalActivity.getShopId()!=0){
@ -273,6 +282,8 @@ public class ActivityLogic {
// if(!initOtherActivity(user, sGlobalActivity)){
activityManager.initAllActivityMission(activityId);
// }
int activityOpenState = getActivityOpenState(user, activityId );
abstractActivity.setOpenState(user,activityOpenState);
openNewActivityIds.add(activityId);
checkNeedOpenStore(user,sGlobalActivity.getShopId(),startTime,endTime);
} else {
@ -295,20 +306,6 @@ public class ActivityLogic {
}
/**
*
*/
// public boolean initOtherActivity(User user, SGlobalActivity sGlobalActivity) throws Exception {
// int type = sGlobalActivity.getType();
// switch (type) {
// case ActivityType.BLESSACTIVITY:
// blessInfoInit(user.getActivityManager(), sGlobalActivity.getId());
// return true;
// default:
// return false;
// }
// }
public static ActivityLogic getInstance() {
return ActivityLogic.Instance.instance;
@ -349,6 +346,9 @@ public class ActivityLogic {
continue;
}
int activityStatus = activityMission.getActivityState();
if(activityStatus == -1){
continue;
}
if (sGlobalActivityMap.get(activityId).getIsSaving()==0 && activityStatus != ActivityType.OPEN_STATE) {
continue;
@ -369,6 +369,28 @@ public class ActivityLogic {
return activityInfoList;
}
public void sendActivityInfo(User user,int activityId){
ISession session = OnlineUserManager.getSessionByUid(user.getId());
if(session!=null){
PlayerInfoProto.ActivityUpateIndication.Builder builder = PlayerInfoProto.ActivityUpateIndication.newBuilder();
Map<Integer, ActivityMission> activityMissionMap = user.getActivityManager().getActivityMissionMap();
Map<Integer, ActivityMission> activityUpdateMap = new HashMap<>();
boolean sendLuckWheelPool =false;
if(ActivityType.LUCK_WHEEL == SGlobalActivity.getsGlobalActivityMap().get(activityId).getType()
||ActivityType.LUCK_WHEEL_ADVANCE == SGlobalActivity.getsGlobalActivityMap().get(activityId).getType())
sendLuckWheelPool=true;
activityUpdateMap.put(activityId, activityMissionMap.get(activityId));
List<CommonProto.ActivityInfo> activityInfos = getActivityInfos(activityUpdateMap, user.getPlayerInfoManager().getCreateTime());
builder.addAllActivityInfo(activityInfos);
if(sendLuckWheelPool){
sendLuckWheelPool(user,session);
}
MessageUtil.sendIndicationMessage(session, 1, MessageTypeProto.MessageType.ACTIVITY_UPDATE_INDICATION_VALUE, builder.build(), true);
}
}
public void openActivityReallyOpen(User user, int activityType) {
ActivityManager activityManager = user.getActivityManager();
Map<Integer, ActivityMission> activityMissionMap = activityManager.getActivityMissionMap();
@ -384,6 +406,33 @@ public class ActivityLogic {
}
}
public int getActivityOpenState(User user,int activityId){
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(activityId);
int[] openRules = sGlobalActivity.getOpenRules();
int state = ActivityType.OPEN_STATE;
if(openRules!=null&&openRules.length>0){
int openRuleType = openRules[0];
int openRulleValue = openRules[1];
if(openRuleType == 1){
int virtureId = SMainLevelConfig.config.get(openRulleValue).getVirtureId();
int fightId = user.getMainLevelManager().getFightId();
SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId);
if(user.getMainLevelManager().getState() == 2 ){
mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId());
}
if(mineMainLevelConfig!=null && virtureId > mineMainLevelConfig.getVirtureId()){
state = ActivityType.UNOPEN_STATE;
}
}else{
if(user.getPlayerInfoManager().getLevel()<openRulleValue){
state = ActivityType.UNOPEN_STATE;
}
}
}
return state;
}
public void updateActivityMissionProgress(User user, int activityType, int count) {

View File

@ -2,6 +2,7 @@ package com.ljsd.jieling.logic.activity;
public interface ActivityType {
int UNOPEN_STATE = -1;
int CLOSE_STATE = 0;
int OPEN_STATE = 1;
int FINISH_STATE = 2;
@ -46,6 +47,8 @@ public interface ActivityType {
int ESPECIALEQUIP_EXPERT = 37;//法宝达人
int SOULEQUIP_EXPERT = 38;//魂印达人
int NEW_WELFARE = 42;//萌新福利
}

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
import config.SGlobalActivity;
import java.util.HashMap;
@ -35,6 +36,7 @@ public enum ActivityTypeEnum {
SOULEQUIP_EXPERT(ActivityType.SOULEQUIP_EXPERT, SoulEquipExpectActivity::new),
LUCK_WHEEL(ActivityType.LUCK_WHEEL, LuckWheelNormalActivity::new),
LUCK_WHEEL_ADVANCE(ActivityType.LUCK_WHEEL_ADVANCE, LuckWheelAdvancedActivity::new),
NEW_WELFARE(ActivityType.NEW_WELFARE, NewWelfareActivity::new),
;
private int type;
private Function<Integer, AbstractActivity> toActivityFunction;

View File

@ -22,12 +22,13 @@ class DailyRechargeActivity extends AbstractActivity {
public void onResume(User user) throws Exception {
//每日充值 补发前日未领取的奖
Map<Integer, ActivityMission> activityMissionMap = user.getActivityManager().getActivityMissionMap();
// Map<Integer, ActivityMission> activityMissionMap = user.getActivityManager().getActivityMissionMap();
// //每日充值隐含开启条件是 首冲完成 策划说首冲的活动id 5绝对不会变
// ActivityMission activityMission = activityMissionMap.get(5);
// if (null != activityMission && activityMission.getActivityState() == ActivityType.FINISH_STATE) {
//
// ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
// takeAllReward(sessionByUid);
// }
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
takeAllReward(sessionByUid);

View File

@ -6,10 +6,13 @@ import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.activity.event.FightMainEvent;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.ItemUtil;
import config.SGlobalActivity;
import config.SGlobalSystemConfig;
import config.SMainLevelConfig;
import manager.STableManager;
import java.util.List;
@ -41,5 +44,24 @@ public class FightMainEventHandler implements IEventHandler{
}
}
for(SGlobalActivity sGlobalActivity : SGlobalActivity.getsGlobalActivityMap().values()){
int[] openRules = sGlobalActivity.getOpenRules();
if(openRules!=null && openRules.length>0 && openRules[0] == 1){
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(sGlobalActivity.getId());
if(activityMission!=null && activityMission.getActivityState() == ActivityType.UNOPEN_STATE){
int virtureId = SMainLevelConfig.config.get( openRules[1]).getVirtureId();
SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId);
if(user.getMainLevelManager().getState() == 2 ){
mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId());
}
if(mineMainLevelConfig!=null && virtureId > mineMainLevelConfig.getVirtureId()){
activityMission.updateActivityState(ActivityType.OPEN_STATE);
ActivityLogic.getInstance().sendActivityInfo(user,sGlobalActivity.getId());
}
}
}
}
}
}

View File

@ -0,0 +1,110 @@
package com.ljsd.jieling.logic.activity;
import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.event.*;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.PlayerInfoProto;
import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import config.SActivityRewardConfig;
import config.SGlobalActivity;
import java.util.List;
import java.util.Map;
public class NewWelfareActivity extends AbstractActivity {
public NewWelfareActivity(int id) {
super(id);
Poster.getPoster().listenEvent(this, NewWelfareEvent.class);
}
@Override
public void onEvent(IEvent event) throws Exception {
if(! (event instanceof NewWelfareEvent) ){
return;
}
NewWelfareEvent newWelfareEvent = (NewWelfareEvent) event;
User user =newWelfareEvent.getUser();
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityProgressInfoMap();
boolean isUpdate = false;
for(SActivityRewardConfig sActivityRewardConfig : sActivityRewardConfigs){
ActivityProgressInfo activityProgressInfo = activityProgressInfoMap.get(sActivityRewardConfig.getId());
if(activityProgressInfo.getState() == 1){
continue;
}
if(sActivityRewardConfig.getValues()[0][0] == newWelfareEvent.getType() ){
int parm = newWelfareEvent.getParm();
if( newWelfareEvent.getType() == NewWelfareTypeEnum.LOGIN_TIMES.getType()){
activityProgressInfo.setProgrss(activityProgressInfo.getProgrss()+1);
parm=activityProgressInfo.getProgrss();
}
if(parm ==sActivityRewardConfig.getValues()[1][0]){
activityProgressInfo.setState(1);
activityMission.updateProgressInfo(sActivityRewardConfig.getId(), activityProgressInfo);
isUpdate = true;
}
}
}
if(isUpdate){
//更新进度
ISession sessionByUid = OnlineUserManager.getSessionByUid(user.getId());
sendActivityProgress(sessionByUid, activityMission, null);
}
}
@Override
public boolean takeReward(ISession session, int missionId) throws Exception {
User user = UserManager.getUser(session.getUid());
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (sGlobalActivity == null || !user.getActivityManager().getActivityMissionMap().containsKey(id)) {
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityProgressInfoMap();
for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){
if(activityProgressInfo.getState() != 1){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
}
for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){
activityProgressInfo.setState(2);
}
sendActivityProgress(session, activityMission, null);
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sActivityRewardConfigs.get(0).getReward(), BIReason.TAKE_ACTIVITY_REWARD);
KtEventUtils.onKtEvent(user, ParamEventBean.UserActivityEvent, id, missionId);
PlayerInfoProto.TakeActivityRewardResponse build = PlayerInfoProto.TakeActivityRewardResponse.newBuilder().setDrop(drop).build();
MessageUtil.sendMessage(session, 1, rewardResponseValue, build, true);
return true;
}
@Override
public void getAllMissRewards(User user, ISession session, List<int[][]> itemAttrs){
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
if (sGlobalActivity == null || !user.getActivityManager().getActivityMissionMap().containsKey(id)) {
return;
}
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(id);
Map<Integer, ActivityProgressInfo> activityProgressInfoMap = activityMission.getActivityProgressInfoMap();
for(ActivityProgressInfo activityProgressInfo : activityProgressInfoMap.values()){
if(activityProgressInfo.getState() != 1){
return;
}
}
List<SActivityRewardConfig> sActivityRewardConfigs = SActivityRewardConfig.getsActivityRewardConfigByActivityId(id);
itemAttrs.add(sActivityRewardConfigs.get(0).getValues());
}
}

View File

@ -5,9 +5,11 @@ import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.activity.event.IEvent;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.UserLevelEvent;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.util.ItemUtil;
import config.SGlobalActivity;
import config.SGlobalSystemConfig;
import config.SMainLevelConfig;
import manager.STableManager;
@ -39,6 +41,19 @@ public class UserLevelEventHandler implements IEventHandler{
}
}
for(SGlobalActivity sGlobalActivity : SGlobalActivity.getsGlobalActivityMap().values()){
int[] openRules = sGlobalActivity.getOpenRules();
if(openRules!=null && openRules.length>0 && openRules[0] == 2){
ActivityMission activityMission = user.getActivityManager().getActivityMissionMap().get(sGlobalActivity.getId());
if(activityMission!=null && activityMission.getActivityState() == ActivityType.UNOPEN_STATE){
if(user.getPlayerInfoManager().getLevel()>=openRules[1]){
activityMission.updateActivityState(ActivityType.OPEN_STATE);
ActivityLogic.getInstance().sendActivityInfo(user,sGlobalActivity.getId());
}
}
}
}
if(sGlobalSystemConfigs == null){
return;
}

View File

@ -0,0 +1,27 @@
package com.ljsd.jieling.logic.activity.event;
import com.ljsd.jieling.logic.dao.root.User;
public class NewWelfareEvent implements IEvent{
private User user;
private int type;
private int parm;
public NewWelfareEvent(User user, int type, int parm) {
this.user = user;
this.type = type;
this.parm = parm;
}
public User getUser() {
return user;
}
public int getType() {
return type;
}
public int getParm() {
return parm;
}
}

View File

@ -0,0 +1,17 @@
package com.ljsd.jieling.logic.activity.event;
public enum NewWelfareTypeEnum {
LEVEL_FIGHT(1),
LOGIN_TIMES(2),
RECHARGE_BUY(3)
;
private int type;
private NewWelfareTypeEnum(int type) {
this.type = type;
}
public int getType() {
return type;
}
}

View File

@ -90,7 +90,7 @@ public class GuilidManager {
String key = RedisUtil.getInstence().getKey("guild-release", "");
while (needContinue){
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores("guild-release", "", round*5, (round+1)*5);
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetRangeWithScores("guild-release", "", round*5, (round+1)*5);
if(zsetreverseRangeWithScores == null || zsetreverseRangeWithScores.isEmpty()){
return;
}

View File

@ -15,6 +15,8 @@ public class HeroManager extends MongoBase {
Map<Integer, Integer> totalCount;
Map<Integer, Integer> randomPoolByType;
Map<Integer,Integer> heroHandBook;
private int firstTenth;
@ -24,6 +26,7 @@ public class HeroManager extends MongoBase {
heroMap = new HashMap();
totalCount = new HashMap();
heroHandBook = new HashMap<>();
randomPoolByType = new HashMap<>();
this.setRootCollection(User._COLLECTION_NAME);
}
@ -32,6 +35,11 @@ public class HeroManager extends MongoBase {
totalCount.put(type,count);
}
public void updateRandPoolTypeCount(int mergePool,int count){
updateString("randomPoolByType." + mergePool, count);
randomPoolByType.put(mergePool,count);
}
public Map<String, Hero> getItemMap() {
return heroMap;
}
@ -89,4 +97,8 @@ public class HeroManager extends MongoBase {
updateString("firstTenth" , 1);
}
public Map<Integer, Integer> getRandomPoolByType() {
return randomPoolByType;
}
}

View File

@ -7,6 +7,9 @@ import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.event.NewWelfareEvent;
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.hero.HeroLogic;
import com.ljsd.jieling.logic.mission.GameEvent;
@ -99,6 +102,7 @@ public class UserManager {
user.getUserMissionManager().onGameEvent(user, GameEvent.DAILY_REFRESH,0);
user.getUserMissionManager().onGameEvent(user, GameEvent.BLOODY_REFRESH,0);
user.getUserMissionManager().onGameEvent(user, GameEvent.BEGINNER);
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.LOGIN_TIMES.getType(),1));
KtEventUtils.onKtEvent(user, ParamEventBean.UserRegister);
}

View File

@ -92,6 +92,8 @@ public class GuildInfo extends MongoBase {
public void setAnnounce(String announce) {
this.announce = announce;
updateString("announce",announce);
}
public int getId() {
@ -102,6 +104,12 @@ public class GuildInfo extends MongoBase {
return name;
}
public void setName(String name) {
this.name = name;
updateString("name",name);
}
public String getAnnounce() {
return announce;
}

View File

@ -470,12 +470,12 @@ public class GuildFightLogic {
LuaValue getOptionData = FightDataUtil.getOptionData("");
int seed = (int) (System.currentTimeMillis() / 1000);
CommonProto.FightData fightData = CommonProto.FightData.newBuilder()
.setFightMaxTime(SArenaSetting.getSArenaSetting().getMostTime())
.setFightMaxTime(SGuildSetting.sGuildSetting.getWarTime())
.setFightSeed(seed)
.setHeroFightInfos(fightAttackTeamInfo)
.addMonsterList(fightDefendTeamInfo)
.build();
int[] fightResult = CheckFight.getInstance().checkFight(seed, 1000, getFightData, getOptionData, FightType.GuildFight);
int[] fightResult = CheckFight.getInstance().checkFight(seed, SGuildSetting.sGuildSetting.getWarTime(), getFightData, getOptionData, FightType.GuildFight);
for (int i = 0; i < fightResult.length; i++) {
System.out.println(fightResult[i]);
}

View File

@ -87,9 +87,13 @@ public class GuildLogic {
int uid = session.getUid();
User user = UserManager.getUser(uid);
int msgId = MessageTypeProto.MessageType.FAMILY_CREATE_RESPONSE_VALUE;
String err = checkForCreateGuild(user, familyName, announce);
if(!"".equals(err)){
throw new ErrorCodeException(ErrorCode.newDefineCode(err));
checkForCreateGuild(user, familyName, announce);
boolean enough= ItemUtil.itemCost(user, SGuildSetting.sGuildSetting.getCreatCost(), BIReason.CREATE_GUILD_CONSUME, 0);
if(!enough){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if(user.getPlayerInfoManager().getGuildId()!=0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
}
if(StringUtil.isEmpty(announce)){
announce= SGuildSetting.sGuildSetting.getDefaultDeclaration();
@ -111,37 +115,29 @@ public class GuildLogic {
MessageUtil.sendMessage(session,1,msgId,build,true);
}
public static String checkForCreateGuild( User user,String familyName,String announce) throws Exception {
public static void checkForCreateGuild( User user,String familyName,String announce) throws Exception {
if(!Repot37EventUtil.Report37Chat(user, ChatContentType.FAMILY_NAME.getType(),announce)){
return "包含敏感字";
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
}
if(StringUtil.isEmpty(familyName)){
return "名字不能为空";
throw new ErrorCodeException(ErrorCode.NULL_NAME);
}
boolean result = true;
if(!StringUtil.isEmpty(announce)){
result = ShieldedWordUtils.checkName(user,announce,false,ChatContentType.FAMILY_NAME);
if (!result) {
return "包含敏感字";
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
}
}
if(familyName.length()<SGuildSetting.sGuildSetting.getNameSize()[0]||familyName.length()>SGuildSetting.sGuildSetting.getNameSize()[1]){
return "公会名长度不符";
throw new ErrorCodeException(ErrorCode.NAME_LENGTH_ERROR);
}
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
for(Map.Entry<Integer, GuildInfo> entry:guildInfoMap.entrySet()){
if(entry.getValue().getName().equals(familyName)){
return "此名已存在";
throw new ErrorCodeException(ErrorCode.EXIST_NAME);
}
}
boolean enough= ItemUtil.itemCost(user, SGuildSetting.sGuildSetting.getCreatCost(), BIReason.CREATE_GUILD_CONSUME, 0);
if(!enough){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
if(user.getPlayerInfoManager().getGuildId()!=0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN);
}
return "";
}
@ -654,7 +650,7 @@ public class GuildLogic {
* @param session
* @param content
*/
public static void changeNotice(ISession session,String content) throws Exception {
public static void changeNotice(ISession session,int type,String content) throws Exception {
int msgId = MessageTypeProto.MessageType.FAMILY_CHANGE_NOTICE_RESPONSE_VALUE;
int uid = session.getUid();
User user = UserManager.getUser(uid);
@ -683,7 +679,17 @@ public class GuildLogic {
if(resultCode==0){
throw new ErrorCodeException(ErrorCode.FAMILY_IN_SENSITIVE);
}else{
guildInfo.setAnnounce(content);
if(type==1){
guildInfo.setAnnounce(content);
}else{
checkForCreateGuild(user, content, guildInfo.getAnnounce());
int[][] renameCost = SGuildSetting.sGuildSetting.getRenameCost();
boolean b = ItemUtil.itemCost(user, renameCost, BIReason.FAMILY_RENAME, 1);
if(!b){
throw new ErrorCodeException(ErrorCode.ITEM_NOT_ENOUGH);
}
guildInfo.setName(content);
}
MessageUtil.sendMessage(session,resultCode,msgId,response,true);
}
}

View File

@ -217,10 +217,15 @@ public class HeroLogic {
}
int[][] dropHeroAndItem = new int[length][];
int randCount = 0;
int poolCount = 0;
Map<Integer, Integer> totalCountMap = heroManager.getTotalCount();
Map<Integer, Integer> randomPoolByType = heroManager.getRandomPoolByType();
if (totalCountMap.containsKey(type)) {
randCount = totalCountMap.get(type);
}
if (randomPoolByType.containsKey(sLotterySetting.getMergePool())) {
poolCount = randomPoolByType.get(sLotterySetting.getMergePool());
}
int totalCount = 0;
for(Integer count : totalCountMap.values()){
totalCount+=count;
@ -230,14 +235,20 @@ public class HeroLogic {
for(int i=0;i<perCount;i++){
randCount++;
if(pooId == 0){
pooId = getSpecialPoolByRandcount(type, randCount);
pooId = getSpecialPoolByRandcount(type, randCount,poolCount);
if(pooId==0){
pooId = getPooId(sLotterySetting, pooId);
}
}
LOGGER.info("the uid={},the type={},the poolId={}",uid,type,pooId);
totalCount++;
int[] reward = randomHeroByPoolId(pooId,totalCount,user.getPlayerInfoManager().getLevel());
SLotteryRewardConfig sLotteryRewardConfig = randomHeroByPoolId(pooId, totalCount, user.getPlayerInfoManager().getLevel());
if(sLotteryRewardConfig.getStar() == 1){
poolCount=0;
}else{
poolCount++;
}
int[] reward =sLotteryRewardConfig.getReward();
if(reward!=null){
dropHeroAndItem[j++] = reward;
}
@ -246,6 +257,7 @@ public class HeroLogic {
}
}
heroManager.updateRandPoolTypeCount(sLotterySetting.getMergePool(),poolCount);
//1群英招募
HeroInfoProto.HeroRandResponse.Builder builder = HeroInfoProto.HeroRandResponse.newBuilder();
@ -275,13 +287,17 @@ public class HeroLogic {
MessageUtil.sendMessage(session, 1, MessageTypeProto.MessageType.HERO_RAND_RESPONSE_VALUE, builder.build(), true);
}
private int getSpecialPoolByRandcount(int type, int randCount) {
private int getSpecialPoolByRandcount(int type, int randCount,int poolCount) {
List<SLotterySpecialConfig> list = SLotterySpecialConfig.getLotterySpecialConfigListByType(type);
if (list == null) {
return 0;
}
int poolId = 0;
for (SLotterySpecialConfig data : list) {
if(data.getDifferentType() == 2 && poolCount==data.getCount()){
poolId = data.getpool_id();
break;
}
if (randCount % data.getCount() != 0) {
continue;
}
@ -333,7 +349,7 @@ public class HeroLogic {
public int[] randomHeroByPoolId(int poolId,int randomCount,int userLevel){
public SLotteryRewardConfig randomHeroByPoolId(int poolId,int randomCount,int userLevel){
List<SLotteryRewardConfig> sLotteryRewardConfigs = new ArrayList<>();
List<SLotteryRewardConfig> sLotteryRewardConfigListByPoolId = SLotteryRewardConfig.getSLotteryRewardConfigListByPoolId(poolId);
int totalCountByPoolId =0;
@ -363,7 +379,7 @@ public class HeroLogic {
for(SLotteryRewardConfig sLotteryRewardConfig :sLotteryRewardConfigs){
weight += sLotteryRewardConfig.getWeight();
if(weight>=randCount){
return sLotteryRewardConfig.getReward();
return sLotteryRewardConfig;
}
}
return null;
@ -2097,5 +2113,14 @@ public class HeroLogic {
}
hero.setIsLock(lockState);
MessageUtil.sendMessage(session,1,responseMsgId,null,true);
Map<Integer,Integer> pokemonAttributeMap = new HashMap<>();
Map<Integer, Pokemon> pokemonMap = user.getPokemonManager().getPokemonMap();
for(Pokemon pokemon : pokemonMap.values()){
combinePokemonAttribute(pokemonAttributeMap, pokemon,false);
}
for(Map.Entry<Integer,Integer> item : pokemonAttributeMap.entrySet()){
LOGGER.info("the proId={},the value={}",item.getKey(),item.getValue());
}
}
}

View File

@ -444,10 +444,10 @@ public class MissionLoigc {
case LEVEL_STORY_PASS:
if(SMainLevelConfig.config.containsKey(missionSubType[0])){
int virtureId = SMainLevelConfig.config.get(missionSubType[0]).getVirtureId();
SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId());
if(user.getMainLevelManager().getState() == -1 ){
int fightId = user.getMainLevelManager().getFightId();
mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId);
int fightId = user.getMainLevelManager().getFightId();
SMainLevelConfig mineMainLevelConfig = SMainLevelConfig.fightPreMap.get(fightId);
if(user.getMainLevelManager().getState() == 2 ){
mineMainLevelConfig = SMainLevelConfig.config.get(user.getMainLevelManager().getFightId());
}
if(mineMainLevelConfig!=null){
count =virtureId <= mineMainLevelConfig.getVirtureId() ?1:0;

View File

@ -8,25 +8,26 @@ public class ArenaChallengeManager implements BaseDataManager{
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
CumulationData.Result result = null;
int fightResult = (int) parm[0];
if(missionType == MissionType.ARENA_FIGHTSUCCES_TIMES){
if(fightResult==1){
data.arenaFightsuccesTimes++;
result = new CumulationData.Result(missionType);
}
}
if(fightResult==-999){
return result;
}
if(missionType == MissionType.ARENA_CHALLENEGE_NUMS){
data.setArenaFightNums(data.getArenaFightNums()+1);
result = new CumulationData.Result(missionType);
}else if(missionType == MissionType.ARENA_SCORE){
if(missionType == MissionType.ARENA_SCORE){
int myscore = (int)parm[1];
if(myscore > data.getArenaScore()){
data.setArenaScore(myscore);
result = new CumulationData.Result(missionType);
}
}
if(fightResult==-999){
return result;
}
if(missionType == MissionType.ARENA_FIGHTSUCCES_TIMES){
if(fightResult==1){
data.arenaFightsuccesTimes++;
result = new CumulationData.Result(missionType);
}
}else if(missionType == MissionType.ARENA_CHALLENEGE_NUMS){
data.setArenaFightNums(data.getArenaFightNums()+1);
result = new CumulationData.Result(missionType);
}
return result;
}

View File

@ -7,7 +7,7 @@ public class FightPlayDataManager implements BaseDataManager{
@Override
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
int type = (int)parm[0];
if(type == 3 && (missionType == MissionType.HERO_STORY_PLAY_TIMES || missionType == MissionType.HERO_STORY_TIMES)){
if(type == 3 && (missionType == MissionType.HERO_STORY_PLAY_TIMES)){
data.heroStoryPlayTimes+=(int)parm[1];
}else if(type == 999 && missionType == MissionType.INVASIONBOSS_PLAY_TIMES){
data.invasionbossPlayTimes+=(int)parm[1];

View File

@ -11,6 +11,10 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.activity.ActivityLogic;
import com.ljsd.jieling.logic.activity.ActivityType;
import com.ljsd.jieling.logic.activity.event.NewWelfareEvent;
import com.ljsd.jieling.logic.activity.event.NewWelfareTypeEnum;
import com.ljsd.jieling.logic.activity.event.Poster;
import com.ljsd.jieling.logic.activity.event.SecretEvent;
import com.ljsd.jieling.logic.dao.RechargeInfo;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.root.User;
@ -166,11 +170,12 @@ public class BuyGoodsLogic {
}
if(sRechargeCommodityConfig.getAccumulativeRecharge() == 1){
int saveAmt = rechargeInfo.getSaveAmt();
int[][] costItemArr = StringUtil.parseFiledInt2(rewardStr);
for (int i = 0; i <costItemArr.length ; i++) {
if(costItemArr[i][0]==Global.SOULCRYSTAL){
rechargeInfo.addSoulCrystalAmt(costItemArr[i][1]);
if(!StringUtil.isEmpty(rewardStr)){
int[][] costItemArr = StringUtil.parseFiledInt2(rewardStr);
for (int i = 0; i <costItemArr.length ; i++) {
if(costItemArr[i][0]==Global.SOULCRYSTAL){
rechargeInfo.addSoulCrystalAmt(costItemArr[i][1]);
}
}
}
rechargeInfo.setSaveAmt(price+saveAmt);
@ -206,6 +211,7 @@ public class BuyGoodsLogic {
KtEventUtils.onKtEvent(user, ParamEventBean.UserPayEvent,goodsId,orderId,resultRes.getResultCode(),price);
notifyPaySuccessFul(uid,goodsId,amount != -999);
MongoUtil.getLjsdMongoTemplate().lastUpdate();
Poster.getPoster().dispatchEvent(new NewWelfareEvent(user, NewWelfareTypeEnum.RECHARGE_BUY.getType(),goodsId));
return resultRes;
}

View File

@ -5,6 +5,7 @@ import com.ljsd.jieling.core.HandlerLogicThread;
import com.ljsd.jieling.db.redis.RedisKey;
import com.ljsd.jieling.db.redis.RedisUtil;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.ktbeans.KtEventUtils;
import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
import com.ljsd.jieling.logic.GlobalDataManaager;
@ -208,6 +209,21 @@ public class ProtocolsManager implements ProtocolsAbstract {
//<<<<<<< HEAD
////<<<<<<< HEAD
////=======
//// public void processReconnect(ISession session) {
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
//// Type type = new TypeToken<Map<Integer, ISession.IndicationMsg>>(){}.getType();
//// Object indicationInRedis = RedisUtil.getInstence().get(key);
//// int maxMsgId = 1;
//// if(indicationInRedis!=null){
//// Map<Integer, ISession.IndicationMsg> map= gson.fromJson(indicationInRedis.toString(),type);
//// for(Map.Entry<Integer,ISession.IndicationMsg> info : map.entrySet()){
//// session.writeAndFlush(info.getValue().getMsg());
//// session.putBackIndicationToMap(info.getKey(),info.getValue().getMsg());
//// if(info.getKey()>maxMsgId){
//// maxMsgId = info.getKey();
//// }
//=======
// public void processReconnect(ISession session) {
// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
@ -259,6 +275,9 @@ public class ProtocolsManager implements ProtocolsAbstract {
// PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(allItemList).setType(0).build();
// MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
// }
// if(userInMem.getMapManager().getEndlessMapInfo().getSeason()!=MapLogic.getEndlessSeason()){
// MapLogic.getInstance().endLessClear(session);
// }
// MongoUtil.getLjsdMongoTemplate().lastUpdate();
// } catch (Exception e) {
// LOGGER.error("the uid={} processFlush wrong ,e={}",session.getUid(),e);
@ -409,7 +428,7 @@ public class ProtocolsManager implements ProtocolsAbstract {
// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
// RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
// }
//
//
// public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
// if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
@ -441,24 +460,244 @@ public class ProtocolsManager implements ProtocolsAbstract {
//// // 那么当前连接应该已经断开,客户端不会收到该消息,则当前设备不会被踢下线
//// //如果用其他设备登录,则当前设备能够收到这条消息,则当前设备被踢下线
//// errorCode = ErrorCode.LOGIN_IN_OTHER;
//>>>>>>> 3c59042b88571e9eaa811ea7140537965aeac324
//// }
//// LOGGER.info("kickOldUser->uid={},errorCode={};sendErrorMessageByChannel!", uid, errorCode);
//// sendErrorMessageByChannel(oldChannl, errorCode, errorMsg);
//// RedisUtil.getInstence().del(key);
//// }
//
// offLine(oldSession);
//// oldSession.close();
// return true;
// }
//
// @Override
// public void readIdel(GameSession gameSession) {
// // TODO
// final ISession session = (ISession) gameSession;
// readIdea(session);
// }
//
//>>>>>>> 843e4f921d5bc65ced6568bf5fc4b58b2b17cf54
//// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
//// type = new TypeToken<Map<Integer, byte[]>>(){}.getType();
//// Object responsInRedis = RedisUtil.getInstence().get(key);
//// session.setFiveReady(1);
//// String indicationIndexInRedisKey = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
//// String indicationIndexInRedis =(String) RedisUtil.getInstence().get(indicationIndexInRedisKey);
//// if(!StringUtil.isEmpty(indicationIndexInRedis)){
//// maxMsgId= Integer.parseInt(indicationIndexInRedis);
//// }
////
//// session.updateIndicationIndex(maxMsgId);
//// if(responsInRedis!=null){
//// Map<Integer, byte[]> response = gson.fromJson(responsInRedis.toString(), type);
//// if(response!=null && !response.isEmpty()){
//// session.setIndexToMessage(new ConcurrentHashMap<Integer, byte[]> (response));
//// Integer index = response.keySet().iterator().next();
//// session.setIndex(index);
//// RedisUtil.getInstence().del(key);
//// LOGGER.info("the uid={} cache repsponse is ={},session={}",session.getUid(),index,session.getCtx().channel());
//// }
////
//// }
//// LOGGER.info("the uid={} reconnect,the maxid={} ",session.getUid(),maxMsgId);
//// User userInMem = UserManager.getUserInMem(session.getUid());
//// if(userInMem!=null){
//// ActivityLogic.getInstance().updateActivityMissionProgress(userInMem, ActivityType.OnlineReward,0);
//// try {
//// StoreLogic.checkStoreRefresh(userInMem,userInMem.getStoreManager().getStoreInfoMap());
//// GlobalDataManaager.checkNeedReFlush(session, userInMem, PlayerInfoProto.FivePlayerUpdateIndication.newBuilder());
//// List<CommonProto.Item> allItemList = ItemUtil.getAllItem(userInMem,false);
//// if(!allItemList.isEmpty()){
//// PlayerInfoProto.UpdateBagIndication build = PlayerInfoProto.UpdateBagIndication.newBuilder().addAllItem(allItemList).setType(0).build();
//// MessageUtil.sendIndicationMessage(session,1,MessageTypeProto.MessageType.UPDATE_BAG_INDICATION_VALUE,build,true);
//// }
//// MongoUtil.getLjsdMongoTemplate().lastUpdate();
//// } catch (Exception e) {
//// LOGGER.error("the uid={} processFlush wrong ,e={}",session.getUid(),e);
//// }
//// }
//// MessageUtil.sendMessageWithoutBack(session,1, MessageTypeProto.MessageType.RECONNECT_RESPONSE_VALUE,null,true);
//// }
////
//// private boolean sessionInit(ISession session, PacketNetData packetNetData) {
//// int uid = packetNetData.getUserId();
//// int token = packetNetData.getToken();
//// session.setUid(uid);
//// String tokenKey = RedisKey.getKey(RedisKey.TOKEN, String.valueOf(uid),false);
//// if(null==tokenKey||tokenKey.isEmpty()){
//// return false;
//// }
//// String tokenK = (String)RedisUtil.getInstence().get(tokenKey);
//// if(null==tokenK||tokenK.isEmpty()){
//// return false;
//// }
//// int serverToken = Integer.parseInt((String)RedisUtil.getInstence().get(tokenKey));
//// if (token == serverToken){
//// session.setToken(token);
//// session.setUserLoginTime(System.currentTimeMillis()/1000);
//// return true;
//// }
//// return true;
//// }
////
////
//// private int dealRepeatLogin(ISession newSession) {
//// int uid = newSession.getUid();
//// if (OnlineUserManager.checkUidOnline(uid)){
//// ISession iSession = OnlineUserManager.getSessionByUid(uid);
//// if(iSession == newSession){
//// return 0;
//// }
//// serverKick(iSession,"您的账号已经在其他设备上登陆,请确认账号安全!");
//// return 1;
//// }
//// return 0;
//// }
////
//// private int checkIndex(ISession iSession, PacketNetData packetNetData) {
//// /* if(packetNetData.getMsgId() == MessageTypeProto.MessageType.LOGIN_REQUEST_VALUE || packetNetData.getMsgId() == MessageTypeProto.MessageType.RECONNECT_REQUEST_VALUE){
//// return 0;
//// }*/
//// int index = packetNetData.getIndex();
//// if (iSession.getIndex() >= index){
//// byte[] message = iSession.getCacheMessage(index);
//// if (message==null){
//// //TODO error
//// LOGGER.info("the uid={},the msg={} is processing,the index={},the sessionIndex={}",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()),index,iSession.getIndex());
//// return 1;
//// }else {
//// LOGGER.info("the uid={},the msg={} reback",iSession.getUid(), MessageTypeProto.MessageType.valueOf(packetNetData.getMsgId()));
//// iSession.writeAndFlush(message);
//// return 1;
//// }
//// }else {
//// iSession.setIndex(index);
//// }
//// return 0;
//// }
////
//// private void ackIndication(ISession iSession, int ackId) {
//// LOGGER.info("the uid={},the ackId={}",iSession.getUid(),ackId);
//// iSession.clearIndication(ackId);
//// MessageUtil.sendAck(iSession,ackId);
//// }
////
//// private void dealHeartBeat(ISession session) {
//// session.setHeartBreatNums(3);
//// MessageUtil.sendHeartBeat(session);
//// }
////
//// private int checkToken(ISession session, PacketNetData packetNetData) {
//// if (session.getToken() != packetNetData.getToken()){
//// return 1;
//// }
//// return 0;
//// }
////
////
//// @Override
//// public void offLine(GameSession gameSession) {
////
//// ISession session = (ISession) gameSession;
//// LOGGER.info("player offLine ..{}",session.getUid());
//// synchronized (session) {
//// if (session.getUid() == 0) {
//// LOGGER.error("offLine->uid={}", session.getUid());
//// return;
//// }
//// if(session.getOfflineType() == ErrorCode.reloginCode){
//// return;
//// }
//// User user = UserManager.getUserInMem(session.getUid());
//// if(user == null){
//// LOGGER.info("the uid={},not in mem",session.getUid());
//// return;
//// }
//// KtEventUtils.onKtEvent(user, ParamEventBean.UserLoginOutEvent,1);
//// KtEventUtils.onKtEvent(user, ParamEventBean.UserLogin,1);
//// LOGGER.info("player={} offLine ...",user.getId());
//// OnlineUserManager.userOffline(session.getUid());
//// if (session.getCtx() != null) {
//// GameMessageHandler.allChannels.remove(session.getCtx().channel());
//// }
////
//// GameMessageHandler.currentSessions.remove(session.getUid());
//// processUserOfflineData(user,session);
////
//// }
//// }
////
//// private void processUserOfflineData(User user,ISession session){
//// try {
//// GuildLogic.updateMyPos(user);
//// if(session.getFiveReady()==1){
//// PlayerManager playerInfoManager = user.getPlayerInfoManager();
//// playerInfoManager.setOffLineTime(TimeUtils.now());
//// long onlineTime = playerInfoManager.getOffLineTime() - session.getLoginTime();
//// playerInfoManager.addOnlineTime(onlineTime);
//// //更新在线时长
//// ActivityLogic.getInstance().updateActivityMissionProgress(user, ActivityType.OnlineReward,(int)(onlineTime/TimeUtils.ONE_SECOND));
//// MongoUtil.getInstence().lastUpdate();
//// session.setFiveReady(0);
//// }
//// backUpMsgToRedis(session);
//// } catch (Exception e) {
//// e.printStackTrace();
//// } finally {
//// //保证数据的保存
//// }
//// }
////
//// private void backUpMsgToRedis(ISession session){
//// ConcurrentHashMap<Integer, ISession.IndicationMsg> indexToIndication = session.getIndexToIndication();
//// LOGGER.info("the uid={} offline.the indication size={}",session.getUid(),indexToIndication.size());
//// if(!indexToIndication.isEmpty() ){
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE, Integer.toString(session.getUid()));
//// RedisUtil.getInstence().set(key,gson.toJson(indexToIndication));
//// }
//// String key = RedisUtil.getInstence().getKey(RedisKey.INDICATION_OFFLINE_INDEX, Integer.toString(session.getUid()));
//// RedisUtil.getInstence().set(key,String.valueOf(session.getIndicationIndex()));
////
//// key = RedisUtil.getInstence().getKey(RedisKey.RESPONSE_OFFLINE, Integer.toString(session.getUid()));
//// RedisUtil.getInstence().set(key,gson.toJson(session.getIndexToMessage()));
//// }
////
////
//// public boolean kickOldUser(int uid, String uToken, int errorCode, String errorMsg, long requestTime) {
//// if (GameMessageHandler.currentSessions.size() != 0 && GameMessageHandler.currentSessions.keySet().contains(uid)) {
//// if (requestTime != 0 && requestTime < GameMessageHandler.currentSessions.get(uid).getUserLoginTime()) {
//// LOGGER.info("kickOldUser->uid={},requestTime={},userLoginTime={}",
//// uid, requestTime, GameMessageHandler.currentSessions.get(uid).getUserLoginTime());
//// return false;
//// }
//// }
////
//// if (!OnlineUserManager.checkUidOnline(uid)) {
//// LOGGER.info("kickOldUser->uid={};isNotOnline", uid);
//// return false;
//// }
//// ISession oldSession = OnlineUserManager.getSessionByUid(uid);
//// if (oldSession == null) {
//// LOGGER.info("kickOldUser->uid={};oldSessionisNull", uid);
//// OnlineUserManager.userOffline(uid);
//// return false;
//// }
//// oldSession.setOfflineType(errorCode);
////
////// if (oldSession.getCtx() != null && !uToken.equals(oldSession.getToken())) {
////// Channel oldChannl = oldSession.getCtx().channel();
////// if (errorCode == ErrorCode.LOGIN_IN_OTHER_GAMESERVER) {
////// OnlineUserLogics.removeFromOnline(uid);
////// //转化为踢人消息,
////// // 如果当前设备重新登录或重连,登录的其他服务器
////// // 那么当前连接应该已经断开,客户端不会收到该消息,则当前设备不会被踢下线
////// //如果用其他设备登录,则当前设备能够收到这条消息,则当前设备被踢下线
////// errorCode = ErrorCode.LOGIN_IN_OTHER;
////// }
////// LOGGER.info("kickOldUser->uid={},errorCode={};sendErrorMessageByChannel!", uid, errorCode);
////// sendErrorMessageByChannel(oldChannl, errorCode, errorMsg);
////// }
////
//// offLine(oldSession);
////// oldSession.close();
//// return true;
//// }
////
//// @Override
//// public void readIdel(GameSession gameSession) {
//// // TODO
//// final ISession session = (ISession) gameSession;
//// readIdea(session);
//// }
////
////>>>>>>> 843e4f921d5bc65ced6568bf5fc4b58b2b17cf54
public BaseHandler getHandler(int msgNum) {
return handlers.get(msgNum);
}

View File

@ -15,8 +15,8 @@ dependencies {
compile project(":gamecommon")
testCompile group: 'junit', name: 'junit', version: '4.12'
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile("com.fasterxml.jackson.core:jackson-core:2.3.1")
compile("com.fasterxml.jackson.core:jackson-databind:2.3.3")
compile("com.fasterxml.jackson.core:jackson-core:2.10.1")
compile("com.fasterxml.jackson.core:jackson-databind:2.10.1")
}
jar {

View File

@ -39,6 +39,8 @@ public class SGlobalActivity implements BaseConfig {
private int openRanking;
private int[] openRules;
@Override
public void init() throws Exception {
@ -130,4 +132,8 @@ public class SGlobalActivity implements BaseConfig {
public int getOpenRanking() {
return openRanking;
}
public int[] getOpenRules() {
return openRules;
}
}

View File

@ -64,6 +64,10 @@ public class SGuildSetting implements BaseConfig {
private String participation;
private int warTime;
private int[][] renameCost;
public static SGuildSetting sGuildSetting;
@ -189,4 +193,12 @@ public class SGuildSetting implements BaseConfig {
public String getParticipation() {
return participation;
}
public int getWarTime() {
return warTime;
}
public int[][] getRenameCost() {
return renameCost;
}
}

View File

@ -23,6 +23,8 @@ public class SLotteryRewardConfig implements BaseConfig {
private int[] openRules;
private int star;
private static Map<Integer, List<SLotteryRewardConfig>> sLotteryRewardConfigsByPoolId;
private static Map<Integer, Integer> sLotteryRewardWeightByPoolId;
@ -82,4 +84,8 @@ public class SLotteryRewardConfig implements BaseConfig {
public int[] getOpenRules() {
return openRules;
}
public int getStar() {
return star;
}
}

View File

@ -31,6 +31,8 @@ public class SLotterySetting implements BaseConfig {
private int lotteryType;
private int mergePool;
@Override
public void init() throws Exception {
@ -89,4 +91,8 @@ public class SLotterySetting implements BaseConfig {
public int getLotteryType() {
return lotteryType;
}
public int getMergePool() {
return mergePool;
}
}

View File

@ -13,6 +13,8 @@ public class SLotterySpecialConfig implements BaseConfig {
private int id;
private int differentType;
private int type;
private int count;
@ -23,6 +25,7 @@ public class SLotterySpecialConfig implements BaseConfig {
private int pool_id;
private static Map<Integer, List<SLotterySpecialConfig>> lotterySpecialConfigMap;
@ -68,5 +71,7 @@ public class SLotterySpecialConfig implements BaseConfig {
return pool_id;
}
public int getDifferentType() {
return differentType;
}
}