Merge branch 'master_test_gn' into master_test_gn_returnRecharge

back_recharge
lvxinran 2021-06-08 16:16:22 +08:00
commit fb47673c1d
18 changed files with 215 additions and 84 deletions

View File

@ -110,11 +110,11 @@ public class CheckFight {
for (int i = 1; i <= result.length(); i++) {
long tolong = result.rawget(i).tolong();
if(tolong>0){
resultCache[i+1]= Math.min((long) Integer.MAX_VALUE,tolong);
resultCache[i+1]= Math.min(Long.MAX_VALUE,tolong);
}else {
resultCache[i+1]= Math.max((long) Integer.MIN_VALUE,tolong);
resultCache[i+1]= Math.max(Long.MIN_VALUE,tolong);
}
resultCache[i+1] = (long) result.rawget(i).toint();
resultCache[i+1] = result.rawget(i).tolong();
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
}

View File

@ -1,6 +1,7 @@
package com.ljsd.jieling.netty.handler;
import com.ljsd.jieling.netty.server.SkyEyeClient;
import io.netty.buffer.ByteBuf;
import io.netty.channel.ChannelHandler;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.EventLoop;
@ -9,45 +10,50 @@ import io.netty.handler.timeout.IdleState;
import io.netty.handler.timeout.IdleStateEvent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import rpc.protocols.ChatProto;
import java.util.concurrent.TimeUnit;
@ChannelHandler.Sharable
public class SkyEyeHandler extends SimpleChannelInboundHandler {
private static final Logger logger = LoggerFactory.getLogger(SkyEyeHandler.class);
long start = 0;
private long heartbeatCount = 0;
private SkyEyeClient cilent;
public SkyEyeHandler(SkyEyeClient cilent){
this.cilent = cilent;
}
@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
logger.info("天眼激活......");
ctx.fireChannelActive();
}
@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
System.out.println("掉线了"+(System.currentTimeMillis()-start)/1000);
logger.info("天眼channelInactive......");
EventLoop loop = ctx.channel().eventLoop();
loop.schedule(() ->{
logger.info("天眼reconnect......");
cilent.connect();
},1, TimeUnit.SECONDS);
ctx.fireChannelInactive();
}
@Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
System.out.println();
ByteBuf in = (ByteBuf)msg;
int length = in.readableBytes();
if(length<=6){
return;
}
byte[] b = new byte[length-6];
in.readBytes(6);
for(int i =0;i<length-6;i++){
b[i] = in.readByte();
}
ChatProto.ChatV3 v3 = ChatProto.ChatV3.parseFrom(b);
}
// @Override
// public void userEventTriggered(ChannelHandlerContext ctx, Object evt) throws Exception {
//// ctx.channel().writeAndFlush("TCX心跳");
//// System.out.println("发送心跳"+(System.currentTimeMillis()-start)/1000);
// super.userEventTriggered(ctx, evt);
//// if (evt instanceof IdleStateEvent) {
//// IdleStateEvent event = (IdleStateEvent) evt;
//// if (event.state().equals(IdleState.READER_IDLE)) {
//// System.out.println("长期没收到服务器推送数据");
//// //可以选择重新连接
//// } else if (event.state().equals(IdleState.WRITER_IDLE)) {
//// System.out.println("长期未向服务器发送数据");
//// } else if (event.state().equals(IdleState.ALL_IDLE)) {
//// System.out.println("ALL");
//// }
//// }
// }
}

View File

