游戏数据
parent
37c27161ea
commit
0ebc3f8064
|
@ -0,0 +1,66 @@
|
|||
#server info
|
||||
server.id = 10180
|
||||
|
||||
|
||||
# redis config
|
||||
# Redis数据库索引(默认为0)
|
||||
spring.redis.database=0
|
||||
# Redis服务器地址
|
||||
spring.redis.host=60.1.1.14
|
||||
# Redis服务器连接端口
|
||||
spring.redis.port=6379
|
||||
# Redis服务器连接密码(默认为空)
|
||||
spring.redis.password=
|
||||
# 连接池最大连接数(使用负值表示没有限制)
|
||||
spring.redis.pool.max-active=8
|
||||
# 连接池最大阻塞等待时间(使用负值表示没有限制)
|
||||
spring.redis.pool.max-wait=-1
|
||||
# 连接池中的最大空闲连接
|
||||
spring.redis.pool.max-idle=8
|
||||
# 连接池中的最小空闲连接
|
||||
spring.redis.pool.min-idle=0
|
||||
# 连接超时时间(毫秒)
|
||||
spring.redis.timeout=0
|
||||
|
||||
spring.redis.expireTime = -1
|
||||
|
||||
|
||||
#spring.data.mongodb.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/ysj_wx_1
|
||||
#spring.data.mongodb2.uri = mongodb://mongouser:ysj#2017#ljsd@111.231.54.96:27017/develop_ysj_wx_1
|
||||
#mongodb2 develop
|
||||
spring.data.mongodb.uri = mongodb://60.1.1.14:27017/ysj_msy
|
||||
mongodb.options.maxWaitTime = 120000
|
||||
mongodb.options.connectTimeout = 1000
|
||||
mongodb.options.socketTimeout = 0
|
||||
mongodb.options.threadsAllowedToBlockForConnectionMultiplier = 20
|
||||
mongodb.options.connectionsPerHost = 256
|
||||
mongodb.options.minConnectionsPerHost = 100
|
||||
mongodb.options.maxConnectionIdleTime = 1000
|
||||
|
||||
|
||||
# netty config
|
||||
netty.tcpPort = 18090
|
||||
netty.chatTcpPort = 20001
|
||||
netty.logintcpPort = 18091
|
||||
netty.udpPort = 18092
|
||||
netty.udpTargetIp=127.0.0.1
|
||||
netty.udpTargetPort=10001
|
||||
netty.reconnectDelay=3000
|
||||
netty.bossThreadCount=1
|
||||
netty.workerThreadCount=10
|
||||
netty.readTimeout=32
|
||||
netty.writeTimeout=32
|
||||
netty.allTimeout=35
|
||||
|
||||
|
||||
#core
|
||||
services.core.ip=60.1.1.180
|
||||
services.core.port=7900
|
||||
services.core.area=1000
|
||||
services.core.id=1
|
||||
services.core.weight=5
|
||||
|
||||
#arena service
|
||||
services.fight.key=key_dir_checkserver_Hash
|
||||
|
||||
logging.config = conf/logback-boot.xml
|
|
@ -11,7 +11,7 @@ public class OnlineUserManager {
|
|||
public static Map<Integer, Integer> onlineUidMap = new ConcurrentHashMap<>();
|
||||
public static Map<Integer, ISession> sessionMap = new ConcurrentHashMap<>();
|
||||
|
||||
public static Map<Integer, PlayerInfo> onlineUserMap = new ConcurrentHashMap<>(10000);
|
||||
public static Map<Integer, PlayerInfoManager> onlineUserMap = new ConcurrentHashMap<>(10000);
|
||||
|
||||
|
||||
public static void registUser(int uid, int serverId, ISession session) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class HeroManager {
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
public class HeroManager extends MongoBase {
|
||||
|
||||
}
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class ItemManager {
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
public class ItemManager extends MongoBase {
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,4 +1,34 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class MapManager {
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
import com.ljsd.jieling.logic.map.CMap;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class MapManager extends MongoBase {
|
||||
private Map<Integer, CMap> cMapMap;
|
||||
|
||||
public MapManager(){
|
||||
cMapMap = new ConcurrentHashMap<>();
|
||||
}
|
||||
public void removeCard(int id) {
|
||||
removeString("cMapMap." + id);
|
||||
cMapMap.remove(id);
|
||||
}
|
||||
|
||||
public void addCard(CMap cMap) throws Exception {
|
||||
cMap.init(getRoot(), getMongoKey() + ".cMapMap." + cMap.getId());
|
||||
updateString("cMapMap." + cMap.getId(), cMap);
|
||||
cMapMap.put(cMap.getId(), cMap);
|
||||
}
|
||||
|
||||
|
||||
public Map<Integer, CMap> getcMapMap() {
|
||||
return cMapMap;
|
||||
}
|
||||
|
||||
public void setcMapMap(Map<Integer, CMap> cMapMap) {
|
||||
this.cMapMap = cMapMap;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +0,0 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
public class PlayerInfo {
|
||||
|
||||
private UserManager userManager;
|
||||
|
||||
private ItemManager itemManager;
|
||||
|
||||
private HeroManager heroManager;
|
||||
|
||||
private MapManager mapManager;
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
public class PlayerInfoManager extends MongoBase {
|
||||
|
||||
private String nickName;
|
||||
|
||||
private int level;
|
||||
|
||||
private int exp;
|
||||
|
||||
public String getNickName() {
|
||||
return nickName;
|
||||
}
|
||||
|
||||
public void setNickName(String nickName) throws Exception {
|
||||
updateString("nickName", nickName);
|
||||
this.nickName = nickName;
|
||||
}
|
||||
|
||||
public int getLevel() {
|
||||
return level;
|
||||
}
|
||||
|
||||
public void setLevel(int level) throws Exception {
|
||||
updateString("level", level);
|
||||
this.level = level;
|
||||
}
|
||||
|
||||
public int getExp() {
|
||||
return exp;
|
||||
}
|
||||
|
||||
public void setExp(int exp) throws Exception {
|
||||
updateString("exp", exp);
|
||||
this.exp = exp;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import com.ljsd.common.mogodb.MongoRoot;
|
||||
|
||||
public class User extends MongoRoot {
|
||||
public static final String _COLLECTION_NAME = "user";
|
||||
private static LjsdMongoTemplate _myMongoDBPool;
|
||||
|
||||
private PlayerInfoManager playerInfoManager;
|
||||
|
||||
private ItemManager itemManager;
|
||||
|
||||
private HeroManager heroManager;
|
||||
|
||||
private MapManager mapManager;
|
||||
|
||||
public User(int uid,MapManager mapManager){
|
||||
setId(Integer.toString(uid));
|
||||
this.mapManager = mapManager;
|
||||
}
|
||||
|
||||
public static void init(LjsdMongoTemplate ljsdMongoTemplate) {
|
||||
_myMongoDBPool = ljsdMongoTemplate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCollection() {
|
||||
return _COLLECTION_NAME;
|
||||
}
|
||||
|
||||
public static String getCollectionName() {
|
||||
return _COLLECTION_NAME;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,55 @@
|
|||
package com.ljsd.jieling.logic.dao;
|
||||
|
||||
|
||||
import com.ljsd.common.mogodb.LjsdMongoTemplate;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class UserManager {
|
||||
private static Map<Integer, User> userMap = new ConcurrentHashMap<>();
|
||||
private static LjsdMongoTemplate ljsdMongoTemplate;
|
||||
public static void init(ConfigurableApplicationContext configurableApplicationContext) {
|
||||
ljsdMongoTemplate =configurableApplicationContext.getBean(LjsdMongoTemplate.class);
|
||||
User.init(ljsdMongoTemplate);
|
||||
}
|
||||
|
||||
public static void addUser(User user) {
|
||||
userMap.put(user._getIntId(), user);
|
||||
}
|
||||
|
||||
public static User getUserForLogin(int uid) throws Exception {
|
||||
User user = userMap.get(uid);
|
||||
if (user == null) {
|
||||
user = ljsdMongoTemplate.findById(User.getCollectionName(), Integer.toString(uid), User.class);
|
||||
}
|
||||
if (user == null) {
|
||||
user = new User(uid,new MapManager());
|
||||
UserManager.addUser(user);
|
||||
ljsdMongoTemplate.save(user);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
public static User getUser(int uid) throws Exception {
|
||||
User user = userMap.get(uid);
|
||||
if (user != null) {
|
||||
return user;
|
||||
}
|
||||
user =ljsdMongoTemplate.findById(User.getCollectionName(), Integer.toString(uid), User.class);
|
||||
if (user == null) {
|
||||
throw new Exception("UserManager::getUser null exception");
|
||||
}
|
||||
UserManager.addUser(user);
|
||||
return user;
|
||||
}
|
||||
|
||||
public static void removeUser(int uid) {
|
||||
userMap.remove(uid);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,33 +1,30 @@
|
|||
package com.ljsd.jieling.logic.map;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.mongodb.core.mapping.Document;
|
||||
import org.springframework.data.mongodb.core.mapping.Field;
|
||||
|
||||
|
||||
import com.ljsd.common.mogodb.MongoBase;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Document(collection = "c_map")
|
||||
public class CMap {
|
||||
|
||||
@Id
|
||||
public class CMap extends MongoBase {
|
||||
|
||||
|
||||
private int id;
|
||||
|
||||
@Field(value = "curMapId")
|
||||
private int curMapId;
|
||||
|
||||
@Field(value = "curXY")
|
||||
private int curXY;
|
||||
|
||||
@Field(value = "mapInfo")
|
||||
private Map<Integer, Cell> mapInfo = new ConcurrentHashMap<>();
|
||||
|
||||
@Field(value = "crossMapInfos")
|
||||
private Map<Integer, List<Integer>> crossMapInfos = new ConcurrentHashMap<>();
|
||||
|
||||
|
||||
public void setId(int id) {
|
||||
public void setId(int id) throws Exception {
|
||||
updateString("id", id);
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
@ -47,7 +44,8 @@ public class CMap {
|
|||
return curMapId;
|
||||
}
|
||||
|
||||
public void setCurMapId(int curMapId) {
|
||||
public void setCurMapId(int curMapId) throws Exception {
|
||||
updateString("curMapId", curXY);
|
||||
this.curMapId = curMapId;
|
||||
}
|
||||
|
||||
|
@ -55,7 +53,8 @@ public class CMap {
|
|||
return curXY;
|
||||
}
|
||||
|
||||
public void setCurXY(int curXY) {
|
||||
public void setCurXY(int curXY) throws Exception {
|
||||
updateString("curXY", curXY);
|
||||
this.curXY = curXY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ public class MapLogic {
|
|||
* 获取地图信息
|
||||
* @param uid
|
||||
*/
|
||||
public void getMapInfo(int uid) {
|
||||
public void getMapInfo(int uid) throws Exception {
|
||||
// get db
|
||||
CMap cMap = null;
|
||||
if (cMap == null) {
|
||||
|
@ -44,7 +44,7 @@ public class MapLogic {
|
|||
}
|
||||
|
||||
|
||||
private void initMap(int uid, int mapId) {
|
||||
private void initMap(int uid, int mapId) throws Exception {
|
||||
if (mapId == 0) {
|
||||
mapId = 1;
|
||||
}
|
||||
|
@ -80,7 +80,7 @@ public class MapLogic {
|
|||
* @param uid
|
||||
* @param xy
|
||||
*/
|
||||
public void finishEvent(int uid, int xy) {
|
||||
public void finishEvent(int uid, int xy) throws Exception {
|
||||
// get db
|
||||
CMap cMap = null;
|
||||
Cell cell = cMap.getMapInfo().get(xy);
|
||||
|
|
Loading…
Reference in New Issue