Merge branch 'main' of https://cnb.cool/blzing/blazing
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
This commit is contained in:
@@ -36,7 +36,10 @@ ENV GOPATH /root/go
|
||||
ENV PATH="${PATH}:${GOPATH}/bin"
|
||||
|
||||
RUN go install -v golang.org/x/tools/gopls@latest
|
||||
|
||||
RUN go install -v github.com/cweill/gotests/gotests@latest
|
||||
RUN go install -v github.com/josharian/impl@latest
|
||||
RUN go install -v github.com/haya14busa/goplay/cmd/goplay@latest
|
||||
RUN go install -v github.com/go-delve/delve/cmd/dlv@latest
|
||||
# install goreleaser
|
||||
RUN go install github.com/goreleaser/goreleaser/v2@latest
|
||||
|
||||
|
||||
@@ -13,18 +13,18 @@ type sConfig struct {
|
||||
File *file `json:"file,omitempty"` // 文件上传配置
|
||||
Name string `json:"name"` // 项目名称
|
||||
// LoginPort string `json:"port"`
|
||||
GameOnlineID uint16 `json:"port_bl"` //这个是命令行输入的参数
|
||||
GameOnlineID uint32 `json:"port_bl"` //这个是命令行输入的参数
|
||||
ServerInfo ServerList
|
||||
|
||||
Address string //rpc端口
|
||||
|
||||
}
|
||||
type ServerList struct {
|
||||
OnlineID uint16 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
|
||||
OnlineID uint32 `gorm:"column:online_id;comment:'在线ID';uniqueIndex" json:"online_id"`
|
||||
//服务器名称Desc
|
||||
Name string `gorm:"comment:'服务器名称'" json:"name"`
|
||||
IP string `gorm:"type:string;comment:'服务器IP'" json:"ip"`
|
||||
Port uint16 `gorm:"comment:'端口号,通常是小整数'" json:"port"`
|
||||
Port uint32 `gorm:"comment:'端口号,通常是小整数'" json:"port"`
|
||||
IsOpen uint8 `gorm:"default:0;not null;comment:'是否开启'" json:"is_open"`
|
||||
//登录地址
|
||||
LoginAddr string `gorm:"type:string;comment:'登录地址'" json:"login_addr"`
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package cool
|
||||
|
||||
// 存值示例
|
||||
func AddClient(id uint16, client *ClientHandler) {
|
||||
func AddClient(id uint32, client *ClientHandler) {
|
||||
// 普通map:Clientmap[id] = client
|
||||
Clientmap.Store(id, client) // sync.Map存值
|
||||
}
|
||||
|
||||
// 取值示例
|
||||
func GetClient(id uint16) (*ClientHandler, bool) {
|
||||
func GetClient(id uint32) (*ClientHandler, bool) {
|
||||
// 普通map:client, ok := Clientmap[id]
|
||||
val, ok := Clientmap.Load(id) // sync.Map取值
|
||||
if !ok {
|
||||
|
||||
@@ -20,8 +20,8 @@ func newSessionStore() *cacheStore[uint32] {
|
||||
}
|
||||
|
||||
// newUserOnlineStore 创建用户在线状态缓存实例
|
||||
func newUserOnlineStore() *cacheStore[uint16] {
|
||||
return &cacheStore[uint16]{
|
||||
func newUserOnlineStore() *cacheStore[uint32] {
|
||||
return &cacheStore[uint32]{
|
||||
manager: cool.CacheManager,
|
||||
prefix: "blazing:useronline:",
|
||||
}
|
||||
@@ -38,7 +38,7 @@ func newEmailCodeStore() *cacheStore[int] {
|
||||
// sessionManager 会话管理器
|
||||
type sessionManager struct {
|
||||
sessionStore *cacheStore[uint32] // 会话缓存
|
||||
userOnlineStore *cacheStore[uint16] // 用户在线状态缓存
|
||||
userOnlineStore *cacheStore[uint32] // 用户在线状态缓存
|
||||
emailCodeStore *cacheStore[int] // 邮件注册码缓存
|
||||
}
|
||||
|
||||
@@ -52,12 +52,12 @@ func newSessionManager() *sessionManager {
|
||||
}
|
||||
|
||||
// SetUserOnline 设置用户在线状态
|
||||
func (m *sessionManager) SetUserOnline(userID uint32, serverID uint16) error {
|
||||
func (m *sessionManager) SetUserOnline(userID uint32, serverID uint32) error {
|
||||
return m.userOnlineStore.Set(gctx.New(), gconv.String(userID), serverID, 0)
|
||||
}
|
||||
|
||||
// GetUserOnline 获取用户在线状态
|
||||
func (m *sessionManager) GetUserOnline(userID uint32) (uint16, error) {
|
||||
func (m *sessionManager) GetUserOnline(userID uint32) (uint32, error) {
|
||||
return m.userOnlineStore.Get(context.Background(), gconv.String(userID))
|
||||
}
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ func GetServerInfoList(isdebug int32) []ServerInfo {
|
||||
|
||||
}
|
||||
tt.Name = v.Name
|
||||
tt.Port = v.Port
|
||||
tt.Port =uint16( v.Port)
|
||||
ret1 = append(ret1, *tt)
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ type ServerInfo struct {
|
||||
// 服务器IP, 16字节UTF-8, 不足16补齐到16
|
||||
IP string `struc:"[16]byte"` // 定长模式:16字节
|
||||
// 端口
|
||||
Port uint16
|
||||
Port uint16
|
||||
// 好友在线的个数
|
||||
Friends uint32
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ func (*ServerHandler) Kick(_ context.Context, userid uint32) error {
|
||||
}
|
||||
|
||||
// 注册logic服务器
|
||||
func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error {
|
||||
func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint32) error {
|
||||
fmt.Println("注册logic服务器", id, port)
|
||||
|
||||
//TODO 待修复滚动更新可能导致的玩家可以同时在旧服务器和新服务器同时在线的bug
|
||||
@@ -44,11 +44,11 @@ func (*ServerHandler) RegisterLogic(ctx context.Context, id, port uint16) error
|
||||
}
|
||||
t := config.NewServerService().GetServerID((id))
|
||||
|
||||
aa, ok := cool.GetClient(t.Port)
|
||||
aa, ok := cool.GetClient(t.OnlineID*100000 + t.Port)
|
||||
if ok && aa != nil { //如果已经存在且这个端口已经被存过
|
||||
aa.QuitSelf(0)
|
||||
}
|
||||
cool.AddClient(port, &revClient)
|
||||
cool.AddClient(100000*id+port, &revClient)
|
||||
|
||||
//Refurh()
|
||||
return nil
|
||||
@@ -67,10 +67,10 @@ func CServer() *jsonrpc.RPCServer {
|
||||
|
||||
var closer jsonrpc.ClientCloser
|
||||
|
||||
func StartClient(id, port uint16, callback any) *struct {
|
||||
func StartClient(id, port uint32, callback any) *struct {
|
||||
Kick func(uint32) error
|
||||
|
||||
RegisterLogic func(uint16, uint16) error
|
||||
RegisterLogic func(uint32, uint32) error
|
||||
} {
|
||||
// cool.Config.File.Domain = "127.0.0.1"
|
||||
var rpcaddr = "ws://" + cool.Config.File.Domain + gconv.String(cool.Config.Address) + "/rpc"
|
||||
@@ -99,7 +99,7 @@ func StartClient(id, port uint16, callback any) *struct {
|
||||
var RPCClient struct {
|
||||
Kick func(uint32) error //踢人
|
||||
|
||||
RegisterLogic func(uint16, uint16) error
|
||||
RegisterLogic func(uint32, uint32) error
|
||||
|
||||
// UserLogin func(int32, int32) error //用户登录事件
|
||||
// UserLogout func(int32, int32) error //用户登出事件
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
"github.com/panjf2000/gnet/v2"
|
||||
)
|
||||
|
||||
func (s *Server) Boot(serverid, port uint16) error {
|
||||
func (s *Server) Boot(serverid, port uint32) error {
|
||||
// go s.bootws()
|
||||
s.serverid = serverid
|
||||
s.port = port
|
||||
|
||||
@@ -25,8 +25,8 @@ type Server struct {
|
||||
discorse bool
|
||||
quit bool
|
||||
// batchRead int
|
||||
serverid uint16
|
||||
port uint16
|
||||
serverid uint32
|
||||
port uint32
|
||||
}
|
||||
|
||||
type Option func(*Server)
|
||||
|
||||
@@ -50,6 +50,7 @@ func (s *Server) QuitSelf(a int) error {
|
||||
return false
|
||||
})
|
||||
} else {
|
||||
|
||||
go func() {
|
||||
player.Mainplayer.Range(func(key uint32, value *player.Player) bool {
|
||||
if value != nil {
|
||||
@@ -63,9 +64,10 @@ func (s *Server) QuitSelf(a int) error {
|
||||
if value != nil {
|
||||
value.Kick(true)
|
||||
}
|
||||
os.Exit(0)
|
||||
|
||||
return false
|
||||
})
|
||||
os.Exit(0)
|
||||
}()
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1,49 @@
|
||||
select setval('base_sys_user_id_seq', 10000000, false);
|
||||
select setval('base_sys_user_id_seq', 10000000, false);
|
||||
|
||||
|
||||
-- 清理旧函数
|
||||
ALTER TABLE base_sys_user
|
||||
ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq');
|
||||
|
||||
DROP FUNCTION IF EXISTS shuffle_8digit() CASCADE;
|
||||
|
||||
-- 8位自增 → 纯数字位置互换 → 依旧8位 → 100%不重复
|
||||
CREATE OR REPLACE FUNCTION shuffle_8digit()
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
VOLATILE
|
||||
AS $$
|
||||
DECLARE
|
||||
seq bigint;
|
||||
d0 int; d1 int; d2 int; d3 int;
|
||||
d4 int; d5 int; d6 int; d7 int;
|
||||
BEGIN
|
||||
seq := nextval('base_sys_user_id_seq'); -- 原本就是8位
|
||||
|
||||
-- 把 8 位数字拆出来:d7 d6 d5 d4 d3 d2 d1 d0
|
||||
d7 := (seq / 10000000) % 10;
|
||||
d6 := (seq / 1000000) % 10;
|
||||
d5 := (seq / 100000) % 10;
|
||||
d4 := (seq / 10000) % 10;
|
||||
d3 := (seq / 1000) % 10;
|
||||
d2 := (seq / 100) % 10;
|
||||
d1 := (seq / 10) % 10;
|
||||
d0 := seq % 10;
|
||||
|
||||
-- 固定位置互换(一对一置换,绝对不重复)
|
||||
RETURN
|
||||
d3*10000000 +
|
||||
d7*1000000 +
|
||||
d1*100000 +
|
||||
d5*10000 +
|
||||
d2*1000 +
|
||||
d6*100 +
|
||||
d0*10 +
|
||||
d4;
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 启用
|
||||
ALTER TABLE base_sys_user
|
||||
ALTER COLUMN id SET DEFAULT shuffle_8digit();
|
||||
|
||||
59
help/随机id生成
Normal file
59
help/随机id生成
Normal file
@@ -0,0 +1,59 @@
|
||||
-- 清理旧的
|
||||
ALTER TABLE base_sys_user
|
||||
ALTER COLUMN id SET DEFAULT nextval('base_sys_user_id_seq');
|
||||
DROP FUNCTION IF EXISTS shuffle_9digit() CASCADE;
|
||||
|
||||
-- 9位乱序:首尾互换 + 中间全部打乱
|
||||
-- 纯数字换位,100% 不重复,速度极快
|
||||
CREATE OR REPLACE FUNCTION shuffle_9digit()
|
||||
RETURNS bigint
|
||||
LANGUAGE plpgsql
|
||||
VOLATILE
|
||||
AS $$
|
||||
DECLARE
|
||||
seq bigint;
|
||||
d0 int; -- 原最后一位
|
||||
d1 int;
|
||||
d2 int;
|
||||
d3 int;
|
||||
d4 int;
|
||||
d5 int;
|
||||
d6 int;
|
||||
d7 int; -- 原第一位
|
||||
BEGIN
|
||||
seq := nextval('base_sys_user_id_seq'); -- 8位自增
|
||||
|
||||
-- 拆分 8 位:d7 d6 d5 d4 d3 d2 d1 d0
|
||||
d7 := (seq / 10000000) % 10;
|
||||
d6 := (seq / 1000000) % 10;
|
||||
d5 := (seq / 100000) % 10;
|
||||
d4 := (seq / 10000) % 10;
|
||||
d3 := (seq / 1000) % 10;
|
||||
d2 := (seq / 100) % 10;
|
||||
d1 := (seq / 10) % 10;
|
||||
d0 := seq % 10;
|
||||
|
||||
-- 构造成 9 位,规则:
|
||||
-- 1. 首尾互换(原最后一位放第1位,原第1位放最后)
|
||||
-- 2. 中间全部打乱位置
|
||||
RETURN
|
||||
d0 * 100000000 + -- 原最后一位 → 第1位
|
||||
d3 * 10000000 +
|
||||
d1 * 1000000 +
|
||||
d5 * 100000 +
|
||||
d2 * 10000 +
|
||||
d6 * 1000 +
|
||||
d4 * 100 +
|
||||
d7 * 10 +
|
||||
d0; -- 原第一位 → 第9位
|
||||
END;
|
||||
$$;
|
||||
|
||||
-- 启用
|
||||
ALTER TABLE base_sys_user
|
||||
ALTER COLUMN id SET DEFAULT shuffle_9digit();
|
||||
|
||||
|
||||
ALTER TABLE base_sys_user
|
||||
ALTER COLUMN id
|
||||
SET DEFAULT nextval('base_sys_user_id_seq');
|
||||
@@ -23,11 +23,11 @@ var Maincontroller = &Controller{} //注入service
|
||||
|
||||
// Controller 分发cmd逻辑实现
|
||||
type Controller struct {
|
||||
Port uint16
|
||||
Port uint32
|
||||
RPCClient *struct {
|
||||
Kick func(uint32) error
|
||||
|
||||
RegisterLogic func(uint16, uint16) error
|
||||
RegisterLogic func(uint32, uint32) error
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -174,9 +174,9 @@ func (Controller) OnPlayerFightNpcMonster(data1 *fight.FightNpcMonsterInboundInf
|
||||
items.ADDitem(3, uint32(poolexp))
|
||||
|
||||
p.AddPetExp(foi.Winpet, int64(addexp))
|
||||
|
||||
if monster.IsShiny() && p.CanGetXUAN() {
|
||||
xuan := 400686 + int64(xmlres.PetMAP[int(refPet.GetID())].Type)
|
||||
pettype := int64(xmlres.PetMAP[int(refPet.GetID())].Type)
|
||||
if monster.IsShiny() && p.CanGetXUAN() && pettype < 16 {
|
||||
xuan := 400686 + pettype
|
||||
ok := p.ItemAdd(xuan, 1)
|
||||
if ok {
|
||||
items.ADDitem(uint32(xuan), 1)
|
||||
|
||||
@@ -97,7 +97,7 @@ func (h Controller) handleNeuronItem(currentPet *model.PetInfo, c *player.Player
|
||||
|
||||
// 炫彩碎片 处理神300212
|
||||
func (h Controller) handlexuancaiItem(currentPet *model.PetInfo, c *player.Player) errorcode.ErrorCode {
|
||||
r, _ := element.Calculator.GetCombination(int(currentPet.ID))
|
||||
r, _ := element.Calculator.GetCombination(int(xmlres.PetMAP[int(currentPet.ID)].Type))
|
||||
if r.Secondary != nil {
|
||||
return errorcode.ErrorCodes.ErrItemUnusable
|
||||
}
|
||||
|
||||
@@ -11,10 +11,6 @@ import (
|
||||
"github.com/jinzhu/copier"
|
||||
)
|
||||
|
||||
// PetEVDiy 自定义分配宠物努力值(EV)
|
||||
// data: 包含宠物捕获时间和EV分配数据的输入信息
|
||||
// c: 当前玩家对象
|
||||
// 返回: 分配结果和错误码
|
||||
func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
||||
_, currentPet, found := c.FindPet(data.CacthTime)
|
||||
if !found {
|
||||
@@ -26,6 +22,9 @@ func (h Controller) PetELV(data *pet.C2S_PET_EVOLVTION, c *player.Player) (resul
|
||||
if flag == 0 {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
|
||||
}
|
||||
if xmlres.PetMAP[int(currentPet.ID)].EvolvingLv > int(currentPet.Level) {
|
||||
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
|
||||
}
|
||||
evinfo := xmlres.EVOLVMAP[flag].Branches[data.Index-1]
|
||||
|
||||
if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < int64(evinfo.EvolvItemCount) {
|
||||
|
||||
@@ -97,7 +97,7 @@ func main() {
|
||||
// go cool.ListenFunc(gctx.New())
|
||||
// }
|
||||
// 解析命令行参数
|
||||
cool.Config.GameOnlineID = gcmd.GetOpt("id", "1").Uint16()
|
||||
cool.Config.GameOnlineID = gcmd.GetOpt("id", "1").Uint32()
|
||||
go Start() //注入service
|
||||
// if cool.Config.GameOnlineID == 2 { //只分析1服务器的
|
||||
// go PprofWeb()
|
||||
|
||||
@@ -66,7 +66,7 @@ func Start() {
|
||||
}
|
||||
|
||||
port, err := determinePort(cool.Config.ServerInfo.CanPort)
|
||||
cool.Config.ServerInfo.Port = uint16(port)
|
||||
cool.Config.ServerInfo.Port = uint32(port)
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to determine port: %v", err)
|
||||
}
|
||||
@@ -75,12 +75,12 @@ func Start() {
|
||||
socket.WithPort(port),
|
||||
)
|
||||
|
||||
rpcClient := rpc.StartClient(serverID, uint16(port), server) //连接rpc
|
||||
rpcClient := rpc.StartClient(serverID, uint32(port), server) //连接rpc
|
||||
|
||||
controller.Maincontroller.RPCClient = rpcClient //将RPC赋值Start
|
||||
controller.Maincontroller.Port = uint16(port) //赋值服务器ID
|
||||
controller.Maincontroller.Port = uint32(port) //赋值服务器ID
|
||||
controller.Init(true)
|
||||
xmlres.Initfile()
|
||||
|
||||
server.Boot(serverID, gconv.Uint16(port))
|
||||
server.Boot(serverID, gconv.Uint32(port))
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ func (o *OgrePetInfo) GetLevel() int {
|
||||
|
||||
// handleNPCFightSpecial 处理NPC战斗特殊情况
|
||||
func (o *OgrePetInfo) HandleNPCFightSpecial(can int) {
|
||||
if can == 0 && o.Ext != 0 {
|
||||
if can == 0 && o.Ext == 0 {//不能抓并且不是尼尔
|
||||
o.IsCapture = 0
|
||||
return
|
||||
}
|
||||
|
||||
@@ -5,15 +5,40 @@ type MapHotInfo struct {
|
||||
MapID uint32 `json:"mapId"` // 地图ID
|
||||
Count int32 `struc:"uint32" json:"count"` // 地图里的人数
|
||||
}
|
||||
type MapTip struct {
|
||||
Count int `struc:"uint32" json:"count"` // 地图里的人数
|
||||
TipInfoS map[uint32]*TipInfo `json:"tipInfoS"`
|
||||
}
|
||||
|
||||
var maphot = make(map[uint32]*int32, 0)
|
||||
type TipInfo struct {
|
||||
Talk []uint32 `json:"talk"` //矿物
|
||||
Boss []uint32 `json:"boss"` //boss
|
||||
Pet []uint32 `json:"pet"` //宠物
|
||||
Diao []uint32 `json:"diao"` //掉落
|
||||
}
|
||||
|
||||
func (m *MapTip) GetCount(t int) int {
|
||||
|
||||
switch {
|
||||
case t < 0:
|
||||
if m.Count > 0 {
|
||||
m.Count -= t
|
||||
}
|
||||
case t > 0:
|
||||
m.Count += t
|
||||
}
|
||||
|
||||
return m.Count
|
||||
}
|
||||
|
||||
var maphot = make(map[uint32]*MapTip, 0)
|
||||
|
||||
func GetMapHot() []MapHotInfo {
|
||||
ret := make([]MapHotInfo, 0)
|
||||
for k, v := range maphot {
|
||||
ret = append(ret, MapHotInfo{
|
||||
MapID: k,
|
||||
Count: *v,
|
||||
Count: int32(v.GetCount(0)),
|
||||
})
|
||||
|
||||
}
|
||||
|
||||
@@ -36,8 +36,9 @@ func (s *Space) LeaveMap(c common.PlayerI) {
|
||||
s.Broadcast(c, 2002, info)
|
||||
|
||||
current, ok := maphot[s.Super]
|
||||
if ok && *current > 0 {
|
||||
atomic.AddInt32(maphot[s.Super], -1)
|
||||
if ok {
|
||||
current.GetCount(-1)
|
||||
|
||||
}
|
||||
if atomic.CompareAndSwapUint32(&s.Owner.UserID, c.GetInfo().UserID, 0) {
|
||||
|
||||
@@ -57,9 +58,10 @@ func (s *Space) EnterMap(c common.PlayerI) {
|
||||
s.Broadcast(c, 2001, out)
|
||||
s.User.Store(c.GetInfo().UserID, c)
|
||||
s.UserInfo.Store(c.GetInfo().UserID, *out)
|
||||
_, ok := maphot[s.Super]
|
||||
curmaps, ok := maphot[s.Super]
|
||||
if ok {
|
||||
atomic.AddInt32(maphot[s.Super], 1)
|
||||
curmaps.GetCount(1)
|
||||
//atomic.AddInt32(maphot[s.Super], 1)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"blazing/common/data/xmlres"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync/atomic"
|
||||
@@ -13,6 +12,7 @@ import (
|
||||
"blazing/logic/service/common"
|
||||
"blazing/logic/service/space/info"
|
||||
|
||||
"blazing/modules/config/service"
|
||||
infomodel "blazing/modules/player/model"
|
||||
|
||||
"github.com/gogf/gf/v2/util/grand"
|
||||
@@ -66,65 +66,8 @@ func GetSpace(id uint32) *Space {
|
||||
return planet
|
||||
}
|
||||
ret := NewSpace()
|
||||
|
||||
if id < 10000 { //说明是玩家地图GetSpace
|
||||
|
||||
for _, v := range xmlres.MapConfig.Maps {
|
||||
if v.ID == int(id) { //找到这个地图
|
||||
|
||||
ret.Super = uint32(v.Super)
|
||||
if ret.Super == 0 {
|
||||
ret.Super = uint32(v.ID)
|
||||
}
|
||||
ret.ID = uint32(v.ID)
|
||||
|
||||
_, ok := maphot[ret.Super]
|
||||
if !ok {
|
||||
var t1 int32
|
||||
maphot[ret.Super] = &t1
|
||||
}
|
||||
|
||||
ret.Name = v.Name
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
|
||||
if r.IsTimeSpace != 0 {
|
||||
ret.IsTime = true
|
||||
}
|
||||
ret.MapBossSInfo = info.MapBossSInfo{}
|
||||
ret.MapBossSInfo.INFO = make([]info.MapBossInfo, 0)
|
||||
if len(r.WeatherType) > 1 {
|
||||
ret.WeatherType = r.WeatherType
|
||||
// ret.CanWeather = 1
|
||||
cool.Cron.CustomFunc(ret, ret.GenWer)
|
||||
}
|
||||
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
|
||||
|
||||
info := info.MapBossInfo{
|
||||
Id: v.TriggerID,
|
||||
Region: v.NodeID, //这个是注册的index
|
||||
Hp: v.HP,
|
||||
PosInfo: ParseCoordinateString(v.Pos),
|
||||
MaxHP: int(v.HP),
|
||||
Wer: v.Weather,
|
||||
}
|
||||
|
||||
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
|
||||
|
||||
}
|
||||
|
||||
if len(ret.MapBossSInfo.INFO) > 0 {
|
||||
cool.Cron.ScheduleFunc(10*time.Second, ret.GenBoss)
|
||||
cool.Cron.ScheduleFunc(300*time.Second, ret.HealHP)
|
||||
}
|
||||
|
||||
}
|
||||
ret.ID = id
|
||||
defer ret.init()
|
||||
|
||||
planetmap.Store(id, ret)
|
||||
return ret
|
||||
@@ -180,6 +123,81 @@ func (t *Space) Next(time.Time) time.Time {
|
||||
|
||||
return time.Now().Add(grand.D(6*time.Second, 30*time.Second))
|
||||
|
||||
}
|
||||
func (ret *Space) init() {
|
||||
|
||||
if ret.ID < 10000 { //说明是玩家地图GetSpace
|
||||
|
||||
for _, v := range xmlres.MapConfig.Maps {
|
||||
if v.ID == int(ret.ID) { //找到这个地图
|
||||
|
||||
ret.Super = uint32(v.Super)
|
||||
if ret.Super == 0 {
|
||||
ret.Super = uint32(v.ID)
|
||||
}
|
||||
ret.ID = uint32(v.ID)
|
||||
|
||||
_, ok := maphot[ret.Super]
|
||||
if !ok {
|
||||
|
||||
maphot[ret.Super] = &MapTip{}
|
||||
maphot[ret.Super].TipInfoS = make(map[uint32]*TipInfo, 0)
|
||||
}
|
||||
_, ok = maphot[ret.Super].TipInfoS[ret.ID]
|
||||
if !ok {
|
||||
tips := &TipInfo{}
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
tips.Diao = service.NewMapService().GetData(ret.ID).DropItemIds
|
||||
}
|
||||
|
||||
tips.Pet = service.NewMapPitService().GetDataALL(ret.ID)
|
||||
tips.Talk = service.NewTalkConfigService().GetTip(ret.ID)
|
||||
tips.Boss = service.NewMapNodeService().GetTip(ret.ID)
|
||||
maphot[ret.Super].TipInfoS[ret.ID] = tips
|
||||
}
|
||||
ret.Name = v.Name
|
||||
break
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
r := service.NewMapService().GetData(ret.ID)
|
||||
if r != nil {
|
||||
|
||||
if r.IsTimeSpace != 0 {
|
||||
ret.IsTime = true
|
||||
}
|
||||
ret.MapBossSInfo = info.MapBossSInfo{}
|
||||
ret.MapBossSInfo.INFO = make([]info.MapBossInfo, 0)
|
||||
if len(r.WeatherType) > 1 {
|
||||
ret.WeatherType = r.WeatherType
|
||||
// ret.CanWeather = 1
|
||||
cool.Cron.CustomFunc(ret, ret.GenWer)
|
||||
}
|
||||
for _, v := range service.NewMapNodeService().GetDataB(ret.ID) {
|
||||
|
||||
info := info.MapBossInfo{
|
||||
Id: v.TriggerID,
|
||||
Region: v.NodeID, //这个是注册的index
|
||||
Hp: v.HP,
|
||||
PosInfo: ParseCoordinateString(v.Pos),
|
||||
MaxHP: int(v.HP),
|
||||
Wer: v.Weather,
|
||||
}
|
||||
|
||||
ret.MapBossSInfo.INFO = append(ret.MapBossSInfo.INFO, info)
|
||||
|
||||
}
|
||||
|
||||
if len(ret.MapBossSInfo.INFO) > 0 {
|
||||
cool.Cron.ScheduleFunc(10*time.Second, ret.GenBoss)
|
||||
cool.Cron.ScheduleFunc(300*time.Second, ret.HealHP)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
func (ret *Space) GenBoss() {
|
||||
|
||||
|
||||
@@ -25,11 +25,26 @@ func init() {
|
||||
}
|
||||
|
||||
type TimeMapReq struct {
|
||||
g.Meta `path:"/timemap" method:"POST"`
|
||||
g.Meta `path:"/timemap" method:"GET"`
|
||||
}
|
||||
|
||||
func (this *MapController) TimeMap(ctx context.Context, req *TimeMapReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
res.Data = service.NewMapService().GetTimeMap()
|
||||
// re := service.NewMapService().GetTimeMap()
|
||||
// for _, v := range re {
|
||||
// v.
|
||||
|
||||
// }
|
||||
return res, nil
|
||||
}
|
||||
|
||||
// type MapTipReq struct {
|
||||
// g.Meta `path:"/maptip" method:"GET"`
|
||||
// }
|
||||
|
||||
// func (this *MapController) MapTip(ctx context.Context, req *MapTipReq) (res *cool.BaseRes, err error) {
|
||||
// res = &cool.BaseRes{}
|
||||
// res.Data = service.NewMapService().GetTimeMap()
|
||||
// return res, nil
|
||||
// }
|
||||
|
||||
@@ -34,9 +34,9 @@ type QuitSReq struct {
|
||||
|
||||
func (this *ServerController) Quit(ctx context.Context, req *QuitSReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
serv := service.NewServerService().GetServerID(uint16(req.ID))
|
||||
serv := service.NewServerService().GetServerID(req.ID)
|
||||
|
||||
aa, ok := cool.GetClient(serv.Port)
|
||||
aa, ok := cool.GetClient(serv.OnlineID*100000 + serv.Port)
|
||||
if ok && aa != nil { //如果已经存在且这个端口已经被存过
|
||||
aa.QuitSelf(req.Code)
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ type MapPit struct {
|
||||
// 复用通用基础配置(ID/创建时间/更新时间等)
|
||||
MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
|
||||
|
||||
RefreshID []int `gorm:"type:int[];comment:'精灵ID列表'" json:"refresh_id"`
|
||||
RefreshID []uint32 `gorm:"type:int[];comment:'精灵ID列表'" json:"refresh_id"`
|
||||
Pos []int `gorm:"type:int[];comment:'坑位位置'" json:"pos"`
|
||||
//最小等级
|
||||
MinLevel int `gorm:"type:int;not null;default:1;comment:'最小等级'" json:"min_level"`
|
||||
|
||||
@@ -39,3 +39,13 @@ func (s *MapService) GetTimeMap() (ret []model.MapConfig) {
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
// func (s *MapService) GetTimeTip() (ret []model.MapConfig) {
|
||||
// //cacheKey := strings.Join([]string{fmt.Sprintf("%d", p1), fmt.Sprintf("%d", p2)}, ":")
|
||||
// m := dbm_notenable(s.Model)
|
||||
|
||||
// m.Where(`is_time_space`, 1).Scan(&ret)
|
||||
|
||||
// return
|
||||
|
||||
// }
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type MapNodeService struct {
|
||||
@@ -44,3 +46,16 @@ func (s *MapNodeService) GetDataNode(mapid, node uint32) *model.MapNode {
|
||||
return pet
|
||||
|
||||
}
|
||||
func (s *MapNodeService) GetTip(mapid uint32) []uint32 {
|
||||
|
||||
var pet []model.MapNode //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet)
|
||||
var ret []uint32
|
||||
for _, v := range pet {
|
||||
ret = append(ret, v.TriggerID)
|
||||
|
||||
}
|
||||
|
||||
return lo.Union(ret)
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type MapPitService struct {
|
||||
@@ -28,3 +30,16 @@ func (s *MapPitService) GetData(mapid, pos uint32) []model.MapPit {
|
||||
return pet
|
||||
|
||||
}
|
||||
func (s *MapPitService) GetDataALL(mapid uint32) []uint32 {
|
||||
|
||||
var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Scan(&pet)
|
||||
var ret []uint32
|
||||
for _, v := range pet {
|
||||
|
||||
ret = append(ret, v.RefreshID...)
|
||||
}
|
||||
|
||||
return lo.Union(ret)
|
||||
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ func NewServerService() *ServerService {
|
||||
var rr []g.MapStrAny
|
||||
r, _ := gconv.Map(data)["list"].(gdb.Result)
|
||||
for i := 0; i < len(r); i++ {
|
||||
t, ok := cool.GetClient(gconv.Uint16(r[i].Map()["port"]))
|
||||
t, ok := cool.GetClient(10000*gconv.Uint32(r[i].Map()["online_id"])+gconv.Uint32(r[i].Map()["port"]))
|
||||
// tt.Friends = v.Friends
|
||||
subm := r[i].GMap()
|
||||
|
||||
@@ -74,7 +74,7 @@ func (s *ServerService) GetPort(DepartmentID uint) gdb.List {
|
||||
var res gdb.Result
|
||||
m := cool.DBM(s.Model).Where("is_open", 1).Fields("ip", "port", "online_id", "is_vip", "name")
|
||||
if DepartmentID != 1 {
|
||||
|
||||
|
||||
res, _ = m.All()
|
||||
|
||||
} else {
|
||||
@@ -107,7 +107,7 @@ func (s *ServerService) StartUPdate(OnlineID uint16, isinstall int) model.Server
|
||||
return tttt
|
||||
|
||||
}
|
||||
func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error {
|
||||
func (s *ServerService) SetServerID(OnlineID uint32, Port uint32) error {
|
||||
|
||||
m := cool.DBM(s.Model).Where("online_id", OnlineID)
|
||||
|
||||
@@ -122,7 +122,7 @@ func (s *ServerService) SetServerID(OnlineID uint16, Port uint16) error {
|
||||
return nil
|
||||
|
||||
}
|
||||
func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList {
|
||||
func (s *ServerService) GetServerID(OnlineID uint32) model.ServerList {
|
||||
var tttt model.ServerList
|
||||
cool.DBM(s.Model).Where("online_id", OnlineID).Scan(&tttt)
|
||||
|
||||
@@ -131,7 +131,7 @@ func (s *ServerService) GetServerID(OnlineID uint16) model.ServerList {
|
||||
}
|
||||
|
||||
// 保存版本号
|
||||
func (s *ServerService) SetServerScreen(id uint16, name string) {
|
||||
func (s *ServerService) SetServerScreen(id uint32, name string) {
|
||||
|
||||
cool.DBM(s.Model).Where("online_id", id).Data("old_screen", name).Update()
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
type TalkConfigService struct {
|
||||
@@ -25,3 +27,16 @@ func (s *TalkConfigService) GetCache(flag int) model.MineralCollectionConfig {
|
||||
return config
|
||||
|
||||
}
|
||||
|
||||
func (s *TalkConfigService) GetTip(mapid uint32) []uint32 {
|
||||
var item []model.TaskConfig
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Scan(&item)
|
||||
var res []uint32
|
||||
for _, v := range item {
|
||||
res = append(res, v.ItemRewardIds...)
|
||||
|
||||
}
|
||||
|
||||
return lo.Union(res)
|
||||
|
||||
}
|
||||
|
||||
@@ -57,3 +57,4 @@ func (s *TaskService) IsAcceptable(taskid uint32) (out *model.TaskConfig) {
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
@@ -313,7 +313,8 @@ func (pet *PetInfo) Downgrade(level uint32) {
|
||||
|
||||
if ok {
|
||||
|
||||
if basic.EvolvesFrom != 0 {
|
||||
if basic.EvolvesFrom != 0 && xmlres.PetMAP[int(basic.EvolvesFrom)].EvolvFlag == 0 {
|
||||
|
||||
pet.ID = uint32(basic.EvolvesFrom)
|
||||
|
||||
}
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
<Eggs>
|
||||
<Egg Id="1" MaleMon="450" FemaleMon="447" OutputMons="445 448 512" Probs="35 35 30" />
|
||||
<Egg Id="2" MaleMon="253" FemaleMon="256" OutputMons="252 254 519" Probs="35 35 30" />
|
||||
<Egg Id="3" MaleMon="516" FemaleMon="470" OutputMons="515 469 517" Probs="35 35 30" />
|
||||
<Egg Id="4" MaleMon="525" FemaleMon="295" OutputMons="523 293 533" Probs="35 35 30" />
|
||||
<Egg Id="5" MaleMon="337" FemaleMon="549" OutputMons="335 547 550" Probs="35 35 30" />
|
||||
<Egg Id="6" MaleMon="597" FemaleMon="599" OutputMons="596 598 600" Probs="50 45 5" />
|
||||
<Egg Id="7" MaleMon="67" FemaleMon="606" OutputMons="65 604 607" Probs="30 30 40" />
|
||||
<Egg Id="8" MaleMon="962" FemaleMon="965" OutputMons="960 963 977" Probs="5 5 90" />
|
||||
</Eggs>
|
||||
Reference in New Issue
Block a user