back_recharge
mashiyu 2019-03-12 17:01:40 +08:00
parent c259bb3e57
commit a5ade7d53b
6 changed files with 38 additions and 20 deletions

View File

@ -381,11 +381,11 @@ function BattleMain.Execute(seed, fightData, optionData)
resultList.result = BattleLogic.Result resultList.result = BattleLogic.Result
-- print ----------------------------------------- -- print -----------------------------------------
for i=1, #resultList do --for i=1, #resultList do
print("hp:"..resultList[i]) -- print("hp:"..resultList[i])
end --end
print("最终运行帧数:"..BattleLogic.CurFrame()) --print("最终运行帧数:"..BattleLogic.CurFrame())
print("result:"..BattleLogic.Result) --print("result:"..BattleLogic.Result)
return resultList return resultList
@ -405,7 +405,8 @@ function BattleMain.Execute(seed, fightData, optionData)
end end
return { result = -1 } return { result = -1 }
end end
BattleMain.Execute(932590676, test_fight_data, optionData)
--BattleMain.Execute(932590676, test_fight_data, optionData)
return BattleMain return BattleMain
--> hp:2084 --> hp:2084

View File

@ -59,7 +59,7 @@ public class GameMessageHandler<T extends GameSession> extends SimpleChannelInbo
@Override @Override
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception { protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
LOGGER.info("receive msg ..."); // LOGGER.info("receive msg ...");
protocols.processMessage(this.session, msg); protocols.processMessage(this.session, msg);
} }

View File

@ -9,6 +9,7 @@ import com.ljsd.jieling.handler.BaseHandler;
import com.ljsd.jieling.handler.map.MapLogic; import com.ljsd.jieling.handler.map.MapLogic;
import com.ljsd.jieling.logic.STableManager; import com.ljsd.jieling.logic.STableManager;
import com.ljsd.jieling.logic.dao.MailingSystemManager; import com.ljsd.jieling.logic.dao.MailingSystemManager;
import com.ljsd.jieling.logic.fight.CheckFight;
import com.ljsd.jieling.netty.server.NettyGameServer; import com.ljsd.jieling.netty.server.NettyGameServer;
import com.ljsd.jieling.network.NettyProperties; import com.ljsd.jieling.network.NettyProperties;
import com.ljsd.jieling.network.NettyServerAutoConfiguration; import com.ljsd.jieling.network.NettyServerAutoConfiguration;
@ -79,6 +80,9 @@ public class GameApplication {
threadManager.init(configurableApplicationContext); threadManager.init(configurableApplicationContext);
MapLogic.getInstance().init(configurableApplicationContext); MapLogic.getInstance().init(configurableApplicationContext);
// 加载lua文件
CheckFight.getInstance().init("luafight\\BattleMain.lua");
final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class); final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
NettyProperties properties = netServerConfig.getNettyProperties(); NettyProperties properties = netServerConfig.getNettyProperties();
//todo 设置开服时间 //todo 设置开服时间

View File

@ -13,10 +13,9 @@ public class CheckFight {
private static final Logger LOGGER = Logger.getLogger("CheckFightLog"); private static final Logger LOGGER = Logger.getLogger("CheckFightLog");
private LuaValue transCoderObj;
private Globals globals; // private String luaFileName = null;
private String luaFileName = null;
private CheckFight(){} private CheckFight(){}
@ -30,13 +29,14 @@ public class CheckFight {
public void init(String path){ public void init(String path){
String luaFileName = null;
try { try {
luaFileName = getPath(path); luaFileName = getPath(path);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
globals = JsePlatform.standardGlobals(); Globals globals = JsePlatform.standardGlobals();
transCoderObj = globals.loadfile(luaFileName).call();
} }
@ -65,18 +65,24 @@ public class CheckFight {
} }
public int[] checkFight(int seed, LuaValue fightData, LuaValue optionData){ /**
LuaValue transCoderObj = globals.loadfile(luaFileName).call(); * 线50ms100线
* @param seed
* @param fightData
* @param optionData
* @return {,1,2,3,4,5}
*/
public synchronized int[] checkFight(int seed, LuaValue fightData, LuaValue optionData){
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute")); LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
LuaValue result = func.call(LuaValue.valueOf(932590676),fightData,optionData); LuaValue result = func.call(LuaValue.valueOf(seed),fightData,optionData);
int status = result.get("result").toint(); int status = result.get("result").toint();
int[] resultCache = new int[6]; int[] resultCache = new int[6];
resultCache[0]=status; resultCache[0]=status;
LOGGER.info("result : "+ status); LOGGER.info(" lua check test fight result : "+ status);
if (status==1){ if (status==1){
for (int i = 1; i <= result.length(); i++) { for (int i = 1; i <= result.length(); i++) {
resultCache[i] = result.rawget(i).toint(); resultCache[i] = result.rawget(i).toint();
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i]); // LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i]);
} }
} }
return resultCache; return resultCache;

View File

@ -274,8 +274,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
@Override @Override
public void readIdel(GameSession gameSession) { public void readIdel(GameSession gameSession) {
// TODO // TODO
// final ISession session = (ISession) gameSession; final ISession session = (ISession) gameSession;
// readIdea(session); readIdea(session);
} }
public BaseHandler getHandler(MessageTypeProto.MessageType messageType) { public BaseHandler getHandler(MessageTypeProto.MessageType messageType) {

View File

@ -20,6 +20,10 @@ public class ThreadManager {
private ScheduledThreadPoolExecutor scheduledExecutor; //管理task private ScheduledThreadPoolExecutor scheduledExecutor; //管理task
public void init() {
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
}
public void init(ConfigurableApplicationContext configurableApplicationContext) { public void init(ConfigurableApplicationContext configurableApplicationContext) {
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class); platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
@ -55,7 +59,7 @@ public class ThreadManager {
public void go() { public void go() {
scheduledExecutor = new ScheduledThreadPoolExecutor(8, new ScheduleThreadFactory()); scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行 // testTask 已秒为单位 延迟10s, 间隔30s为周期执行
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS); scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
@ -63,4 +67,7 @@ public class ThreadManager {
LOGGER.info("All Task running ..."); LOGGER.info("All Task running ...");
} }
public ScheduledThreadPoolExecutor getScheduledExecutor() {
return scheduledExecutor;
}
} }