@ -19,7 +19,6 @@ public class SkyEyeClient {
private static Bootstrap bootstrap = null;
public static Channel channel;
private EventLoopGroup group = new NioEventLoopGroup();
protected final HashedWheelTimer timer = new HashedWheelTimer();
private final int port = 8741;
private final String host = "api.gamegs.cn";
@ -30,49 +29,43 @@ public class SkyEyeClient {
public void doConnect(EventLoopGroup group){
// ChannelFuture f = null;
ChannelFuture future=null;
Bootstrap bootstrap = new Bootstrap();
bootstrap = new Bootstrap();
bootstrap.group(group)
.option(ChannelOption.SO_KEEPALIVE,true)
.channel(NioSocketChannel.class);
final ConnectionWatchdog watchdog = new ConnectionWatchdog(bootstrap, timer, port,host, true) {
@Override
public ChannelHandler[] handlers() {
return new ChannelHandler[] {
this,
new SkyEyeHandler()
};
}
};
try {
synchronized (bootstrap){
bootstrap.remoteAddress(host,port);
bootstrap.handler(new ChannelInitializer<Channel>() {
//初始化channel
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(watchdog.handlers());
}
});
future = bootstrap.connect(host,port);
}
future.sync();
// f = bootstrap.connect();
// f.addListener(new ConnectionListener());
channel = future.channel();
// channel.closeFuture().sync();
} catch (Throwable t) {
LOGGER.error("客户端连接失败------------,ip为{},端口为{}",host,port);
if (null != future) {
try {
timer.newTimeout(watchdog,60, TimeUnit.SECONDS);
} catch (Exception e1) {
e1.printStackTrace();
bootstrap.remoteAddress(host,port);
bootstrap.handler(new ChannelInitializer<Channel>() {
//初始化channel
@Override
protected void initChannel(Channel ch) throws Exception {
ch.pipeline().addLast(new SkyEyeHandler(SkyEyeClient.this));
}
}
}finally {
// group.shutdownGracefully();
});
connect();
// channel.closeFuture().sync();
} catch (Exception e1) {
LOGGER.error("客户端连接失败------------,ip为{},端口为{}",host,port);
e1.printStackTrace();
}
}
public void connect(){
synchronized (bootstrap) {
ChannelFuture future = bootstrap.connect(host, port);
channel = future.channel();
future.addListener(new ChannelFutureListener() {
public void operationComplete(ChannelFuture f) throws Exception {
boolean succeed = f.isSuccess();
Channel channel = f.channel();
if (!succeed) {
LOGGER.info("重连失败");
f.channel().pipeline().fireChannelInactive();
} else {
LOGGER.info("重连成功");
}
}
});
}
}

View File

@ -0,0 +1,16 @@
package com.ljsd.jieling.config.skyeye;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@EnableConfigurationProperties(SkyEyeProperties.class)
public class SkyEyeAutoConfigration {
@Autowired
private SkyEyeProperties skyEyeProperties;
public SkyEyeProperties getSkyEyeProperties() {
return skyEyeProperties;
}
}

View File

@ -0,0 +1,28 @@
package com.ljsd.jieling.config.skyeye;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
@Configuration
@ConfigurationProperties(prefix = "skyeye")
public class SkyEyeProperties {
private String appId;
private String gmAddress;
public String getAppId() {
return appId;
}
public void setAppId(String appId) {
this.appId = appId;
}
public String getGmAddress() {
return gmAddress;
}
public void setGmAddress(String gmAddress) {
this.gmAddress = gmAddress;
}
}

View File

@ -251,6 +251,10 @@ public class TreasureActivity extends AbstractActivity {
private void getAllTreasureRewards(User user, ActivityMission activityMission, int destState, List<int[][]> dropList){
for(int i = 1 ; i<=user.getPlayerInfoManager().getTreasureLevel();i++){
Map<Integer, ActivityProgressInfo> progressInfoMap = activityMission.getActivityMissionMap();
if(progressInfoMap.get(i)==null){
LOGGER.info("问题id:{}",i);
continue;
}
int state =progressInfoMap.get(i).getState();
if(state == destState || state == ActivityType.FINISH_TAKED) {
continue;

View File

@ -194,6 +194,9 @@ public class CumulationData {
//山河社稷章节数
public int hardstage_node;
// 公会boss
public int guild_boss_room;
public Result updateData(MissionType missionType, Object...parm) throws Exception {
return DataManagerDistributor.updateData(this, missionType,parm);
}

View File

@ -55,7 +55,7 @@ public class GuildInfo extends MongoBase {
private int currBossId;
private int bossHpRemain;
private long bossHpRemain;
private int buffIndex;
@ -286,11 +286,11 @@ public class GuildInfo extends MongoBase {
updateString("currBossId",currBossId);
}
public int getBossHpRemain() {
public long getBossHpRemain() {
return bossHpRemain;
}
public void setBossHpRemain(int bossHpRemain) {
public void setBossHpRemain(long bossHpRemain) {
this.bossHpRemain = bossHpRemain;
updateString("bossHpRemain",bossHpRemain);
}

View File

@ -18,6 +18,7 @@ import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.fight.*;
import com.ljsd.jieling.logic.fight.result.FightResult;
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.RankContext;
import com.ljsd.jieling.logic.rank.RankEnum;
@ -225,7 +226,7 @@ public class GuildChallengeLogic {
}else if(checkResult[0]==0){
//怪物保持在第四位
if(guildInfo.getBossHpRemain()!=-1){
guildInfo.setBossHpRemain(checkResult[3]==0?10000: (int) checkResult[3]);
guildInfo.setBossHpRemain(checkResult[3]);
}
}else{
error = "战斗异常!";
@ -240,7 +241,7 @@ public class GuildChallengeLogic {
}else{
//扫荡
if(guildInfo.getBossHpRemain()!=-1){
int remain = guildInfo.getBossHpRemain() - guildMyInfo.getGuildChallengeDamage();
long remain = guildInfo.getBossHpRemain() - guildMyInfo.getGuildChallengeDamage();
if(remain>=0){
guildInfo.setBossHpRemain(remain);
}else{
@ -373,6 +374,8 @@ public class GuildChallengeLogic {
PlayerLogic.getInstance().checkAndUpdate(user,config.getPrivilege()[0],1);
user.getUserMissionManager().onGameEvent(user, GameEvent.GUILD_BOSS_ROOM,1);
MessageUtil.sendMessage(session,1,messageType.getNumber(),response.build(),true);
if(kill==1&&!UserManager.getUser(uid).getGuildMyInfo().getRefreshedBoss().contains(bossId)&&guildInfo.getBossHpRemain()!=-1){
indication.setIsRefresh(1);//需要前端刷新次数

View File

@ -123,4 +123,6 @@ public enum GameEvent {
HARSTAGE_STARS,//山河社稷图星数
HARSTAGE_NODE,//山河社稷图通关章节
GUILD_BOSS_ROOM,//公会boos副本
}

View File

@ -136,6 +136,8 @@ public enum MissionType {
ENDLESS_OPEN_PERCENT(128),
ENDLESS_SMALL_REWARD(129),
ENDLESS_BIG_REWARD(130),
GUILD_BOSS_ROOM(131),//公会副本boss
;
private int missionType;

View File

@ -158,6 +158,8 @@ public class DataManagerDistributor {
judges.put(MissionType.HARSTAGE_STARS, new HardStageStarsDataManager());
judges.put(MissionType.HARSTAGE_NODE, new HardStageNodeDataManager());
// 公会副本/boss
judges.put(MissionType.GUILD_BOSS_ROOM,new GuildBossRoomManager());
}

View File

@ -0,0 +1,30 @@
package com.ljsd.jieling.logic.mission.data;
import com.ljsd.jieling.logic.dao.CumulationData;
import com.ljsd.jieling.logic.dao.root.User;
import com.ljsd.jieling.logic.mission.MissionType;
/**
* @Author hj
* @Date 2021/6/7 11:03
* @Description:
* @Version 1.0
*/
public class GuildBossRoomManager extends AbstractDataManager {
@Override
public CumulationData.Result updateData(CumulationData data, MissionType missionType, Object... parm) {
int num = (int)parm[0];
data.guild_boss_room+=num;
return new CumulationData.Result(missionType);
}
@Override
public boolean isFinish(User user,CumulationData data, int[][] value, Object... parm) {
return data.guild_boss_room>=value[1][0];
}
@Override
public int getProcess(User user, CumulationData data, int[] missionSubType) {
return data.guild_boss_room;
}
}

View File

@ -345,6 +345,11 @@ public class MissionEventDistributor {
eventEnumListMap.put(GameEvent.LOGIN_GAME,typeList);
eventProcessor.put(GameEvent.LOGIN_GAME,new CumulationDataEventProcessor());
typeList = new ArrayList<>();
typeList.add(MissionType.GUILD_BOSS_ROOM);
eventEnumListMap.put(GameEvent.GUILD_BOSS_ROOM,typeList);
eventProcessor.put(GameEvent.GUILD_BOSS_ROOM,new CumulationDataEventProcessor());
typeList = new ArrayList<>();
typeList.add(MissionType.SEVEN_GIFT_BUY);
eventEnumListMap.put(GameEvent.BUY_SEVEN_GIFT,typeList);

View File

@ -769,7 +769,7 @@ public class ItemUtil {
}
}
}else{
item.setItemNum((int) (item.getItemNum() + entry.getValue()));
item.setItemNum(item.getItemNum() + entry.getValue());
}
}
@ -847,7 +847,6 @@ public class ItemUtil {
if (playerInfoManager.getLevel() >= maxLevel.getPlayerLv()) {
return;
}
// 从1级升到满级需要得经验
long totalExp = levelConfigMap.values().stream().mapToLong(SPlayerLevelConfig::getExp).sum();
// 最高等级得经验是多余得,需要减去

View File

@ -1,5 +1,6 @@
package com.ljsd.jieling.util;
import com.alibaba.fastjson.JSON;
import com.google.gson.Gson;
import com.google.protobuf.ByteString;
import com.google.protobuf.GeneratedMessage;
@ -7,6 +8,8 @@ import com.googlecode.protobuf.format.JsonFormat;
import com.ljsd.GameApplication;
import com.ljsd.SkyEyeService;
import com.ljsd.jieling.chat.messge.MessageCache;
import com.ljsd.jieling.config.skyeye.SkyEyeAutoConfigration;
import com.ljsd.jieling.config.skyeye.SkyEyeProperties;
import com.ljsd.jieling.core.GlobalsDef;
import com.ljsd.jieling.core.SimpleTransaction;
import com.ljsd.jieling.db.redis.RedisKey;
@ -36,6 +39,7 @@ import java.util.*;
public class MessageUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(MessageUtil.class);
private static HashMap<String, String> skyEyeExtraMap = new HashMap<>();
public static byte[] wrappedBuffer(int uid, int token, int index, int result, int msgId, GeneratedMessage generatedMessage) {
byte[] backMessage;
@ -79,8 +83,12 @@ public class MessageUtil {
return bytes1;
}
public static byte[] wrappedBufferSE(GeneratedMessage generatedMessage) {
byte[] idByte = short2byte((short) 0xd6ac);
public static byte[] wrappedBufferSE(GeneratedMessage generatedMessage,SkyEyeProperties properties) {
int b1 = 0;
if(properties.getAppId() != null){
b1 = Integer.parseInt(properties.getAppId(),16);
}
byte[] idByte = short2byte((short) b1);
byte[] backMessage = generatedMessage.toByteArray();
byte[] verifyByte = new byte[2+4+backMessage.length];
byte[] lengthByte =int2bytes(backMessage.length);
@ -457,8 +465,13 @@ public class MessageUtil {
if(uid != 0){
he = UserManager.getUser(uid);
}
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,he,channel);
byte[] byteBuf = wrappedBufferSE(v3.build());
SkyEyeAutoConfigration netServerConfig = ConfigurableApplicationContextManager.getBean(SkyEyeAutoConfigration.class);
SkyEyeProperties properties = netServerConfig.getSkyEyeProperties();
if(properties == null){
return;
}
ChatProto.ChatV3.Builder v3 = buildChatV3(msg,me,he,channel,properties);
byte[] byteBuf = wrappedBufferSE(v3.build(),properties);
// session.writeAndFlush(byteBuf);
// session.putBackMassageToMap(byteBuf);
ByteBuf bb = PooledByteBufAllocator.DEFAULT.heapBuffer();
@ -466,7 +479,7 @@ public class MessageUtil {
SkyEyeService.sendMsg(bb);
}
public static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,User he,int type){
public static ChatProto.ChatV3.Builder buildChatV3(String msg,User me,User he,int type,SkyEyeProperties properties){
ChatProto.ChatV3.Builder v3 = ChatProto.ChatV3.newBuilder();
String uuid = UUID.randomUUID().toString().replaceAll("-","");
v3.setId(uuid);
@ -479,6 +492,13 @@ public class MessageUtil {
ISession iSession = OnlineUserManager.getSessionByUid(me.getId());
String ip = iSession.getChannel().getLocalAddress().getHostString();
v3.setIp(ip);
skyEyeExtraMap.clear();
String url = properties.getGmAddress();
if(url == null){
return v3;
}
skyEyeExtraMap.put("url",url);
v3.setExtra(JSON.toJSONString(skyEyeExtraMap));
return v3;
}
@ -491,7 +511,7 @@ public class MessageUtil {
v3.setVipLevel(user.getPlayerInfoManager().getVipLevel());
v3.setZoneId(String.valueOf(GameApplication.serverId));
v3.setZoneName(String.valueOf(GameApplication.serverId));
v3.setServerId(1+"");
v3.setServerId(user.getPlayerInfoManager().getChannel_id());
return v3;
}
//高位在前,低位在后

View File

@ -1,5 +1,5 @@
#server info
server.id = 10161
server.id = 10163
server.openTime = 20190101000101
server.num = 1
server.debug = true
@ -33,7 +33,7 @@ spring.redis.expireTime = -1
#spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1
#spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1
#mongodb2 develop
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10161
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10163
spring.data.mongodbcore.uri = mongodb://60.1.1.14:27017/jl_core
#spring.data.mongodb.uri = mongodb://60.1.1.14:27017/jieling_10212
mongodb.options.maxWaitTime = 120000
@ -62,13 +62,16 @@ netty.allTimeout=35
#core
services.core.ip=60.1.1.161
services.core.ip=60.1.1.163
services.core.port=7900
services.core.area=1000
services.core.id=1
services.core.gmport = 7902
services.core.weight=5
#skyeye
skyeye.appId=d6ac
skyeye.gmAddress=http://193.112.78.218:8888/skyEye
logging.config = conf/logback-boot.xml

View File

@ -1,12 +1,14 @@
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFCell;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.*;
import java.util.*;
public class ExcelUtils {
private static boolean isWrite = true;
private static String excelPath ="D:\\A-duhui\\project\\data_execl\\master_zh_c\\base_data\\"; //excel 文件
private static String excelPath ="E:\\work\\data_execl\\master_en\\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<>();
@ -361,16 +363,29 @@ public class ExcelUtils {
//读取excel
private static Workbook readExcel(String filePath) {
Workbook wb = null;
if (filePath == null) {
return null;
}
String extString = filePath.substring(filePath.lastIndexOf("."));
InputStream is;
try {
InputStream is = new FileInputStream(filePath);
return WorkbookFactory.create(is);
is = new FileInputStream(filePath);
if (".xls".equals(extString)) {
return wb = new HSSFWorkbook(is);
} else if (".xlsx".equals(extString)) {
wb = new XSSFWorkbook(is);
return wb;
} else {
return wb = null;
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (Exception e) {
e.printStackTrace();
}
return null;
return wb;
}
public static Object getCellFormatValue(Cell cell,Cell cellType) {