Merge branch 'master' of http://60.1.1.230/backend/jieling_server
commit
90bc0c62c6
|
@ -1,412 +0,0 @@
|
|||
package com.ljsd.common.mogodb;
|
||||
|
||||
|
||||
import com.mongodb.BasicDBList;
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import sun.reflect.generics.reflectiveObjects.ParameterizedTypeImpl;
|
||||
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
public class BeanUtil {
|
||||
private static Map<Class<?>, Field[]> fieldMap = new ConcurrentHashMap<>();
|
||||
//是否是byte[]
|
||||
private static boolean isByteArray(Object obj){
|
||||
return obj instanceof byte[];
|
||||
}
|
||||
//是否是数组
|
||||
private static boolean isArray(Object obj){
|
||||
if(isByteArray(obj)){
|
||||
return false;
|
||||
}
|
||||
return obj.getClass().isArray();
|
||||
}
|
||||
//将数组对象转为DBObject
|
||||
private static DBObject array2DBObject(Object obj) throws IllegalAccessException {
|
||||
Object[] arr = (Object[]) obj;
|
||||
BasicDBList dbList = new BasicDBList();
|
||||
for(int i=0; i<arr.length; i++){
|
||||
Object dbObject = bean2DBObject(arr[i]);
|
||||
dbList.add(dbObject);
|
||||
}
|
||||
return dbList;
|
||||
}
|
||||
//是否是list
|
||||
private static boolean isList(Object obj){
|
||||
return obj instanceof List;
|
||||
}
|
||||
//将list对象转为DBObject
|
||||
private static DBObject list2DBObject(Object obj) throws IllegalAccessException {
|
||||
List list = (List) obj;
|
||||
BasicDBList dbList = new BasicDBList();
|
||||
for(int i=0; i<list.size(); i++){
|
||||
Object dbObject = bean2DBObject(list.get(i));
|
||||
dbList.add(dbObject);
|
||||
}
|
||||
return dbList;
|
||||
}
|
||||
//是否是map对象
|
||||
private static boolean isMap(Object obj){
|
||||
return obj instanceof Map;
|
||||
}
|
||||
//将map对象转为DBObject
|
||||
private static DBObject map2DBObject(Object obj) throws IllegalAccessException {
|
||||
Map<Object, Object> map = (Map) obj;
|
||||
DBObject dbObject = new BasicDBObject();
|
||||
for (Map.Entry<Object, Object> entry : map.entrySet()) {
|
||||
Object dbObject1 = bean2DBObject(entry.getValue());
|
||||
dbObject.put(entry.getKey().toString(), dbObject1);
|
||||
}
|
||||
return dbObject;
|
||||
}
|
||||
//是否是集合对象
|
||||
private static boolean isSet(Object obj){
|
||||
return obj instanceof Set;
|
||||
}
|
||||
//将集合对象转为DBObject
|
||||
private static DBObject set2DBObject(Object obj) throws IllegalAccessException {
|
||||
Set<Object> set = (Set) obj;
|
||||
BasicDBList dbList = new BasicDBList();
|
||||
for(Object val: set){
|
||||
Object dbObject = bean2DBObject(val);
|
||||
dbList.add(dbObject);
|
||||
}
|
||||
return dbList;
|
||||
}
|
||||
|
||||
private static <T> boolean isBaseType(T param){
|
||||
if (param instanceof Integer) {//判断变量的类型
|
||||
return true;
|
||||
} else if (param instanceof String) {
|
||||
return true;
|
||||
} else if (param instanceof Double) {
|
||||
return true;
|
||||
} else if (param instanceof Float) {
|
||||
return true;
|
||||
} else if (param instanceof Long) {
|
||||
return true;
|
||||
} else if (param instanceof Boolean) {
|
||||
return true;
|
||||
} else if (param instanceof Date) {
|
||||
return true;
|
||||
} else if (param instanceof Byte) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static Field[] getFields(Class<?> clazz){
|
||||
Field[] fields = fieldMap.get(clazz);
|
||||
if(fields == null) {
|
||||
fields = clazz.getDeclaredFields();
|
||||
fieldMap.put(clazz, fields);
|
||||
}
|
||||
return fields;
|
||||
}
|
||||
public static <T> Object bean2DBObject(T bean) throws IllegalArgumentException,
|
||||
IllegalAccessException {
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
if(isBaseType(bean)){
|
||||
return bean;
|
||||
}
|
||||
DBObject dbObject = new BasicDBObject();
|
||||
if (isMap(bean)) {
|
||||
return map2DBObject(bean);
|
||||
} else if (isSet(bean)) {
|
||||
return set2DBObject(bean);
|
||||
} else if (isArray(bean)) {
|
||||
return array2DBObject(bean);
|
||||
} else if (isList(bean)) {
|
||||
return list2DBObject(bean);
|
||||
} else if (isByteArray(bean)) {
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
// 获取对象对应类中的所有属性域
|
||||
Class<?> clazz = bean.getClass();
|
||||
while(clazz != null) {
|
||||
Field[] fields = getFields(clazz);
|
||||
|
||||
for (Field field : fields) {
|
||||
// 获取属性名
|
||||
String varName = field.getName();
|
||||
if(varName.startsWith("_")){
|
||||
continue;
|
||||
} else if(varName.equals("root")){
|
||||
continue;
|
||||
} else if (varName.equals("id")) {
|
||||
varName = "_id";
|
||||
}
|
||||
// 修改访问控制权限
|
||||
boolean accessFlag = field.isAccessible();
|
||||
if (!accessFlag) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
Object param = field.get(bean);
|
||||
if (param == null) {
|
||||
continue;
|
||||
}
|
||||
if (isBaseType(param)) {
|
||||
dbObject.put(varName, param);
|
||||
} else {
|
||||
DBObject rdbObject = (DBObject) bean2DBObject(param);
|
||||
dbObject.put(varName, rdbObject);
|
||||
}
|
||||
// 恢复访问控制权限
|
||||
field.setAccessible(accessFlag);
|
||||
}
|
||||
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
//从基础类型中取得值
|
||||
private static Object getBaseObj(Object object, Class<?> clazz){
|
||||
if(clazz == String.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == int.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == long.class){
|
||||
return object;
|
||||
}
|
||||
if( clazz.equals(float.class)){
|
||||
return ((Double)object).floatValue();
|
||||
}
|
||||
if(clazz == double.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == byte.class){
|
||||
return ((Integer)object).byteValue();
|
||||
}
|
||||
if(clazz == boolean.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == Integer.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == Long.class){
|
||||
return object;
|
||||
}
|
||||
if( clazz.equals(Float.class)){
|
||||
return ((Double)object).floatValue();
|
||||
}
|
||||
if(clazz == Double.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == Byte.class){
|
||||
return object;
|
||||
}
|
||||
if(clazz == Boolean.class){
|
||||
return object;
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
//是否是map对象
|
||||
private static boolean isMap(Class<?> clazz){
|
||||
if( clazz == Map.class){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//取得key对应的值
|
||||
private static Object getKey(String key, Class<?> clazz){
|
||||
if(clazz == Integer.class){
|
||||
return Integer.valueOf(key);
|
||||
}
|
||||
if(clazz == Long.class){
|
||||
return Long.valueOf(key);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
//将DBObject转为map
|
||||
private static <K, V> Map<K, V> dbObject2Map(DBObject dbObject, Field field) throws Exception {
|
||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||
Type[] types = pt.getActualTypeArguments();
|
||||
|
||||
Map map = new HashMap<K, V>();
|
||||
BasicDBObject dbObj = (BasicDBObject)dbObject;
|
||||
for (Map.Entry<String, Object> entry : dbObj.entrySet()) {
|
||||
Type type = types[1];
|
||||
if(type.getClass()== ParameterizedTypeImpl.class){
|
||||
Class actualTypeArgument = (Class) (((ParameterizedTypeImpl) type).getActualTypeArguments()[0]);
|
||||
|
||||
ArrayList<Object> objects = new ArrayList<>();
|
||||
BasicDBList values = (BasicDBList)entry.getValue();
|
||||
Iterator<Object> iterator = values.iterator();
|
||||
while (iterator.hasNext()){
|
||||
Object next = iterator.next();
|
||||
Object obj = getObj(next,actualTypeArgument);
|
||||
objects.add(obj);
|
||||
}
|
||||
Object key = getKey(entry.getKey(), (Class)types[0]);
|
||||
map.put(key,objects);
|
||||
}else{
|
||||
Object obj = getObj(entry.getValue(), (Class)type);
|
||||
// Object value = ((Class)types[1]).newInstance();
|
||||
// Object obj = dbObject2Bean((DBObject) entry.getValue(), value, root);
|
||||
Object key = getKey(entry.getKey(), (Class)types[0]);
|
||||
map.put(key, obj);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return map;
|
||||
}
|
||||
//是否是集合对象
|
||||
private static boolean isSet(Class<?> clazz){
|
||||
if(clazz == Set.class){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//将dbobj转为普通对象
|
||||
private static Object getObj(Object dbobj, Class<?> clazz) throws Exception {
|
||||
Object obj = getBaseObj(dbobj, clazz);
|
||||
if(obj == null){
|
||||
Constructor constructor = clazz.getDeclaredConstructor();
|
||||
boolean isAccessible = constructor.isAccessible();
|
||||
constructor.setAccessible(true);
|
||||
obj = constructor.newInstance();
|
||||
constructor.setAccessible(isAccessible);
|
||||
dbObject2Bean((DBObject) dbobj, obj);
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
//将DBObject转为set
|
||||
private static <T> Set<T> dbObject2Set(DBObject dbObject, Field field) throws Exception {
|
||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||
Type[] types = pt.getActualTypeArguments();
|
||||
Set set = ConcurrentHashMap.<T> newKeySet();
|
||||
BasicDBList dbList = (BasicDBList)dbObject;
|
||||
for (Object dbobj : dbList) {
|
||||
Object obj = getObj(dbobj, (Class)types[0]);
|
||||
set.add(obj);
|
||||
}
|
||||
return set;
|
||||
}
|
||||
//是否是byte[]
|
||||
private static boolean isByteArray(Class<?> clazz){
|
||||
return clazz == byte[].class;
|
||||
}
|
||||
//是否是数组
|
||||
private static boolean isArray(Class<?> clazz){
|
||||
if(isByteArray(clazz)){
|
||||
return false;
|
||||
}
|
||||
return clazz.isArray();
|
||||
}
|
||||
//将DBObject转换为数组
|
||||
private static Object[] dbObject2Array(DBObject dbObject, Class<?> clazz) throws Exception {
|
||||
BasicDBList basicDBList = (BasicDBList)dbObject;
|
||||
Object[] objs = (Object[])Array.newInstance(clazz.getComponentType(), basicDBList.size());
|
||||
for(int i=0; i<basicDBList.size(); i++){
|
||||
Object dbobj = (Object)basicDBList.get(i);
|
||||
Object obj = getObj(dbobj, clazz.getComponentType());
|
||||
objs[i] = obj;
|
||||
}
|
||||
return objs;
|
||||
}
|
||||
//是否是list
|
||||
private static boolean isList(Class<?> clazz){
|
||||
if(clazz == List.class){
|
||||
return true;
|
||||
}
|
||||
if(clazz == ArrayList.class){
|
||||
return true;
|
||||
}
|
||||
if(clazz == CopyOnWriteArrayList.class){
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//将DBObject转为list
|
||||
private static <T> List<T> dbObject2List(DBObject dbObject, Field field) throws Exception {
|
||||
ParameterizedType pt = (ParameterizedType) field.getGenericType();
|
||||
Type[] types = pt.getActualTypeArguments();
|
||||
List list = new CopyOnWriteArrayList<T>();
|
||||
BasicDBList dbList = (BasicDBList)dbObject;
|
||||
for (Object dbobj : dbList) {
|
||||
Object obj = getObj(dbobj, (Class)types[0]);
|
||||
list.add(obj);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
//DBObject转换为Bean对象
|
||||
public static Object dbObject2Bean(DBObject dbObject, Object bean) throws Exception {
|
||||
if (bean == null) {
|
||||
return null;
|
||||
}
|
||||
Class<?> clazz = bean.getClass();
|
||||
while (clazz != null) {
|
||||
Field[] fields = getFields(clazz);
|
||||
for (Field field : fields) {
|
||||
String varName = field.getName();
|
||||
Object object = null;
|
||||
if (varName.equals("id")) {
|
||||
object = dbObject.get("_id");
|
||||
}
|
||||
// else if(varName.equals("_root")){
|
||||
// ((MongoBase)bean).setRoot((MongoRoot) root);
|
||||
// continue;
|
||||
// }
|
||||
// else if(varName.equals("bsave")){
|
||||
// ((MongoRoot)bean).setBsave(true);
|
||||
// continue;
|
||||
// }
|
||||
else {
|
||||
object = dbObject.get(varName);
|
||||
}
|
||||
if (object == null) {
|
||||
continue;
|
||||
}
|
||||
boolean accessFlag = field.isAccessible();
|
||||
if (!accessFlag) {
|
||||
field.setAccessible(true);
|
||||
}
|
||||
|
||||
//System.out.println("varName=" + varName);
|
||||
Class<?> fieldClazz = field.getType();
|
||||
Object obj = getBaseObj(object, fieldClazz);
|
||||
if (obj != null) {
|
||||
field.set(bean, obj);
|
||||
} else if (isMap(fieldClazz)) {
|
||||
obj = dbObject2Map((DBObject) object, field);
|
||||
} else if (isSet(fieldClazz)) {
|
||||
obj = dbObject2Set((DBObject) object, field);
|
||||
} else if (isArray(fieldClazz)) {
|
||||
obj = dbObject2Array((DBObject) object, fieldClazz);
|
||||
} else if (isList(fieldClazz)) {
|
||||
obj = dbObject2List((DBObject) object, field);
|
||||
} else if (isByteArray(fieldClazz)) {
|
||||
obj = object;
|
||||
} else {
|
||||
obj = fieldClazz.newInstance();
|
||||
obj = dbObject2Bean((DBObject) object, obj);
|
||||
}
|
||||
field.set(bean, obj);
|
||||
// 恢复访问控制权限
|
||||
field.setAccessible(accessFlag);
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
return bean;
|
||||
}
|
||||
|
||||
public static <T> T dbObject2Bean(DBObject dbObject, Class<T> clazz) throws Exception {
|
||||
if(dbObject == null){
|
||||
return null;
|
||||
}
|
||||
T bean = clazz.newInstance();
|
||||
dbObject2Bean(dbObject, bean);
|
||||
return bean;
|
||||
}
|
||||
}
|
|
@ -34,19 +34,14 @@ public class LjsdMongoTemplate {
|
|||
}
|
||||
|
||||
public <T> List<T> findAll(String collectionName, Class<T> clazz) throws Exception {
|
||||
DBCollection coll = mongoTemplate.getCollection(collectionName);
|
||||
DBCursor dbCursor = coll.find();
|
||||
List<T> list= new ArrayList<>(dbCursor.count());
|
||||
for (Iterator<DBObject> it = dbCursor.iterator(); it.hasNext(); ) {
|
||||
list.add(BeanUtil.dbObject2Bean(it.next(), clazz));
|
||||
}
|
||||
return list;
|
||||
return mongoTemplate.findAll(clazz,collectionName);
|
||||
}
|
||||
|
||||
public <T> T findById(String collectionName, String id, Class<T> clazz) throws Exception {
|
||||
DBCollection coll = mongoTemplate.getCollection(collectionName);
|
||||
return mongoTemplate.findById(id,clazz,collectionName);
|
||||
/* DBCollection coll = mongoTemplate.getCollection(collectionName);
|
||||
DBObject doc = coll.findOne(id);
|
||||
return BeanUtil.dbObject2Bean(doc, clazz);
|
||||
return BeanUtil.dbObject2Bean(doc, clazz);*/
|
||||
}
|
||||
|
||||
public <T> T findById(int id, Class<T> clazz) throws Exception {
|
||||
|
@ -104,26 +99,4 @@ public class LjsdMongoTemplate {
|
|||
public Object convertToMongoType(Object obj){
|
||||
return this.mongoTemplate.getConverter().convertToMongoType(obj);
|
||||
}
|
||||
|
||||
public void dynamicChangeTheMongoRoot(Object obj,MongoRoot mongoRoot) throws Exception {
|
||||
Class clazz = obj.getClass();
|
||||
while (clazz != null && clazz != Object.class && clazz != MongoRoot.class) {
|
||||
if(clazz == MongoBase.class){
|
||||
Field root = clazz.getDeclaredField("_root");
|
||||
root.setAccessible(true);
|
||||
root.set(obj, new WeakReference<>(mongoRoot));
|
||||
return;
|
||||
}
|
||||
Field[] declaredFields = clazz.getDeclaredFields();
|
||||
for (Field tmpField : declaredFields){
|
||||
Class<?> type = tmpField.getType();
|
||||
if(!MongoBase.class.isAssignableFrom(type)){
|
||||
continue;
|
||||
}
|
||||
tmpField.setAccessible(true);
|
||||
dynamicChangeTheMongoRoot(tmpField.get(obj),mongoRoot);
|
||||
}
|
||||
clazz = clazz.getSuperclass();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -34,12 +34,15 @@ public class MongoUpdateCache {
|
|||
while (it.hasNext()) {
|
||||
Map.Entry<String, UpdateRequest> entry = it.next();
|
||||
String key1 = entry.getKey();
|
||||
if (fullKey.contains(key1)) {
|
||||
return;
|
||||
}
|
||||
if (key1.contains(fullKey)) {
|
||||
it.remove();
|
||||
if(!fullKey.equals(key1)){
|
||||
if (fullKey.contains(key1)) {
|
||||
return;
|
||||
}
|
||||
if (key1.contains(fullKey)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
UpdateRequest request = new UpdateRequest(fullKey, value, opCode, mongoBase);
|
||||
|
|
|
@ -9,50 +9,3 @@ int mut,int#int,2 mut,int#int,1
|
|||
7 null 6021#6022#6023#6024
|
||||
8 null 6025#6026#6027#6028
|
||||
9 null 6029#6030#6031#6032
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
0 null null
|
||||
|
|
|
@ -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 设置开服时间
|
||||
|
|
|
@ -155,7 +155,7 @@ public class Hero extends MongoBase {
|
|||
public void removeEquip(int position){
|
||||
String value = this.equipByPositionMap.get(position);
|
||||
if (value!=null){
|
||||
removeString("equipByPositionMap." + position);
|
||||
removeString(getMongoKey()+".equipByPositionMap." + position);
|
||||
this.equipByPositionMap.remove(position);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import com.ljsd.common.mogodb.MongoBase;
|
|||
import com.ljsd.jieling.config.SWorkShopSetting;
|
||||
import com.ljsd.jieling.db.mongo.MongoKey;
|
||||
import com.ljsd.jieling.logic.dao.root.MailingSystem;
|
||||
import com.ljsd.jieling.logic.dao.root.User;
|
||||
import com.ljsd.jieling.util.MathUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -22,7 +23,7 @@ public class WorkShopController extends MongoBase {
|
|||
private int cookExp;
|
||||
|
||||
public WorkShopController(){
|
||||
this.setRootCollection(MailingSystem._COLLECTION_NAME);
|
||||
this.setRootCollection(User._COLLECTION_NAME);
|
||||
|
||||
this.openBlueStateMap = new HashMap<>();
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,11 +86,11 @@ public class ItemUtil {
|
|||
selectDrop(sRewardGroup,itemMap,cardMap,equipMap,randomMap,dropRatio);
|
||||
}
|
||||
useRandomItem(user,randomMap);
|
||||
if (isMapping == 1) {
|
||||
addItemToTemporaryBag(user,itemMap,dropBuilder);
|
||||
} else {
|
||||
addItem(user,itemMap,dropBuilder);
|
||||
}
|
||||
// if (isMapping == 1) {
|
||||
// addItemToTemporaryBag(user,itemMap,dropBuilder);
|
||||
// } else {
|
||||
// }
|
||||
addItem(user,itemMap,dropBuilder);
|
||||
addCard(user,cardMap,dropBuilder);
|
||||
addEquip(user,equipMap,dropBuilder);
|
||||
return dropBuilder;
|
||||
|
|
Loading…
Reference in New Issue