Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
6bbd27d1f5
|
@ -1,9 +1,7 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
|
||||
|
||||
import com.ljsd.jieling.logic.STableManager;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
|
@ -11,13 +9,14 @@ import org.luaj.vm2.lib.jse.JsePlatform;
|
|||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CheckFight {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CheckFight.class);
|
||||
|
||||
private LuaValue transCoderObj;
|
||||
private ThreadLocal<LuaValue> localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
|
||||
// private String luaFileName = null;
|
||||
|
||||
|
@ -49,6 +48,7 @@ public class CheckFight {
|
|||
init("luafight/BattleMain.lua");
|
||||
LOGGER.info("the luahotfix done");
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
this.localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -59,13 +59,12 @@ public class CheckFight {
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Globals globals = JsePlatform.debugGlobals();
|
||||
transCoderObj = globals.loadfile(luaFileName).call();
|
||||
// Globals globals = JsePlatform.debugGlobals();
|
||||
// transCoderObj = globals.loadfile(luaFileName).call();
|
||||
LuaHotFixBean luaHotFixBean = STableManager.getJsonFilePathInJsonConf("lua-hotfix.json", LuaHotFixBean.class);
|
||||
if(luaHotFixBean!=null) {
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -102,7 +101,8 @@ public class CheckFight {
|
|||
* @param optionData
|
||||
* @return {战斗结果,战斗时间,单位1剩余血量,单位2剩余血量,单位3剩余血量,单位4剩余血量,单位5剩余血量}
|
||||
*/
|
||||
public synchronized int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData){
|
||||
public int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData){
|
||||
LuaValue transCoderObj = this.getTransCoderObj();
|
||||
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
|
||||
LuaValue args = new LuaTable();
|
||||
args.set("seed",seed);
|
||||
|
@ -122,6 +122,23 @@ public class CheckFight {
|
|||
return resultCache;
|
||||
}
|
||||
|
||||
public LuaValue getTransCoderObj(){
|
||||
LuaValue transCoderObj = localTransCoderObj.get();
|
||||
if(transCoderObj == null){
|
||||
String luaFileName = null;
|
||||
try {
|
||||
luaFileName = getPath("luafight/BattleMain.lua");
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Globals globals = JsePlatform.debugGlobals();
|
||||
transCoderObj = globals.loadfile(luaFileName).call();
|
||||
localTransCoderObj.set(transCoderObj);
|
||||
return transCoderObj;
|
||||
}
|
||||
return transCoderObj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue