fix fight
parent
4f8bc6ba15
commit
b3834ed6ee
|
@ -3,7 +3,6 @@ plugins {
|
|||
}
|
||||
|
||||
group 'com.ljsd'
|
||||
version '1.0.0-SNAPSHOT'
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
|
@ -19,5 +18,4 @@ dependencies {
|
|||
|
||||
jar {
|
||||
baseName = 'fightmanager'
|
||||
version = '1.0.0'
|
||||
}
|
|
@ -1,3 +1,5 @@
|
|||
package com.ljsd.fight;
|
||||
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaTable;
|
|
@ -1,3 +1,5 @@
|
|||
package com.ljsd.fight;
|
||||
|
||||
public enum FightType {
|
||||
StoryFight(1), //故事副本
|
||||
MapExploreFight(2), // 地图探索
|
||||
|
@ -8,6 +10,7 @@ public enum FightType {
|
|||
BloodyFight(7), // 血战
|
||||
MonterFight(8), // 兽潮
|
||||
|
||||
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
@ -17,6 +20,7 @@ public enum FightType {
|
|||
}
|
||||
|
||||
FightType(int type) {
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -27,6 +27,7 @@ dependencies {
|
|||
compile project(":common")
|
||||
compile project(":gamecommon")
|
||||
compile project(":tablemanager")
|
||||
compile project(":fightmanager")
|
||||
testCompile group: 'junit', name: 'junit', version: '4.12'
|
||||
compile("org.javassist:javassist:3.18.2-GA")
|
||||
compile("org.springframework.boot:spring-boot:1.5.9.RELEASE")
|
||||
|
@ -38,7 +39,7 @@ dependencies {
|
|||
compile("com.fasterxml.jackson.core:jackson-databind:2.3.3")
|
||||
compile group: 'com.googlecode.protobuf-java-format', name: 'protobuf-java-format', version: '1.2'
|
||||
compile group: 'com.google.code.gson', name: 'gson', version: '2.2.4'
|
||||
compile("org.luaj:luaj-jse:3.0.1")
|
||||
// compile("org.luaj:luaj-jse:3.0.1")
|
||||
compile("org.apache.thrift:libthrift:0.9.2")
|
||||
compile("com.alibaba:fastjson:1.2.47")
|
||||
compile("org.apache.httpcomponents:httpclient:4.5.3")
|
||||
|
|
|
@ -9,33 +9,17 @@ import com.ljsd.jieling.core.CoreLogic;
|
|||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.handler.map.MapLogic;
|
||||
import com.ljsd.jieling.logic.GlobalDataManaager;
|
||||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.MailingSystemManager;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.NetManager;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.thread.ThreadManager;
|
||||
import com.ljsd.jieling.thread.task.MongoDataHandlerTask;
|
||||
import com.ljsd.jieling.thrift.pool.ThriftPoolUtils;
|
||||
|
||||
import com.ljsd.jieling.util.ConfigurableApplicationContextManager;
|
||||
import com.ljsd.jieling.util.KeyGenUtils;
|
||||
import com.ljsd.jieling.util.SensitivewordFilter;
|
||||
import util.TimeUtils;
|
||||
import com.ljsd.jieling.util.http.HttpPool;
|
||||
import com.ljsd.jieling.logic.dao.ServerConfig;
|
||||
import manager.STableManager;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
|
||||
import java.net.URL;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
|
||||
|
|
|
@ -2,6 +2,7 @@ package com.ljsd;
|
|||
|
||||
import com.google.gson.Gson;
|
||||
import com.ljsd.common.mogodb.util.MongoKeys;
|
||||
import com.ljsd.fight.CheckFight;
|
||||
import com.ljsd.jieling.config.json.CoreSettings;
|
||||
import com.ljsd.jieling.core.CoreLogic;
|
||||
import com.ljsd.jieling.db.mongo.MongoUtil;
|
||||
|
@ -12,7 +13,6 @@ import com.ljsd.jieling.logic.GlobalDataManaager;
|
|||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.dao.GuilidManager;
|
||||
import com.ljsd.jieling.logic.dao.MailingSystemManager;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.network.server.ProtocolsManager;
|
||||
import com.ljsd.jieling.thread.ThreadManager;
|
||||
|
@ -95,12 +95,6 @@ public class GameLogicService implements IService {
|
|||
MongoKeys.initmongoKey();
|
||||
SensitivewordFilter.init();
|
||||
HttpPool.init();
|
||||
|
||||
// 加载lua文件
|
||||
CheckFight.getInstance().init("luafight/BattleMain.lua");
|
||||
|
||||
|
||||
|
||||
KeyGenUtils.setMachineNum(GameApplication.serverProperties.getNum());
|
||||
ActivityLogic.getInstance().checkActiviyStatus();
|
||||
//初始化cdk
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler.map;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.MapStaticConfig;
|
||||
import com.ljsd.jieling.core.FunctionIdEnum;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.handler.map.behavior;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.logic.hero.HeroAttributeEnum;
|
||||
import com.ljsd.jieling.util.CBean2Proto;
|
||||
import config.MapPointConfig;
|
||||
|
@ -16,7 +17,6 @@ import com.ljsd.jieling.logic.OnlineUserManager;
|
|||
import com.ljsd.jieling.logic.dao.Hero;
|
||||
import com.ljsd.jieling.logic.dao.TeamPosHeroInfo;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.logic.fight.FightType;
|
||||
import com.ljsd.jieling.logic.hero.HeroLogic;
|
||||
import com.ljsd.jieling.protocols.CommonProto;
|
||||
import com.ljsd.jieling.protocols.FightInfoProto;
|
||||
|
|
|
@ -1,152 +0,0 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
|
||||
import manager.STableManager;
|
||||
import org.luaj.vm2.Globals;
|
||||
import org.luaj.vm2.LuaTable;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import org.luaj.vm2.lib.jse.JsePlatform;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CheckFight {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(CheckFight.class);
|
||||
|
||||
private ThreadLocal<LuaValue> localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
|
||||
// private String luaFileName = null;
|
||||
|
||||
private CheckFight(){}
|
||||
|
||||
public static class Instance {
|
||||
public final static CheckFight instance = new CheckFight();
|
||||
}
|
||||
|
||||
public static CheckFight getInstance() {
|
||||
return CheckFight.Instance.instance;
|
||||
}
|
||||
|
||||
private int hotFixVersion = 0;
|
||||
|
||||
static class LuaHotFixBean{
|
||||
private int version;
|
||||
|
||||
public int getVersion() {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void luaHotFix(){
|
||||
LuaHotFixBean luaHotFixBean = STableManager.getJsonFilePathInJsonConf("lua-hotfix.json", LuaHotFixBean.class);
|
||||
if(luaHotFixBean!=null && hotFixVersion < luaHotFixBean.getVersion()){
|
||||
LOGGER.info("the curhotFixVersion={},the new hotFixVersion={} will hotifx ",hotFixVersion,luaHotFixBean.getVersion());
|
||||
init("luafight/BattleMain.lua");
|
||||
LOGGER.info("the luahotfix done");
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
this.localTransCoderObj = new ThreadLocal<LuaValue>();
|
||||
}
|
||||
}
|
||||
|
||||
public void init(String path){
|
||||
String luaFileName = null;
|
||||
try {
|
||||
luaFileName = getPath(path);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
// Globals globals = JsePlatform.debugGlobals();
|
||||
// transCoderObj = globals.loadfile(luaFileName).call();
|
||||
LuaHotFixBean luaHotFixBean = STableManager.getJsonFilePathInJsonConf("lua-hotfix.json", LuaHotFixBean.class);
|
||||
if(luaHotFixBean!=null) {
|
||||
hotFixVersion = luaHotFixBean.getVersion();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String getPath(String prefixDir, String... filePath) throws IOException {
|
||||
StringBuilder path = new StringBuilder();
|
||||
path.append(getRootPath()).append(prefixDir);
|
||||
for (String p : filePath) {
|
||||
path.append(File.separator).append(p);
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public static String getRootPath() throws IOException {
|
||||
StringBuilder path = new StringBuilder();
|
||||
if (isWindows()) {// Window 系统
|
||||
path.append(new File(".").getCanonicalPath()).append(File.separator);
|
||||
}else {
|
||||
path.append("../");
|
||||
}
|
||||
return path.toString();
|
||||
}
|
||||
|
||||
public static boolean isWindows() {
|
||||
String osName = System.getProperty("os.name");
|
||||
return osName.matches("^(?i)Windows.*$");
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 单线程执行每次用时50ms,目前支持并发100以内,再大用线程池异步处理
|
||||
* http://www.luaj.org/luaj/3.0/examples/jse/SampleMultiThreaded.java
|
||||
* @param seed
|
||||
* @param fightData
|
||||
* @param optionData
|
||||
* @return {战斗结果,战斗时间,单位1剩余血量,单位2剩余血量,单位3剩余血量,单位4剩余血量,单位5剩余血量}
|
||||
*/
|
||||
public int[] checkFight(int seed,int maxTime, LuaValue fightData, LuaValue optionData,FightType fightType){
|
||||
LuaValue transCoderObj = this.getTransCoderObj();
|
||||
LuaValue func = transCoderObj.get(LuaValue.valueOf("Execute"));
|
||||
LuaValue args = new LuaTable();
|
||||
args.set("seed",seed);
|
||||
args.set("maxTime",maxTime);
|
||||
//todo type
|
||||
args.set("type",fightType.getType());
|
||||
LuaValue result = func.call( args,fightData,optionData);
|
||||
int status = result.get("result").toint();
|
||||
int duration = result.get("duration").toint();
|
||||
int[] resultCache = new int[7];
|
||||
resultCache[0]=status;
|
||||
resultCache[1]=duration;
|
||||
LOGGER.info(" lua check test fight result : "+ status);
|
||||
for (int i = 1; i <= result.length(); i++) {
|
||||
resultCache[i+1] = result.rawget(i).toint();
|
||||
LOGGER.info(i+" --> 单位剩余血量 : "+ resultCache[i+1]);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,5 +1,7 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.fight.CheckFight;
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.config.clazzStaticCfg.CommonStaticConfig;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
import com.ljsd.jieling.core.VipPrivilegeType;
|
||||
|
@ -536,7 +538,7 @@ public class CombatLogic {
|
|||
.addAllMonsterList(monsterGroupList)
|
||||
.build();
|
||||
builder.setFightData(build);
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sMainLevelConfig.getInvasionBossTime(), getFightData, getOptionData,FightType.InvasionBossFight);
|
||||
int[] checkResult = CheckFight.getInstance().checkFight(seed, sMainLevelConfig.getInvasionBossTime(), getFightData, getOptionData, FightType.InvasionBossFight);
|
||||
totalHurt+= updateBossAndGetHurtForFight(checkResult, adventureBoss);
|
||||
fightResult = checkResult[0];
|
||||
//发送击杀boss奖励和发现者奖励
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
public enum FightType {
|
||||
StoryFight(1), //故事副本
|
||||
MapExploreFight(2), // 地图探索
|
||||
ArenaFight(3), //竞技场
|
||||
InvasionBossFight(4),//秘境boss
|
||||
AdventureLock(5), // 解锁秘境
|
||||
GuildFight(6), // 公会站
|
||||
BloodyFight(7), // 血战
|
||||
MonterFight(8), // 兽潮
|
||||
|
||||
|
||||
;
|
||||
|
||||
private int type;
|
||||
|
||||
public int getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
FightType(int type) {
|
||||
|
||||
this.type = type;
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.googlecode.protobuf.format.JsonFormat;
|
||||
import com.ljsd.fight.CheckFight;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.db.redis.RedisUtil;
|
||||
import com.ljsd.jieling.exception.ErrorCode;
|
||||
|
@ -15,10 +16,8 @@ import com.ljsd.jieling.util.FightDataUtil;
|
|||
import com.ljsd.jieling.util.MonsterUtil;
|
||||
import config.SArenaRobotConfig;
|
||||
import org.luaj.vm2.LuaValue;
|
||||
import util.StringUtil;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.ljsd.jieling.logic.fight;
|
||||
|
||||
import com.ljsd.fight.FightType;
|
||||
import com.ljsd.jieling.db.redis.RedisKey;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.DefaultOfRedisCacheFightHandler;
|
||||
import com.ljsd.jieling.logic.fight.eventhandler.DefaultWithoutHandFightHandler;
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.ljsd.jieling.thread.task;
|
||||
|
||||
import com.ljsd.GameApplication;
|
||||
import com.ljsd.fight.CheckFight;
|
||||
import com.ljsd.jieling.config.reportData.DataMessageUtils;
|
||||
import com.ljsd.jieling.core.CoreLogic;
|
||||
import com.ljsd.jieling.core.GlobalsDef;
|
||||
|
@ -18,7 +19,6 @@ import com.ljsd.jieling.logic.OnlineUserManager;
|
|||
import com.ljsd.jieling.logic.activity.ActivityLogic;
|
||||
import com.ljsd.jieling.logic.arena.ArenaLogic;
|
||||
import com.ljsd.jieling.logic.family.GuildFightLogic;
|
||||
import com.ljsd.jieling.logic.fight.CheckFight;
|
||||
import com.ljsd.jieling.logic.fight.CombatLogic;
|
||||
import com.ljsd.jieling.logic.mail.MailLogic;
|
||||
import com.ljsd.jieling.logic.question.QuestionLogic;
|
||||
|
|
Loading…
Reference in New Issue