zhangshanxue 2020-05-04 05:07:10 +08:00
commit 252da3274f
6 changed files with 78 additions and 84 deletions

View File

@ -1,21 +0,0 @@
package com.ljsd.jieling.handler.store;
import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.logic.store.StoreLogic;
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;
@Component
public class BuyTreasureHandler extends BaseHandler {
@Override
public MessageTypeProto.MessageType getMessageCode() {
return MessageTypeProto.MessageType.BUY_TREASURE_REQUEST;
}
@Override
public void process(ISession iSession, PacketNetData netData) throws Exception {
StoreLogic.buyTreasure(iSession);
}
}

View File

@ -4,12 +4,10 @@ import com.ljsd.jieling.exception.ErrorCode;
import com.ljsd.jieling.exception.ErrorCodeException;
import com.ljsd.jieling.globals.BIReason;
import com.ljsd.jieling.logic.OnlineUserManager;
import com.ljsd.jieling.logic.dao.ActivityMission;
import com.ljsd.jieling.logic.dao.ActivityProgressInfo;
import com.ljsd.jieling.logic.dao.PlayerManager;
import com.ljsd.jieling.logic.dao.UserManager;
import com.ljsd.jieling.logic.dao.*;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.GameEvent;
import com.ljsd.jieling.logic.store.GiftGoodsType;
import com.ljsd.jieling.network.session.ISession;
import com.ljsd.jieling.protocols.CommonProto;
import com.ljsd.jieling.protocols.MessageTypeProto;
@ -18,6 +16,7 @@ import com.ljsd.jieling.util.ItemUtil;
import com.ljsd.jieling.util.MessageUtil;
import com.ljsd.jieling.util.ToolsUtil;
import config.SGlobalActivity;
import config.SRechargeCommodityConfig;
import config.STreasureSunlongConfig;
import java.util.*;
@ -38,8 +37,22 @@ public class TreasureActivity extends AbstractActivity {
@Override
public void initActivity(User user) throws Exception {
user.getPlayerInfoManager().setHadBuyTreasure(0);
LOGGER.info("戒灵秘宝初始化...");
if(user.getPlayerInfoManager().getHadBuyTreasure() == 1){
LOGGER.info("戒灵秘宝初始化...reset buy");
user.getPlayerInfoManager().setHadBuyTreasure(0);
Map<Integer, Integer> buyGoodsTimes = user.getPlayerInfoManager().getRechargeInfo().getBuyGoodsTimes();
int id=0;
for(SRechargeCommodityConfig sRechargeCommodityConfig : SRechargeCommodityConfig.rechargeCommodityConfigMap.values()){
if(sRechargeCommodityConfig.getType() == GiftGoodsType.SUN_LONG){
id=sRechargeCommodityConfig.getId();
}
}
buyGoodsTimes.put(id,0);
user.getPlayerInfoManager().getRechargeInfo().setBuyGoodsTimes(buyGoodsTimes);
user.getPlayerInfoManager().getRechargeInfo().clearCacheSendId();
}
SGlobalActivity sGlobalActivity = SGlobalActivity.getsGlobalActivityMap().get(id);
user.getUserMissionManager().onGameEvent(user, GameEvent.TREASH_MONTH_REFRESH, sGlobalActivity.getId());
user.getUserMissionManager().onGameEvent(user, GameEvent.TREASH_WEEK_REFRESH, sGlobalActivity.getId());

View File

@ -82,7 +82,6 @@ public class ChampionshipLogic {
}
List<Object> arenaIds = new ArrayList<>(arenaRecodeds);
List<ArenaRecord> arenaRecords = RedisUtil.getInstence().getMapEntrys(RedisKey.CHAMPION_ARENA_RECORD, "", arenaIds, ArenaRecord.class);
Map<Integer, SArenaRobotConfig> config = STableManager.getConfig(SArenaRobotConfig.class);
ArenaInfoProto.ChampionViewFinalResponse.Builder builder = ArenaInfoProto.ChampionViewFinalResponse.newBuilder();
String selectIdForRedis = getSelectIdForRedis();
for (ArenaRecord arenaRecord : arenaRecords) {
@ -502,7 +501,7 @@ public class ChampionshipLogic {
public static void getChampionBetInfo(ISession session,int type) throws Exception {
int uid = session.getUid();
if(progress==-1){
if(progress==-1 || schedule==1){
throw new ErrorCodeException(ErrorCode.SERVER_SELF_DEFINE);
}
String selectIdForRedis = getSelectIdForRedis();
@ -1147,7 +1146,11 @@ public class ChampionshipLogic {
public static String getSelectIdForRedis(){
String key = RedisUtil.getInstence().getKey(RedisKey.CHAMPION_CUR_BETID, "");
return RedisUtil.getInstence().get(key).toString();
Object result = RedisUtil.getInstence().get(key);
if(result!=null){
return result.toString();
}
return "";
}
@ -1217,6 +1220,10 @@ public class ChampionshipLogic {
int[][] itemNum = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting().getItemNum();
SGlobalSystemConfig sGlobalSystemConfig = STableManager.getConfig(SGlobalSystemConfig.class).get(functionId);
Map<String,Integer> sendIds = new HashMap<>();
snapPlayFightInfo();
if(schedule==2){
OnlineUserManager.sessionMap.values().forEach(session->{
try {
sendIds.put(Integer.toString(session.getUid()),1);
@ -1237,10 +1244,11 @@ public class ChampionshipLogic {
}
});
RedisUtil.getInstence().putMapEntrys(RedisKey.CHAMPION_GUESSS_UIDS,"",sendIds);
snapPlayFightInfo();
selectBetTeam();
}
}
//获取排行榜信息
public static void getWorldRankByPage(ISession session,int type,int page) throws Exception {
@ -1354,17 +1362,25 @@ public class ChampionshipLogic {
long now = TimeUtils.now();
long startTime = timeControllerOfFunction.getStartTime();
SChampionshipSetting sChampionshipSetting = STableManager.getFigureConfig(CommonStaticConfig.class).getsChampionshipSetting();
int duration = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
int progressState=getProgress((int)((now - startTime)/1000%duration +1));
long round = (now - startTime) /1000/ duration + 1;
int durationSelect = sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
int durationFinal = durationSelect+ sChampionshipSetting.getGuessTime() ;
int progressState=getProgress((int)((now - startTime)/1000%durationSelect +1));
long round = (now - startTime) /1000/ durationSelect + 1;
roundTimes = (int) round;
long diff = round - (sChampionshipSetting.getTrialsGroup() - 1);
int progressTmp;
if(diff<=0){ //选拔赛
//竞猜阶段取消,改成直接战斗
progressState = progressState==1?2:progressState;
progressTmp =100 + roundTimes*10 + progressState;
schedule=1;
}else {//决赛
long passTIme = (now - startTime - (sChampionshipSetting.getTrialsGroup() - 1) * 1000L * durationSelect )/1000;
round = passTIme / durationFinal + sChampionshipSetting.getTrialsGroup() ;
roundTimes = (int) round ;
diff = round - (sChampionshipSetting.getTrialsGroup() - 1);
progressState=getProgress((int)(passTIme%durationFinal +1));
int totalWiner =sChampionshipSetting.getChampionshipPlayer()/ sChampionshipSetting.getTrialsGroup() * sChampionshipSetting.getTrialsGroupWinner();
if(diff>totalWiner || Math.pow(2,diff)>totalWiner){
schedule=2;
@ -1386,7 +1402,11 @@ public class ChampionshipLogic {
if(progressTmp == progress){
return;
}
endTime = (int)( startTime/1000 + (round-1)*duration + getDuratimeByProgressState(progressState));
if(schedule ==1) {
endTime = (int)( startTime/1000 + (round-1)*durationSelect + getDuratimeByProgressState(progressState));
}else{
endTime = (int)( startTime/1000 + (sChampionshipSetting.getTrialsGroup()-1)*durationSelect + (round-sChampionshipSetting.getTrialsGroup())*durationFinal + getDuratimeByProgressState(progressState));
}
progress = progressTmp;
if(isServerStart){
return;
@ -1400,7 +1420,7 @@ public class ChampionshipLogic {
}
});
}
if(progress%10%4==1){ //竞猜阶段 后台自动运行战斗
if(progress%10%4==1 || (schedule==1 && progress%10%4==2)){ //竞猜阶段 后台自动运行战斗
ThreadManager.getScheduledExecutor().execute(new Runnable() {
@Override
public void run() {
@ -1419,7 +1439,9 @@ public class ChampionshipLogic {
public void run() {
try {
scoreToRedis();
if(schedule==2){
sendBetReward();
}
} catch (Exception e) {
e.printStackTrace();
}
@ -1442,12 +1464,12 @@ public class ChampionshipLogic {
return sChampionshipSetting.getPrepareTime();
}
if(progressState == 1){
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime();
return sChampionshipSetting.getPrepareTime() +(schedule==2? sChampionshipSetting.getGuessTime():0);
}
if(progressState == 2){
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime();
return sChampionshipSetting.getPrepareTime() + (schedule==2? sChampionshipSetting.getGuessTime():0) + sChampionshipSetting.getBattleTime();
}
return sChampionshipSetting.getPrepareTime() + sChampionshipSetting.getGuessTime() + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
return sChampionshipSetting.getPrepareTime() + (schedule==2? sChampionshipSetting.getGuessTime():0) + sChampionshipSetting.getBattleTime() + sChampionshipSetting.getSettleTime();
}

View File

@ -364,6 +364,9 @@ public class BuyGoodsLogic {
if(user.getPlayerInfoManager().getMonthCard().containsKey(Global.MONTHCARDID) || goodsType == GiftGoodsType.WEEKCARD || goodsType == GiftGoodsType.FOUND_ONE || goodsType == GiftGoodsType.FOUND_TWO){
PlayerLogic.getInstance().sendDayilyMail(user,goodsType);
}else if(goodsType == GiftGoodsType.SUN_LONG ){
user.getPlayerInfoManager().setHadBuyTreasure(1);
}
}

View File

@ -10,4 +10,5 @@ public interface GiftGoodsType {
int WEEKCARD = 7; //周卡
int FOUND_ONE = 8; //豪华基金
int FOUND_TWO = 9; //豪华基金
int SUN_LONG = 11; //豪华基金
}

View File

@ -660,30 +660,6 @@ public class StoreLogic implements IEventHandler {
return false;
}
public static void buyTreasure(ISession session) throws Exception {
User user = UserManager.getUser(session.getUid());
int msgId = MessageTypeProto.MessageType.BUY_TREASURE_RESPONSE_VALUE;
int hadBuyTreasure = user.getPlayerInfoManager().getHadBuyTreasure();
int[] treasurePrice = STableManager.getFigureConfig(CommonStaticConfig.class).getGameSetting().getTreasurePrice();
if(hadBuyTreasure == 1){
throw new ErrorCodeException(ErrorCode.newDefineCode("had bought"));
}
int[][] cost = new int[1][];
cost[0] = treasurePrice;
boolean enough = ItemUtil.itemCost(user, cost, BIReason.BUY_TREASURE_CONSUME, 0);
if(!enough){
throw new ErrorCodeException(ErrorCode.newDefineCode("not enough money"));
}
user.getPlayerInfoManager().setHadBuyTreasure(1);
MailLogic.getInstance().sendMail(session.getUid(),SErrorCodeEerverConfig.getI18NMessage("secret_extra_title"), SErrorCodeEerverConfig.getI18NMessage("secret_extra_txt"), SSpecialConfig.getStringValue(SSpecialConfig.SUNLONG_REWARD),(int)(TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
MailLogic.getInstance().sendMail(session.getUid(),SErrorCodeEerverConfig.getI18NMessage("secret_daily_title"),SErrorCodeEerverConfig.getI18NMessage("secret_daily_txt"),SSpecialConfig.getStringValue(SSpecialConfig.SUNLONG_INTEGRAL),(int)(TimeUtils.now()/1000), Global.MAIL_EFFECTIVE_TIME);
MessageUtil.sendMessage(session, 1,msgId, null, true);
}
public static void checkAllowOfFunction(FunctionRefreshEvent functionRefreshEvent) throws Exception {
if(functionRefreshEvent.getInvokeId()!=-1){
return;