Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
8d640e290b
|
|
@ -214,7 +214,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
Random.SetSeed(args.seed)
|
||||
BattleLogic.Init(args.maxTime, fightData, optionData)
|
||||
BattleLogic.Type = _type
|
||||
if _type == 9 then
|
||||
if _type == 9 or _type == 10 then
|
||||
AddRecord(fightData)
|
||||
end
|
||||
BattleLogic.StartOrder()
|
||||
|
|
@ -263,7 +263,19 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
else
|
||||
resultList.result = BattleLogic.Result
|
||||
end
|
||||
--print("result:"..BattleLogic.Result)
|
||||
|
||||
if _type == 10 then
|
||||
local playerDamage=0
|
||||
for k,v in pairs(BattleRecord)do
|
||||
if v.camp == 0 then
|
||||
playerDamage = playerDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.duration = playerDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
else
|
||||
resultList.duration = BattleLogic.CurFrame() / BattleLogic.GameFrameRate
|
||||
end
|
||||
|
||||
|
||||
addBattleData()
|
||||
return resultList
|
||||
|
|
|
|||
|
|
@ -138,9 +138,8 @@ public class TimeUtils {
|
|||
public static final String Stand_CeHua_Data_format = "yyyyMMdd HHmmss";
|
||||
|
||||
public static void main(String[] args) {
|
||||
System.out.println(Integer.MAX_VALUE);
|
||||
System.out.println((Integer.MAX_VALUE-now()/1000)/Math.pow(10,9));
|
||||
|
||||
// long lastHour = getLastHour(5);
|
||||
// System.out.println(lastHour);
|
||||
}
|
||||
/**
|
||||
* 判断是否合法的时间格式(HH:mm:ss)
|
||||
|
|
@ -1319,6 +1318,27 @@ public class TimeUtils {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*获取传入时间的上个几时
|
||||
* @param hour
|
||||
* @return
|
||||
*/
|
||||
public static long getLastHour(long time,int hour){
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTimeInMillis(time);
|
||||
int i = cal.get(Calendar.HOUR_OF_DAY);
|
||||
cal.set(Calendar.HOUR_OF_DAY,hour);
|
||||
cal.set(Calendar.MINUTE,0);
|
||||
cal.set(Calendar.SECOND,0);
|
||||
cal.set(Calendar.MILLISECOND,0);
|
||||
long result = cal.getTimeInMillis();
|
||||
if(i<5){
|
||||
result = result -TimeUtils.DAY;
|
||||
}
|
||||
return result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回Integer最大值-now()之后变成小于一的小数;
|
||||
* @return
|
||||
|
|
|
|||
|
|
@ -215,7 +215,7 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
Random.SetSeed(args.seed)
|
||||
BattleLogic.Init(args.maxTime, fightData, optionData)
|
||||
BattleLogic.Type = _type
|
||||
if _type == 9 then
|
||||
if _type == 9 or _type == 10 then
|
||||
AddRecord(fightData)
|
||||
end
|
||||
BattleLogic.StartOrder()
|
||||
|
|
@ -265,9 +265,18 @@ function BattleMain.Execute(args, fightData, optionData)
|
|||
resultList.result = BattleLogic.Result
|
||||
end
|
||||
|
||||
resultList.duration = BattleLogic.CurFrame() / BattleLogic.GameFrameRate
|
||||
if _type == 10 then
|
||||
local playerDamage=0
|
||||
for k,v in pairs(BattleRecord)do
|
||||
if v.camp == 0 then
|
||||
playerDamage = playerDamage + v.damage
|
||||
end
|
||||
end
|
||||
resultList.duration = playerDamage --TODO:公会boss的持续时间传递的是我方总伤害值
|
||||
else
|
||||
resultList.duration = BattleLogic.CurFrame() / BattleLogic.GameFrameRate
|
||||
end
|
||||
|
||||
--print("result:"..BattleLogic.Result)
|
||||
|
||||
addBattleData()
|
||||
return resultList
|
||||
|
|
|
|||
|
|
@ -3,26 +3,19 @@ package com.ljsd.jieling.core.function;
|
|||
import com.ljsd.jieling.core.FunctionManager;
|
||||
import com.ljsd.jieling.logic.dao.TimeControllerOfFunction;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import config.SGuildBossConfig;
|
||||
import manager.STableManager;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
public class GuildBossFunction implements FunctionManager {
|
||||
@Override
|
||||
public void startAction(TimeControllerOfFunction timeControllerOfFunction) throws Exception {
|
||||
int times = timeControllerOfFunction.getTimes();
|
||||
Map<Integer, SGuildBossConfig> config = STableManager.getConfig(SGuildBossConfig.class);
|
||||
int id = times%config.size();
|
||||
if(id == 0){
|
||||
id = config.size();
|
||||
}
|
||||
GuildFightLogic.updateGuildBossInfo(config.get(id));
|
||||
|
||||
GuildFightLogic.updateGuildBossInfoByTimes(times);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeAction() throws Exception {
|
||||
GuildFightLogic.updateGuildBossInfo(null);
|
||||
GuildFightLogic.updateGuildBossInfoByTimes(-1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -131,6 +131,8 @@ public class RedisKey {
|
|||
public static final String RANDOM_CARD_RANK="RANDOM_CARD_RANK";
|
||||
public static final String RANDOM_CARD_PERFECT_RANK = "RANDOM_CARD_PERFECT_RANK";
|
||||
|
||||
public static final String GUILD_BOSS_RANK = "GUILD_BOSS_RANK";
|
||||
|
||||
public static final String FAMILY_ID = "FAMILY_ID";
|
||||
|
||||
public static final String FAMILY_JOIN = "FAMILY_JOIN";
|
||||
|
|
@ -157,6 +159,10 @@ public class RedisKey {
|
|||
public static final String FAMILY_FIGHT_TOTAL_EXP = "FAMILY_FIGHT_TOTAL_EXP";
|
||||
//公会战服务器准备就绪标识
|
||||
public static final String FAMILY_FIGHT_FINISH_MATCHING = "FAMILY_FIGHT_FINISH_MATCHING";
|
||||
//公会红包
|
||||
public static final String FAMILY_RED_PACKAGE = "FAMILY_RED_PACKAGE";
|
||||
//公会红包自增Id
|
||||
public static final String FAMILY_RED_PACKAGE_INCRE_ID = "FAMILY_RED_PACKAGE_INCRE_ID";
|
||||
//给用户发送邮件
|
||||
public static final String READY_TO_USER_MAIL = "READY_TO_USER_MAIL";
|
||||
//把用户踢下线
|
||||
|
|
@ -223,6 +229,8 @@ public class RedisKey {
|
|||
|
||||
public final static String PIDGIDTEMP = "PIDGIDTEMP";
|
||||
|
||||
public final static String GUILDBOSS_ARENA_RECORD = "GUILDBOSS_ARENA_RECORD";
|
||||
|
||||
|
||||
|
||||
public static Set<String> familyKey = new HashSet<>();
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import com.ljsd.GameApplication;
|
|||
import com.ljsd.common.mogodb.util.GlobalData;
|
||||
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
|
||||
import org.springframework.data.redis.RedisConnectionFailureException;
|
||||
import util.StringUtil;
|
||||
import util.TimeUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
|
@ -132,6 +133,15 @@ public class RedisUtil {
|
|||
return key == null ? null : redisTemplate.opsForValue().get(key);
|
||||
}
|
||||
|
||||
public <T> T get(String type,String key,Class<T> tClass) {
|
||||
String rkey = getKey(type, key);
|
||||
String s = redisTemplate.opsForValue().get(rkey);
|
||||
if(StringUtil.isEmpty(s)){
|
||||
return null;
|
||||
}
|
||||
return gson.fromJson(s,tClass);
|
||||
}
|
||||
|
||||
public Object getAndDelete(String key) {
|
||||
Object value = redisTemplate.opsForValue().get(key);
|
||||
del(key);
|
||||
|
|
@ -213,6 +223,11 @@ public class RedisUtil {
|
|||
}
|
||||
}
|
||||
|
||||
public <T> void set(String type, String rkey, T t) {
|
||||
String key = getKey(type, rkey);
|
||||
redisTemplate.opsForValue().set(key, gson.toJson(t));
|
||||
}
|
||||
|
||||
/**
|
||||
* 递增
|
||||
*
|
||||
|
|
@ -716,6 +731,21 @@ public class RedisUtil {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除集合中的左边第一个元素
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public Object lPop(String key){
|
||||
try {
|
||||
Object pop= redisTemplate.opsForList().leftPop(key);
|
||||
return pop;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//操作sortset
|
||||
public void zsetAddAall(String key, Set<ZSetOperations.TypedTuple<String>> items){
|
||||
|
|
|
|||
|
|
@ -101,8 +101,7 @@ public interface BIReason {
|
|||
|
||||
int CHAMPIION_BET_WIN_REWARD = 60 ; // 巅峰赛竞猜赢取
|
||||
|
||||
int GUILD_BOSS_FIGHT_BASE_REWARD = 61;//工会boss基础奖励
|
||||
int GUILD_BOSS_FIGHT_RANDOM_REWARD = 62;//工会boss随机奖励
|
||||
int GUILD_BOSS_FIGHT_REWARD = 61;//工会boss奖励
|
||||
|
||||
int EXPEDITION_BOX_REWARD = 63;//猎妖之路宝箱奖励
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class GetAllRedPackageHandler extends BaseHandler {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_GET_ALL_REDPACKAGE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void process(ISession iSession, PacketNetData netData) throws Exception {
|
||||
GuildLogic.getAllRedPackageInfo(iSession, MessageTypeProto.MessageType.J_GET_ALL_REDPACKAGE_INFO_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class RedPackageDetailHandler extends BaseHandler<Family.RedPackageDetailRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_GET_REDPACKAGE_DETAIL_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.RedPackageDetailRequest proto) throws Exception {
|
||||
GuildLogic.getRedPackageDetail(iSession,proto.getId(),MessageTypeProto.MessageType.J_GET_REDPACKAGE_DETAIL_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
package com.ljsd.jieling.handler.family;
|
||||
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
@Component
|
||||
public class RobFamilyRedPackageHandler extends BaseHandler<Family.RobRedPackageRequest> {
|
||||
@Override
|
||||
public MessageTypeProto.MessageType getMessageCode() {
|
||||
return MessageTypeProto.MessageType.J_ROB_REDPACKAGE_INFO_REQUEST;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processWithProto(ISession iSession, Family.RobRedPackageRequest proto) throws Exception {
|
||||
GuildLogic.robRedPackage(iSession,proto.getId(),MessageTypeProto.MessageType.J_ROB_REDPACKAGE_INFO_RESPONSE);
|
||||
}
|
||||
}
|
||||
|
|
@ -1081,8 +1081,8 @@ public class MapLogic {
|
|||
mapManager.setHighestTower(mapManager.getTower());
|
||||
AbstractRank towerRank = RankContext.getRankEnum(RankEnum.TOWER_RANK.getType());
|
||||
// TowerRankUtil.getRankNumber(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000))
|
||||
if(towerRank.getScore(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000))>towerRank.getScoreById(user.getId(),0)){
|
||||
towerRank.addRank(user.getId(),0,mapManager.getTower(),(int)mapManager.getCurrTowerTime()/1000);
|
||||
if(towerRank.getScore(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000))>towerRank.getScoreById(user.getId(),"")){
|
||||
towerRank.addRank(user.getId(),"",mapManager.getTower(),(int)mapManager.getCurrTowerTime()/1000);
|
||||
// RedisUtil.getInstence().zsetAddOne(RedisKey.getKey(RedisKey.TOWER_RANK,"",false),String.valueOf(user.getId()),TowerRankUtil.getRankNumber(mapManager.getTower(),(int)(mapManager.getCurrTowerTime()/1000)));
|
||||
}
|
||||
}
|
||||
|
|
@ -2122,7 +2122,7 @@ public class MapLogic {
|
|||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
|
||||
// String rankKey = RedisKey.getKey(RedisKey.MAINLEVEL_RANK, "", false);
|
||||
// RedisUtil.getInstence().zsetAddOne(rankKey, String.valueOf(user.getId()), sMainLevelConfig.getVirtureId());
|
||||
RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,0,sMainLevelConfig.getVirtureId());
|
||||
RankContext.getRankEnum(RankEnum.MAIN_LEVEL_RANK.getType()).addRank(uid,"",sMainLevelConfig.getVirtureId());
|
||||
}
|
||||
|
||||
// public void getMainLevelRankInfo(ISession session) throws Exception {
|
||||
|
|
@ -2330,7 +2330,7 @@ public class MapLogic {
|
|||
//排行榜
|
||||
// String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false);
|
||||
// RedisUtil.getInstence().zsetAddOneOffsetByTime(rankKey, String.valueOf(user.getId()), checkFightId);
|
||||
RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid,0,checkFightId);
|
||||
RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid,"",checkFightId);
|
||||
//归还水滴
|
||||
Map<Integer,Integer> itemMap = new HashMap<>(1);
|
||||
itemMap.put( Global.DROP,1);
|
||||
|
|
@ -2883,7 +2883,7 @@ public class MapLogic {
|
|||
// User user = UserManager.getUser(session.getUid());
|
||||
|
||||
int rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.TRIAL_RANKINGSHOWNUM);
|
||||
PlayerInfoProto.RankResponse rankResponse= RankContext.getRankEnum(type).getRank(session.getUid(),0,1, rankEndLine);
|
||||
PlayerInfoProto.RankResponse rankResponse= RankContext.getRankEnum(type).getRank(session.getUid(),"",1, rankEndLine);
|
||||
|
||||
|
||||
// Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.TOWER_RANK, "", 0, rankEndLine);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import com.ljsd.jieling.ktbeans.parmsBean.ParamEventBean;
|
|||
import com.ljsd.jieling.logic.dao.Item;
|
||||
import com.ljsd.jieling.logic.dao.PlayerManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import util.MathUtils;
|
||||
import config.SVipLevelConfig;
|
||||
import manager.STableManager;
|
||||
|
|
@ -257,10 +258,7 @@ public class MapManager extends MongoBase {
|
|||
if(recoveryItemInfo == null){
|
||||
return;
|
||||
}
|
||||
SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(user.getPlayerInfoManager().getVipLevel());
|
||||
Map<Integer, Integer> privilegeMap = sVipLevelConfig.getPrivilegeMap();
|
||||
Integer heroTimes = privilegeMap.get(recoveryItemInfo[3]);
|
||||
|
||||
Integer heroTimes = PlayerLogic.getInstance().getMaxCountByPrivilegeType(user,recoveryItemInfo[3]);
|
||||
int recoveryTimes = (updateTime - lastUpdateEnergyTime)/recoveryItemInfo[2];
|
||||
if(itemNum>=heroTimes){
|
||||
item.setEndingTime(updateTime);
|
||||
|
|
|
|||
|
|
@ -44,10 +44,10 @@ public class FourtyTwoBehavior extends BaseBehavior {
|
|||
AbstractRank towerRank = RankContext.getRankEnum(RankEnum.TOWER_RANK.getType());
|
||||
// Double zSetScore = RedisUtil.getInstence().getZSetScore(RedisKey.TOWER_RANK, "", String.valueOf(user.getId()));
|
||||
// TowerRankUtil.getRankNumber(mapManager.getTower(),(int)time/1000)
|
||||
if(towerRank.getScore(mapManager.getTower(),(int)time/1000)>towerRank.getScoreById(user.getId(),0)){
|
||||
if(towerRank.getScore(mapManager.getTower(),(int)time/1000)>towerRank.getScoreById(user.getId(),"")){
|
||||
// String key = RedisKey.getKey(RedisKey.TOWER_RANK,"",false);
|
||||
// RedisUtil.getInstence().zsetAddOne(key,String.valueOf(user.getId()),TowerRankUtil.getRankNumber(mapManager.getTower(),(int)time/1000));
|
||||
towerRank.addRank(user.getId(),0,mapManager.getTower(),(int)time/1000);
|
||||
towerRank.addRank(user.getId(),"",mapManager.getTower(),(int)time/1000);
|
||||
}
|
||||
}
|
||||
user.getUserMissionManager().onGameEvent(user, GameEvent.COPY_TOWER_LEVEL, mapManager.getTower());
|
||||
|
|
|
|||
|
|
@ -4,14 +4,11 @@ import com.ljsd.jieling.exception.ErrorCode;
|
|||
import com.ljsd.jieling.exception.ErrorCodeException;
|
||||
import com.ljsd.jieling.handler.BaseHandler;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.netty.cocdex.PacketNetData;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
import com.ljsd.jieling.protocols.MessageTypeProto;
|
||||
import com.ljsd.jieling.util.MessageUtil;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
|
|
@ -42,7 +39,7 @@ public class StartFightRequestHandler extends BaseHandler<FightInfoProto.FightSt
|
|||
// }
|
||||
// MapLogic.getInstance().startLevelDifficultyFight(iSession,fightId,teamId,type,MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
// }else if(type == 2){
|
||||
// MapLogic.getInstance().startFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
// MapLogic.getInstance().startBossFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
//
|
||||
// }else if(type == 3){
|
||||
// MapLogic.getInstance().startSuddlenlyFight(iSession,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
|
|
@ -69,7 +66,7 @@ public class StartFightRequestHandler extends BaseHandler<FightInfoProto.FightSt
|
|||
}else if(type == 6){
|
||||
MapLogic.getInstance().startMainLevelFight(iSession,fightId,teamId, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
} else if(type == 7){
|
||||
GuildFightLogic.startFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
GuildFightLogic.startBossFight(iSession, MessageTypeProto.MessageType.FIGHT_START_RESPONSE);
|
||||
}else {
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("type is wrong:" + type));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,7 +121,7 @@ public class QuickStartMonsterFighter extends BaseHandler<FightInfoProto.QuickSt
|
|||
//排行榜
|
||||
// String rankKey = RedisKey.getKey(RedisKey.MONSTER_ATTACK_RANK,"", false);
|
||||
// RedisUtil.getInstence().zsetAddOneOffsetByTime(rankKey, String.valueOf(user.getId()), fightId);
|
||||
RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid,0,fightId);
|
||||
RankContext.getRankEnum(RankEnum.MONSTER_ATTACK_RANK.getType()).addRank(uid,"",fightId);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sFloodConfig.getReward(), BIReason.MONSTERATTACK_REWARD);
|
||||
|
||||
FightInfoProto.QuickStartMonsterFightResponse builder = FightInfoProto.QuickStartMonsterFightResponse.newBuilder()
|
||||
|
|
|
|||
|
|
@ -13,6 +13,10 @@ import com.ljsd.jieling.logic.activity.ActivityLogic;
|
|||
import com.ljsd.jieling.logic.activity.FightMainEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.RemoveEventHeroHandler;
|
||||
import com.ljsd.jieling.logic.activity.UserLevelEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.HeroFiveStarGetEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.activity.eventhandler.BuyGoodsDirectHandler;
|
||||
import com.ljsd.jieling.logic.activity.eventhandler.HeroFiveStarGetEventHandler;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.championship.ChampionshipLogic;
|
||||
import com.ljsd.jieling.logic.dao.ExpeditionManager;
|
||||
|
|
@ -228,6 +232,9 @@ public class GlobalDataManaager implements IManager {
|
|||
MapLogic.getInstance().updateEndlessSeason(globalSystemControl.getTimeControllerOfFunctionMap().get(FunctionIdEnum.Endless.getFunctionType()).getTimes());
|
||||
MapLogic.setEndlessMapId(getEndleeMapIdByLevel());
|
||||
}
|
||||
if(globalSystemControl.getTimeControllerOfFunctionMap().containsKey(FunctionIdEnum.GuildBossFight.getFunctionType())){
|
||||
GuildFightLogic.updateGuildBossInfoByTimes(globalSystemControl.getTimeControllerOfFunctionMap().get(FunctionIdEnum.GuildBossFight.getFunctionType()).getTimes());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -240,6 +247,7 @@ public class GlobalDataManaager implements IManager {
|
|||
new UserLevelEventHandler();
|
||||
new RemoveEventHeroHandler();
|
||||
new FightMainEventHandler();
|
||||
new BuyGoodsDirectHandler();
|
||||
ChampionshipLogic.minuteCheck(true);
|
||||
} catch (Exception e) {
|
||||
LOGGER.error("e",e);
|
||||
|
|
@ -323,6 +331,7 @@ public class GlobalDataManaager implements IManager {
|
|||
FriendLogic.getInstance().refreshState(session);
|
||||
|
||||
PlayerLogic.getInstance().sendTimingMail(user);
|
||||
user.getGuildMyInfo().setLastHurt(0);
|
||||
|
||||
if(fBuilder!=null){
|
||||
fBuilder.setSignInInfo(CommonProto.SignInInfo.newBuilder().setDays(user.getPlayerInfoManager().getSign()+1).setState(user.getPlayerInfoManager().getSignTotay()).build());
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class ForceRankActivity extends AbstractActivity {
|
|||
return;
|
||||
}
|
||||
UserForceChangeEvent forceChangeEvent = (UserForceChangeEvent) event;
|
||||
RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).addRank(forceChangeEvent.getUid(),id,forceChangeEvent.getForce());
|
||||
RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).addRank(forceChangeEvent.getUid(),String.valueOf(id),forceChangeEvent.getForce());
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +60,7 @@ class ForceRankActivity extends AbstractActivity {
|
|||
activityMission.setValue(count);
|
||||
// String key = RedisKey.getKey(RedisKey.FORCE_RANK, "", false);
|
||||
// RedisUtil.getInstence().zsetAddOne(key, String.valueOf(user.getId()), count);
|
||||
RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).addRank(user.getId(),id,count);
|
||||
RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).addRank(user.getId(),String.valueOf(id),count);
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +89,7 @@ class ForceRankActivity extends AbstractActivity {
|
|||
}
|
||||
|
||||
// Set<ZSetOperations.TypedTuple<String>> rankInfo = RedisUtil.getInstence().getZsetreverseRangeWithScores(RedisKey.FORCE_RANK, "", 0, maxRank-1);
|
||||
Set<ZSetOperations.TypedTuple<String>> rankInfo = RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).getRankByKey(id,0,maxRank - 1);
|
||||
Set<ZSetOperations.TypedTuple<String>> rankInfo = RankContext.getRankEnum(RankEnum.FORCE_RANK.getType()).getRankByKey(String.valueOf(id),0,maxRank - 1);
|
||||
int rank = 1;
|
||||
int nowTime = (int) (TimeUtils.now() / 1000);
|
||||
for (ZSetOperations.TypedTuple<String> item : rankInfo) {
|
||||
|
|
|
|||
|
|
@ -53,14 +53,14 @@ public class LimitRandomCardActivity extends AbstractActivity {
|
|||
return;
|
||||
}
|
||||
AbstractRank randomRank= RankContext.getRankEnum(RankEnum.RANDOM_CARD_RANK.getType());
|
||||
int scoreById = Double.valueOf(randomRank.getScoreById(((RandomCardEvent) event).getUid(),id)).intValue();
|
||||
int scoreById = Double.valueOf(randomRank.getScoreById(((RandomCardEvent) event).getUid(),String.valueOf(id))).intValue();
|
||||
if(scoreById==-1){
|
||||
scoreById=0;
|
||||
}
|
||||
randomRank.addRank(cardEvent.getUid(),id,scoreById+cardEvent.getScore());
|
||||
randomRank.addRank(cardEvent.getUid(),String.valueOf(id),scoreById+cardEvent.getScore());
|
||||
Predicate<int[]> pre = a-> (SCHero.getHeroByPieceId(a[0])!=null&&SCHero.getHeroByPieceId(a[0]).getNatural()>=13);
|
||||
|
||||
Consumer<int[]> consumer = a->RankContext.getRankEnum(RankEnum.RANDOM_CARD_PERFECT_RANK.getType()).addRank(cardEvent.getUid(),id, TimeUtils.now()/1000,a[0]);
|
||||
Consumer<int[]> consumer = a->RankContext.getRankEnum(RankEnum.RANDOM_CARD_PERFECT_RANK.getType()).addRank(cardEvent.getUid(),String.valueOf(id), TimeUtils.now()/1000,a[0]);
|
||||
Stream.of(cardEvent.getHeros()).filter(pre).forEach(consumer);
|
||||
update(UserManager.getUser(cardEvent.getUid()),cardEvent.getScore());
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.logic.activity.event;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class BuyGoodsDirectEvent implements IEvent{
|
||||
private int uid;
|
||||
private int goodsId;
|
||||
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getGoodsId() {
|
||||
return goodsId;
|
||||
}
|
||||
|
||||
public void setGoodsId(int goodsId) {
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
|
||||
public BuyGoodsDirectEvent(int uid,int goodsId) {
|
||||
this.uid = uid;
|
||||
this.goodsId = goodsId;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
package com.ljsd.jieling.logic.activity.eventhandler;
|
||||
|
||||
import com.ljsd.jieling.logic.activity.IEventHandler;
|
||||
import com.ljsd.jieling.logic.activity.event.BuyGoodsDirectEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.IEvent;
|
||||
import com.ljsd.jieling.logic.activity.event.Poster;
|
||||
import com.ljsd.jieling.logic.family.GuildLogic;
|
||||
import config.SGuildRedPackConfig;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class BuyGoodsDirectHandler implements IEventHandler{
|
||||
public BuyGoodsDirectHandler() {
|
||||
Poster.getPoster().listenEvent(this,BuyGoodsDirectEvent.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEvent(IEvent event) throws Exception {
|
||||
if (!(event instanceof BuyGoodsDirectEvent))
|
||||
return;
|
||||
BuyGoodsDirectEvent directEvent = (BuyGoodsDirectEvent) event;
|
||||
if(!SGuildRedPackConfig.sGuildRedPackByGoodsId.containsKey(directEvent.getGoodsId())){
|
||||
return;
|
||||
}
|
||||
SGuildRedPackConfig sGuildRedPackConfig = SGuildRedPackConfig.sGuildRedPackByGoodsId.get(directEvent.getGoodsId());
|
||||
GuildLogic.sendRedPackage(directEvent.getUid(),sGuildRedPackConfig.getId());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -589,7 +589,8 @@ public class ArenaLogic {
|
|||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.CHAMPION_ARENA_RECORD,"", fightId, ArenaRecord.class);
|
||||
}else if(type == 1){
|
||||
arenaRecord = RedisUtil.getInstence().getMapEntry(RedisKey.ARENA_RRECORD, Integer.toString(uid), fightId, ArenaRecord.class);
|
||||
|
||||
}else if(type == 3){
|
||||
arenaRecord = RedisUtil.getInstence().get(RedisKey.GUILDBOSS_ARENA_RECORD, fightId, ArenaRecord.class);
|
||||
}
|
||||
if(arenaRecord == null){
|
||||
throw new ErrorCodeException(ErrorCode.newDefineCode("arena_rrecord null"));
|
||||
|
|
|
|||
|
|
@ -350,6 +350,7 @@ public class PlayerManager extends MongoBase {
|
|||
maxTime = (int)(TimeUtils.now()/1000+config.getContinueTime());
|
||||
}
|
||||
}
|
||||
maxTime = (int)(TimeUtils.getLastHour(maxTime*1000,5)/1000);
|
||||
vipInfo.put(privilageId,new VipInfo(0,maxTime));
|
||||
updateString("vipInfo", vipInfo);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/8
|
||||
* @discribe
|
||||
*/
|
||||
public class AcceptRedInfo {
|
||||
public int uid;
|
||||
public int count;
|
||||
public int itemId;
|
||||
public int time;
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getCount() {
|
||||
return count;
|
||||
}
|
||||
|
||||
public void setCount(int count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
public int getItemId() {
|
||||
return itemId;
|
||||
}
|
||||
|
||||
public void setItemId(int itemId) {
|
||||
this.itemId = itemId;
|
||||
}
|
||||
|
||||
public int getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(int time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public AcceptRedInfo(int uid, int itemId,int count, int time) {
|
||||
this.uid = uid;
|
||||
this.itemId = itemId;
|
||||
this.count = count;
|
||||
this.time = time;
|
||||
}
|
||||
}
|
||||
|
|
@ -27,6 +27,8 @@ import com.ljsd.jieling.logic.hero.HeroLogic;
|
|||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.mission.GameEvent;
|
||||
import com.ljsd.jieling.logic.player.PlayerLogic;
|
||||
import com.ljsd.jieling.logic.rank.RankEnum;
|
||||
import com.ljsd.jieling.logic.rank.rankImpl.GuildBossRank;
|
||||
import com.ljsd.jieling.network.session.ISession;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.Family;
|
||||
|
|
@ -63,6 +65,7 @@ public class GuildFightLogic {
|
|||
|
||||
|
||||
private static SGuildBossConfig curSGuildBossConfig; // 为null代表关闭
|
||||
public static int bossSeason;
|
||||
|
||||
public static int getStatus() {
|
||||
return status;
|
||||
|
|
@ -1041,7 +1044,7 @@ public class GuildFightLogic {
|
|||
|
||||
}
|
||||
|
||||
public static void startFight(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
public static void startBossFight(ISession session, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
if(curSGuildBossConfig == null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
|
|
@ -1062,9 +1065,9 @@ public class GuildFightLogic {
|
|||
String fightInfo =Integer.toString(monsterId);
|
||||
String key = RedisKey.getKey(RedisKey.GUILD_MONSTER_INFO, String.valueOf(uid), false);
|
||||
RedisUtil.getInstence().set(key, fightInfo, -1);
|
||||
//扣除预先道具
|
||||
|
||||
FightInfoProto.FightStartResponse.Builder fightStartResponse = FightInfoProto.FightStartResponse.newBuilder();
|
||||
BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.GuildBossFight,monsterId, teamId, 90, fightStartResponse, RedisKey.GUILD_MONSTER_FIGHT);
|
||||
BehaviorUtil.getLevelDifficultyifficuFightInfo(user, FightType.GuildBossFight,monsterId, teamId, SGuildSetting.sGuildSetting.getBossTime(), fightStartResponse, RedisKey.GUILD_MONSTER_FIGHT);
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightStartResponse.build(), true);
|
||||
|
||||
}
|
||||
|
|
@ -1079,24 +1082,32 @@ public class GuildFightLogic {
|
|||
LOGGER.info("endFight() uid=>{} fightKey={},fightId={} fightInfos == null", uid, fightKey);
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, 90,frames, GameFightType.GuildBossFight);
|
||||
FightEvent fightEvent = new FightEvent(uid, -1, SGuildSetting.sGuildSetting.getBossTime(),frames, GameFightType.GuildBossFight);
|
||||
FightResult fightResult = FightDispatcher.dispatcher(fightEvent);
|
||||
PlayerLogic.getInstance().checkAndUpdate(user, VipPrivilegeType.GUILD_BOSS_CHALLENGE_TIMES, 1);
|
||||
//校验结果码 1:胜利
|
||||
int[] checkResult = fightResult.getCheckResult();
|
||||
int myHurt = 1000;
|
||||
int myHurt = fightResult.getCheckResult()[1];
|
||||
if(myHurt>user.getGuildMyInfo().getMaxBossHurt()){
|
||||
user.getGuildMyInfo().setMaxBossHurt(myHurt);
|
||||
}
|
||||
if(myHurt>user.getGuildMyInfo().getLastHurt()){
|
||||
//排行榜更新
|
||||
String rkey = user.getPlayerInfoManager().getGuildId() + RedisKey.Delimiter_colon + bossSeason;
|
||||
double scoreById = RankEnum.toRank(RankEnum.GUILD_BOSS_RANK.getType()).getScoreById(uid, rkey);
|
||||
if(myHurt>scoreById){
|
||||
RankEnum.toRank(RankEnum.GUILD_BOSS_RANK.getType()).addRank(uid,rkey,myHurt);
|
||||
ArenaRecord arenaRecord = new ArenaRecord();
|
||||
arenaRecord.setFightData(fightResult.getFightData().toByteArray());
|
||||
RedisUtil.getInstence().set(RedisKey.GUILDBOSS_ARENA_RECORD, Integer.toString(uid),arenaRecord);
|
||||
}
|
||||
}
|
||||
user.getGuildMyInfo().setLastHurt(myHurt);
|
||||
SGuildBossRewardConfig sGuildBossRewardConfig = SGuildBossRewardConfig.getIndexByHurt(myHurt);
|
||||
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sGuildBossRewardConfig.getReward(), 1, 0, BIReason.GUILD_BOSS_FIGHT_BASE_REWARD);
|
||||
CommonProto.Drop.Builder randomDrop = ItemUtil.drop(user, sGuildBossRewardConfig.getReward(), 1, 0, BIReason.GUILD_BOSS_FIGHT_RANDOM_REWARD);
|
||||
CommonProto.Drop.Builder drop = ItemUtil.drop(user, sGuildBossRewardConfig.getReward(), 1, 0, BIReason.GUILD_BOSS_FIGHT_REWARD);
|
||||
|
||||
FightInfoProto.FightEndResponse.Builder fightEndResponse = FightInfoProto.FightEndResponse.newBuilder();
|
||||
fightEndResponse.setEnventDrop(drop);
|
||||
fightEndResponse.setMissionDrop(randomDrop);
|
||||
fightEndResponse.setEssenceValue(myHurt);
|
||||
fightEndResponse.build();
|
||||
MessageUtil.sendMessage(session, 1, messageType.getNumber(), fightEndResponse.build(), true);
|
||||
|
|
@ -1104,8 +1115,71 @@ public class GuildFightLogic {
|
|||
|
||||
|
||||
|
||||
public static void updateGuildBossInfo(SGuildBossConfig sGuildBossConfig){
|
||||
curSGuildBossConfig = sGuildBossConfig;
|
||||
public static void updateGuildBossInfoByTimes(int times) {
|
||||
if(times == -1){
|
||||
ThreadManager.getScheduledExecutor().execute(()->{
|
||||
try {
|
||||
sendBossFightReward(bossSeason);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
bossSeason = times;
|
||||
return;
|
||||
}
|
||||
Map<Integer, SGuildBossConfig> config = STableManager.getConfig(SGuildBossConfig.class);
|
||||
int id = times%config.size();
|
||||
if(id == 0){
|
||||
id = config.size();
|
||||
}
|
||||
bossSeason = times;
|
||||
curSGuildBossConfig = config.get(id);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void sendBossFightReward( int season) throws Exception {
|
||||
String title= SErrorCodeEerverConfig.getI18NMessage("arena_daily_reward_title");;
|
||||
String content = SErrorCodeEerverConfig.getI18NMessage("arena_season_reward_title");;
|
||||
Map<Integer, GuildInfo> guildInfoMap = GuilidManager.guildInfoMap;
|
||||
int now = (int)(TimeUtils.now()/1000);
|
||||
float[][] bossReward = SGuildSetting.sGuildSetting.getBossReward();
|
||||
List<String> delKeys = new ArrayList<>();
|
||||
for(GuildInfo guildInfo : guildInfoMap.values()){
|
||||
int guildId = guildInfo.getId();
|
||||
String rkey =guildId + RedisKey.Delimiter_colon + season;
|
||||
Set<ZSetOperations.TypedTuple<String>> bossHurtRankInfo = RankEnum.toRank(RankEnum.GUILD_BOSS_RANK.getType()).getRankByKey(rkey, 0, 1);
|
||||
|
||||
if(bossHurtRankInfo==null || bossHurtRankInfo.isEmpty()){
|
||||
continue;
|
||||
}
|
||||
int maxHurt = bossHurtRankInfo.iterator().next().getScore().intValue();
|
||||
int[][] mineReward = new int[bossReward.length][];
|
||||
int j=0;
|
||||
for(int i=0;i<bossReward.length;i++){
|
||||
int itemNum = (int) (bossReward[i][1] * maxHurt);
|
||||
if(itemNum==0){
|
||||
continue;
|
||||
}
|
||||
mineReward[j] = new int[2];
|
||||
mineReward[j][0] =(int)bossReward[i][0];
|
||||
mineReward[j++][1] =itemNum;
|
||||
}
|
||||
String rewardByRank = StringUtil.parseArrayToString(mineReward);
|
||||
Map<Integer, Set<Integer>> members = guildInfo.getMembers();
|
||||
Iterator<Set<Integer>> iterator = members.values().iterator();
|
||||
while (iterator.hasNext()){
|
||||
Set<Integer> uids = iterator.next();
|
||||
for(Integer uid : uids){
|
||||
MailLogic.getInstance().sendMail(uid,title,content,rewardByRank,now, Global.MAIL_EFFECTIVE_TIME);
|
||||
}
|
||||
}
|
||||
delKeys.add( RankEnum.toRank(RankEnum.GUILD_BOSS_RANK.getType()).getRedisKey() + rkey);
|
||||
}
|
||||
MongoUtil.getLjsdMongoTemplate().lastUpdate();
|
||||
RedisUtil.getInstence().del(delKeys.toArray(new String[0]));
|
||||
|
||||
}
|
||||
|
||||
public static SGuildBossConfig getCurSGuildBossConfig() {
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import com.google.gson.Gson;
|
||||
import com.google.protobuf.GeneratedMessage;
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
|
|
@ -26,6 +27,7 @@ import com.ljsd.jieling.protocols.MessageTypeProto;
|
|||
import com.ljsd.jieling.util.*;
|
||||
import config.SErrorCodeEerverConfig;
|
||||
import config.SGuildLevelConfig;
|
||||
import config.SGuildRedPackConfig;
|
||||
import config.SGuildSetting;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -38,6 +40,7 @@ import java.util.*;
|
|||
|
||||
public class GuildLogic {
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(GuildLogic.class);
|
||||
private static Gson gson = new Gson();
|
||||
|
||||
|
||||
public static int getMemberType(int targetUid, Map<Integer, Set<Integer>> members ){
|
||||
|
|
@ -978,4 +981,108 @@ public class GuildLogic {
|
|||
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_INFO,"", String.valueOf(playerInfoManager.getGuildId()),new GuildCache(GameApplication.serverId,iconId,GuilidManager.guildInfoMap.get(playerInfoManager.getGuildId()).getLevel(),GuilidManager.guildInfoMap.get(playerInfoManager.getGuildId()).getName()));
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),null,true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发公会红包
|
||||
* @param redId
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void sendRedPackage(int uid,int redId) throws Exception {
|
||||
User user = UserManager.getUser(uid);
|
||||
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(redId);
|
||||
if(config==null){
|
||||
return;
|
||||
}
|
||||
long[] generate = HongBaoAlgorithm.generate(config.getTotalMoney()[1], config.getNum(), config.getMaxPercent(), config.getMinPercent());
|
||||
if(generate==null){
|
||||
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
|
||||
}
|
||||
long increment = RedisUtil.getInstence().increment(RedisKey.getKey(RedisKey.FAMILY_RED_PACKAGE_INCRE_ID, "", false));
|
||||
RedisUtil.getInstence().putMapEntry(RedisKey.FAMILY_RED_PACKAGE,String.valueOf(user.getPlayerInfoManager().getGuildId()),String.valueOf(increment),new RedPackage(redId,uid,(int)(TimeUtils.now()/1000),config.getLastTime()));
|
||||
List<String> reward = new ArrayList<>();
|
||||
for(Long count:generate){
|
||||
reward.add(String.valueOf(count));
|
||||
}
|
||||
RedisUtil.getInstence().lSet(RedisKey.getKey("red_remain_list",String.valueOf(increment),false),reward,config.getLastTime());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取所有红包信息
|
||||
* @param session
|
||||
* @param messageType
|
||||
*/
|
||||
public static void getAllRedPackageInfo(ISession session,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
User user = UserManager.getUser(session.getUid());
|
||||
int guildId = user.getPlayerInfoManager().getGuildId();
|
||||
Map<String, RedPackage> redPackageMap = RedisUtil.getInstence().getMapValues(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(guildId), String.class, RedPackage.class);
|
||||
Family.GetAllRedPackageResponse.Builder builder = Family.GetAllRedPackageResponse.newBuilder();
|
||||
List<String> removeId = new ArrayList<>();
|
||||
for(Map.Entry<String, RedPackage> entry:redPackageMap.entrySet()){
|
||||
if(TimeUtils.now()/1000>entry.getValue().getEffectTime()+entry.getValue().getSendTime()){
|
||||
removeId.add(entry.getKey());
|
||||
continue;
|
||||
}
|
||||
CommonProto.RedPackage.Builder redPackage = CommonProto.RedPackage.newBuilder();
|
||||
redPackage.setGetCount(RedisUtil.getInstence().getMapValues("red_already_list", entry.getKey(),int.class,AcceptRedInfo.class).size());
|
||||
AcceptRedInfo already = RedisUtil.getInstence().getMapEntry("red_already_list", entry.getKey(), String.valueOf(session.getUid()), AcceptRedInfo.class);
|
||||
redPackage.setIsGet(already==null?0:1);
|
||||
redPackage.setRedId(Integer.parseInt(entry.getKey()));
|
||||
redPackage.setUserName(UserManager.getUser(entry.getValue().getUid()).getPlayerInfoManager().getNickName());
|
||||
redPackage.setRedType(entry.getValue().getTypeId());
|
||||
builder.addInfo(redPackage);
|
||||
}
|
||||
for(String id:removeId){
|
||||
RedisUtil.getInstence().removeMapEntrys(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(guildId),id);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 抢红包
|
||||
*/
|
||||
public static void robRedPackage(ISession session, int redId, MessageTypeProto.MessageType messageType) throws Exception{
|
||||
int uid = session.getUid();
|
||||
Object redPackage = RedisUtil.getInstence().lPop(RedisKey.getKey("red_remain_list", String.valueOf(redId),false));
|
||||
Family.RobRedPackageResponse.Builder builder = Family.RobRedPackageResponse.newBuilder();
|
||||
if(redPackage!=null){
|
||||
builder.setIsSuccess(1);
|
||||
RedPackage packInfo = RedisUtil.getInstence().getMapValue(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(UserManager.getUser(uid).getPlayerInfoManager().getGuildId()), String.valueOf(redId), RedPackage.class);
|
||||
SGuildRedPackConfig config = SGuildRedPackConfig.sGuildRedPackConfigMap.get(packInfo.getTypeId());
|
||||
RedisUtil.getInstence().putMapEntry("red_already_list", String.valueOf(redId),String.valueOf(uid),new AcceptRedInfo(uid,config.getTotalMoney()[0],Integer.parseInt(String.valueOf(redPackage)),(int)(TimeUtils.now()/1000)));
|
||||
}
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查看红包详情
|
||||
* @param session
|
||||
* @param redId
|
||||
* @param messageType
|
||||
*/
|
||||
public static void getRedPackageDetail(ISession session,int redId, MessageTypeProto.MessageType messageType) throws Exception {
|
||||
Map<Integer, AcceptRedInfo> alreadyList = RedisUtil.getInstence().getMapValues("red_already_list", String.valueOf(redId), Integer.class, AcceptRedInfo.class);
|
||||
Family.RedPackageDetailResponse.Builder builder = Family.RedPackageDetailResponse.newBuilder();
|
||||
if(!alreadyList.isEmpty()) {
|
||||
for(Map.Entry<Integer, AcceptRedInfo> already:alreadyList.entrySet()){
|
||||
PlayerManager playerInfoManager = UserManager.getUser(already.getValue().getUid()).getPlayerInfoManager();
|
||||
CommonProto.RedOneDetail.Builder detail= CommonProto.RedOneDetail.newBuilder()
|
||||
.setUid(already.getValue().getUid())
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame())
|
||||
.setName(playerInfoManager.getNickName())
|
||||
.setTime(already.getValue().getTime())
|
||||
.setItemId(already.getValue().getItemId())
|
||||
.setCount(already.getValue().getCount());
|
||||
builder.addInfo(detail.build());
|
||||
}
|
||||
}
|
||||
RedPackage packInfo = RedisUtil.getInstence().getMapValue(RedisKey.FAMILY_RED_PACKAGE, String.valueOf(UserManager.getUser(session.getUid()).getPlayerInfoManager().getGuildId()), String.valueOf(redId), RedPackage.class);
|
||||
PlayerManager playerInfoManager = UserManager.getUser(packInfo.getUid()).getPlayerInfoManager();
|
||||
builder.setSendName(playerInfoManager.getNickName())
|
||||
.setHead(playerInfoManager.getHead())
|
||||
.setHeadFrame(playerInfoManager.getHeadFrame())
|
||||
.setRemainTime(packInfo.getSendTime()+packInfo.getEffectTime()-(int)(TimeUtils.now()/1000));
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),builder.build(),true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,133 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class HongBaoAlgorithm {
|
||||
static Random random = new Random();
|
||||
static {
|
||||
random.setSeed(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
long max = 3000;
|
||||
long min = 300;
|
||||
|
||||
long[] result = HongBaoAlgorithm.generate(6480, 20, max, min);
|
||||
long total = 0;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
System.out.println("result[" + i + "]:" + result[i]);
|
||||
System.out.println(result[i]);
|
||||
total += result[i];
|
||||
}
|
||||
//检查生成的红包的总额是否正确
|
||||
System.out.println("total:" + total);
|
||||
|
||||
//统计每个钱数的红包数量,检查是否接近正态分布
|
||||
int count[] = new int[(int) max + 1];
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
count[(int) result[i]] += 1;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count.length; i++) {
|
||||
System.out.println("" + i + " " + count[i]);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 生产min和max之间的随机数,但是概率不是平均的,从min到max方向概率逐渐加大。
|
||||
* 先平方,然后产生一个平方值范围内的随机数,再开方,这样就产生了一种“膨胀”再“收缩”的效果。
|
||||
*
|
||||
* @param min
|
||||
* @param max
|
||||
* @return
|
||||
*/
|
||||
static long xRandom(long min, long max) {
|
||||
return sqrt(nextLong(sqr(max - min)));
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param total
|
||||
* 红包总额
|
||||
* @param count
|
||||
* 红包个数
|
||||
* @param max
|
||||
* 每个小红包的最大额
|
||||
* @param min
|
||||
* 每个小红包的最小额
|
||||
* @return 存放生成的每个小红包的值的数组
|
||||
*/
|
||||
public static long[] generate(long total, int count, long max, long min) {
|
||||
if(total/count>max||total/count<min){
|
||||
return null;
|
||||
}
|
||||
long[] result = new long[count];
|
||||
|
||||
long average = total / count;
|
||||
|
||||
long a = average - min;
|
||||
long b = max - min;
|
||||
|
||||
//
|
||||
//这样的随机数的概率实际改变了,产生大数的可能性要比产生小数的概率要小。
|
||||
//这样就实现了大部分红包的值在平均数附近。大红包和小红包比较少。
|
||||
long range1 = sqr(average - min);
|
||||
long range2 = sqr(max - average);
|
||||
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
//因为小红包的数量通常是要比大红包的数量要多的,因为这里的概率要调换过来。
|
||||
//当随机数>平均值,则产生小红包
|
||||
//当随机数<平均值,则产生大红包
|
||||
if (nextLong(min, max) > average) {
|
||||
// 在平均线上减钱
|
||||
// long temp = min + sqrt(nextLong(range1));
|
||||
long temp = min + xRandom(min, average);
|
||||
result[i] = temp;
|
||||
total -= temp;
|
||||
} else {
|
||||
// 在平均线上加钱
|
||||
// long temp = max - sqrt(nextLong(range2));
|
||||
long temp = max - xRandom(average, max);
|
||||
result[i] = temp;
|
||||
total -= temp;
|
||||
}
|
||||
}
|
||||
// 如果还有余钱,则尝试加到小红包里,如果加不进去,则尝试下一个。
|
||||
while (total > 0) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (total > 0 && result[i] < max) {
|
||||
result[i]++;
|
||||
total--;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 如果钱是负数了,还得从已生成的小红包中抽取回来
|
||||
while (total < 0) {
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (total < 0 && result[i] > min) {
|
||||
result[i]--;
|
||||
total++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
static long sqrt(long n) {
|
||||
// 改进为查表?
|
||||
return (long) Math.sqrt(n);
|
||||
}
|
||||
|
||||
static long sqr(long n) {
|
||||
// 查表快,还是直接算快?
|
||||
return n * n;
|
||||
}
|
||||
|
||||
static long nextLong(long n) {
|
||||
return random.nextInt((int) n);
|
||||
}
|
||||
|
||||
static long nextLong(long min, long max) {
|
||||
return random.nextInt((int) (max - min + 1)) + min;
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,61 @@
|
|||
package com.ljsd.jieling.logic.family;
|
||||
|
||||
/**
|
||||
* @author lvxinran
|
||||
* @date 2020/1/7
|
||||
* @discribe
|
||||
*/
|
||||
public class RedPackage {
|
||||
|
||||
private int typeId;
|
||||
|
||||
private int uid;
|
||||
|
||||
private int sendTime;
|
||||
|
||||
private int effectTime;
|
||||
|
||||
|
||||
|
||||
public int getTypeId() {
|
||||
return typeId;
|
||||
}
|
||||
|
||||
public void setTypeId(int typeId) {
|
||||
this.typeId = typeId;
|
||||
}
|
||||
|
||||
public int getUid() {
|
||||
return uid;
|
||||
}
|
||||
|
||||
public void setUid(int uid) {
|
||||
this.uid = uid;
|
||||
}
|
||||
|
||||
public int getSendTime() {
|
||||
return sendTime;
|
||||
}
|
||||
|
||||
public void setSendTime(int sendTime) {
|
||||
this.sendTime = sendTime;
|
||||
}
|
||||
|
||||
public int getEffectTime() {
|
||||
return effectTime;
|
||||
}
|
||||
|
||||
public void setEffectTime(int effectTime) {
|
||||
this.effectTime = effectTime;
|
||||
}
|
||||
|
||||
public RedPackage(int typeId, int uid, int sendTime, int effectTime) {
|
||||
this.typeId = typeId;
|
||||
this.uid = uid;
|
||||
this.sendTime = sendTime;
|
||||
this.effectTime = effectTime;
|
||||
}
|
||||
|
||||
public RedPackage() {
|
||||
}
|
||||
}
|
||||
|
|
@ -128,7 +128,7 @@ public class FightUtil {
|
|||
}
|
||||
|
||||
|
||||
public static int[] getFightFromRedis(FightEvent fightEvent) throws Exception {
|
||||
public static FightResult getFightFromRedis(FightEvent fightEvent) throws Exception {
|
||||
GameFightType fightType = fightEvent.getFightType();
|
||||
int playerId = fightEvent.getAttackUid();
|
||||
String frames = fightEvent.getFrames();
|
||||
|
|
@ -148,7 +148,13 @@ public class FightUtil {
|
|||
List<CommonProto.FightTeamInfo> monsterTeamList = BehaviorUtil.getFightTeamInfos(valueMap);
|
||||
LuaValue getFightData = FightDataUtil.getFinalFightData(fightTeamInfo, monsterTeamList);
|
||||
LuaValue getOptionData = FightDataUtil.getOptionData(frames);
|
||||
return CheckFight.getInstance().checkFight(seed,fightTime, getFightData, getOptionData,fightType.getFightType());
|
||||
|
||||
FightResult.Builder fightResult = FightResult.newBuilder();
|
||||
int[] fightResultInfo = CheckFight.getInstance().checkFight(seed, fightTime, getFightData, getOptionData, fightType.getFightType());
|
||||
fightResult.setCheckResult(fightResultInfo);
|
||||
CommonProto.FightData fightData = CommonProto.FightData.newBuilder().setFightType(fightType.getFightType().getType()).setHeroFightInfos(fightTeamInfo).addAllMonsterList(monsterTeamList).setFightSeed(seed).setFightMaxTime(fightTime).build();
|
||||
fightResult.setFightData(fightData);
|
||||
return fightResult.build();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ public class DefaultOfRedisCacheFightHandler implements IFightEventProcesor {
|
|||
|
||||
@Override
|
||||
public FightResult process(FightEvent fightEvent) throws Exception {
|
||||
int[] fightResult = FightUtil.getFightFromRedis(fightEvent);
|
||||
return FightResult.newBuilder().setCheckResult(fightResult).build();
|
||||
return FightUtil.getFightFromRedis(fightEvent);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -305,23 +305,21 @@ public class PlayerLogic {
|
|||
}
|
||||
|
||||
public void sendVipDailyOrLevlUpReward(User user, int vipLevel,int reson) throws Exception {
|
||||
SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel);
|
||||
Map<Integer, Integer> privilegeMap = sVipLevelConfig.getPrivilegeMap();
|
||||
int[][] dailyGifts = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getDailyGift();
|
||||
for(int[] dailyGift : dailyGifts){
|
||||
if(privilegeMap!=null&&privilegeMap.containsKey(dailyGift[1])){
|
||||
int num = PlayerLogic.getInstance().getMaxCountByPrivilegeType(user, dailyGift[1]);
|
||||
if(num>0){
|
||||
Item item = user.getItemManager().getItem(dailyGift[0]);
|
||||
Integer num = privilegeMap.get(dailyGift[1]);
|
||||
int hadNum=0;
|
||||
if(item!=null){
|
||||
hadNum=item.getItemNum();
|
||||
}
|
||||
if(hadNum<num){
|
||||
Map<Integer,Integer> itemMap = new HashMap<>(1);
|
||||
if(reson == BIReason.VIP_LEVEL_REWARD && vipLevel!=0){
|
||||
/* if(reson == BIReason.VIP_LEVEL_REWARD && vipLevel!=0){
|
||||
Map<Integer, Integer> privilegePreMap = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel - 1).getPrivilegeMap();
|
||||
hadNum = privilegePreMap.get(dailyGift[1]);
|
||||
}
|
||||
}*/
|
||||
itemMap.put(dailyGift[0],num-hadNum);
|
||||
ItemUtil.addItem(user,itemMap,null, reson);
|
||||
}
|
||||
|
|
@ -781,7 +779,7 @@ public class PlayerLogic {
|
|||
}
|
||||
return false;
|
||||
}
|
||||
public int getMaxCountByPrivilege(User user,int privilegeId){
|
||||
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 = 0;
|
||||
|
|
|
|||
|
|
@ -9,9 +9,9 @@ import com.ljsd.jieling.protocols.PlayerInfoProto;
|
|||
*/
|
||||
public interface IRank {
|
||||
|
||||
PlayerInfoProto.RankResponse getRank(int uid,int activityId,int page,int rankEndLine) throws Exception ;
|
||||
PlayerInfoProto.RankResponse getRank(int uid,String rkey,int page,int rankEndLine) throws Exception ;
|
||||
|
||||
void addRank(int uid,int activityId,double... data);
|
||||
void addRank(int uid,String rkey,double... data);
|
||||
|
||||
int getParam1(double data);
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,8 @@ public enum RankEnum {
|
|||
MAIN_LEVEL_RANK(3,RedisKey.MAIN_LEVEL_RANK, MainLevelRank::new),//param1:通关关卡Id param2:无 param3:无
|
||||
MONSTER_ATTACK_RANK(4,RedisKey.MONSTER_ATTACK_RANK,MonsterAttackRank::new),//param1:兽潮层数 param2:无 param3:无
|
||||
RANDOM_CARD_RANK(10,RedisKey.RANDOM_CARD_RANK, RandomCardRank::new),//param1:抽取积分 param2:无 param3:无
|
||||
RANDOM_CARD_PERFECT_RANK(11,RedisKey.RANDOM_CARD_PERFECT_RANK,RandomCardPerfectRank::new)//param1:时间 param2:英雄tempId param3:uid
|
||||
RANDOM_CARD_PERFECT_RANK(11,RedisKey.RANDOM_CARD_PERFECT_RANK,RandomCardPerfectRank::new),//param1:时间 param2:英雄tempId param3:uid
|
||||
GUILD_BOSS_RANK(12,RedisKey.GUILD_BOSS_RANK,GuildBossRank::new),//param1:时间 param2:英雄tempId param3:uid
|
||||
;
|
||||
private int type;
|
||||
private String redisKey;
|
||||
|
|
|
|||
|
|
@ -33,7 +33,11 @@ public class RankLogic {
|
|||
}
|
||||
public void getRank(ISession session, int type, int activityId,MessageTypeProto.MessageType messageType) throws Exception {
|
||||
int page = 1;
|
||||
PlayerInfoProto.RankResponse rankResponse= RankContext.getRankEnum(type).getRank(session.getUid(),activityId,1, -1);
|
||||
String rkey = "";
|
||||
if(activityId != 0){
|
||||
rkey = String.valueOf(activityId);
|
||||
}
|
||||
PlayerInfoProto.RankResponse rankResponse= RankContext.getRankEnum(type).getRank(session.getUid(),rkey,1, -1);
|
||||
MessageUtil.sendMessage(session,1,messageType.getNumber(),rankResponse,true);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,13 +28,13 @@ public abstract class AbstractRank implements IRank {
|
|||
|
||||
/**
|
||||
* 获取排行榜数据,包括个人的排名和所有人的信息,获取调用此方法
|
||||
* @param activityId 活动id(活动有多期,排行榜保留)
|
||||
* @param rkey 自定义小key 可以是 活动id(活动有多期,排行榜保留) 、 工会boss里工会id+“:”+期数 组合的key
|
||||
* @param uid 改用户id
|
||||
* @param rankEndLine 所有人条目上线
|
||||
* @return 当前排行榜数据
|
||||
* @throws Exception
|
||||
*/
|
||||
public PlayerInfoProto.RankResponse getRank(int uid,int activityId,int page,int rankEndLine) throws Exception {
|
||||
public PlayerInfoProto.RankResponse getRank(int uid,String rkey,int page,int rankEndLine) throws Exception {
|
||||
if(rankEndLine==-1){
|
||||
rankEndLine = 100;
|
||||
}
|
||||
|
|
@ -43,23 +43,24 @@ public abstract class AbstractRank implements IRank {
|
|||
page = 1;
|
||||
}
|
||||
int start = (page - 1) * rankEndLine, end = page * rankEndLine - 1;
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = getRankByKey(activityId,start,end);
|
||||
Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores = getRankByKey(rkey,start,end);
|
||||
if(start==0){
|
||||
start=1;
|
||||
}
|
||||
PlayerInfoProto.RankResponse.Builder allUserResponse = getAllUserResponse(zsetreverseRangeWithScores,start);
|
||||
//当前用户信息
|
||||
getMyInfo(user,activityId,allUserResponse);
|
||||
getMyInfo(user,rkey,allUserResponse);
|
||||
return allUserResponse.build();
|
||||
}
|
||||
|
||||
/**
|
||||
* 向排行榜添加或修改某条数据
|
||||
* @param uid 修改用户id
|
||||
* @param rkey redis 小key 自定义
|
||||
* @param data 注意:此处为传入修改的分数需要的所有参数即可,里面调用getScore方法,注意参数顺序
|
||||
*/
|
||||
public void addRank(int uid,int activityId,double... data){
|
||||
String key = RedisKey.getKey(redisKey,String.valueOf(activityId),false);
|
||||
public void addRank(int uid,String rkey,double... data){
|
||||
String key = RedisKey.getKey(redisKey,rkey,false);
|
||||
RedisUtil.getInstence().zsetAddOne(key,String.valueOf(uid), getScore(data));
|
||||
}
|
||||
public AbstractRank(int type,String redisKey){
|
||||
|
|
@ -74,8 +75,8 @@ public abstract class AbstractRank implements IRank {
|
|||
return type;
|
||||
}
|
||||
|
||||
public Set<ZSetOperations.TypedTuple<String>> getRankByKey(int activityId,int start,int end){
|
||||
return RedisUtil.getInstence().getZsetreverseRangeWithScores(redisKey, String.valueOf(activityId), start, end);
|
||||
public Set<ZSetOperations.TypedTuple<String>> getRankByKey(String rkey,int start,int end){
|
||||
return RedisUtil.getInstence().getZsetreverseRangeWithScores(redisKey, rkey, start, end);
|
||||
}
|
||||
protected PlayerInfoProto.RankResponse.Builder getAllUserResponse(Set<ZSetOperations.TypedTuple<String>> zsetreverseRangeWithScores,int start) throws Exception{
|
||||
PlayerInfoProto.RankResponse.Builder builder = PlayerInfoProto.RankResponse.newBuilder();
|
||||
|
|
@ -107,9 +108,9 @@ public abstract class AbstractRank implements IRank {
|
|||
builder.addRanks(everyRank);
|
||||
}
|
||||
|
||||
protected void getMyInfo(User user,int activityId,PlayerInfoProto.RankResponse.Builder allUserResponse){
|
||||
int myRank= RedisUtil.getInstence().getZSetreverseRank(redisKey,String.valueOf(activityId),Integer.toString(user.getId())).intValue();
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScore(redisKey, String.valueOf(activityId), Integer.toString(user.getId()));
|
||||
protected void getMyInfo(User user,String rkey,PlayerInfoProto.RankResponse.Builder allUserResponse){
|
||||
int myRank= RedisUtil.getInstence().getZSetreverseRank(redisKey,rkey,Integer.toString(user.getId())).intValue();
|
||||
Double zSetScore = RedisUtil.getInstence().getZSetScore(redisKey, rkey, Integer.toString(user.getId()));
|
||||
CommonProto.RankInfo towerRankInfo = CommonProto.RankInfo.newBuilder()
|
||||
.setRank(myRank)
|
||||
.setParam1(getParam1(zSetScore))
|
||||
|
|
@ -162,7 +163,8 @@ public abstract class AbstractRank implements IRank {
|
|||
public int getParam3(double data) {
|
||||
return getDataByScore(data).length>2?getDataByScore(data)[2]:0;
|
||||
}
|
||||
public double getScoreById(int uid,int activityId){
|
||||
return RedisUtil.getInstence().getZSetScore(redisKey, String.valueOf(activityId), String.valueOf(uid));
|
||||
|
||||
public double getScoreById(int uid,String rkey){
|
||||
return RedisUtil.getInstence().getZSetScore(redisKey,rkey, String.valueOf(uid));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,27 @@
|
|||
package com.ljsd.jieling.logic.rank.rankImpl;
|
||||
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.protocols.PlayerInfoProto;
|
||||
|
||||
public class GuildBossRank extends AbstractRank{
|
||||
public GuildBossRank(int type, String redisKey) {
|
||||
super(type, redisKey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int[] getDataByScore(double score) {
|
||||
return new int[]{(int)score};
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getScore(double... data) {
|
||||
return data[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInfoProto.RankResponse getRank(int uid, String rkey, int page, int rankEndLine) throws Exception {
|
||||
rkey = UserManager.getUser(uid).getPlayerInfoManager().getGuildId() + ":" + GuildFightLogic.bossSeason;
|
||||
return super.getRank(uid, rkey, page, rankEndLine);
|
||||
}
|
||||
}
|
||||
|
|
@ -50,8 +50,8 @@ public class MainLevelRank extends AbstractRank {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Set<ZSetOperations.TypedTuple<String>> getRankByKey(int activityId,int start, int end) {
|
||||
Set<ZSetOperations.TypedTuple<String>> rankByKey = super.getRankByKey(0,start, end);
|
||||
public Set<ZSetOperations.TypedTuple<String>> getRankByKey(String rkey,int start, int end) {
|
||||
Set<ZSetOperations.TypedTuple<String>> rankByKey = super.getRankByKey(rkey,start, end);
|
||||
|
||||
return rankByKey;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ public class RandomCardPerfectRank extends AbstractRank {
|
|||
}
|
||||
|
||||
@Override
|
||||
public void addRank(int uid,int activityId, double... data) {
|
||||
public void addRank(int uid,String rkey, double... data) {
|
||||
String key = RedisKey.getKey(redisKey,"",false);
|
||||
double[] doubles = new double[3];
|
||||
System.arraycopy(data, 0, doubles, 0, data.length);
|
||||
|
|
|
|||
|
|
@ -15,9 +15,9 @@ public class TowerRank extends AbstractRank {
|
|||
}
|
||||
|
||||
@Override
|
||||
public PlayerInfoProto.RankResponse getRank(int uid,int activityId,int page,int rankEndLine) throws Exception {
|
||||
public PlayerInfoProto.RankResponse getRank(int uid,String rkey,int page,int rankEndLine) throws Exception {
|
||||
rankEndLine = SSpecialConfig.getIntegerValue(SSpecialConfig.TRIAL_RANKINGSHOWNUM);
|
||||
return super.getRank(uid,activityId,1, rankEndLine);
|
||||
return super.getRank(uid,rkey,1, rankEndLine);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -13,10 +13,7 @@ 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.activity.event.*;
|
||||
import com.ljsd.jieling.logic.dao.RechargeInfo;
|
||||
import com.ljsd.jieling.logic.dao.UserManager;
|
||||
import com.ljsd.jieling.logic.dao.VipInfo;
|
||||
|
|
@ -213,7 +210,7 @@ public class BuyGoodsLogic {
|
|||
// user.getPlayerInfoManager().updateVipInfo(user,newLeve);
|
||||
user.getPlayerInfoManager().setVipLevel(newLeve);
|
||||
user.getPlayerInfoManager().updateVipInfo(GlobalsDef.VIP_UNLOCK_PRIVILEGE,newLeve);
|
||||
CombatLogic.getInstance().getNewAdventureReward(user, true);
|
||||
// CombatLogic.getInstance().getNewAdventureReward(user, true);
|
||||
}
|
||||
PlayerInfoProto.RefreshRechargeIndication.Builder builder = PlayerInfoProto.RefreshRechargeIndication.newBuilder();
|
||||
builder.setAmount(rechargeInfo.getSaveAmt());
|
||||
|
|
@ -230,7 +227,6 @@ public class BuyGoodsLogic {
|
|||
PlayerInfoProto.DirectBuyIndication build = PlayerInfoProto.DirectBuyIndication.newBuilder().setDrop(drop).build();
|
||||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.DIRECT_BUY_GOODS_INDICATION_VALUE,build,true);
|
||||
}
|
||||
|
||||
if(sRechargeCommodityConfig.getTime()==4&&sRechargeCommodityConfig.getDiscountType().length==3){
|
||||
int[] discountType = sRechargeCommodityConfig.getDiscountType();
|
||||
int temptype = discountType[0];
|
||||
|
|
@ -255,6 +251,8 @@ public class BuyGoodsLogic {
|
|||
MessageUtil.sendIndicationMessage(session,1, MessageTypeProto.MessageType.ALL_GIFTGOODS_INDICATION_VALUE,build,true);
|
||||
}
|
||||
}
|
||||
//发送直购事件
|
||||
Poster.getPoster().dispatchEvent(new BuyGoodsDirectEvent(uid,goodsId));
|
||||
|
||||
}else{
|
||||
String title = SErrorCodeEerverConfig.getI18NMessage("recharge_" + sRechargeCommodityConfig.getType() + "_title");
|
||||
|
|
@ -289,7 +287,7 @@ public class BuyGoodsLogic {
|
|||
|
||||
public static void addNewPrivilege(User user ,int privilege,PlayerInfoProto.PrivilegeIndication.Builder indication) throws Exception {
|
||||
int privilegeType = SPrivilegeTypeConfig.getsPrivilegeTypeConfigMap().get(privilege).getPrivilegeType();
|
||||
if(privilegeType== VipPrivilegeType.ADVENTURE_BASE_REWARD||privilegeType==VipPrivilegeType.FAST_MAP_LIMIT){
|
||||
if(privilegeType== VipPrivilegeType.ADVENTURE_BASE_REWARD){
|
||||
CombatLogic.getInstance().getNewAdventureReward(user,true);
|
||||
}
|
||||
user.getPlayerInfoManager().addVipInfo(privilege);
|
||||
|
|
|
|||
|
|
@ -394,10 +394,8 @@ public class StoreLogic {
|
|||
add += sPlayerLevelConfig.getExtraAdd();
|
||||
}else if(type == 2){
|
||||
int addPrivageId = extra[1];
|
||||
int vipLevel = user.getPlayerInfoManager().getVipLevel();
|
||||
SVipLevelConfig sVipLevelConfig = SVipLevelConfig.getsVipLevelConfigMap().get(vipLevel);
|
||||
Map<Integer, Integer> privilegeMap = sVipLevelConfig.getPrivilegeMap();
|
||||
add +=privilegeMap.get(addPrivageId);
|
||||
PlayerLogic.getInstance().getMaxCountByPrivilegeType(user,addPrivageId);
|
||||
add += PlayerLogic.getInstance().getMaxCountByPrivilegeType(user,addPrivageId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,85 @@
|
|||
package config;
|
||||
|
||||
|
||||
import manager.STableManager;
|
||||
import manager.Table;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Table(name ="GuildRedPackConfig")
|
||||
public class SGuildRedPackConfig implements BaseConfig {
|
||||
|
||||
private int id;
|
||||
|
||||
private int dailyNum;
|
||||
|
||||
private int[] totalMoney;
|
||||
|
||||
private int num;
|
||||
|
||||
private int reward;
|
||||
|
||||
private int lastTime;
|
||||
|
||||
private int minPercent;
|
||||
|
||||
private int maxPercent;
|
||||
|
||||
private int tradeId;
|
||||
|
||||
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackConfigMap;
|
||||
|
||||
public static Map<Integer,SGuildRedPackConfig> sGuildRedPackByGoodsId;
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
sGuildRedPackConfigMap = STableManager.getConfig(SGuildRedPackConfig.class);
|
||||
sGuildRedPackByGoodsId = new HashMap<>();
|
||||
for(Map.Entry<Integer,SGuildRedPackConfig> entry:sGuildRedPackConfigMap.entrySet()){
|
||||
int tradeId = entry.getValue().getTradeId();
|
||||
if(!sGuildRedPackConfigMap.containsKey(tradeId)){
|
||||
sGuildRedPackByGoodsId.put(tradeId,entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public int getDailyNum() {
|
||||
return dailyNum;
|
||||
}
|
||||
|
||||
public int[] getTotalMoney() {
|
||||
return totalMoney;
|
||||
}
|
||||
|
||||
public int getNum() {
|
||||
return num;
|
||||
}
|
||||
|
||||
public int getReward() {
|
||||
return reward;
|
||||
}
|
||||
|
||||
public int getLastTime() {
|
||||
return lastTime;
|
||||
}
|
||||
|
||||
public int getMinPercent() {
|
||||
return minPercent;
|
||||
}
|
||||
|
||||
public int getMaxPercent() {
|
||||
return maxPercent;
|
||||
}
|
||||
|
||||
public int getTradeId() {
|
||||
return tradeId;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -70,9 +70,9 @@ public class SGuildSetting implements BaseConfig {
|
|||
|
||||
public static SGuildSetting sGuildSetting;
|
||||
|
||||
private int[] bossTime;
|
||||
private int bossTime;
|
||||
|
||||
private int[][] bossReward;
|
||||
private float[][] bossReward;
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -205,4 +205,12 @@ public class SGuildSetting implements BaseConfig {
|
|||
public int[][] getRenameCost() {
|
||||
return renameCost;
|
||||
}
|
||||
|
||||
public int getBossTime() {
|
||||
return bossTime;
|
||||
}
|
||||
|
||||
public float[][] getBossReward() {
|
||||
return bossReward;
|
||||
}
|
||||
}
|
||||
|
|
@ -14,8 +14,6 @@ public class SVipLevelConfig implements BaseConfig {
|
|||
private static TreeMap<Integer,Integer> money2vip ;
|
||||
private int vipLevel;
|
||||
|
||||
private int[][] privileges;
|
||||
|
||||
private int[][] vipBoxDailyReward;
|
||||
|
||||
private int[][] vipBoxReward;
|
||||
|
|
@ -24,24 +22,12 @@ public class SVipLevelConfig implements BaseConfig {
|
|||
|
||||
private int moneyLimit;
|
||||
|
||||
|
||||
private Map<Integer,Integer> privilegeMap;
|
||||
|
||||
|
||||
@Override
|
||||
public void init() throws Exception {
|
||||
Map<Integer, SVipLevelConfig> config = STableManager.getConfig(SVipLevelConfig.class);
|
||||
money2vip = new TreeMap<>();
|
||||
for(SVipLevelConfig sVipLevelConfig : config.values()){
|
||||
int[][] privileges = sVipLevelConfig.getPrivileges();
|
||||
if(privileges!=null&&privileges.length>0){
|
||||
Map<Integer,Integer> privilegeMap = new HashMap<>(privileges.length);
|
||||
for(int[] temp : privileges){
|
||||
privilegeMap.put(temp[0],temp[1]);
|
||||
}
|
||||
sVipLevelConfig.setPrivilegeMap(privilegeMap);
|
||||
|
||||
}
|
||||
money2vip.put(sVipLevelConfig.getMoneyLimit(),sVipLevelConfig.getVipLevel());
|
||||
}
|
||||
sVipLevelConfigMap =config;
|
||||
|
|
@ -64,22 +50,10 @@ public class SVipLevelConfig implements BaseConfig {
|
|||
return vipLevel;
|
||||
}
|
||||
|
||||
public int[][] getPrivileges() {
|
||||
return privileges;
|
||||
}
|
||||
|
||||
public int[][] getVipBoxReward() {
|
||||
return vipBoxReward;
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getPrivilegeMap() {
|
||||
return privilegeMap;
|
||||
}
|
||||
|
||||
public void setPrivilegeMap(Map<Integer, Integer> privilegeMap) {
|
||||
this.privilegeMap = privilegeMap;
|
||||
}
|
||||
|
||||
public int[][] getVipBoxDailyReward() {
|
||||
return vipBoxDailyReward;
|
||||
}
|
||||
|
|
@ -92,15 +66,8 @@ public class SVipLevelConfig implements BaseConfig {
|
|||
return moneyLimit;
|
||||
}
|
||||
|
||||
public void setMoneyLimit(int moneyLimit) {
|
||||
this.moneyLimit = moneyLimit;
|
||||
}
|
||||
|
||||
public static TreeMap<Integer, Integer> getMoney2vip() {
|
||||
return money2vip;
|
||||
}
|
||||
|
||||
public static void setMoney2vip(TreeMap<Integer, Integer> money2vip) {
|
||||
SVipLevelConfig.money2vip = money2vip;
|
||||
}
|
||||
}
|
||||
|
|
@ -8,7 +8,7 @@ import java.util.*;
|
|||
|
||||
public class ExcelUtils {
|
||||
private static boolean isWrite = true;
|
||||
private static String excelPath ="D:/excel/0.94/data_execl/base_data/"; //excel 文件
|
||||
private static String excelPath ="F:/work2/data_execl/base_data/"; //excel 文件
|
||||
// private static String excelPath ="D:/excel/0.94/data_execl/Map_data/"; //excel 文件
|
||||
private static String path = "conf/server/";
|
||||
private static Set<String> oldFileNames = new HashSet<>();
|
||||
|
|
@ -19,30 +19,28 @@ public class ExcelUtils {
|
|||
String[] list = oldfile.list();
|
||||
oldFileNames.addAll(Arrays.asList(list));
|
||||
readExcelData();
|
||||
// //只加载新文件
|
||||
//// Set<String> newFileNames = new HashSet<>();
|
||||
//// File newfile = new File(path);
|
||||
//// String[] newList = newfile.list();
|
||||
//// newFileNames.addAll(Arrays.asList(newList));
|
||||
//// newFileNames.removeAll(oldFileNames);
|
||||
//// if(!newFileNames.isEmpty()){
|
||||
//// for(String newFileName : newFileNames){
|
||||
//// String finalNewFileName = newFileName.replaceAll(".txt", "");
|
||||
//// genJavaFile(finalNewFileName);
|
||||
//// }
|
||||
////
|
||||
//// }
|
||||
// genJavaFile("DialRewardSetting");
|
||||
//只加载新文件
|
||||
Set<String> newFileNames = new HashSet<>();
|
||||
File newfile = new File(path);
|
||||
String[] newList = newfile.list();
|
||||
newFileNames.addAll(Arrays.asList(newList));
|
||||
newFileNames.removeAll(oldFileNames);
|
||||
if(!newFileNames.isEmpty()) {
|
||||
for (String newFileName : newFileNames) {
|
||||
String finalNewFileName = newFileName.replaceAll(".txt", "");
|
||||
genJavaFile(finalNewFileName);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public static void genJavaFile(String fileName){
|
||||
|
||||
Map<String,String> fieldInfo = new HashMap<>();
|
||||
File file = new File("conf/server/"+fileName +".txt");
|
||||
StringBuffer stringBuffer = new StringBuffer("package com.ljsd.jieling.config;\n" +
|
||||
StringBuffer stringBuffer = new StringBuffer("package config;\n" +
|
||||
"\n" +
|
||||
"import manager.STableManager;\n" +
|
||||
"import com.ljsd.jieling.logic.Table;\n" +
|
||||
"import manager.Table;\n" +
|
||||
"\n" +
|
||||
"import java.util.Map;\n" +
|
||||
"\n" +
|
||||
|
|
|
|||
Loading…
Reference in New Issue