back_recharge
parent
c259bb3e57
commit
a5ade7d53b
|
@ -381,11 +381,11 @@ function BattleMain.Execute(seed, fightData, optionData)
|
|||
resultList.result = BattleLogic.Result
|
||||
|
||||
-- print -----------------------------------------
|
||||
for i=1, #resultList do
|
||||
print("hp:"..resultList[i])
|
||||
end
|
||||
print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
print("result:"..BattleLogic.Result)
|
||||
--for i=1, #resultList do
|
||||
-- print("hp:"..resultList[i])
|
||||
--end
|
||||
--print("最终运行帧数:"..BattleLogic.CurFrame())
|
||||
--print("result:"..BattleLogic.Result)
|
||||
|
||||
|
||||
return resultList
|
||||
|
@ -405,7 +405,8 @@ function BattleMain.Execute(seed, fightData, optionData)
|
|||
end
|
||||
return { result = -1 }
|
||||
end
|
||||
BattleMain.Execute(932590676, test_fight_data, optionData)
|
||||
|
||||
--BattleMain.Execute(932590676, test_fight_data, optionData)
|
||||
|
||||
return BattleMain
|
||||
--> hp:2084
|
||||
|
|
|
@ -59,7 +59,7 @@ public class GameMessageHandler<T extends GameSession> extends SimpleChannelInbo
|
|||
|
||||
@Override
|
||||
protected void channelRead0(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
LOGGER.info("receive msg ...");
|
||||
// LOGGER.info("receive msg ...");
|
||||
protocols.processMessage(this.session, msg);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ import com.ljsd.jieling.handler.BaseHandler;
|
|||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
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.network.NettyProperties;
|
||||
import com.ljsd.jieling.network.NettyServerAutoConfiguration;
|
||||
|
@ -79,6 +80,9 @@ public class GameApplication {
|
|||
threadManager.init(configurableApplicationContext);
|
||||
MapLogic.getInstance().init(configurableApplicationContext);
|
||||
|
||||
// 加载lua文件
|
||||
CheckFight.getInstance().init("luafight\\BattleMain.lua");
|
||||
|
||||
final NettyServerAutoConfiguration netServerConfig = configurableApplicationContext.getBean(NettyServerAutoConfiguration.class);
|
||||
NettyProperties properties = netServerConfig.getNettyProperties();
|
||||
//todo 设置开服时间
|
||||
|
|
|
@ -13,10 +13,9 @@ public class CheckFight {
|
|||
|
||||
private static final Logger LOGGER = Logger.getLogger("CheckFightLog");
|
||||
|
||||
private LuaValue transCoderObj;
|
||||
|
||||
private Globals globals;
|
||||
|
||||
private String luaFileName = null;
|
||||
// private String luaFileName = null;
|
||||
|
||||
private CheckFight(){}
|
||||
|
||||
|
@ -30,13 +29,14 @@ public class CheckFight {
|
|||
|
||||
|
||||
public void init(String path){
|
||||
String luaFileName = null;
|
||||
try {
|
||||
luaFileName = getPath(path);
|
||||
} catch (IOException e) {
|
||||
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();
|
||||
/**
|
||||
* 单线程执行每次用时50ms,目前支持并发100以内,再大用线程池异步处理
|
||||
* @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 result = func.call(LuaValue.valueOf(932590676),fightData,optionData);
|
||||
LuaValue result = func.call(LuaValue.valueOf(seed),fightData,optionData);
|
||||
int status = result.get("result").toint();
|
||||
int[] resultCache = new int[6];
|
||||
resultCache[0]=status;
|
||||
LOGGER.info("result : "+ status);
|
||||
LOGGER.info(" lua check test fight result : "+ status);
|
||||
if (status==1){
|
||||
for (int i = 1; i <= result.length(); i++) {
|
||||
resultCache[i] = result.rawget(i).toint();
|
||||
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i]);
|
||||
// LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i]);
|
||||
}
|
||||
}
|
||||
return resultCache;
|
||||
|
|
|
@ -274,8 +274,8 @@ public class ProtocolsManager implements ProtocolsAbstract {
|
|||
@Override
|
||||
public void readIdel(GameSession gameSession) {
|
||||
// TODO
|
||||
// final ISession session = (ISession) gameSession;
|
||||
// readIdea(session);
|
||||
final ISession session = (ISession) gameSession;
|
||||
readIdea(session);
|
||||
}
|
||||
|
||||
public BaseHandler getHandler(MessageTypeProto.MessageType messageType) {
|
||||
|
|
|
@ -20,6 +20,10 @@ public class ThreadManager {
|
|||
|
||||
private ScheduledThreadPoolExecutor scheduledExecutor; //管理task
|
||||
|
||||
public void init() {
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
||||
}
|
||||
|
||||
public void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
|
||||
platConfigureTask = configurableApplicationContext.getBean(PlatConfigureTask.class);
|
||||
|
@ -55,7 +59,7 @@ public class ThreadManager {
|
|||
|
||||
public void go() {
|
||||
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(8, new ScheduleThreadFactory());
|
||||
scheduledExecutor = new ScheduledThreadPoolExecutor(16, new ScheduleThreadFactory());
|
||||
|
||||
// testTask 已秒为单位 延迟10s, 间隔30s为周期执行
|
||||
scheduledExecutor.scheduleAtFixedRate(platConfigureTask, 10, PlatConfigureTask.SLEEP_INTEVAL_TIME, TimeUnit.SECONDS);
|
||||
|
@ -63,4 +67,7 @@ public class ThreadManager {
|
|||
LOGGER.info("All Task running ...");
|
||||
}
|
||||
|
||||
public ScheduledThreadPoolExecutor getScheduledExecutor() {
|
||||
return scheduledExecutor;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue