代码整理
This commit is contained in:
parent
83f33f24ec
commit
859433eee7
@ -135,6 +135,16 @@ func GetEmitProduceType(Id int) []string {
|
|||||||
return strings.Split(gamedata.ParseString(data["Emit_Product"]), ",")
|
return strings.Split(gamedata.ParseString(data["Emit_Product"]), ",")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 根据Id获取发射器产出类型
|
||||||
|
func GetEmitProduceChessType(Id int) []string {
|
||||||
|
data, err := gamedata.GetDataByIntKey(CFG_NAME, Id)
|
||||||
|
if err != nil {
|
||||||
|
log.Debug("GetTypeById GetOne Id:%v not found", Id)
|
||||||
|
return []string{}
|
||||||
|
}
|
||||||
|
return strings.Split(gamedata.ParseString(data["Product_Type"]), ",")
|
||||||
|
}
|
||||||
|
|
||||||
// 根据Id获取发射器Id
|
// 根据Id获取发射器Id
|
||||||
func GetEmitId(Id int) string {
|
func GetEmitId(Id int) string {
|
||||||
data, err := gamedata.GetDataByIntKey(CFG_NAME, Id)
|
data, err := gamedata.GetDataByIntKey(CFG_NAME, Id)
|
||||||
|
|||||||
@ -1,783 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"server/GoUtil"
|
|
||||||
"server/MergeConst"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"sort"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type ChampshipsManager struct {
|
|
||||||
MStatus int32
|
|
||||||
MChampshipMap map[int32]*db.SqlChampshipsStruct
|
|
||||||
MChampshipPlayerMap map[int32][]*msg.ChampshipsPlayerInfo
|
|
||||||
IsSettle int32
|
|
||||||
IsLoadDB bool
|
|
||||||
MUpdateNotifyList []int32
|
|
||||||
McronSave *cron.Cron
|
|
||||||
McronSaveID cron.EntryID
|
|
||||||
RobotCronID cron.EntryID
|
|
||||||
RobotCronID10s cron.EntryID
|
|
||||||
MPlayerBaseInfoMap map[int32]*db.ResPlayerBaseInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) SaveDataFromDB(Key interface{}) bool {
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) AIGrow1() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) DeleteOutLineChampship(CurChampshipsId int32) {
|
|
||||||
sqlStr := "DELETE FROM t_championships_data WHERE CurChampshipsId = ?"
|
|
||||||
|
|
||||||
for k, v := range p.MChampshipPlayerMap {
|
|
||||||
if v[0].CurChampshipsId == CurChampshipsId {
|
|
||||||
delete(p.MChampshipPlayerMap, k)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
result, err := db.SqlDb.Exec(sqlStr, CurChampshipsId)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("exec failed, err:%v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
affectedRows, err := result.RowsAffected()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("get affected failed, err:%v\n", err)
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
fmt.Printf("delete t_championships_data affectedRows:%d\n", affectedRows)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) DeleteUneffectPlayer(deleteIds []int32) {
|
|
||||||
sqlStr := "DELETE FROM t_player_baseinfo WHERE dwUin = ?"
|
|
||||||
|
|
||||||
for i := 0; i < len(deleteIds); i++ {
|
|
||||||
_, err := db.SqlDb.Exec(sqlStr, deleteIds[i])
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("exec failed, err:%v\n", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) GetFriendListId(id int32) []int32 {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_Friend_Data WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlFriendStruct{}
|
|
||||||
ret := []int32{}
|
|
||||||
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, id); err != nil {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
if sqlStruck.FriendList != "" {
|
|
||||||
arr := strings.Split(sqlStruck.FriendList, "_")
|
|
||||||
for i := 0; i < len(arr); i++ {
|
|
||||||
id, _ := strconv.ParseInt(arr[i], 10, 32)
|
|
||||||
ret = append(ret, int32(id))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) NotifyOpenNewChampShip(args []interface{}) {
|
|
||||||
go func() {
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId + 1
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.StartChampshipsSvrTime = args[0].(int32)
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) OpenNewChampShip(args []interface{}) {
|
|
||||||
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId + 1
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.StartChampshipsSvrTime = args[0].(int32)
|
|
||||||
p.MUpdateNotifyList = []int32{}
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_baseinfo"
|
|
||||||
sqlStrucks := []db.ResPlayerBaseInfo{}
|
|
||||||
if err := db.SqlDb.Select(&sqlStrucks, sqlStr); err != nil {
|
|
||||||
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
deleteIds := []int32{}
|
|
||||||
sqlStrucksList := []db.ResPlayerBaseInfo{}
|
|
||||||
for i := 0; i < len(sqlStrucks); i++ {
|
|
||||||
if sqlStrucks[i].UserName == "" {
|
|
||||||
deleteIds = append(deleteIds, sqlStrucks[i].DwUin)
|
|
||||||
} else {
|
|
||||||
sqlStrucksList = append(sqlStrucksList, sqlStrucks[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sqlStrucks = sqlStrucksList
|
|
||||||
p.DeleteUneffectPlayer(deleteIds)
|
|
||||||
|
|
||||||
sort.Slice(sqlStrucks, func(i, j int) bool {
|
|
||||||
if sqlStrucks[i].Level != sqlStrucks[j].Level {
|
|
||||||
return sqlStrucks[i].Level < sqlStrucks[j].Level
|
|
||||||
} else {
|
|
||||||
return sqlStrucks[i].Exp < sqlStrucks[j].Exp
|
|
||||||
}
|
|
||||||
|
|
||||||
})
|
|
||||||
var playerCnt int = 15
|
|
||||||
groups := int(math.Ceil((float64)(len(sqlStrucks)) / float64(playerCnt)))
|
|
||||||
StartRobotUin := 200000
|
|
||||||
p.MStatus = 1
|
|
||||||
rand.Seed(time.Now().Unix())
|
|
||||||
for i := 0; i < groups; i++ {
|
|
||||||
if i < groups-1 {
|
|
||||||
temp := db.SqlChampshipsStruct{}
|
|
||||||
temp.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
CSPlayerInfo := []*msg.ChampshipsPlayerInfo{}
|
|
||||||
|
|
||||||
strr := []string{}
|
|
||||||
for j := 0; j < int(playerCnt); j++ {
|
|
||||||
dwUin := sqlStrucks[i*int(playerCnt)+j].DwUin
|
|
||||||
res := strconv.Itoa(int(dwUin)) + "_" + "1" + "_" + "0" + "_" + "0" + "_" + "1" + "_" + strconv.Itoa(int(G_GameLogicPtr.M_SvrGlobal.CurChampshipsId)) + "_0"
|
|
||||||
strr = append(strr, res)
|
|
||||||
playerinfo := &msg.ChampshipsPlayerInfo{}
|
|
||||||
playerinfo.DwUin = dwUin
|
|
||||||
playerinfo.IsGet = 0
|
|
||||||
playerinfo.IsPlayer = 1
|
|
||||||
playerinfo.Score = 0
|
|
||||||
playerinfo.Times = 1
|
|
||||||
playerinfo.AIEnum = 0
|
|
||||||
playerinfo.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
CSPlayerInfo = append(CSPlayerInfo, playerinfo)
|
|
||||||
}
|
|
||||||
for j := int(playerCnt); j < 30; j++ {
|
|
||||||
StartRobotUin = StartRobotUin + 1
|
|
||||||
dwUin := StartRobotUin
|
|
||||||
enum := rand.Intn(4) + 1
|
|
||||||
res := strconv.Itoa(int(dwUin)) + "_" + "0" + "_" + "0" + "_" + "0" + "_" + "1" + "_" + strconv.Itoa(int(G_GameLogicPtr.M_SvrGlobal.CurChampshipsId)) + "_" + strconv.Itoa(enum)
|
|
||||||
strr = append(strr, res)
|
|
||||||
playerinfo := &msg.ChampshipsPlayerInfo{}
|
|
||||||
playerinfo.DwUin = int32(dwUin)
|
|
||||||
playerinfo.IsGet = 0
|
|
||||||
playerinfo.IsPlayer = 0
|
|
||||||
playerinfo.Score = 0
|
|
||||||
playerinfo.Times = 1
|
|
||||||
playerinfo.AIEnum = int32(enum)
|
|
||||||
playerinfo.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
CSPlayerInfo = append(CSPlayerInfo, playerinfo)
|
|
||||||
}
|
|
||||||
temp.GroupRankData = strings.Join(strr, ";")
|
|
||||||
insertId, _ := db.FormatAllMemInsertDb(&temp, "t_championships_data")
|
|
||||||
|
|
||||||
p.MChampshipPlayerMap[int32(insertId)] = CSPlayerInfo
|
|
||||||
|
|
||||||
for j := 0; j < int(playerCnt); j++ {
|
|
||||||
dwUin := sqlStrucks[i*int(playerCnt)+j].DwUin
|
|
||||||
player, ok := G_GameLogicPtr.M_Players[dwUin]
|
|
||||||
if ok {
|
|
||||||
player.GetIFGameData("PlayerBaseData").(*PlayerBaseData).SetChampshipID(int32(insertId), true)
|
|
||||||
} else {
|
|
||||||
player = G_GameLogicPtr.FindOfflinePlayer(dwUin)
|
|
||||||
if player != nil {
|
|
||||||
player.GetIFGameData("PlayerBaseData").(*PlayerBaseData).SetChampshipID(int32(insertId), false)
|
|
||||||
} else {
|
|
||||||
sqlStrucks[i*int(playerCnt)+j].LastChampGroupID = sqlStrucks[i*int(playerCnt)+j].ChampshipsGroupID
|
|
||||||
sqlStrucks[i*int(playerCnt)+j].ChampshipsGroupID = int32(insertId)
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStrucks[i*int(playerCnt)+j], "t_player_baseinfo", "dwUin")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
remain := len(sqlStrucks) - (groups-1)*int(playerCnt)
|
|
||||||
cnt := 0
|
|
||||||
strr := []string{}
|
|
||||||
temp := db.SqlChampshipsStruct{}
|
|
||||||
temp.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
|
|
||||||
CSPlayerInfo := []*msg.ChampshipsPlayerInfo{}
|
|
||||||
|
|
||||||
for j := 0; j < remain; j++ {
|
|
||||||
dwUin := sqlStrucks[i*int(playerCnt)+j].DwUin
|
|
||||||
res := strconv.Itoa(int(dwUin)) + "_" + "1" + "_" + "0" + "_" + "0" + "_" + "1" + "_" + strconv.Itoa(int(G_GameLogicPtr.M_SvrGlobal.CurChampshipsId)) + "_0"
|
|
||||||
strr = append(strr, res)
|
|
||||||
cnt = cnt + 1
|
|
||||||
playerinfo := &msg.ChampshipsPlayerInfo{}
|
|
||||||
playerinfo.DwUin = dwUin
|
|
||||||
playerinfo.IsGet = 0
|
|
||||||
playerinfo.IsPlayer = 1
|
|
||||||
playerinfo.Score = 0
|
|
||||||
playerinfo.Times = 1
|
|
||||||
playerinfo.AIEnum = 0
|
|
||||||
playerinfo.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
CSPlayerInfo = append(CSPlayerInfo, playerinfo)
|
|
||||||
}
|
|
||||||
for j := cnt; j < 30; j++ {
|
|
||||||
StartRobotUin = StartRobotUin + 1
|
|
||||||
dwUin := StartRobotUin
|
|
||||||
enum := rand.Intn(4) + 1
|
|
||||||
res := strconv.Itoa(int(dwUin)) + "_" + "0" + "_" + "0" + "_" + "0" + "_" + "1" + "_" + strconv.Itoa(int(G_GameLogicPtr.M_SvrGlobal.CurChampshipsId)) + "_" + strconv.Itoa(enum)
|
|
||||||
strr = append(strr, res)
|
|
||||||
playerinfo := &msg.ChampshipsPlayerInfo{}
|
|
||||||
playerinfo.DwUin = int32(dwUin)
|
|
||||||
playerinfo.IsGet = 0
|
|
||||||
playerinfo.IsPlayer = 0
|
|
||||||
playerinfo.Score = 0
|
|
||||||
playerinfo.Times = 1
|
|
||||||
playerinfo.AIEnum = int32(enum)
|
|
||||||
playerinfo.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
CSPlayerInfo = append(CSPlayerInfo, playerinfo)
|
|
||||||
}
|
|
||||||
temp.GroupRankData = strings.Join(strr, ";")
|
|
||||||
insertId, _ := db.FormatAllMemInsertDb(&temp, "t_championships_data")
|
|
||||||
p.MChampshipPlayerMap[int32(insertId)] = CSPlayerInfo
|
|
||||||
for j := 0; j < remain; j++ {
|
|
||||||
dwUin := sqlStrucks[i*int(playerCnt)+j].DwUin
|
|
||||||
player, ok := G_GameLogicPtr.M_Players[dwUin]
|
|
||||||
if ok {
|
|
||||||
player.GetIFGameData("PlayerBaseData").(*PlayerBaseData).SetChampshipID(int32(insertId), true)
|
|
||||||
} else {
|
|
||||||
player = G_GameLogicPtr.FindOfflinePlayer(dwUin)
|
|
||||||
if player != nil {
|
|
||||||
player.GetIFGameData("PlayerBaseData").(*PlayerBaseData).SetChampshipID(int32(insertId), false)
|
|
||||||
} else {
|
|
||||||
|
|
||||||
sqlStrucks[i*int(playerCnt)+j].LastChampGroupID = sqlStrucks[i*int(playerCnt)+j].ChampshipsGroupID
|
|
||||||
sqlStrucks[i*int(playerCnt)+j].ChampshipsGroupID = int32(insertId)
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStrucks[i*int(playerCnt)+j], "t_player_baseinfo", "dwUin")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.IsLoadDB = true
|
|
||||||
|
|
||||||
p.AIScoreGrowth1h()
|
|
||||||
db.FormatAllMemUpdateDb(&G_GameLogicPtr.M_SvrGlobal, "t_server_global_data", "Id")
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) OpenChampShipTimes(args []interface{}) {
|
|
||||||
p.MStatus = 2
|
|
||||||
notify := &msg.NotifyChampshipTimesOpen{}
|
|
||||||
notify.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.broadcastInfoAllPlayer("NotifyChampshipTimesOpen", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) CloseChampShipTimes(args []interface{}) {
|
|
||||||
p.MStatus = 1
|
|
||||||
notify := &msg.NotifyChampshipTimesClose{}
|
|
||||||
notify.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.broadcastInfoAllPlayer("NotifyChampshipTimesClose", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) Notify_Clock_Tick_Sec(args []interface{}) {
|
|
||||||
timeStamp := args[0].(int64)
|
|
||||||
t := time.Unix(timeStamp, 0).Local()
|
|
||||||
zero := timeStamp - (int64)(t.Hour()*3600+t.Minute()*60+t.Second())
|
|
||||||
OpenTime := zero + MergeConst.G_Champion_Start_Offset
|
|
||||||
OpenTimesTime := zero + MergeConst.G_Champion_Start_Effect_Time
|
|
||||||
CloseTimesTime := zero + MergeConst.G_Champion_Start_Effect_Time + MergeConst.G_Champion_Start_Effect_Durtion
|
|
||||||
DeleteLastTimesTime := zero + MergeConst.G_Champion_settlement_Duration
|
|
||||||
if G_GameLogicPtr.M_SvrGlobal.StartChampshipsSvrTime < int32(OpenTime) { //今日没有开启
|
|
||||||
if timeStamp >= OpenTime { //开启
|
|
||||||
GoUtil.CallEvent(MergeConst.Notify_Champion_Renew, []interface{}{int32(OpenTime)})
|
|
||||||
} else {
|
|
||||||
//开启时间未到
|
|
||||||
if p.MStatus == 1 {
|
|
||||||
GoUtil.CallEvent(MergeConst.Notify_EndChampShip, []interface{}{int32(OpenTime)})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if p.MStatus == 0 {
|
|
||||||
p.MStatus = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
if !p.IsLoadDB {
|
|
||||||
p.LoadDbDataByGroupId(G_GameLogicPtr.M_SvrGlobal.CurChampshipsId)
|
|
||||||
if G_GameLogicPtr.M_SvrGlobal.LastChampshipsId > 0 {
|
|
||||||
p.LoadDbDataByGroupId(G_GameLogicPtr.M_SvrGlobal.LastChampshipsId)
|
|
||||||
}
|
|
||||||
p.IsLoadDB = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if p.MStatus == 1 {
|
|
||||||
if timeStamp >= OpenTimesTime && timeStamp <= CloseTimesTime {
|
|
||||||
GoUtil.CallEvent(MergeConst.Notify_OpenChampShipTimes, []interface{}{int32(OpenTime)})
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if p.MStatus == 2 {
|
|
||||||
if timeStamp > CloseTimesTime {
|
|
||||||
GoUtil.CallEvent(MergeConst.Notify_CloseChampShipTimes, []interface{}{int32(OpenTime)})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if p.IsSettle == 0 {
|
|
||||||
if timeStamp <= DeleteLastTimesTime {
|
|
||||||
p.IsSettle = 1
|
|
||||||
} else {
|
|
||||||
if G_GameLogicPtr.M_SvrGlobal.LastChampshipsId > 0 {
|
|
||||||
p.DeleteOutLineChampship(G_GameLogicPtr.M_SvrGlobal.LastChampshipsId)
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.LastChampshipsId = 0
|
|
||||||
db.FormatAllMemUpdateDb(&G_GameLogicPtr.M_SvrGlobal, "t_server_global_data", "Id")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if p.IsSettle == 1 {
|
|
||||||
if timeStamp > DeleteLastTimesTime {
|
|
||||||
notify := &msg.NotifyChampshipSettleClose{}
|
|
||||||
notify.LastChampshipsId = G_GameLogicPtr.M_SvrGlobal.LastChampshipsId
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.broadcastInfoAllPlayer("NotifyChampshipSettleClose", data)
|
|
||||||
p.IsSettle = 0
|
|
||||||
if G_GameLogicPtr.M_SvrGlobal.LastChampshipsId > 0 {
|
|
||||||
p.DeleteOutLineChampship(G_GameLogicPtr.M_SvrGlobal.LastChampshipsId)
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.LastChampshipsId = 0
|
|
||||||
db.FormatAllMemUpdateDb(&G_GameLogicPtr.M_SvrGlobal, "t_server_global_data", "Id")
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) EndChampShip(args []interface{}) {
|
|
||||||
p.MStatus = 0
|
|
||||||
G_GameLogicPtr.M_SvrGlobal.LastChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
db.FormatAllMemUpdateDb(&G_GameLogicPtr.M_SvrGlobal, "t_server_global_data", "Id")
|
|
||||||
|
|
||||||
notify := &msg.NotifyChampshipSettleOpen{}
|
|
||||||
notify.LastChampshipsId = G_GameLogicPtr.M_SvrGlobal.LastChampshipsId
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.broadcastInfoAllPlayer("NotifyChampshipSettleOpen", data)
|
|
||||||
|
|
||||||
notify1 := &msg.NotifyChampshipClose{}
|
|
||||||
notify1.CurChampshipsId = G_GameLogicPtr.M_SvrGlobal.CurChampshipsId
|
|
||||||
data1, _ := proto.Marshal(notify1)
|
|
||||||
G_GameLogicPtr.broadcastInfoAllPlayer("NotifyChampshipClose", data1)
|
|
||||||
|
|
||||||
p.NotifyRenewChampshipData()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) NotifyRenewChampshipData() {
|
|
||||||
for i := 0; i < len(p.MUpdateNotifyList); i++ {
|
|
||||||
groupid := p.MUpdateNotifyList[i]
|
|
||||||
playerlist, ok := p.MChampshipPlayerMap[groupid]
|
|
||||||
if ok {
|
|
||||||
for j := 0; j < len(playerlist); j++ {
|
|
||||||
if playerlist[j].IsPlayer == 1 {
|
|
||||||
dwUin := playerlist[j].DwUin
|
|
||||||
player, ok1 := G_GameLogicPtr.M_Players[dwUin]
|
|
||||||
if ok1 {
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
notify := &msg.NotifyUpdateChampshipRank{}
|
|
||||||
notify.ChampshipsGroupID = groupid
|
|
||||||
notify.GroupRankDataList = playerlist
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "NotifyUpdateChampshipRank", data)
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.MUpdateNotifyList = p.MUpdateNotifyList[0:0]
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) ReqChampshipData(player *Player, buf []byte) {
|
|
||||||
req := &msg.ReqChampshipData{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
res := &msg.ResChampshipData{}
|
|
||||||
_, ok := p.MChampshipPlayerMap[req.ChampshipsGroupID]
|
|
||||||
if ok {
|
|
||||||
res.GroupRankDataList = p.MChampshipPlayerMap[req.ChampshipsGroupID]
|
|
||||||
}
|
|
||||||
res.ChampshipsGroupID = req.ChampshipsGroupID
|
|
||||||
res.Status = p.MStatus
|
|
||||||
res.IsSettle = p.IsSettle
|
|
||||||
res.EndTime = G_GameLogicPtr.M_SvrGlobal.StartChampshipsSvrTime + MergeConst.G_Champion_Duration
|
|
||||||
res.EndSettleTime = G_GameLogicPtr.M_SvrGlobal.StartChampshipsSvrTime - MergeConst.G_Champion_Start_Offset + MergeConst.G_Champion_Start_Effect_Time + MergeConst.G_Champion_Start_Effect_Durtion
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResChampshipData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) InitManager() {
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_Champion_Renew, p.OpenNewChampShip, p)
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_OpenChampShipTimes, p.OpenChampShipTimes, p)
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_CloseChampShipTimes, p.CloseChampShipTimes, p)
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_EndChampShip, p.EndChampShip, p)
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_Clock_Tick_Sec, p.Notify_Clock_Tick_Sec, p)
|
|
||||||
p.MChampshipMap = make(map[int32]*db.SqlChampshipsStruct)
|
|
||||||
p.MChampshipPlayerMap = make(map[int32][]*msg.ChampshipsPlayerInfo)
|
|
||||||
p.MStatus = 0
|
|
||||||
p.IsSettle = 0
|
|
||||||
p.IsLoadDB = false
|
|
||||||
p.MUpdateNotifyList = []int32{}
|
|
||||||
p.McronSave = cron.New()
|
|
||||||
p.McronSaveID, _ = p.McronSave.AddFunc("@every 70s", func() {
|
|
||||||
p.NotifyRenewChampshipData()
|
|
||||||
})
|
|
||||||
p.RobotCronID, _ = p.McronSave.AddFunc("@every 1h", func() {
|
|
||||||
p.AIScoreGrowth1h()
|
|
||||||
})
|
|
||||||
|
|
||||||
p.RobotCronID10s, _ = p.McronSave.AddFunc("@every 15m", func() {
|
|
||||||
if p.MStatus == 2 {
|
|
||||||
p.RobotIntervalAddScore15m()
|
|
||||||
}
|
|
||||||
})
|
|
||||||
p.McronSave.Start()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) RobotIntervalAddScore() {
|
|
||||||
seed := time.Now().Unix()
|
|
||||||
rand.Seed(seed)
|
|
||||||
needToUpdateDb := []int32{}
|
|
||||||
for k, v := range p.MChampshipPlayerMap {
|
|
||||||
ishaveRobot := false
|
|
||||||
for i := 0; i < len(v); i++ {
|
|
||||||
if v[i].IsPlayer == 0 {
|
|
||||||
ishaveRobot = true
|
|
||||||
addScore := 3
|
|
||||||
ran := rand.Intn(100) + 1
|
|
||||||
if ran <= 25 {
|
|
||||||
addScore = addScore + 1
|
|
||||||
} else {
|
|
||||||
if ran <= 50 {
|
|
||||||
addScore = addScore + 2
|
|
||||||
}
|
|
||||||
}
|
|
||||||
v[i].Score = v[i].Score + int32(addScore)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ishaveRobot {
|
|
||||||
sort.Slice(v, func(i, j int) bool { return v[i].Score > v[j].Score })
|
|
||||||
isAdd := false
|
|
||||||
for i := 0; i < len(p.MUpdateNotifyList); i++ {
|
|
||||||
if p.MUpdateNotifyList[i] == k {
|
|
||||||
isAdd = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !isAdd {
|
|
||||||
p.MUpdateNotifyList = append(p.MUpdateNotifyList, k)
|
|
||||||
}
|
|
||||||
needToUpdateDb = append(needToUpdateDb, k)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
for i := 0; i < len(needToUpdateDb); i++ {
|
|
||||||
p.SaveDbDataByGroupId(needToUpdateDb[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) GetMinGroupId() int32 {
|
|
||||||
var Min int32 = 0
|
|
||||||
for k := range p.MChampshipPlayerMap {
|
|
||||||
if Min == 0 {
|
|
||||||
Min = k
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
if k < Min {
|
|
||||||
Min = k
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Min
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) AIScoreGrowth1h() {
|
|
||||||
seed := time.Now().Unix()
|
|
||||||
rand.Seed(seed)
|
|
||||||
needToUpdateDb := []int32{}
|
|
||||||
// MinGroupId := p.GetMinGroupId()
|
|
||||||
for k, v := range p.MChampshipPlayerMap {
|
|
||||||
ishaveRobot := false
|
|
||||||
groupId := 0 //k - MinGroupId + 1
|
|
||||||
for i := 0; i < len(v); i++ {
|
|
||||||
if v[i].IsPlayer == 0 {
|
|
||||||
ishaveRobot = true
|
|
||||||
addScore := 0
|
|
||||||
if v[i].AIEnum == 1 {
|
|
||||||
var num1 float64 = 0.5
|
|
||||||
var num2 float64 = 5.5
|
|
||||||
groupId = rand.Intn(7) + 1
|
|
||||||
addScore = addScore + int(math.Floor(float64(groupId-1)*num1*num2))
|
|
||||||
}
|
|
||||||
if v[i].AIEnum == 2 {
|
|
||||||
addScore = 16
|
|
||||||
|
|
||||||
ran := rand.Intn(100) + 1
|
|
||||||
if ran <= 25 {
|
|
||||||
addScore = addScore + 6
|
|
||||||
} else {
|
|
||||||
if ran <= 50 {
|
|
||||||
addScore = addScore + 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if v[i].AIEnum == 3 {
|
|
||||||
addScore = 16
|
|
||||||
|
|
||||||
ran := rand.Intn(100) + 1
|
|
||||||
if ran <= 25 {
|
|
||||||
addScore = addScore + 10
|
|
||||||
} else {
|
|
||||||
if ran <= 75 {
|
|
||||||
addScore = addScore + 6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
var num1 float64 = 0.5
|
|
||||||
var num2 float64 = 5.5
|
|
||||||
groupId = rand.Intn(7) + 1
|
|
||||||
addScore = addScore + int(math.Floor(float64(groupId-1)*num1*num2))
|
|
||||||
}
|
|
||||||
if v[i].AIEnum == 4 {
|
|
||||||
var num1 float64 = 0.5
|
|
||||||
var num2 float64 = 5.5
|
|
||||||
groupId = rand.Intn(7) + 1
|
|
||||||
addScore = addScore + int(math.Floor(float64(groupId-1)*num1*num2))
|
|
||||||
score := rand.Intn(23)
|
|
||||||
addScore = addScore + score
|
|
||||||
}
|
|
||||||
v[i].Score = v[i].Score + int32(addScore)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ishaveRobot {
|
|
||||||
sort.Slice(v, func(i, j int) bool { return v[i].Score > v[j].Score })
|
|
||||||
isAdd := false
|
|
||||||
for i := 0; i < len(p.MUpdateNotifyList); i++ {
|
|
||||||
if p.MUpdateNotifyList[i] == k {
|
|
||||||
isAdd = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !isAdd {
|
|
||||||
p.MUpdateNotifyList = append(p.MUpdateNotifyList, k)
|
|
||||||
}
|
|
||||||
needToUpdateDb = append(needToUpdateDb, k)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
for i := 0; i < len(needToUpdateDb); i++ {
|
|
||||||
p.SaveDbDataByGroupId(needToUpdateDb[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) RobotIntervalAddScore15m() {
|
|
||||||
seed := time.Now().Unix()
|
|
||||||
rand.Seed(seed)
|
|
||||||
needToUpdateDb := []int32{}
|
|
||||||
for k, v := range p.MChampshipPlayerMap {
|
|
||||||
ishaveRobot := false
|
|
||||||
for i := 0; i < len(v); i++ {
|
|
||||||
if v[i].IsPlayer == 0 {
|
|
||||||
|
|
||||||
addScore := 0
|
|
||||||
if v[i].AIEnum == 1 {
|
|
||||||
|
|
||||||
ran := rand.Intn(100) + 1
|
|
||||||
if ran <= 25 {
|
|
||||||
addScore = addScore + 10
|
|
||||||
} else {
|
|
||||||
if ran <= 75 {
|
|
||||||
addScore = addScore + 6
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ran = rand.Intn(100) + 1
|
|
||||||
if ran <= 25 {
|
|
||||||
addScore = addScore + 5
|
|
||||||
} else {
|
|
||||||
if ran <= 50 {
|
|
||||||
addScore = addScore + 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if addScore > 0 {
|
|
||||||
ishaveRobot = true
|
|
||||||
v[i].Score = v[i].Score + int32(addScore)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ishaveRobot {
|
|
||||||
sort.Slice(v, func(i, j int) bool { return v[i].Score > v[j].Score })
|
|
||||||
isAdd := false
|
|
||||||
for i := 0; i < len(p.MUpdateNotifyList); i++ {
|
|
||||||
if p.MUpdateNotifyList[i] == k {
|
|
||||||
isAdd = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !isAdd {
|
|
||||||
p.MUpdateNotifyList = append(p.MUpdateNotifyList, k)
|
|
||||||
}
|
|
||||||
needToUpdateDb = append(needToUpdateDb, k)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
for i := 0; i < len(needToUpdateDb); i++ {
|
|
||||||
p.SaveDbDataByGroupId(needToUpdateDb[i])
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (p *ChampshipsManager) SaveDbDataByGroupId(GroupId int32) {
|
|
||||||
_, ok := p.MChampshipPlayerMap[GroupId]
|
|
||||||
if ok {
|
|
||||||
List := p.MChampshipPlayerMap[GroupId]
|
|
||||||
strr := []string{}
|
|
||||||
for i := 0; i < len(List); i++ {
|
|
||||||
Item := List[i]
|
|
||||||
unit := strconv.Itoa(int(Item.DwUin)) + "_" + strconv.Itoa(int(Item.IsPlayer)) + "_" + strconv.Itoa(int(Item.Score)) + "_" + strconv.Itoa(int(Item.IsGet)) + "_" + strconv.Itoa(int(Item.Times)) + "_" + strconv.Itoa(int(Item.CurChampshipsId)) + "_" + strconv.Itoa(int(Item.AIEnum))
|
|
||||||
strr = append(strr, unit)
|
|
||||||
}
|
|
||||||
data := strings.Join(strr, ";")
|
|
||||||
sqlStruct := &db.SqlChampionshipsStruct{}
|
|
||||||
sqlStruct.ChampshipsGroupID = GroupId
|
|
||||||
sqlStruct.GroupRankData = data
|
|
||||||
sqlStruct.CurChampshipsId = List[0].CurChampshipsId
|
|
||||||
db.FormatAllMemUpdateDb(sqlStruct, "t_championships_data", "ChampshipsGroupID")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) LoadDbDataByGroupId(ChampshipsId int32) {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_championships_data WHERE CurChampshipsId = ?"
|
|
||||||
|
|
||||||
sqlStruck := []db.SqlChampionshipsStruct{}
|
|
||||||
|
|
||||||
if err := db.SqlDb.Select(&sqlStruck, sqlStr, ChampshipsId); err != nil {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
for m := 0; m < len(sqlStruck); m++ {
|
|
||||||
units := strings.Split(sqlStruck[m].GroupRankData, ";")
|
|
||||||
list := []*msg.ChampshipsPlayerInfo{}
|
|
||||||
for i := 0; i < len(units); i++ {
|
|
||||||
item := units[i]
|
|
||||||
strr := strings.Split(item, "_")
|
|
||||||
temp := &msg.ChampshipsPlayerInfo{}
|
|
||||||
dwuin, _ := strconv.Atoi(strr[0])
|
|
||||||
temp.DwUin = int32(dwuin)
|
|
||||||
IsPlayer, _ := strconv.Atoi(strr[1])
|
|
||||||
temp.IsPlayer = int32(IsPlayer)
|
|
||||||
Score, _ := strconv.Atoi(strr[2])
|
|
||||||
temp.Score = int32(Score)
|
|
||||||
IsGet, _ := strconv.Atoi(strr[3])
|
|
||||||
temp.IsGet = int32(IsGet)
|
|
||||||
Times, _ := strconv.Atoi(strr[4])
|
|
||||||
temp.Times = int32(Times)
|
|
||||||
CS, _ := strconv.Atoi(strr[5])
|
|
||||||
temp.CurChampshipsId = int32(CS)
|
|
||||||
AI, _ := strconv.Atoi(strr[6])
|
|
||||||
temp.AIEnum = int32(AI)
|
|
||||||
list = append(list, temp)
|
|
||||||
}
|
|
||||||
p.MChampshipPlayerMap[sqlStruck[m].ChampshipsGroupID] = list
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) ReqChampshipAddScore(player *Player, buf []byte) {
|
|
||||||
req := &msg.ReqChampshipAddScore{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
res := &msg.ResChampshipAddScore{}
|
|
||||||
|
|
||||||
if p.MStatus == 0 {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_End
|
|
||||||
} else {
|
|
||||||
_, ok := p.MChampshipPlayerMap[req.GroupId]
|
|
||||||
if ok {
|
|
||||||
List := p.MChampshipPlayerMap[req.GroupId]
|
|
||||||
isHave := false
|
|
||||||
for i := 0; i < len(List); i++ {
|
|
||||||
if List[i].DwUin == player.M_DwUin {
|
|
||||||
List[i].Score = List[i].Score + req.AddScore
|
|
||||||
res.ResultCode = 0
|
|
||||||
isHave = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Slice(List, func(i, j int) bool { return List[i].Score > List[j].Score })
|
|
||||||
if !isHave {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_No_Join
|
|
||||||
} else {
|
|
||||||
res.GroupRankDataList = List
|
|
||||||
isAdd := false
|
|
||||||
for i := 0; i < len(p.MUpdateNotifyList); i++ {
|
|
||||||
if p.MUpdateNotifyList[i] == req.GroupId {
|
|
||||||
isAdd = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if !isAdd {
|
|
||||||
p.MUpdateNotifyList = append(p.MUpdateNotifyList, req.GroupId)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.SaveDbDataByGroupId(req.GroupId)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_No_Exsit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
res.GroupId = req.GroupId
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResChampshipAddScore", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *ChampshipsManager) ReqChampshipAddTime(player *Player, buf []byte) {
|
|
||||||
req := &msg.ReqChampshipAddTime{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
res := &msg.ResChampshipAddTime{}
|
|
||||||
if p.MStatus == 0 {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_End
|
|
||||||
} else {
|
|
||||||
_, ok := p.MChampshipPlayerMap[req.GroupId]
|
|
||||||
if ok {
|
|
||||||
List := p.MChampshipPlayerMap[req.GroupId]
|
|
||||||
isHave := false
|
|
||||||
for i := 0; i < len(List); i++ {
|
|
||||||
if List[i].DwUin == player.M_DwUin {
|
|
||||||
List[i].Times = List[i].Times + req.AddTimes
|
|
||||||
res.ResultCode = 0
|
|
||||||
isHave = true
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sort.Slice(List, func(i, j int) bool { return List[i].Score > List[j].Score })
|
|
||||||
if !isHave {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_No_Join
|
|
||||||
} else {
|
|
||||||
res.GroupRankDataList = List
|
|
||||||
p.SaveDbDataByGroupId(req.GroupId)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Champship_No_Exsit
|
|
||||||
}
|
|
||||||
}
|
|
||||||
res.GroupId = req.GroupId
|
|
||||||
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResChampshipAddTime", data)
|
|
||||||
}
|
|
||||||
@ -1,10 +1,12 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"server/GoUtil"
|
"server/GoUtil"
|
||||||
mergeCluster "server/cluster"
|
mergeCluster "server/cluster"
|
||||||
"server/conf"
|
"server/conf"
|
||||||
|
"server/game/mod/card"
|
||||||
"server/game/mod/msg"
|
"server/game/mod/msg"
|
||||||
"server/pkg/github.com/name5566/leaf/log"
|
"server/pkg/github.com/name5566/leaf/log"
|
||||||
)
|
)
|
||||||
@ -19,7 +21,7 @@ type FirendData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (f *FriendMgr) Init() {
|
func (f *FriendMgr) Init() {
|
||||||
|
gob.Register(card.CardInfo{})
|
||||||
f.key = FRIEND_MGR_KEY
|
f.key = FRIEND_MGR_KEY
|
||||||
f.data = &FirendData{
|
f.data = &FirendData{
|
||||||
List: make(map[int][]*msg.Msg),
|
List: make(map[int][]*msg.Msg),
|
||||||
|
|||||||
@ -9,7 +9,6 @@ import (
|
|||||||
"server/GoUtil"
|
"server/GoUtil"
|
||||||
"server/MergeConst"
|
"server/MergeConst"
|
||||||
"server/conf"
|
"server/conf"
|
||||||
"sort"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
l "log"
|
l "log"
|
||||||
@ -20,8 +19,6 @@ import (
|
|||||||
"server/msg"
|
"server/msg"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"math/rand"
|
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
"github.com/robfig/cron/v3"
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
@ -66,22 +63,18 @@ type LimitActPeriod struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type GameLogic struct {
|
type GameLogic struct {
|
||||||
Db_AccountInfo db.Db_Account
|
Db_AccountInfo db.Db_Account
|
||||||
DailyTaskTimestamp int64
|
DailyTaskTimestamp int64
|
||||||
M_Players map[int32]*Player
|
M_Players map[int32]*Player
|
||||||
m_CronEntryIDs map[int]*LimitActPeriod
|
m_CronEntryIDs map[int]*LimitActPeriod
|
||||||
Mdispatr *timer.Dispatcher
|
Mdispatr *timer.Dispatcher
|
||||||
M_LimitActiveList []int
|
M_LimitActiveList []int
|
||||||
NotInitPlayer *Player
|
NotInitPlayer *Player
|
||||||
MReadyToRemoveList map[*Player]*timer.Timer
|
Mlogger *log.Logger
|
||||||
Mlogger *log.Logger
|
MloggerErr error
|
||||||
MloggerErr error
|
Version int32
|
||||||
Version int32
|
M_SvrGlobal db.SqlSvrGlobalStruct
|
||||||
M_SvrGlobal db.SqlSvrGlobalStruct
|
MHttpManager *HttpManager
|
||||||
MChampshipsManager *NewChampshipsManager
|
|
||||||
MPlayerProfileManager *PlayerProfileManager
|
|
||||||
MOldPlayerCompensateMgr *OldPlayerCompensateMgr
|
|
||||||
MHttpManager *HttpManager
|
|
||||||
|
|
||||||
MLogManager *LogMgr
|
MLogManager *LogMgr
|
||||||
SeverInfo *ServerInfo
|
SeverInfo *ServerInfo
|
||||||
@ -260,19 +253,6 @@ func (ad *GameLogic) CreateNewPlayer(a gate.Agent, UserName string) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 重新绑定玩家和网络连接代理
|
|
||||||
func (ad *GameLogic) RebindPlayerAndAgent(a gate.Agent, player *Player) {
|
|
||||||
internal.AsignPlayerToAgents(a, player)
|
|
||||||
ad.M_Players[player.M_DwUin] = player
|
|
||||||
player.Reconnect()
|
|
||||||
player.SetAgent(a)
|
|
||||||
timer1 := ad.MReadyToRemoveList[player]
|
|
||||||
timer1.Disabled()
|
|
||||||
ad.Mdispatr.ChanTimer <- timer1
|
|
||||||
timer1.Stop()
|
|
||||||
delete(G_GameLogicPtr.MReadyToRemoveList, player)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) GetPlayerByAgent(gate gate.Agent) *Player {
|
func (ad *GameLogic) GetPlayerByAgent(gate gate.Agent) *Player {
|
||||||
p, ok := internal.Agents.Load(gate)
|
p, ok := internal.Agents.Load(gate)
|
||||||
if ok {
|
if ok {
|
||||||
@ -433,25 +413,21 @@ func G_getGameLogic() *GameLogic {
|
|||||||
G_GameLogicPtr.Mdispatr = timer.NewDispatcher(10)
|
G_GameLogicPtr.Mdispatr = timer.NewDispatcher(10)
|
||||||
G_GameLogicPtr.InitServerInfo()
|
G_GameLogicPtr.InitServerInfo()
|
||||||
G_GameLogicPtr.M_Players = make(map[int32]*Player)
|
G_GameLogicPtr.M_Players = make(map[int32]*Player)
|
||||||
G_GameLogicPtr.MReadyToRemoveList = make(map[*Player]*timer.Timer)
|
|
||||||
G_GameLogicPtr.NotInitPlayer = new(Player)
|
G_GameLogicPtr.NotInitPlayer = new(Player)
|
||||||
G_GameLogicPtr.M_LimitActiveList = []int{}
|
G_GameLogicPtr.M_LimitActiveList = []int{}
|
||||||
G_GameLogicPtr.LoadSvrGlobalData() // 加载服务器全局数据
|
G_GameLogicPtr.LoadSvrGlobalData() // 加载服务器全局数据
|
||||||
G_GameLogicPtr.CreateChamshipsMgr() // 创建锦标赛管理器
|
G_GameLogicPtr.OpenTimestampTick() // 开启时间戳计时器
|
||||||
G_GameLogicPtr.CreateProfileManager() // 创建玩家档案管理器
|
G_GameLogicPtr.ReadAllConfigs() // 读取所有配置文件
|
||||||
G_GameLogicPtr.CreateCompensateMgr() // 创建老玩家补偿管理器
|
G_GameLogicPtr.RegisterEvent() // 注册事件
|
||||||
G_GameLogicPtr.OpenTimestampTick() // 开启时间戳计时器
|
G_GameLogicPtr.RegisterNetWorkFunc() // 注册客户端接口
|
||||||
G_GameLogicPtr.ReadAllConfigs() // 读取所有配置文件
|
G_GameLogicPtr.InitActivity() // 初始化活动
|
||||||
G_GameLogicPtr.RegisterEvent() // 注册事件
|
G_GameLogicPtr.GetVersion() // 获取版本号
|
||||||
G_GameLogicPtr.RegisterNetWorkFunc() // 注册客户端接口
|
G_GameLogicPtr.CreateLogManager() //加载日志管理器
|
||||||
G_GameLogicPtr.InitActivity() // 初始化活动
|
G_GameLogicPtr.CreateFriendMgr() //创建好友管理器
|
||||||
G_GameLogicPtr.GetVersion() // 获取版本号
|
G_GameLogicPtr.CreateRankMgr() //创建排行榜管理器
|
||||||
G_GameLogicPtr.CreateLogManager() //加载日志管理器
|
G_GameLogicPtr.CreateMailMgr() //创建邮件管理器
|
||||||
G_GameLogicPtr.CreateFriendMgr() //创建好友管理器
|
G_GameLogicPtr.CreateChampshipMgr() // 创建竞标赛管理器
|
||||||
G_GameLogicPtr.CreateRankMgr() //创建排行榜管理器
|
ClusterMgrInit() //初始化集群
|
||||||
G_GameLogicPtr.CreateMailMgr() //创建邮件管理器
|
|
||||||
G_GameLogicPtr.CreateChampshipMgr() // 创建竞标赛管理器
|
|
||||||
ClusterMgrInit() //初始化集群
|
|
||||||
|
|
||||||
// G_GameLogicPtr.CreateHttpManager()
|
// G_GameLogicPtr.CreateHttpManager()
|
||||||
}
|
}
|
||||||
@ -472,34 +448,6 @@ func (ad *GameLogic) InitServerInfo() {
|
|||||||
ad.SeverInfo = ServerInfo
|
ad.SeverInfo = ServerInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *GameLogic) DisorderLuaTable(length int, Cnt int) []int {
|
|
||||||
|
|
||||||
// length := len(tb)
|
|
||||||
indexList := []int{}
|
|
||||||
copy := []int{}
|
|
||||||
for i := 0; i < Cnt; i++ {
|
|
||||||
index := rand.Intn(length - i)
|
|
||||||
if len(indexList) == 0 {
|
|
||||||
indexList = append(indexList, index)
|
|
||||||
} else {
|
|
||||||
for n := 0; n < len(copy); n++ {
|
|
||||||
if index >= copy[n] {
|
|
||||||
index = index + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
indexList = append(indexList, index)
|
|
||||||
}
|
|
||||||
copy = []int{}
|
|
||||||
for j := 0; j < len(indexList); j++ {
|
|
||||||
copy = append(copy, indexList[j])
|
|
||||||
}
|
|
||||||
|
|
||||||
sort.Slice(copy, func(i, j int) bool { return copy[i] < copy[j] })
|
|
||||||
}
|
|
||||||
contentList := indexList[:]
|
|
||||||
return contentList
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) GetVersion() {
|
func (ad *GameLogic) GetVersion() {
|
||||||
sqlStr := "SELECT * FROM t_gameserver WHERE id = ?"
|
sqlStr := "SELECT * FROM t_gameserver WHERE id = ?"
|
||||||
sqlStruck := db.SqlVersionStruct{}
|
sqlStruck := db.SqlVersionStruct{}
|
||||||
@ -549,32 +497,6 @@ func (ad *GameLogic) ClearData(args []interface{}) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *GameLogic) FindOfflinePlayer(dwUin int32) *Player {
|
|
||||||
for k := range G_GameLogicPtr.MReadyToRemoveList {
|
|
||||||
if k.M_DwUin == dwUin {
|
|
||||||
return k
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) InitPassportInsertDb(player *Player, StartSvrTime int32, EndSvrTime int32, ConfigActId int) int32 {
|
|
||||||
st := &db.SqlLimitPassportStruct{}
|
|
||||||
st.CurFreeLv = 0
|
|
||||||
st.CurPayLv = 0
|
|
||||||
st.DwUin = player.M_DwUin
|
|
||||||
st.IsPay = 0
|
|
||||||
st.Star = 0
|
|
||||||
st.StartSvrTime = StartSvrTime
|
|
||||||
st.EndSvrTime = EndSvrTime
|
|
||||||
st.Status = 0
|
|
||||||
st.ActiveID = 0
|
|
||||||
st.ConfigActId = int32(ConfigActId)
|
|
||||||
activityID, _ := db.FormatAllMemInsertDb(st, "t_player_LimitPassport")
|
|
||||||
|
|
||||||
return int32(activityID)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) InitPromotionInsertDb(player *Player, StartSvrTime int32, EndSvrTime int32, ConfigActId int) int32 {
|
func (ad *GameLogic) InitPromotionInsertDb(player *Player, StartSvrTime int32, EndSvrTime int32, ConfigActId int) int32 {
|
||||||
st := &db.SqlLimitPromotionStruct{}
|
st := &db.SqlLimitPromotionStruct{}
|
||||||
st.DwUin = player.M_DwUin
|
st.DwUin = player.M_DwUin
|
||||||
@ -648,53 +570,10 @@ func (ad *GameLogic) LoadSvrGlobalData() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *GameLogic) OpenNewLimitActivity(args []interface{}) {
|
|
||||||
go func() {
|
|
||||||
internal.Agents.Range(func(k, v interface{}) bool {
|
|
||||||
if v == ad.NotInitPlayer {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
player := v.(*Player)
|
|
||||||
notify := &msg.NotifyLimitedTimeActiveData{}
|
|
||||||
notify.MActiveList = []*msg.LimitedTimeActiveStruct{}
|
|
||||||
|
|
||||||
id := args[0].(int)
|
|
||||||
activityCfg := gamedata.GetConfigByName("Activity")
|
|
||||||
record := activityCfg.Index(id).(*gamedata.ActivityRecord)
|
|
||||||
|
|
||||||
act := &msg.LimitedTimeActiveStruct{}
|
|
||||||
act.StartSvrTime = args[1].(int32)
|
|
||||||
act.EndSvrTime = args[2].(int32)
|
|
||||||
act.Type = int32(record.Type)
|
|
||||||
if act.Type == 1 {
|
|
||||||
act.ActiveID = ad.InitPassportInsertDb(player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
}
|
|
||||||
if act.Type == 2 {
|
|
||||||
act.ActiveID = ad.InitPromotionInsertDb(player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
}
|
|
||||||
if act.Type == 3 {
|
|
||||||
act.ActiveID = ad.InitInfinitePackInsertDb(player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
}
|
|
||||||
if act.Type == 4 {
|
|
||||||
act.ActiveID = ad.Init7DayLoginInsertDb(player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
}
|
|
||||||
if act.Type == 5 {
|
|
||||||
act.ActiveID = ad.InitCardCollectInsertDb(player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
}
|
|
||||||
notify.MActiveList = append(notify.MActiveList, act)
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
ad.PackResInfo(k.(gate.Agent), "NotifyLimitedTimeActiveData", data)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}()
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) RegisterEvent() {
|
func (ad *GameLogic) RegisterEvent() {
|
||||||
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_Socket_Closed, ad.ClearData, nil)
|
GoUtil.RegisterEvent(MergeConst.Notify_Socket_Closed, ad.ClearData, nil)
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_Socket_Connect, ad.NewPlayerConnect, nil)
|
GoUtil.RegisterEvent(MergeConst.Notify_Socket_Connect, ad.NewPlayerConnect, nil)
|
||||||
GoUtil.RegisterEvent(MergeConst.OpenNewLimitActivity, ad.OpenNewLimitActivity, nil)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *GameLogic) NewPlayerConnect(args []interface{}) {
|
func (ad *GameLogic) NewPlayerConnect(args []interface{}) {
|
||||||
@ -769,144 +648,9 @@ func (ad *GameLogic) CreateDailyLogFile() {
|
|||||||
|
|
||||||
func (ad *GameLogic) RegisterNetWorkFunc() {
|
func (ad *GameLogic) RegisterNetWorkFunc() {
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerEmitUnlockData", ReqPlayerEmitUnlockDatafunction)
|
|
||||||
RegisterMsgProcessFunc("UpdatePlayerEmitUnlockData", UpdatePlayerEmitUnlockDatafunction)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerChessData", ReqPlayerChessDataFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdatePlayerChessData", UpdatePlayerChessDataFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("UpdateChessColorData", UpdateChessColorDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqChessColorData", ResChessColorDataFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqUnlockingChestID", ReqUnlockingChestIDFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqChestUnlockCD", ReqChestUnlockCDFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqEmitMergeMap", ReqEmitMergeMapFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqEmitCountMap", ReqResEmitCountMapFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqEmitCDStartData", ReqEmitCDStartDataFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateEmitMergeMap", UpdateEmitMergeMapFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateEmitCountMap", UpdateEmitCountMapFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqEmitSubCD", ReqEmitSubCDFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqShopData", ReqShopDatafunc)
|
|
||||||
RegisterMsgProcessFunc("ReqShopBuy", ReqShopBuyFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRenewItemBuyCnt", ReqRenewItemBuyCntFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqBriefEmailData", ReqBriefEmailDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqDetailEmailData", ReqDetailEmailDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetEmailReward", ReqGetEmailRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqDeleteEmail", ReqDeleteEmailFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqLimitPassportDetail", ReqLimitPassportDetailFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqPromotionDetail", ReqPromotionDetailFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqInfinitePackDetail", ReqInfinitePackDetailFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqGetLimitPassportReward", ReqGetLimitPassportRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyLimitPromotionReward", ReqBuyLimitPromotionRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyInfinitePack", ReqBuyInfinitePackFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPayPassport", ReqPayPassportFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqActiveAddStar", ReqActiveAddStarFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqOfflineReconnect", ReqOfflineReconnectFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqOpenNewPig", ReqOpenNewPigFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqPigDetailInfo", ReqPigDetailInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateFinishOrderDiamond", UpdateFinishOrderDiamondFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetPigReward", ReqGetPigRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqDropPigReward", ReqDropPigRewardFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqLevelUpPackInfo", ReqLevelUpPackInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyLevelUpPack", ReqBuyLevelUpPackFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqGrowthFundInfo", ReqGrowthFundInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyGrowthFund", ReqBuyGrowthFundFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetGrowthFundWard", ReqGetGrowthFundWardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRemoveAd", ReqRemoveAdFunc)
|
RegisterMsgProcessFunc("ReqRemoveAd", ReqRemoveAdFunc)
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqSupremeGiftInfo", ReqSupremeGiftInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuySupremeGift", ReqBuySupremeGiftFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqIllustratedInfo", ReqIllustratedInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetIllustrateItemReward", ReqGetIllustrateItemRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateIllustrateItem", UpdateIllustrateItemFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqCardCollectDetail", ReqCardCollectDetailFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetCardAlbumReward", ReqGetCardAlbumRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetAllCardReward", ReqGetAllCardRewardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddCard", ReqAddCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqUnpackCard", ReqUnpackCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddMasterCard", ReqAddMasterCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqUseMasterCard", ReqUseMasterCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyStickerItem", ReqBuyStickerItemFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqGetDonateCard", ReqGetDonateCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqReceiptCard", ReqReceiptCardFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqGetExchangeCard", ReqGetExchangeCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRefuseExchange", ReqRefuseExchangeFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRequestCard", ReqRequestCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqCompleteRequestCard", ReqCompleteRequestCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRefuseRequestCard", ReqRefuseRequestCardFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqGetRequestCard", ReqGetRequestCardFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqDailyTaskData", ResDailyTaskDataFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateDailyTaskData", UpdateDailyTaskDataFunc)
|
|
||||||
RegisterMsgProcessFunc("RenewDailyTaskData", RenewDailyTaskDataFunc)
|
|
||||||
RegisterMsgProcessFunc("RenewWeekyActiveData", RenewWeekyActiveDataFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqMileStoneData", ResMileStoneDataFunc)
|
|
||||||
RegisterMsgProcessFunc("UpdateMileStoneData", UpdateMileStoneDataFunc)
|
|
||||||
RegisterMsgProcessFunc("RenewMileStoneData", RenewMileStoneDataFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqChampshipData", ReqChampshipDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqChampshipAddScore", ReqChampshipAddScoreFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqChampshipAddTime", ReqChampshipAddTimeFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerChampshipData", ReqPlayerChampshipData)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqAdPackData", ReqAdPackDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqWatchAdPack", ReqWatchAdPackFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerSingleData", ReqPlayerSingleDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqOpenNewbiePack", ReqOpenNewbiePackFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqBuyNewbiePack", ReqBuyNewbiePackFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddNoAdCnt", ReqAddNoAdCntFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddWatchAdCnt", ReqAddWatchAdCntFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerPayData", ReqPlayerPayDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddPay", ReqAddPayFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqFriendData", ReqFriendDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqWillPlayerDetail", ReqWillPlayerDetailFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAddFriendData", ReqAddFriendDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAllAddFriendInfo", ReqAllAddFriendInfoFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAgreeFriendReq", ReqAgreeFriendReqFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqRefuseFriendReq", ReqRefuseFriendReqFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqDeleteFriend", ReqDeleteFriendFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqAutoFBAddFriend", ReqAutoFBAddFriend)
|
|
||||||
RegisterMsgProcessFunc("ReqRecommendFriendList", ReqRecommendFriendList)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqFriendTreasureData", ReqFriendTreasureData)
|
|
||||||
RegisterMsgProcessFunc("ReqUpdateFriendStar", ReqUpdateFriendStar)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerProfileData", ReqPlayerProfileDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqUpdatePlayerProfile", ReqUpdatePlayerProfileFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerBriefProfileData", ReqPlayerBriefProfileDataFunc)
|
RegisterMsgProcessFunc("ReqPlayerBriefProfileData", ReqPlayerBriefProfileDataFunc)
|
||||||
RegisterMsgProcessFunc("ReqFriendEventData", ReqFriendEventDataFunc)
|
|
||||||
RegisterMsgProcessFunc("ReqUpdateFBPicURL", ReqUpdateFBPicURLFunc)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPlayerPetData", ReqPlayerPetData)
|
|
||||||
RegisterMsgProcessFunc("ReqUpdatePetProfile", ReqUpdatePetProfile)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqPetHomeData", ReqPetHomeData)
|
|
||||||
RegisterMsgProcessFunc("ReqOpenOtherPetHome", ReqOpenOtherPetHome)
|
|
||||||
|
|
||||||
RegisterMsgProcessFunc("ReqOpenSelfPet", ReqOpenSelfPet)
|
|
||||||
RegisterMsgProcessFunc("ReqPetHomeInterActST", ReqPetHomeInterActST)
|
|
||||||
RegisterMsgProcessFunc("ReqShiftVisitPet", ReqShiftVisitPet)
|
|
||||||
RegisterMsgProcessFunc("ReqCallBackPet", ReqCallBackPet)
|
|
||||||
RegisterMsgProcessFunc("ReqUnlockDecorate", ReqUnlockDecorate)
|
|
||||||
RegisterMsgProcessFunc("ReqSaveSelectDecorate", ReqSaveSelectDecorate)
|
|
||||||
|
|
||||||
// 玩家
|
// 玩家
|
||||||
RegisterMsgProcessFunc("ReqUserInfo", ReqUserInfo)
|
RegisterMsgProcessFunc("ReqUserInfo", ReqUserInfo)
|
||||||
@ -917,6 +661,7 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
|||||||
RegisterMsgProcessFunc("ReqKv", ReqKv) // 保存客户端数据
|
RegisterMsgProcessFunc("ReqKv", ReqKv) // 保存客户端数据
|
||||||
|
|
||||||
// 棋盘
|
// 棋盘
|
||||||
|
RegisterMsgProcessFunc("ReqPlayerChessData", ReqPlayerChessDataFunc)
|
||||||
RegisterMsgProcessFunc("UpdatePlayerChessData", UpdatePlayerChessDataFunc) // 更新棋盘数据
|
RegisterMsgProcessFunc("UpdatePlayerChessData", UpdatePlayerChessDataFunc) // 更新棋盘数据
|
||||||
RegisterMsgProcessFunc("ReqSetEnergyMul", RegSetEneryFunc) //设置能量倍数
|
RegisterMsgProcessFunc("ReqSetEnergyMul", RegSetEneryFunc) //设置能量倍数
|
||||||
RegisterMsgProcessFunc("ReqChessEx", ReqChessEx) // 转换棋子
|
RegisterMsgProcessFunc("ReqChessEx", ReqChessEx) // 转换棋子
|
||||||
@ -1032,80 +777,6 @@ func (ad *GameLogic) RegisterNetWorkFunc() {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (ad *GameLogic) ResPlayerEmitUnlockData(param []interface{}) {
|
|
||||||
data := (param[0].(*Player).GetIFGameData("PlayerEmitUnlockData"))
|
|
||||||
data.(*PlayerEmitUnlockData).ResPlayerEmitUnlockData(param[0].(*Player))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) broadcastInfoAllPlayer(Func string, data []byte) {
|
|
||||||
internal.Agents.Range(func(k, v interface{}) bool {
|
|
||||||
if v == ad.NotInitPlayer {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
ad.PackResInfo(k.(gate.Agent), Func, data)
|
|
||||||
return true
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) JudgeIsActivity(c *cron.Cron, Id int) int {
|
|
||||||
activityCfg := gamedata.GetConfigByName("Activity")
|
|
||||||
record := activityCfg.Index(Id).(*gamedata.ActivityRecord)
|
|
||||||
|
|
||||||
timeStamp := time.Now().Unix()
|
|
||||||
t := time.Unix(timeStamp, 0).Local()
|
|
||||||
nianchu := timeStamp - (int64)(t.Hour()*3600+t.Minute()*60+t.Second()) - int64((t.YearDay()-1)*3600*24)
|
|
||||||
|
|
||||||
key := ad.m_CronEntryIDs[record.Id]
|
|
||||||
Schedule := c.Entry(key.StartCronID).Schedule
|
|
||||||
Next := Schedule.Next(time.Unix(nianchu, 0))
|
|
||||||
|
|
||||||
if timeStamp >= Next.Unix() && timeStamp <= Next.Unix()+int64(record.Duration) {
|
|
||||||
return 2
|
|
||||||
} else {
|
|
||||||
if timeStamp < Next.Unix() {
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 3
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) CalcDeltaEndTime(c *cron.Cron, Id int) int32 {
|
|
||||||
activityCfg := gamedata.GetConfigByName("Activity")
|
|
||||||
record := activityCfg.Index(Id).(*gamedata.ActivityRecord)
|
|
||||||
|
|
||||||
timeStamp := time.Now().Unix()
|
|
||||||
t := time.Unix(timeStamp, 0).Local()
|
|
||||||
nianchu := timeStamp - (int64)(t.Hour()*3600+t.Minute()*60+t.Second()) - int64((t.YearDay()-1)*3600*24)
|
|
||||||
|
|
||||||
key := ad.m_CronEntryIDs[record.Id]
|
|
||||||
Schedule := c.Entry(key.StartCronID).Schedule
|
|
||||||
Next := Schedule.Next(time.Unix(nianchu, 0))
|
|
||||||
return int32(Next.Unix() + int64(record.Duration) - timeStamp)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) GetActiveParamById(Id int) *LimitActPeriod {
|
|
||||||
v, ok := ad.m_CronEntryIDs[Id]
|
|
||||||
if ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) CreateProfileManager() {
|
|
||||||
ad.MPlayerProfileManager = new(PlayerProfileManager)
|
|
||||||
ad.MPlayerProfileManager.InitManager()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) CreateChamshipsMgr() {
|
|
||||||
ad.MChampshipsManager = new(NewChampshipsManager)
|
|
||||||
ad.MChampshipsManager.InitManager()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) CreateCompensateMgr() {
|
|
||||||
ad.MOldPlayerCompensateMgr = new(OldPlayerCompensateMgr)
|
|
||||||
ad.MOldPlayerCompensateMgr.InitManager()
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ad *GameLogic) CreateHttpManager() {
|
func (ad *GameLogic) CreateHttpManager() {
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|||||||
@ -102,9 +102,11 @@ func ReqGmCommand(args []interface{}) error {
|
|||||||
G_GameLogicPtr.ChampshipMgrSend(&MsgMod.Msg{
|
G_GameLogicPtr.ChampshipMgrSend(&MsgMod.Msg{
|
||||||
Type: MsgMod.HANDLE_TYPE_CHAMPSHIP_ZERO,
|
Type: MsgMod.HANDLE_TYPE_CHAMPSHIP_ZERO,
|
||||||
})
|
})
|
||||||
case "debug":
|
case "resetEmitOrder":
|
||||||
OrderMod := player.PlayMod.getOrderMod()
|
OrderMod := player.PlayMod.getOrderMod()
|
||||||
OrderMod.EimtOrder = make(map[string]struct{})
|
OrderMod.EimtOrder = make(map[string]struct{})
|
||||||
|
HandbookMod := player.PlayMod.getHandbookMod()
|
||||||
|
delete(HandbookMod.BookList, 125)
|
||||||
}
|
}
|
||||||
player.PlayMod.save()
|
player.PlayMod.save()
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@ -4,11 +4,8 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"server/conf"
|
"server/conf"
|
||||||
"server/msg"
|
|
||||||
|
|
||||||
// "server/msg"
|
// "server/msg"
|
||||||
"encoding/json"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
@ -36,23 +33,7 @@ func (p *HttpManager) InitPlayerProfileInfo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *HttpManager) GetPlayerProfileInfo(w http.ResponseWriter, r *http.Request) {
|
func (p *HttpManager) GetPlayerProfileInfo(w http.ResponseWriter, r *http.Request) {
|
||||||
vars := mux.Vars(r)
|
|
||||||
|
|
||||||
Id, ok := vars["Id"]
|
|
||||||
|
|
||||||
if ok {
|
|
||||||
Uin, _ := strconv.Atoi(Id)
|
|
||||||
data := G_GameLogicPtr.MPlayerProfileManager.HttpReqPlayerBriefProfileData(int32(Uin))
|
|
||||||
test := []*msg.ResPlayerBriefProfileData{data, data}
|
|
||||||
bytes, _ := json.Marshal(test)
|
|
||||||
|
|
||||||
v := []*msg.ResPlayerBriefProfileData{}
|
|
||||||
json.Unmarshal(bytes, &v)
|
|
||||||
|
|
||||||
fmt.Println("bytes Length:" + strconv.Itoa(len(v)))
|
|
||||||
fmt.Println("bytes Length:" + strconv.Itoa(len(v)))
|
|
||||||
w.Write(bytes)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *HttpManager) AddFriend(w http.ResponseWriter, r *http.Request) {
|
func (p *HttpManager) AddFriend(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
package game
|
package game
|
||||||
|
|
||||||
type PlayerSimpleData struct {
|
type PlayerSimpleData struct {
|
||||||
Uid int
|
Uid int
|
||||||
Name string
|
Name string
|
||||||
Avatar int
|
Avatar int
|
||||||
Level int
|
Level int
|
||||||
Face int
|
Face int
|
||||||
Decorate int
|
Decorate int
|
||||||
Login int64
|
Login int64
|
||||||
Loginout int64
|
Loginout int64
|
||||||
FaceBook string
|
FaceBook string
|
||||||
|
FaceBookPic string
|
||||||
}
|
}
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,113 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"math"
|
|
||||||
"server/db"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
)
|
|
||||||
|
|
||||||
type OldPlayerCompensateMgr struct {
|
|
||||||
MSqlCompensateStruct map[string]*db.SqlCompensateStruct
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *OldPlayerCompensateMgr) SuccessSendEmail(username string) bool {
|
|
||||||
|
|
||||||
emailst, ok := p.MSqlCompensateStruct[username]
|
|
||||||
if ok {
|
|
||||||
emailst.IsSendEmail = 1
|
|
||||||
db.FormatAllMemUpdateDb(emailst, "t_player_compensate_Data", "auto_id")
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *OldPlayerCompensateMgr) SendEmailToDb(username string, dwUin int32) bool {
|
|
||||||
|
|
||||||
emailst, ok := p.MSqlCompensateStruct[username]
|
|
||||||
if ok {
|
|
||||||
if emailst.IsSendEmail == 1 {
|
|
||||||
return false
|
|
||||||
} else {
|
|
||||||
sqlSt := &db.SqlEmailStruct{}
|
|
||||||
sqlSt.DwUin = dwUin
|
|
||||||
sqlSt.Content = `Welcome back to our game!
|
|
||||||
Here comes your refund for your scene progress and payment in test version!
|
|
||||||
Have fun in new version!`
|
|
||||||
sqlSt.CurrencyCount = 0
|
|
||||||
sqlSt.CurrencyInfo = ""
|
|
||||||
sqlSt.RecvTime = 0
|
|
||||||
sqlSt.Title = "Test Players' Refund"
|
|
||||||
sqlSt.Sender = "System"
|
|
||||||
sqlSt.ItemCount = 0
|
|
||||||
sqlSt.ItemInfo = ""
|
|
||||||
sqlSt.SendTime = int32(time.Now().Unix())
|
|
||||||
sqlSt.Status = 0
|
|
||||||
sqlSt.Type = 1
|
|
||||||
sqlSt.RewardId = ""
|
|
||||||
sqlSt.RewardCount = ""
|
|
||||||
sqlSt.LinkUrl = ""
|
|
||||||
strarr := []string{}
|
|
||||||
if emailst.DecorationCnt-5 > 0 {
|
|
||||||
SceneDiamond := (emailst.DecorationCnt-5)*10 + 25
|
|
||||||
|
|
||||||
temp := fmt.Sprintf("Diamond|%d", SceneDiamond)
|
|
||||||
strarr = append(strarr, temp)
|
|
||||||
}
|
|
||||||
f, err := strconv.ParseFloat(emailst.ChargeCnt, 64)
|
|
||||||
var ChargeDiamond float64 = 0
|
|
||||||
if err == nil {
|
|
||||||
ChargeDiamond = f * 1.5 * 75
|
|
||||||
}
|
|
||||||
if ChargeDiamond > 0 {
|
|
||||||
cd := int32(math.Ceil(ChargeDiamond))
|
|
||||||
remain := cd % 10
|
|
||||||
if remain != 0 && remain != 5 {
|
|
||||||
if remain < 5 {
|
|
||||||
cd = cd - remain + 5
|
|
||||||
} else {
|
|
||||||
cd = cd - remain + 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
temp := fmt.Sprintf("Diamond|%d", cd)
|
|
||||||
strarr = append(strarr, temp)
|
|
||||||
|
|
||||||
}
|
|
||||||
sqlSt.RewardType = strings.Join(strarr, "_")
|
|
||||||
|
|
||||||
insertId, err1 := db.FormatAllMemInsertDb(sqlSt, "system_mail_info")
|
|
||||||
|
|
||||||
if err1 == nil {
|
|
||||||
p.SuccessSendEmail(username)
|
|
||||||
fmt.Sprintln("Success Intert Mail:" + strconv.Itoa(int(insertId)))
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *OldPlayerCompensateMgr) LoadData() {
|
|
||||||
sqlStr := "SELECT * FROM t_player_compensate_Data"
|
|
||||||
sqlStrucks := []db.SqlCompensateStruct{}
|
|
||||||
|
|
||||||
p.MSqlCompensateStruct = make(map[string]*db.SqlCompensateStruct)
|
|
||||||
if err := db.SqlDb.Select(&sqlStrucks, sqlStr); err != nil {
|
|
||||||
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
|
|
||||||
}
|
|
||||||
for i := 0; i < len(sqlStrucks); i++ {
|
|
||||||
p.MSqlCompensateStruct[sqlStrucks[i].DeviceId] = &sqlStrucks[i]
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *OldPlayerCompensateMgr) InitManager() {
|
|
||||||
p.LoadData()
|
|
||||||
}
|
|
||||||
@ -44,7 +44,6 @@ type Player struct {
|
|||||||
PlayMod PlayerMod
|
PlayMod PlayerMod
|
||||||
M_DwUin int32
|
M_DwUin int32
|
||||||
agent gate.Agent
|
agent gate.Agent
|
||||||
PAMgr *PlayerActiveMgr
|
|
||||||
lock sync.Mutex
|
lock sync.Mutex
|
||||||
stopSignal chan bool
|
stopSignal chan bool
|
||||||
Msg map[string]PlayerMsg
|
Msg map[string]PlayerMsg
|
||||||
@ -197,27 +196,6 @@ func (p *Player) InitPlayer(UserName string) error {
|
|||||||
p.playerdataIF[PLAYER_BASE_DATA] = Base
|
p.playerdataIF[PLAYER_BASE_DATA] = Base
|
||||||
p.M_DwUin = Base.Data.DwUin
|
p.M_DwUin = Base.Data.DwUin
|
||||||
|
|
||||||
// 发射器解锁数据
|
|
||||||
unlock := &PlayerEmitUnlockData{PlayerData: NewPlayerData("PlayerEmitUnlockData", p)}
|
|
||||||
ok = unlock.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerEmitUnlockData failed:", UserName)
|
|
||||||
return errors.New("load PlayerEmitUnlockData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerEmitUnlockData"] = unlock
|
|
||||||
p.playerdataIF["PlayerEmitUnlockData"] = unlock
|
|
||||||
|
|
||||||
// 发射器数据
|
|
||||||
Detail := &PlayerEmitDetailData{PlayerData: NewPlayerData("PlayerEmitDetailData", p)}
|
|
||||||
ok = Detail.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerEmitDetailData failed! username: %s", UserName)
|
|
||||||
return errors.New("load PlayerEmitDetailData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerEmitDetailData"] = Detail
|
|
||||||
p.playerdataIF["PlayerEmitDetailData"] = Detail
|
|
||||||
G_getGameLogic().Mlogger.Debug("load PlayerEmitDetailData:", Base.Data.DwUin)
|
|
||||||
|
|
||||||
// 棋盘数据
|
// 棋盘数据
|
||||||
Chess := &PlayerChessData{PlayerData: NewPlayerData("PlayerChessData", p)}
|
Chess := &PlayerChessData{PlayerData: NewPlayerData("PlayerChessData", p)}
|
||||||
ok = Chess.LoadDataFromDB(Base.Data.DwUin)
|
ok = Chess.LoadDataFromDB(Base.Data.DwUin)
|
||||||
@ -228,46 +206,6 @@ func (p *Player) InitPlayer(UserName string) error {
|
|||||||
p.playerdata["PlayerChessData"] = Chess
|
p.playerdata["PlayerChessData"] = Chess
|
||||||
p.playerdataIF["PlayerChessData"] = Chess
|
p.playerdataIF["PlayerChessData"] = Chess
|
||||||
|
|
||||||
// 玩家解锁宝箱数据
|
|
||||||
Chest := &PlayerUnlockingChestData{PlayerData: NewPlayerData("PlayerUnlockingChestData", p)}
|
|
||||||
ok = Chest.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerUnlockingChestData failed:", UserName)
|
|
||||||
return errors.New("load PlayerUnlockingChestData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerUnlockingChestData"] = Chest
|
|
||||||
p.playerdataIF["PlayerUnlockingChestData"] = Chest
|
|
||||||
|
|
||||||
// 玩家解锁宝箱数据
|
|
||||||
Single := &PlayerSingleData{PlayerData: NewPlayerData("PlayerSingleData", p)}
|
|
||||||
ok = Single.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerSingleData failed:", UserName)
|
|
||||||
return errors.New("load PlayerSingleData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerSingleData"] = Single
|
|
||||||
p.playerdataIF["PlayerSingleData"] = Single
|
|
||||||
|
|
||||||
// 玩家订单数据
|
|
||||||
Charge := &PlayerChargeData{PlayerData: NewPlayerData("PlayerChargeData", p)}
|
|
||||||
ok = Charge.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerChargeData failed:", UserName)
|
|
||||||
return errors.New("load PlayerChargeData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerChargeData"] = Charge
|
|
||||||
p.playerdataIF["PlayerChargeData"] = Charge
|
|
||||||
|
|
||||||
// 玩家好友数据
|
|
||||||
friendEvt := &PlayerFriendEventData{PlayerData: NewPlayerData("PlayerFriendEventData", p)}
|
|
||||||
ok = friendEvt.LoadDataFromDB(Base.Data.DwUin)
|
|
||||||
if !ok {
|
|
||||||
log.Debug("load PlayerFriendEventData failed:", UserName)
|
|
||||||
return errors.New("load PlayerFriendEventData failed")
|
|
||||||
}
|
|
||||||
p.playerdata["PlayerFriendEventData"] = friendEvt
|
|
||||||
p.playerdataIF["PlayerFriendEventData"] = friendEvt
|
|
||||||
|
|
||||||
// 玩家模块数据
|
// 玩家模块数据
|
||||||
modData := &PlayerModData{PlayerData: NewPlayerData("PlayerModData", p)}
|
modData := &PlayerModData{PlayerData: NewPlayerData("PlayerModData", p)}
|
||||||
ok = modData.LoadDataFromDB(Base.Data.DwUin)
|
ok = modData.LoadDataFromDB(Base.Data.DwUin)
|
||||||
@ -283,8 +221,6 @@ func (p *Player) InitPlayer(UserName string) error {
|
|||||||
p.PlayMod.mod_list = modData.ModList
|
p.PlayMod.mod_list = modData.ModList
|
||||||
p.PlayMod.is_update = IsUpdate
|
p.PlayMod.is_update = IsUpdate
|
||||||
|
|
||||||
p.PAMgr = new(PlayerActiveMgr)
|
|
||||||
p.PAMgr.InitActiveMgr(p)
|
|
||||||
go func() { // 处理数据回调
|
go func() { // 处理数据回调
|
||||||
var cb *timer.Timer
|
var cb *timer.Timer
|
||||||
for {
|
for {
|
||||||
@ -761,6 +697,7 @@ func (p *Player) UpdateUserInfo() {
|
|||||||
simple.Login = int64(Base.Data.LoginTime)
|
simple.Login = int64(Base.Data.LoginTime)
|
||||||
simple.Loginout = int64(Base.Data.LogoutTime)
|
simple.Loginout = int64(Base.Data.LogoutTime)
|
||||||
simple.FaceBook = Base.Data.FaceBookId
|
simple.FaceBook = Base.Data.FaceBookId
|
||||||
|
simple.FaceBookPic = p.PlayMod.getBaseMod().FacebookUrl
|
||||||
value, _ := json.Marshal(simple)
|
value, _ := json.Marshal(simple)
|
||||||
IdStr := strconv.Itoa(int(p.M_DwUin))
|
IdStr := strconv.Itoa(int(p.M_DwUin))
|
||||||
db.RedisSetKey(IdStr, string(value), 0)
|
db.RedisSetKey(IdStr, string(value), 0)
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,208 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"server/db"
|
|
||||||
"server/gamedata"
|
|
||||||
"server/msg"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerActiveMgr struct {
|
|
||||||
M_Player *Player
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerActiveMgr) OpenNewLimitActivity(args []interface{}) {
|
|
||||||
notify := &msg.NotifyLimitedTimeActiveData{}
|
|
||||||
notify.MActiveList = []*msg.LimitedTimeActiveStruct{}
|
|
||||||
|
|
||||||
id := args[0].(int)
|
|
||||||
activityCfg := gamedata.GetConfigByName("Activity")
|
|
||||||
record := activityCfg.Index(id).(*gamedata.ActivityRecord)
|
|
||||||
|
|
||||||
act := &msg.LimitedTimeActiveStruct{}
|
|
||||||
act.StartSvrTime = args[1].(int32)
|
|
||||||
act.EndSvrTime = args[2].(int32)
|
|
||||||
act.Type = int32(record.Type)
|
|
||||||
ActiveID := args[3].(int32)
|
|
||||||
if act.Type == 1 {
|
|
||||||
|
|
||||||
if ActiveID == int32(0) {
|
|
||||||
act.ActiveID = G_GameLogicPtr.InitPassportInsertDb(p.M_Player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
} else {
|
|
||||||
act.ActiveID = ActiveID
|
|
||||||
}
|
|
||||||
actor := &PlayerPassportData{PlayerActiveData: NewActiveData("PlayerPassportData", p.M_Player)}
|
|
||||||
ok := actor.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["PlayerPassportData"] = actor
|
|
||||||
p.M_Player.playerdataIF["PlayerPassportData"] = actor
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if act.Type == 2 {
|
|
||||||
if ActiveID == int32(0) {
|
|
||||||
act.ActiveID = G_GameLogicPtr.InitPromotionInsertDb(p.M_Player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
} else {
|
|
||||||
act.ActiveID = ActiveID
|
|
||||||
}
|
|
||||||
actor := &PlayerPromotionData{PlayerActiveData: NewActiveData("PlayerPromotionData", p.M_Player)}
|
|
||||||
ok := actor.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["PlayerPromotionData"] = actor
|
|
||||||
p.M_Player.playerdataIF["PlayerPromotionData"] = actor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if act.Type == 3 {
|
|
||||||
if ActiveID == int32(0) {
|
|
||||||
act.ActiveID = G_GameLogicPtr.InitInfinitePackInsertDb(p.M_Player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
} else {
|
|
||||||
act.ActiveID = ActiveID
|
|
||||||
}
|
|
||||||
actor := &PlayerInfinitePackData{PlayerActiveData: NewActiveData("PlayerInfinitePackData", p.M_Player)}
|
|
||||||
ok := actor.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["PlayerInfinitePackData"] = actor
|
|
||||||
p.M_Player.playerdataIF["PlayerInfinitePackData"] = actor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if act.Type == 4 {
|
|
||||||
if ActiveID == int32(0) {
|
|
||||||
act.ActiveID = G_GameLogicPtr.Init7DayLoginInsertDb(p.M_Player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
} else {
|
|
||||||
act.ActiveID = ActiveID
|
|
||||||
}
|
|
||||||
actor := &Player7DayLoginData{PlayerActiveData: NewActiveData("Player7DayLoginData", p.M_Player)}
|
|
||||||
ok := actor.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["Player7DayLoginData"] = actor
|
|
||||||
p.M_Player.playerdataIF["Player7DayLoginData"] = actor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if act.Type == 5 {
|
|
||||||
if ActiveID == int32(0) {
|
|
||||||
act.ActiveID = G_GameLogicPtr.InitCardCollectInsertDb(p.M_Player, act.StartSvrTime, act.EndSvrTime, id)
|
|
||||||
} else {
|
|
||||||
act.ActiveID = ActiveID
|
|
||||||
}
|
|
||||||
actor := &PlayerCardCollectData{PlayerActiveData: NewActiveData("PlayerCardCollectData", p.M_Player)}
|
|
||||||
ok := actor.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["PlayerCardCollectData"] = actor
|
|
||||||
p.M_Player.playerdataIF["PlayerCardCollectData"] = actor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
notify.MActiveList = append(notify.MActiveList, act)
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
agent := p.M_Player.GetAgentByPlayer()
|
|
||||||
G_GameLogicPtr.PackResInfo(agent, "NotifyLimitedTimeActiveData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func NewActiveData(dataName string, player *Player) *PlayerActiveData {
|
|
||||||
act := &PlayerActiveData{
|
|
||||||
PlayerData: NewPlayerData(dataName, player),
|
|
||||||
MisDirty: false,
|
|
||||||
}
|
|
||||||
|
|
||||||
return act
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerActiveMgr) InitActiveMgr(player *Player) {
|
|
||||||
p.M_Player = player
|
|
||||||
activityCfg := gamedata.GetConfigByName("Activity")
|
|
||||||
map1 := make(map[int]string)
|
|
||||||
map1[1] = "t_player_LimitPassport"
|
|
||||||
map1[2] = "t_player_LimitPromotion"
|
|
||||||
map1[3] = "t_player_LimitInfinitePack"
|
|
||||||
map1[4] = "t_player_Limit7DayLogin"
|
|
||||||
map1[5] = "t_player_card_data"
|
|
||||||
for i := 0; i < len(G_GameLogicPtr.M_LimitActiveList); i++ {
|
|
||||||
Id := G_GameLogicPtr.M_LimitActiveList[i]
|
|
||||||
record := activityCfg.Index(Id).(*gamedata.ActivityRecord)
|
|
||||||
sqlStr := "Select * From " + map1[record.Type] + " Where ConfigActId = ? And dwUin = ?"
|
|
||||||
if record.Type == 1 {
|
|
||||||
struct1 := []db.SqlLimitPassportStruct{}
|
|
||||||
st := G_GameLogicPtr.GetActiveParamById(Id)
|
|
||||||
Start := st.StartTime
|
|
||||||
EndTime := st.EndTime
|
|
||||||
if err := db.SqlDb.Select(&struct1, sqlStr, Id, player.M_DwUin); err != nil {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
if len(struct1) == 0 {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, struct1[0].ActiveID})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if record.Type == 2 {
|
|
||||||
struct1 := []db.SqlLimitPromotionStruct{}
|
|
||||||
st := G_GameLogicPtr.GetActiveParamById(Id)
|
|
||||||
Start := st.StartTime
|
|
||||||
EndTime := st.EndTime
|
|
||||||
if err := db.SqlDb.Select(&struct1, sqlStr, Id, player.M_DwUin); err != nil {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
if len(struct1) == 0 {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, struct1[0].ActiveID})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if record.Type == 3 {
|
|
||||||
struct1 := []db.SqlLimitInfinitePackStruct{}
|
|
||||||
st := G_GameLogicPtr.GetActiveParamById(Id)
|
|
||||||
Start := st.StartTime
|
|
||||||
EndTime := st.EndTime
|
|
||||||
if err := db.SqlDb.Select(&struct1, sqlStr, Id, player.M_DwUin); err != nil {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
if len(struct1) == 0 {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, struct1[0].ActiveID})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
if record.Type == 4 {
|
|
||||||
struct1 := []db.SqlSevenDayLoginStruct{}
|
|
||||||
st := G_GameLogicPtr.GetActiveParamById(Id)
|
|
||||||
Start := st.StartTime
|
|
||||||
EndTime := st.EndTime
|
|
||||||
if err := db.SqlDb.Select(&struct1, sqlStr, Id, player.M_DwUin); err != nil {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
if len(struct1) == 0 {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, struct1[0].ActiveID})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if record.Type == 5 {
|
|
||||||
struct1 := []db.SqlCardCollectStruct{}
|
|
||||||
st := G_GameLogicPtr.GetActiveParamById(Id)
|
|
||||||
Start := st.StartTime
|
|
||||||
EndTime := st.EndTime
|
|
||||||
if err := db.SqlDb.Select(&struct1, sqlStr, Id, player.M_DwUin); err != nil {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
if len(struct1) == 0 {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, int32(0)})
|
|
||||||
} else {
|
|
||||||
p.OpenNewLimitActivity([]interface{}{Id, Start, EndTime, struct1[0].ActiveID})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -141,7 +141,7 @@ func (p *PlayerBaseData) LoadDataFromDB(UserName interface{}) bool {
|
|||||||
p.Data.FaceBookId = sqlStruck.FaceBookId
|
p.Data.FaceBookId = sqlStruck.FaceBookId
|
||||||
p.McronSave = cron.New()
|
p.McronSave = cron.New()
|
||||||
p.Reconnect(false)
|
p.Reconnect(false)
|
||||||
p.AddCompensateEmail()
|
|
||||||
p.KeyValueData = make(map[int]string)
|
p.KeyValueData = make(map[int]string)
|
||||||
if len(sqlStruck1.ModData) > 0 {
|
if len(sqlStruck1.ModData) > 0 {
|
||||||
var buf bytes.Buffer
|
var buf bytes.Buffer
|
||||||
@ -189,10 +189,6 @@ func (p *PlayerBaseData) Reconnect(b bool) {
|
|||||||
GoUtil.RegisterEvent(MergeConst.Notify_Daily_Renew, p.Notify_Daily_Renew, p)
|
GoUtil.RegisterEvent(MergeConst.Notify_Daily_Renew, p.Notify_Daily_Renew, p)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlayerBaseData) AddCompensateEmail() {
|
|
||||||
G_GameLogicPtr.MOldPlayerCompensateMgr.SendEmailToDb(p.Data.UserName, p.Data.DwUin)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerBaseData) SetChampshipID(ChampshipsGroupID int32, isNotify bool) {
|
func (p *PlayerBaseData) SetChampshipID(ChampshipsGroupID int32, isNotify bool) {
|
||||||
p.Data.LastChampGroupID = p.Data.ChampshipsGroupID
|
p.Data.LastChampGroupID = p.Data.ChampshipsGroupID
|
||||||
p.Data.ChampshipsGroupID = ChampshipsGroupID
|
p.Data.ChampshipsGroupID = ChampshipsGroupID
|
||||||
@ -751,7 +747,6 @@ func (p *PlayerBaseData) GetDataByUid(Uid interface{}) bool {
|
|||||||
p.Data.FaceBookId = sqlStruck.FaceBookId
|
p.Data.FaceBookId = sqlStruck.FaceBookId
|
||||||
p.McronSave = cron.New()
|
p.McronSave = cron.New()
|
||||||
p.Reconnect(false)
|
p.Reconnect(false)
|
||||||
p.AddCompensateEmail()
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -5,14 +5,11 @@ import (
|
|||||||
"math"
|
"math"
|
||||||
"server/GoUtil"
|
"server/GoUtil"
|
||||||
mergeDataCfg "server/conf/mergeData"
|
mergeDataCfg "server/conf/mergeData"
|
||||||
"server/db"
|
|
||||||
"server/game/mod/item"
|
"server/game/mod/item"
|
||||||
"server/game/mod/quest"
|
"server/game/mod/quest"
|
||||||
"server/msg"
|
"server/msg"
|
||||||
"server/pkg/github.com/name5566/leaf/log"
|
"server/pkg/github.com/name5566/leaf/log"
|
||||||
"sort"
|
"sort"
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
@ -24,51 +21,7 @@ type PlayerChessData struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlayerChessData) LoadDataFromDB(dwUin interface{}) bool {
|
func (p *PlayerChessData) LoadDataFromDB(dwUin interface{}) bool {
|
||||||
sqlStr := "SELECT * FROM t_player_chess_data WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlChessStruct{}
|
|
||||||
p.Data.MChessData = make(map[string]int32)
|
|
||||||
p.ColorData.MChessColorData = make(map[string]int32)
|
|
||||||
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
|
|
||||||
if sqlStruck.MChessData != "" {
|
|
||||||
arr := strings.Split(sqlStruck.MChessData, "_")
|
|
||||||
|
|
||||||
for i := 0; i < len(arr); i++ {
|
|
||||||
ss := strings.Split(arr[i], ",")
|
|
||||||
id, err := strconv.ParseInt(ss[1], 10, 32)
|
|
||||||
key := ss[0]
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Data.MChessData[key] = int32(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if sqlStruck.MChessColorData != "" {
|
|
||||||
arr := strings.Split(sqlStruck.MChessColorData, "_")
|
|
||||||
|
|
||||||
for i := 0; i < len(arr); i++ {
|
|
||||||
ss := strings.Split(arr[i], ",")
|
|
||||||
id, err := strconv.ParseInt(ss[1], 10, 32)
|
|
||||||
key := ss[0]
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.ColorData.MChessColorData[key] = int32(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Data.DwUin = dwUin.(int32)
|
|
||||||
p.Reconnect(false)
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -76,58 +29,8 @@ func (p *PlayerChessData) Reconnect(b bool) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlayerChessData) SetValueByKey(k string) {
|
|
||||||
if k != "" {
|
|
||||||
p.Data.MChessData[k] = p.Data.MChessData[k] + 1
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerChessData) GetValueByKey(k string) int32 {
|
|
||||||
|
|
||||||
v, ok := p.Data.MChessData[k]
|
|
||||||
if ok {
|
|
||||||
return v
|
|
||||||
}
|
|
||||||
return -1
|
|
||||||
}
|
|
||||||
func (p *PlayerChessData) GetKeyByEmitID(EmitID int32) string {
|
|
||||||
for k := range p.Data.MChessData {
|
|
||||||
units := strings.Split(k, "@")
|
|
||||||
if len(units) >= 4 {
|
|
||||||
n, _ := strconv.Atoi(units[3])
|
|
||||||
if EmitID == int32(n) {
|
|
||||||
return k
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerChessData) SaveDataFromDB(Key interface{}) bool {
|
func (p *PlayerChessData) SaveDataFromDB(Key interface{}) bool {
|
||||||
var strarr []string
|
|
||||||
var strarr1 []string
|
|
||||||
for k, v := range p.Data.MChessData {
|
|
||||||
str := fmt.Sprintf("%s,%d", k, v)
|
|
||||||
strarr = append(strarr, str)
|
|
||||||
}
|
|
||||||
str_concat := strings.Join(strarr, "_")
|
|
||||||
|
|
||||||
for k, v := range p.ColorData.MChessColorData {
|
|
||||||
str := fmt.Sprintf("%s,%d", k, v)
|
|
||||||
strarr1 = append(strarr1, str)
|
|
||||||
}
|
|
||||||
str_concat1 := strings.Join(strarr1, "_")
|
|
||||||
|
|
||||||
sqlStruck := db.SqlChessStruct{}
|
|
||||||
sqlStruck.DwUin = p.M_Player.M_DwUin
|
|
||||||
sqlStruck.MChessData = str_concat
|
|
||||||
sqlStruck.MChessColorData = str_concat1
|
|
||||||
if p.IsHaveDataDb {
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStruck, "t_player_chess_data", "dwUin")
|
|
||||||
} else {
|
|
||||||
db.FormatAllMemInsertDb(&sqlStruck, "t_player_chess_data")
|
|
||||||
}
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -319,30 +222,6 @@ func (p *PlayerChessData) HandleChess(handle_list []*msg.ChessHandle) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *PlayerChessData) UpdateChessColorData(buf []byte) {
|
|
||||||
update := &msg.UpdateChessColorData{}
|
|
||||||
err := proto.Unmarshal(buf, update)
|
|
||||||
if err != nil {
|
|
||||||
fmt.Println("unmarshal failed, err:", err)
|
|
||||||
return
|
|
||||||
|
|
||||||
}
|
|
||||||
p.ColorData.MChessColorData = update.MChessColorData
|
|
||||||
|
|
||||||
}
|
|
||||||
func (p *PlayerChessData) GetChestKeyByValue(id int32) string {
|
|
||||||
for k, v := range p.Data.MChessData {
|
|
||||||
if id == v {
|
|
||||||
return k
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ""
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerChessData) ClearData() bool {
|
func (p *PlayerChessData) ClearData() bool {
|
||||||
p.SaveDataFromDB("")
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
//********************************************************************************
|
|
||||||
// api
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@ -1,284 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"server/MergeConst"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"sort"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/robfig/cron/v3"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerEmailData struct {
|
|
||||||
*PlayerData
|
|
||||||
Data msg.ResBriefEmailData
|
|
||||||
SqlStructs []db.SqlEmailStruct
|
|
||||||
ZeroCronID cron.EntryID
|
|
||||||
WeekCronID cron.EntryID
|
|
||||||
Mcron *cron.Cron
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM system_mail_info WHERE dwUin = ?"
|
|
||||||
if err := db.SqlDb.Select(&p.SqlStructs, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
|
|
||||||
CurTime := int32(time.Now().Unix())
|
|
||||||
|
|
||||||
deleteList := []int{}
|
|
||||||
deleteDbList := []int32{}
|
|
||||||
for i := 0; i < len(p.SqlStructs); i++ {
|
|
||||||
item := p.SqlStructs[i]
|
|
||||||
if item.RecvTime > 0 && item.Status == 1 && CurTime-item.RecvTime >= MergeConst.G_Clear_Read_Email_Limit {
|
|
||||||
deleteList = append(deleteList, i)
|
|
||||||
deleteDbList = append(deleteDbList, item.EmailId)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
tempList := []db.SqlEmailStruct{}
|
|
||||||
startIndex := 0
|
|
||||||
for i := 0; i < len(deleteList); i++ {
|
|
||||||
curIndex := deleteList[i]
|
|
||||||
if curIndex == startIndex {
|
|
||||||
startIndex = startIndex + 1
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
tempList = append(tempList, p.SqlStructs[startIndex:curIndex]...)
|
|
||||||
startIndex = curIndex + 1
|
|
||||||
}
|
|
||||||
if startIndex <= len(p.SqlStructs)-1 {
|
|
||||||
tempList = append(tempList, p.SqlStructs[startIndex:]...)
|
|
||||||
}
|
|
||||||
p.SqlStructs = tempList
|
|
||||||
p.DeleteOutlineMail(deleteDbList)
|
|
||||||
|
|
||||||
sort.Slice(p.SqlStructs, func(i, j int) bool {
|
|
||||||
if p.SqlStructs[i].Status == p.SqlStructs[j].Status {
|
|
||||||
if p.SqlStructs[i].Type == p.SqlStructs[j].Type {
|
|
||||||
return p.SqlStructs[i].SendTime > p.SqlStructs[j].SendTime
|
|
||||||
} else {
|
|
||||||
return p.SqlStructs[i].Type > p.SqlStructs[j].Type
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return p.SqlStructs[i].Status < p.SqlStructs[j].Status
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
for i := 0; i < len(p.SqlStructs); i++ {
|
|
||||||
item := p.SqlStructs[i]
|
|
||||||
if item.Status == 0 {
|
|
||||||
p.SqlStructs[i].Status = 1
|
|
||||||
db.FormatAllMemUpdateDb(&p.SqlStructs[i], "system_mail_info", "mail_id")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Mcron = cron.New()
|
|
||||||
p.Reconnect(false)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
func (p *PlayerEmailData) Reconnect(b bool) {
|
|
||||||
p.ZeroCronID, _ = p.Mcron.AddFunc("@every 5s", func() {
|
|
||||||
p.IntervalGetUnsendMails()
|
|
||||||
})
|
|
||||||
p.Mcron.Start()
|
|
||||||
}
|
|
||||||
func (p *PlayerEmailData) DeleteOutlineMail(deleteList []int32) {
|
|
||||||
sqlStr := "DELETE FROM system_mail_info WHERE mail_id = ?"
|
|
||||||
for i := 0; i < len(deleteList); i++ {
|
|
||||||
|
|
||||||
result, err := db.SqlDb.Exec(sqlStr, deleteList[i])
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("exec failed, err:%v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
affectedRows, err := result.RowsAffected()
|
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("get affected failed, err:%v\n", err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
fmt.Printf("delete data success, affected rows:%d\n", affectedRows)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) IntervalGetUnsendMails() {
|
|
||||||
sqlStr := "SELECT * FROM system_mail_info WHERE dwUin = ? AND state = ?"
|
|
||||||
SqlStructs := []db.SqlEmailStruct{}
|
|
||||||
if err := db.SqlDb.Select(&SqlStructs, sqlStr, p.M_Player.M_DwUin, 0); err != nil {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
for i := 0; i < len(SqlStructs); i++ {
|
|
||||||
SqlStructs[i].Status = 1
|
|
||||||
db.FormatAllMemUpdateDb(&SqlStructs[i], "system_mail_info", "mail_id")
|
|
||||||
}
|
|
||||||
if len(SqlStructs) > 0 {
|
|
||||||
p.NotifyNewBriefEmailData(SqlStructs)
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) NotifyNewBriefEmailData(SqlStructs []db.SqlEmailStruct) {
|
|
||||||
notify := &msg.NotifyNewBriefEmailData{}
|
|
||||||
notify.DwUin = p.M_Player.M_DwUin
|
|
||||||
notify.MEmailList = []*msg.BriefEmailStruct{}
|
|
||||||
|
|
||||||
p.SqlStructs = append(p.SqlStructs, SqlStructs...)
|
|
||||||
|
|
||||||
for i := 0; i < len(SqlStructs); i++ {
|
|
||||||
st := &msg.BriefEmailStruct{}
|
|
||||||
st.EmailId = SqlStructs[i].EmailId
|
|
||||||
st.Sender = SqlStructs[i].Sender
|
|
||||||
st.Title = SqlStructs[i].Title
|
|
||||||
st.CurrencyCount = SqlStructs[i].CurrencyCount
|
|
||||||
st.CurrencyInfo = SqlStructs[i].CurrencyInfo
|
|
||||||
st.ItemCount = SqlStructs[i].ItemCount
|
|
||||||
st.ItemInfo = SqlStructs[i].ItemInfo
|
|
||||||
st.SendTime = SqlStructs[i].SendTime
|
|
||||||
st.Status = 1
|
|
||||||
st.Type = SqlStructs[i].Type
|
|
||||||
SqlStructs[i].Status = 1
|
|
||||||
notify.MEmailList = append(notify.MEmailList, st)
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "NotifyNewBriefEmailData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) ResBriefEmailData() {
|
|
||||||
res := &msg.ResBriefEmailData{}
|
|
||||||
res.DwUin = p.M_Player.M_DwUin
|
|
||||||
res.MEmailList = []*msg.BriefEmailStruct{}
|
|
||||||
for i := 0; i < len(p.SqlStructs); i++ {
|
|
||||||
st := &msg.BriefEmailStruct{}
|
|
||||||
st.EmailId = p.SqlStructs[i].EmailId
|
|
||||||
st.Sender = p.SqlStructs[i].Sender
|
|
||||||
st.Title = p.SqlStructs[i].Title
|
|
||||||
st.CurrencyCount = p.SqlStructs[i].CurrencyCount
|
|
||||||
st.CurrencyInfo = p.SqlStructs[i].CurrencyInfo
|
|
||||||
st.ItemCount = p.SqlStructs[i].ItemCount
|
|
||||||
st.ItemInfo = p.SqlStructs[i].ItemInfo
|
|
||||||
st.SendTime = p.SqlStructs[i].SendTime
|
|
||||||
st.Status = p.SqlStructs[i].Status
|
|
||||||
st.Type = p.SqlStructs[i].Type
|
|
||||||
res.MEmailList = append(res.MEmailList, st)
|
|
||||||
}
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResBriefEmailData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) FindSqlStructByMailId(mailId int32) *db.SqlEmailStruct {
|
|
||||||
for i := 0; i < len(p.SqlStructs); i++ {
|
|
||||||
if p.SqlStructs[i].EmailId == mailId {
|
|
||||||
return &p.SqlStructs[i]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) DeleteSqlStructByMailId(mailId int32) *db.SqlEmailStruct {
|
|
||||||
var temp *db.SqlEmailStruct = nil
|
|
||||||
var list []db.SqlEmailStruct
|
|
||||||
for i := 0; i < len(p.SqlStructs); i++ {
|
|
||||||
if p.SqlStructs[i].EmailId == mailId {
|
|
||||||
temp = &p.SqlStructs[i]
|
|
||||||
if i > 0 {
|
|
||||||
list = append(list, p.SqlStructs[:i]...)
|
|
||||||
}
|
|
||||||
if i < len(p.SqlStructs)-1 {
|
|
||||||
list = append(list, p.SqlStructs[i+1:]...)
|
|
||||||
}
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.SqlStructs = list
|
|
||||||
|
|
||||||
return temp
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) ResDetailEmailData(buf []byte) {
|
|
||||||
res := &msg.ResDetailEmailData{}
|
|
||||||
req := &msg.ReqDetailEmailData{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
|
|
||||||
st := p.FindSqlStructByMailId(req.EmailId)
|
|
||||||
if st != nil {
|
|
||||||
res.ResultCode = 0
|
|
||||||
res.Content = st.Content
|
|
||||||
res.EmailId = req.EmailId
|
|
||||||
res.RewardType = st.RewardType
|
|
||||||
res.RewardId = st.RewardId
|
|
||||||
res.RewardCount = st.RewardCount
|
|
||||||
res.LinkUrl = st.LinkUrl
|
|
||||||
if st.Type == 0 {
|
|
||||||
st.Status = 2
|
|
||||||
st.RecvTime = int32(time.Now().Unix())
|
|
||||||
db.FormatAllMemUpdateDb(st, "system_mail_info", "mail_id")
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Email_Find_Fail
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResDetailEmailData", data)
|
|
||||||
}
|
|
||||||
func (p *PlayerEmailData) ResDeleteEmail(buf []byte) {
|
|
||||||
res := &msg.ResDeleteEmail{}
|
|
||||||
req := &msg.ReqDeleteEmail{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
|
|
||||||
if p.DeleteSqlStructByMailId(req.EmailId) != nil {
|
|
||||||
res.EmailId = req.EmailId
|
|
||||||
res.ResultCode = 0
|
|
||||||
deleteList := []int32{req.EmailId}
|
|
||||||
p.DeleteOutlineMail(deleteList)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Email_Find_Fail
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResDeleteEmail", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmailData) ResGetEmailReward(buf []byte) {
|
|
||||||
res := &msg.ResGetEmailReward{}
|
|
||||||
req := &msg.ReqGetEmailReward{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
|
|
||||||
st := p.FindSqlStructByMailId(req.EmailId)
|
|
||||||
if st != nil {
|
|
||||||
res.ResultCode = 0
|
|
||||||
res.EmailId = req.EmailId
|
|
||||||
res.RewardType = st.RewardType
|
|
||||||
res.RewardId = st.RewardId
|
|
||||||
res.RewardCount = st.RewardCount
|
|
||||||
st.Status = 2
|
|
||||||
st.RecvTime = int32(time.Now().Unix())
|
|
||||||
db.FormatAllMemUpdateDb(st, "system_mail_info", "mail_id")
|
|
||||||
///发送奖励
|
|
||||||
} else {
|
|
||||||
res.ResultCode = MergeConst.Protocol_Email_Find_Fail
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResGetEmailReward", data)
|
|
||||||
}
|
|
||||||
func (p *PlayerEmailData) ClearData() bool {
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
p.Mcron.Remove(p.ZeroCronID)
|
|
||||||
p.Mcron.Stop()
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
@ -1,129 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"server/GoUtil"
|
|
||||||
"server/MergeConst"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerEmitUnlockData struct {
|
|
||||||
*PlayerData
|
|
||||||
Data msg.ResPlayerEmitUnlockData
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
sqlStr := "SELECT * FROM t_player_emit_unlock WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlEmitUnlockStruct{RenewTime: 0}
|
|
||||||
p.Data.MEmitUnlockData = make(map[int32]int32)
|
|
||||||
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
if sqlStruck.Value != "" {
|
|
||||||
arr := strings.Split(sqlStruck.Value, "_")
|
|
||||||
for i := 0; i < len(arr); i++ {
|
|
||||||
ss := strings.Split(arr[i], ",")
|
|
||||||
id, err := strconv.ParseInt(ss[0], 10, 32)
|
|
||||||
cnt, _ := strconv.ParseInt(ss[1], 10, 32)
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
p.Data.MEmitUnlockData[int32(id)] = int32(cnt)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.Data.DwUin = dwUin.(int32)
|
|
||||||
p.Data.RenewTime = sqlStruck.RenewTime
|
|
||||||
|
|
||||||
p.Reconnect(false)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) Reconnect(b bool) {
|
|
||||||
if G_GameLogicPtr.DailyTaskTimestamp > (int64)(p.Data.RenewTime) {
|
|
||||||
p.Data.RenewTime = int32(G_GameLogicPtr.DailyTaskTimestamp)
|
|
||||||
for k := range p.Data.MEmitUnlockData {
|
|
||||||
p.Data.MEmitUnlockData[k] = 0
|
|
||||||
}
|
|
||||||
if b {
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "NotifyDailyRenewEmitUnlock", data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
GoUtil.RegisterEvent(MergeConst.Notify_Daily_Renew, p.NotifyDailyRenewEmitUnlock, p)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) GetUnlockCntByID(id int32) int32 {
|
|
||||||
cnt, ok := p.Data.MEmitUnlockData[id]
|
|
||||||
if ok {
|
|
||||||
return cnt
|
|
||||||
}
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) ClearData() bool {
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
GoUtil.RemoveEvent(MergeConst.Notify_Daily_Renew, p.NotifyDailyRenewEmitUnlock, p)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) SaveDataFromDB(Key interface{}) bool {
|
|
||||||
var strarr []string
|
|
||||||
for k, v := range p.Data.MEmitUnlockData {
|
|
||||||
str := fmt.Sprintf("%d,%d", k, v)
|
|
||||||
strarr = append(strarr, str)
|
|
||||||
}
|
|
||||||
str_concat := strings.Join(strarr, "_")
|
|
||||||
// sqlStr := "UPDATE user SET age = ?, degree = ? WHERE id = ?"
|
|
||||||
// result, err := SqlDb.Exec(sqlStr, 22, 10, 4)
|
|
||||||
sqlStruck := db.SqlEmitUnlockStruct{}
|
|
||||||
sqlStruck.DwUin = p.M_Player.M_DwUin
|
|
||||||
sqlStruck.Value = str_concat
|
|
||||||
if p.IsHaveDataDb {
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStruck, "t_player_emit_unlock", "dwUin")
|
|
||||||
} else {
|
|
||||||
db.FormatAllMemInsertDb(&sqlStruck, "t_player_emit_unlock")
|
|
||||||
}
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) ResPlayerEmitUnlockData(player *Player) {
|
|
||||||
if player != p.M_Player {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResPlayerEmitUnlockData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) NotifyDailyRenewEmitUnlock(param []interface{}) {
|
|
||||||
p.Data.RenewTime = int32(param[0].(int64))
|
|
||||||
for k := range p.Data.MEmitUnlockData {
|
|
||||||
p.Data.MEmitUnlockData[k] = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "NotifyDailyRenewEmitUnlock", data)
|
|
||||||
// p.SaveDataFromDB("")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerEmitUnlockData) UpdatePlayerEmitUnlockData(buf []byte) {
|
|
||||||
|
|
||||||
update := &msg.UpdatePlayerEmitUnlockData{}
|
|
||||||
proto.Unmarshal(buf, update)
|
|
||||||
|
|
||||||
p.Data.MEmitUnlockData = update.MEmitUnlockData
|
|
||||||
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -289,6 +289,8 @@ func FriendLogBackData(p *Player) {
|
|||||||
Player: ps,
|
Player: ps,
|
||||||
Type: int32(v.Type),
|
Type: int32(v.Type),
|
||||||
Time: int32(v.Time),
|
Time: int32(v.Time),
|
||||||
|
Param: v.Param,
|
||||||
|
Id: int32(v.Id),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
p.PushClientRes(&proto.ResFriendTimeLine{
|
p.PushClientRes(&proto.ResFriendTimeLine{
|
||||||
|
|||||||
@ -1,97 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"strconv"
|
|
||||||
"strings"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerGiftData struct {
|
|
||||||
*PlayerData
|
|
||||||
Data msg.ResPlayerGiftData
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_gift_data WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlGiftStruct{}
|
|
||||||
p.Data.MGiftData = make(map[int32]int32)
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
if sqlStruck.MGiftData != "" {
|
|
||||||
arr := strings.Split(sqlStruck.MGiftData, "_")
|
|
||||||
|
|
||||||
for i := 0; i < len(arr); i++ {
|
|
||||||
ss := strings.Split(arr[i], ",")
|
|
||||||
id, err := strconv.ParseInt(ss[1], 10, 32)
|
|
||||||
key, _ := strconv.ParseInt(ss[0], 10, 32)
|
|
||||||
|
|
||||||
if err != nil {
|
|
||||||
panic(err)
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Data.MGiftData[int32(key)] = int32(id)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.Data.DwUin = dwUin.(int32)
|
|
||||||
p.Reconnect(false)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) Reconnect(b bool) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) SaveDataFromDB(Key interface{}) bool {
|
|
||||||
var strarr []string
|
|
||||||
for k, v := range p.Data.MGiftData {
|
|
||||||
str := fmt.Sprintf("%d,%d", k, v)
|
|
||||||
strarr = append(strarr, str)
|
|
||||||
}
|
|
||||||
str_concat := strings.Join(strarr, "_")
|
|
||||||
|
|
||||||
sqlStruck := db.SqlGiftStruct{}
|
|
||||||
sqlStruck.DwUin = p.M_Player.M_DwUin
|
|
||||||
sqlStruck.MGiftData = str_concat
|
|
||||||
if p.IsHaveDataDb {
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStruck, "t_player_gift_data", "dwUin")
|
|
||||||
} else {
|
|
||||||
db.FormatAllMemInsertDb(&sqlStruck, "t_player_gift_data")
|
|
||||||
}
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) ResPlayerGiftData(player *Player) {
|
|
||||||
if player != p.M_Player {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResPlayerGiftData", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) UpdatePlayerGiftData(buf []byte) {
|
|
||||||
|
|
||||||
update := &msg.UpdatePlayerGiftData{}
|
|
||||||
proto.Unmarshal(buf, update)
|
|
||||||
|
|
||||||
p.Data.MGiftData = update.MGiftData
|
|
||||||
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerGiftData) ClearData() bool {
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
@ -165,7 +165,7 @@ func (p *PlayerMod) ClearData(player *Player) {
|
|||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
log.Debug("uid: %d, ClearData, playmod", player.M_DwUin)
|
// log.Debug("uid: %d, ClearData, playmod", player.M_DwUin)
|
||||||
modData := &db.SqlModStruct{
|
modData := &db.SqlModStruct{
|
||||||
DwUin: player.M_DwUin,
|
DwUin: player.M_DwUin,
|
||||||
ModData: buf.Bytes(),
|
ModData: buf.Bytes(),
|
||||||
|
|||||||
@ -1,168 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"server/MergeConst"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerPigData struct {
|
|
||||||
*PlayerData
|
|
||||||
Data msg.ResPigDetailInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_piginfo WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlPigDetailInfoStruct{}
|
|
||||||
sqlStruck.PigId = 0
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
p.Data.CurDiamonds = sqlStruck.CurDiamonds
|
|
||||||
p.Data.DwUin = p.M_Player.M_DwUin
|
|
||||||
p.Data.PigId = sqlStruck.PigId
|
|
||||||
p.Data.PigType = sqlStruck.PigType
|
|
||||||
p.Data.StartSvrTime = sqlStruck.StartSvrTime
|
|
||||||
p.Data.EndSvrTime = sqlStruck.EndSvrTime
|
|
||||||
p.Data.CurGetLv = sqlStruck.CurGetLv
|
|
||||||
p.Reconnect(false)
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
func (p *PlayerPigData) Reconnect(b bool) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) DeleteLastPigData(pigid int32) {
|
|
||||||
sqlStr := "DELETE FROM " + "t_player_piginfo" + " WHERE PigId = ?"
|
|
||||||
|
|
||||||
db.SqlDb.Exec(sqlStr, pigid)
|
|
||||||
p.Data.PigId = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) ClearData() bool {
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
func (p *PlayerPigData) SaveDataFromDB(Key interface{}) bool {
|
|
||||||
|
|
||||||
sqlStruck := db.SqlPigDetailInfoStruct{}
|
|
||||||
sqlStruck.DwUin = p.M_Player.M_DwUin
|
|
||||||
sqlStruck.CurDiamonds = p.Data.CurDiamonds
|
|
||||||
sqlStruck.CurGetLv = p.Data.CurGetLv
|
|
||||||
sqlStruck.CurSvrTime = 0
|
|
||||||
sqlStruck.EndSvrTime = p.Data.EndSvrTime
|
|
||||||
sqlStruck.StartSvrTime = p.Data.StartSvrTime
|
|
||||||
sqlStruck.PigId = p.Data.PigId
|
|
||||||
sqlStruck.PigType = p.Data.PigType
|
|
||||||
|
|
||||||
if p.IsHaveDataDb {
|
|
||||||
if p.Data.PigId != 0 {
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStruck, "t_player_piginfo", "PigId")
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if p.Data.PigId != 0 {
|
|
||||||
db.FormatAllMemInsertDb(&sqlStruck, "t_player_piginfo")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) ResOpenNewPig(player *Player) {
|
|
||||||
res := &msg.ResOpenNewPig{}
|
|
||||||
st := &db.SqlPigDetailInfoStruct{}
|
|
||||||
st.DwUin = player.M_DwUin
|
|
||||||
st.StartSvrTime = (int32)(time.Now().Unix())
|
|
||||||
st.EndSvrTime = st.StartSvrTime + MergeConst.G_Pig_Limite
|
|
||||||
st.PigType = 1
|
|
||||||
st.CurDiamonds = 0
|
|
||||||
st.CurSvrTime = 0
|
|
||||||
st.CurGetLv = 1
|
|
||||||
|
|
||||||
PigId, _ := db.FormatAllMemInsertDb(st, "t_player_piginfo")
|
|
||||||
res.PigId = (int32)(PigId)
|
|
||||||
|
|
||||||
p.Data.CurDiamonds = st.CurDiamonds
|
|
||||||
p.Data.DwUin = p.M_Player.M_DwUin
|
|
||||||
p.Data.PigId = int32(PigId)
|
|
||||||
p.Data.PigType = st.PigType
|
|
||||||
p.Data.StartSvrTime = st.StartSvrTime
|
|
||||||
p.Data.EndSvrTime = st.EndSvrTime
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResOpenNewPig", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) ResPigDetailInfo(player *Player) {
|
|
||||||
// res := &msg.ReqPigDetailInfo{}
|
|
||||||
p.Data.CurSvrTime = int32(time.Now().Unix())
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResPigDetailInfo", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) UpdateFinishOrderDiamond(buf []byte) {
|
|
||||||
|
|
||||||
update := &msg.UpdateFinishOrderDiamond{}
|
|
||||||
proto.Unmarshal(buf, update)
|
|
||||||
|
|
||||||
p.Data.CurDiamonds = update.CurDiamonds
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) ResGetPigReward(buf []byte) {
|
|
||||||
|
|
||||||
req := &msg.ReqGetPigReward{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
|
|
||||||
res := &msg.ResGetPigReward{}
|
|
||||||
res.PigId = req.PigId
|
|
||||||
|
|
||||||
if req.PigId != p.Data.PigId {
|
|
||||||
res.ResultCode = MergeConst.Protocol_PigID_No_Exsit
|
|
||||||
} else {
|
|
||||||
res.ResultCode = 0
|
|
||||||
p.Data.CurGetLv = p.Data.CurGetLv + 1
|
|
||||||
res.CurGetLv = p.Data.CurGetLv
|
|
||||||
}
|
|
||||||
res.CurDiamonds = p.Data.CurDiamonds
|
|
||||||
|
|
||||||
if MergeConst.G_PigIsOne {
|
|
||||||
p.DeleteLastPigData(req.PigId)
|
|
||||||
}
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResGetPigReward", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerPigData) ResDropPigReward(buf []byte) {
|
|
||||||
|
|
||||||
req := &msg.ReqDropPigReward{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
|
|
||||||
res := &msg.ResDropPigReward{}
|
|
||||||
res.PigId = req.PigId
|
|
||||||
|
|
||||||
if req.PigId != p.Data.PigId {
|
|
||||||
res.ResultCode = MergeConst.Protocol_PigID_No_Exsit
|
|
||||||
} else {
|
|
||||||
res.ResultCode = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
p.DeleteLastPigData(req.PigId)
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResDropPigReward", data)
|
|
||||||
}
|
|
||||||
@ -1,418 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"math"
|
|
||||||
"math/rand"
|
|
||||||
"server/db"
|
|
||||||
"server/game/internal"
|
|
||||||
"server/msg"
|
|
||||||
"strconv"
|
|
||||||
|
|
||||||
"server/pkg/github.com/name5566/leaf/gate"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerProfileManager struct {
|
|
||||||
MsqlStrucks []db.SqlPlayerProfileStruct
|
|
||||||
MapSql map[int32]*db.SqlPlayerProfileStruct
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_Profile_Data"
|
|
||||||
p.MsqlStrucks = []db.SqlPlayerProfileStruct{}
|
|
||||||
p.MapSql = make(map[int32]*db.SqlPlayerProfileStruct)
|
|
||||||
db.SqlDb.Select(&p.MsqlStrucks, sqlStr)
|
|
||||||
|
|
||||||
for i := 0; i < len(p.MsqlStrucks); i++ {
|
|
||||||
item := p.MsqlStrucks[i]
|
|
||||||
p.MapSql[item.DwUin] = &item
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) GetPlayerDecorate(dwUin int32) (int, int, string) {
|
|
||||||
sqlStr := "SELECT * FROM t_player_baseinfo WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.ResPlayerBaseInfo{}
|
|
||||||
decorate := 0
|
|
||||||
ActiveTime := 0
|
|
||||||
FaceBookId := ""
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin); err != nil {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
Score := 0
|
|
||||||
for i := 1; i < int(sqlStruck.Level); i++ {
|
|
||||||
Score = Score + (i-1)*10 + 20
|
|
||||||
}
|
|
||||||
Score = Score + int(sqlStruck.Exp)
|
|
||||||
decorate = Score / 10
|
|
||||||
ActiveTime = int(math.Max(float64(sqlStruck.LoginTime), float64(sqlStruck.LogoutTime)))
|
|
||||||
FaceBookId = sqlStruck.FaceBookId
|
|
||||||
}
|
|
||||||
return decorate, ActiveTime, FaceBookId
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) InitManager() {
|
|
||||||
p.LoadDataFromDB("")
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) AddNewProfile(st *db.SqlPlayerProfileStruct) bool {
|
|
||||||
if p.GetPlayerProfile(st.DwUin) == nil {
|
|
||||||
p.MapSql[st.DwUin] = st
|
|
||||||
db.FormatAllMemInsertDb(st, "t_player_Profile_Data")
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) UpdateNewProfile(st *db.SqlPlayerProfileStruct) bool {
|
|
||||||
if p.GetPlayerProfile(st.DwUin) != nil {
|
|
||||||
p.MapSql[st.DwUin] = st
|
|
||||||
db.FormatAllMemUpdateDb(st, "t_player_Profile_Data", "dwUin")
|
|
||||||
} else {
|
|
||||||
p.AddNewProfile(st)
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) GetPlayerProfileByNick(nick string) []*db.SqlPlayerProfileStruct {
|
|
||||||
ret := []*db.SqlPlayerProfileStruct{}
|
|
||||||
// G_getGameLogic().Mlogger.Debug("p.MapSql" + strconv.Itoa(len(p.MapSql)))
|
|
||||||
// G_getGameLogic().Mlogger.Debug("nick:" + nick)
|
|
||||||
for k, v := range p.MapSql {
|
|
||||||
if strconv.Itoa(int(k)) == nick {
|
|
||||||
ret = append(ret, v)
|
|
||||||
} else {
|
|
||||||
// G_getGameLogic().Mlogger.Debug("v.NickName:" + v.NickName)
|
|
||||||
if nick == v.NickName {
|
|
||||||
ret = append(ret, v)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) GetPlayerProfile(id int32) *db.SqlPlayerProfileStruct {
|
|
||||||
|
|
||||||
st, ok := p.MapSql[id]
|
|
||||||
if ok {
|
|
||||||
return st
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
func (p *PlayerProfileManager) GetIsHavePlayerById(id int32) bool {
|
|
||||||
sqlStr := "SELECT * FROM t_player_baseinfo WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.ResPlayerBaseInfo{}
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, id); err != nil {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) ReqPlayerProfileData(args []interface{}) {
|
|
||||||
a := args[0].(gate.Agent)
|
|
||||||
play, _ := internal.Agents.Load(a)
|
|
||||||
buf := args[1].([]byte)
|
|
||||||
player := play.(*Player)
|
|
||||||
|
|
||||||
req := &msg.ReqPlayerProfileData{}
|
|
||||||
res := &msg.ResPlayerProfileData{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
profile := p.GetPlayerProfile(player.M_DwUin)
|
|
||||||
if profile != nil {
|
|
||||||
res.DwUin = player.M_DwUin
|
|
||||||
res.NickName = profile.NickName
|
|
||||||
res.ImageFrame = profile.ImageFrame
|
|
||||||
res.ImageIcon = profile.ImageIcon
|
|
||||||
res.PicURL = profile.PicURL
|
|
||||||
res.UnlockFrame = profile.UnlockFrame
|
|
||||||
res.UnlockIcon = profile.UnlockIcon
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(player.M_DwUin)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
} else {
|
|
||||||
res.DwUin = player.M_DwUin
|
|
||||||
res.NickName = "Player" + strconv.Itoa(int(player.M_DwUin))
|
|
||||||
res.ImageFrame = 1
|
|
||||||
res.ImageIcon = 1
|
|
||||||
res.UnlockFrame = ""
|
|
||||||
res.UnlockIcon = ""
|
|
||||||
res.PicURL = ""
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(player.M_DwUin)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = player.M_DwUin
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = ""
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(player.M_DwUin))
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
}
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data1, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResPlayerProfileData", data1)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) ReqUpdatePlayerProfile(args []interface{}) {
|
|
||||||
a := args[0].(gate.Agent)
|
|
||||||
play, _ := internal.Agents.Load(a)
|
|
||||||
buf := args[1].([]byte)
|
|
||||||
player := play.(*Player)
|
|
||||||
|
|
||||||
req := &msg.ReqUpdatePlayerProfile{}
|
|
||||||
res := &msg.ResUpdatePlayerProfile{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
profile := p.GetPlayerProfile(player.M_DwUin)
|
|
||||||
if profile != nil {
|
|
||||||
if req.Type == 1 {
|
|
||||||
profile.NickName = req.Param
|
|
||||||
}
|
|
||||||
if req.Type == 2 {
|
|
||||||
value, _ := strconv.Atoi(req.Param)
|
|
||||||
profile.ImageFrame = int32(value)
|
|
||||||
}
|
|
||||||
if req.Type == 3 {
|
|
||||||
value, _ := strconv.Atoi(req.Param)
|
|
||||||
profile.ImageIcon = int32(value)
|
|
||||||
}
|
|
||||||
p.UpdateNewProfile(profile)
|
|
||||||
} else {
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = player.M_DwUin
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(player.M_DwUin))
|
|
||||||
if req.Type == 1 {
|
|
||||||
st.NickName = req.Param
|
|
||||||
}
|
|
||||||
if req.Type == 2 {
|
|
||||||
value, _ := strconv.Atoi(req.Param)
|
|
||||||
st.ImageFrame = int32(value)
|
|
||||||
}
|
|
||||||
if req.Type == 3 {
|
|
||||||
value, _ := strconv.Atoi(req.Param)
|
|
||||||
st.ImageIcon = int32(value)
|
|
||||||
}
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = ""
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
}
|
|
||||||
res.DwUin = req.DwUin
|
|
||||||
res.Type = req.Type
|
|
||||||
res.Param = req.Param
|
|
||||||
res.ResultCode = 0
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data1, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResUpdatePlayerProfile", data1)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) HttpReqPlayerBriefProfileData(Id int32) *msg.ResPlayerBriefProfileData {
|
|
||||||
profile := p.GetPlayerProfile(Id)
|
|
||||||
res := &msg.ResPlayerBriefProfileData{}
|
|
||||||
if profile != nil {
|
|
||||||
res.DwUin = profile.DwUin
|
|
||||||
res.NickName = profile.NickName
|
|
||||||
res.ImageFrame = profile.ImageFrame
|
|
||||||
res.ImageIcon = profile.ImageIcon
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(Id)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
res.PicURL = profile.PicURL
|
|
||||||
} else {
|
|
||||||
res.DwUin = Id
|
|
||||||
res.NickName = "Player" + strconv.Itoa(int(Id))
|
|
||||||
res.ImageFrame = 1
|
|
||||||
res.ImageIcon = 1
|
|
||||||
res.PicURL = ""
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(Id)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = Id
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = ""
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(Id))
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
}
|
|
||||||
return res
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) ReqPlayerBriefProfileData(args []interface{}) {
|
|
||||||
a := args[0].(gate.Agent)
|
|
||||||
play, _ := internal.Agents.Load(a)
|
|
||||||
buf := args[1].([]byte)
|
|
||||||
player := play.(*Player)
|
|
||||||
|
|
||||||
req := &msg.ReqPlayerBriefProfileData{}
|
|
||||||
res := &msg.ResPlayerBriefProfileData{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
profile := p.GetPlayerProfile(req.DwUin)
|
|
||||||
if profile != nil {
|
|
||||||
res.DwUin = profile.DwUin
|
|
||||||
res.NickName = profile.NickName
|
|
||||||
res.ImageFrame = profile.ImageFrame
|
|
||||||
res.ImageIcon = profile.ImageIcon
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(req.DwUin)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
res.PicURL = profile.PicURL
|
|
||||||
} else {
|
|
||||||
res.DwUin = req.DwUin
|
|
||||||
res.NickName = "Player" + strconv.Itoa(int(req.DwUin))
|
|
||||||
res.ImageFrame = 1
|
|
||||||
res.ImageIcon = 1
|
|
||||||
res.PicURL = ""
|
|
||||||
|
|
||||||
DecorateCnt, ActiveTime, _ := p.GetPlayerDecorate(req.DwUin)
|
|
||||||
res.DecorateCnt = int32(DecorateCnt)
|
|
||||||
res.ActiveTime = int32(ActiveTime)
|
|
||||||
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = req.DwUin
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = ""
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(req.DwUin))
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
}
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data1, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResPlayerBriefProfileData", data1)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) RandomGetAnPlayer(origin int32) *db.SqlPlayerProfileStruct {
|
|
||||||
idx := rand.Intn(len(p.MsqlStrucks))
|
|
||||||
|
|
||||||
for p.MsqlStrucks[idx].DwUin == origin {
|
|
||||||
idx = rand.Intn(len(p.MsqlStrucks))
|
|
||||||
}
|
|
||||||
Profile := p.GetPlayerProfile(p.MsqlStrucks[idx].DwUin)
|
|
||||||
|
|
||||||
if Profile != nil {
|
|
||||||
return Profile
|
|
||||||
} else {
|
|
||||||
sql := &db.SqlPlayerProfileStruct{}
|
|
||||||
sql.DwUin = p.MsqlStrucks[idx].DwUin
|
|
||||||
sql.ImageFrame = 1
|
|
||||||
sql.ImageIcon = 1
|
|
||||||
sql.NickName = "Player" + strconv.Itoa(int(p.MsqlStrucks[idx].DwUin))
|
|
||||||
sql.PicURL = ""
|
|
||||||
p.UpdateNewProfile(sql)
|
|
||||||
return sql
|
|
||||||
}
|
|
||||||
}
|
|
||||||
func (p *PlayerProfileManager) GetIsHaveAddFriendInfo(sender int32, receive int32) (bool, *db.SqlAddFriendStruct) {
|
|
||||||
sqlStr := "SELECT * FROM t_player_Req_add_Friend WHERE SenderId = ? AND ReceiverId = ?"
|
|
||||||
sqlStruck := db.SqlAddFriendStruct{}
|
|
||||||
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, sender, receive); err != nil {
|
|
||||||
return false, nil
|
|
||||||
} else {
|
|
||||||
return true, &sqlStruck
|
|
||||||
}
|
|
||||||
// return false
|
|
||||||
}
|
|
||||||
func (p *PlayerProfileManager) RandomGetPlayers(Cnt int, originId int32, ExcludeList []int32) []*db.SqlPlayerProfileStruct {
|
|
||||||
|
|
||||||
var CurCnt int = 0
|
|
||||||
ret := []*db.SqlPlayerProfileStruct{}
|
|
||||||
var Loops int = 0
|
|
||||||
for {
|
|
||||||
Ids := G_GameLogicPtr.DisorderLuaTable(len(p.MsqlStrucks), int(math.Min(float64(len(p.MsqlStrucks)), float64(Cnt))))
|
|
||||||
for i := 0; i < len(Ids); i++ {
|
|
||||||
IsIll := true
|
|
||||||
for j := 0; j < len(ExcludeList); j++ {
|
|
||||||
if ExcludeList[j] == p.MsqlStrucks[Ids[i]].DwUin {
|
|
||||||
IsIll = false
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if IsIll {
|
|
||||||
isHave1, _ := p.GetIsHaveAddFriendInfo(originId, p.MsqlStrucks[Ids[i]].DwUin)
|
|
||||||
isHave2, _ := p.GetIsHaveAddFriendInfo(p.MsqlStrucks[Ids[i]].DwUin, originId)
|
|
||||||
|
|
||||||
if !isHave1 && !isHave2 {
|
|
||||||
CurCnt += 1
|
|
||||||
ret = append(ret, &p.MsqlStrucks[Ids[i]])
|
|
||||||
ExcludeList = append(ExcludeList, p.MsqlStrucks[Ids[i]].DwUin)
|
|
||||||
if CurCnt == Cnt {
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loops += 1
|
|
||||||
if Loops == 3 {
|
|
||||||
break
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) ReqUpdateFBPicURL(args []interface{}) {
|
|
||||||
a := args[0].(gate.Agent)
|
|
||||||
play, _ := internal.Agents.Load(a)
|
|
||||||
buf := args[1].([]byte)
|
|
||||||
player := play.(*Player)
|
|
||||||
|
|
||||||
req := &msg.ReqUpdateFBPicURL{}
|
|
||||||
res := &msg.ResUpdateFBPicURL{}
|
|
||||||
proto.Unmarshal(buf, req)
|
|
||||||
profile := p.GetPlayerProfile(player.M_DwUin)
|
|
||||||
res.ResultCode = 0
|
|
||||||
if profile != nil {
|
|
||||||
profile.PicURL = req.URL
|
|
||||||
p.UpdateNewProfile(profile)
|
|
||||||
} else {
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = player.M_DwUin
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = req.URL
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(player.M_DwUin))
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
}
|
|
||||||
agent := player.GetAgentByPlayer()
|
|
||||||
data1, _ := proto.Marshal(res)
|
|
||||||
G_getGameLogic().PackResInfo(agent, "ResUpdateFBPicURL", data1)
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerProfileManager) NewGetPlayerProfile(DwUin int32) *db.SqlPlayerProfileStruct {
|
|
||||||
profile := p.GetPlayerProfile(DwUin)
|
|
||||||
if profile != nil {
|
|
||||||
return profile
|
|
||||||
} else {
|
|
||||||
st := db.SqlPlayerProfileStruct{}
|
|
||||||
st.DwUin = DwUin
|
|
||||||
st.ImageFrame = 1
|
|
||||||
st.ImageIcon = 1
|
|
||||||
st.UnlockFrame = ""
|
|
||||||
st.UnlockIcon = ""
|
|
||||||
st.PicURL = ""
|
|
||||||
st.NickName = "Player" + strconv.Itoa(int(DwUin))
|
|
||||||
p.UpdateNewProfile(&st)
|
|
||||||
return &st
|
|
||||||
}
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,227 +0,0 @@
|
|||||||
package game
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
mergeDataCfg "server/conf/mergeData"
|
|
||||||
"server/db"
|
|
||||||
"server/msg"
|
|
||||||
"server/pkg/github.com/name5566/leaf/timer"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"google.golang.org/protobuf/proto"
|
|
||||||
)
|
|
||||||
|
|
||||||
type PlayerUnlockingChestData struct {
|
|
||||||
*PlayerData
|
|
||||||
Data msg.ResUnlockingChestID
|
|
||||||
MLeafTimer *timer.Timer
|
|
||||||
Mdispatr *timer.Dispatcher
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) LoadDataFromDB(dwUin interface{}) bool {
|
|
||||||
|
|
||||||
sqlStr := "SELECT * FROM t_player_chest_data WHERE dwUin = ?"
|
|
||||||
sqlStruck := db.SqlChestStruct{}
|
|
||||||
p.Mdispatr = timer.NewDispatcher(1)
|
|
||||||
if err := db.SqlDb.Get(&sqlStruck, sqlStr, dwUin.(int32)); err != nil {
|
|
||||||
|
|
||||||
p.IsHaveDataDb = false
|
|
||||||
} else {
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
}
|
|
||||||
p.Data.DwUin = dwUin.(int32)
|
|
||||||
p.Data.ChestID = sqlStruck.ChestID
|
|
||||||
p.Data.UnlockStartTime = sqlStruck.UnlockStartTime
|
|
||||||
p.Data.CurSvrTime = int32(time.Now().Unix())
|
|
||||||
|
|
||||||
p.Reconnect(false)
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
func (p *PlayerUnlockingChestData) Reconnect(b bool) {
|
|
||||||
if p.Data.ChestID > 0 {
|
|
||||||
chessKey := p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).GetKeyByEmitID(p.Data.ChestID)
|
|
||||||
if chessKey == "" {
|
|
||||||
p.Data.ChestID = 0
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
return
|
|
||||||
}
|
|
||||||
MergeId := p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).GetValueByKey(chessKey)
|
|
||||||
item, _ := mergeDataCfg.GetOne(int(MergeId))
|
|
||||||
cool := item.CoolTime
|
|
||||||
deltaTime := time.Now().Unix() - (int64)(p.Data.UnlockStartTime)
|
|
||||||
if deltaTime >= (int64)(cool) { //注意后面读表
|
|
||||||
if p.M_Player.GetGameData("PlayerChessData") == nil {
|
|
||||||
data := &PlayerChessData{PlayerData: NewPlayerData("PlayerChessData", p.M_Player)}
|
|
||||||
ok := data.LoadDataFromDB(p.M_Player.M_DwUin)
|
|
||||||
if ok {
|
|
||||||
p.M_Player.playerdata["PlayerChessData"] = data
|
|
||||||
p.M_Player.playerdataIF["PlayerChessData"] = data
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).SetValueByKey(chessKey)
|
|
||||||
fmt.Println("chessKey:", chessKey)
|
|
||||||
p.Data.ChestID = 0
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
if b {
|
|
||||||
p.NotifyUnlockingChestData()
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
go func() {
|
|
||||||
// 注释内容也可以使用
|
|
||||||
t1 := (int64)(cool) - deltaTime
|
|
||||||
|
|
||||||
p.MLeafTimer = p.Mdispatr.AfterFunc(time.Duration(t1)*time.Second, func() {
|
|
||||||
p.NotifyUnlockingChestData()
|
|
||||||
p.MLeafTimer = nil
|
|
||||||
})
|
|
||||||
(<-p.Mdispatr.ChanTimer).Cb()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
p.NotifyInitUnlockingChestID()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) RenewData() {
|
|
||||||
if p.Data.ChestID > 0 {
|
|
||||||
chessKey := p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).GetKeyByEmitID(p.Data.ChestID)
|
|
||||||
MergeId := p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).GetValueByKey(chessKey)
|
|
||||||
// MergeId := p.M_Player.GetIFGameData("PlayerEmitDetailData").(*PlayerEmitDetailData).GetMergeIDByChestid(p.Data.ChestID)
|
|
||||||
item, _ := mergeDataCfg.GetOne(int(MergeId))
|
|
||||||
cool := item.CoolTime
|
|
||||||
deltaTime := time.Now().Unix() - (int64)(p.Data.UnlockStartTime)
|
|
||||||
if p.MLeafTimer != nil {
|
|
||||||
p.MLeafTimer.Disabled()
|
|
||||||
p.Mdispatr.ChanTimer <- p.MLeafTimer
|
|
||||||
p.MLeafTimer.Stop()
|
|
||||||
p.MLeafTimer = nil
|
|
||||||
}
|
|
||||||
if deltaTime >= (int64)(cool) { //注意后面读表
|
|
||||||
|
|
||||||
p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).SetValueByKey(chessKey)
|
|
||||||
|
|
||||||
p.Data.ChestID = 0
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
} else {
|
|
||||||
go func() {
|
|
||||||
// 注释内容也可以使用
|
|
||||||
t1 := (int64)(cool) - deltaTime
|
|
||||||
|
|
||||||
p.MLeafTimer = p.Mdispatr.AfterFunc(time.Duration(t1)*time.Second, func() {
|
|
||||||
p.NotifyUnlockingChestData()
|
|
||||||
p.MLeafTimer = nil
|
|
||||||
})
|
|
||||||
(<-p.Mdispatr.ChanTimer).Cb()
|
|
||||||
}()
|
|
||||||
}
|
|
||||||
p.NotifyInitUnlockingChestID()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) NotifyInitUnlockingChestID() {
|
|
||||||
notify := &msg.NotifyInitUnlockingChestID{}
|
|
||||||
notify.ChestID = p.Data.ChestID
|
|
||||||
notify.UnlockStartTime = p.Data.UnlockStartTime
|
|
||||||
notify.DwUin = p.M_Player.M_DwUin
|
|
||||||
notify.CurSvrTime = int32(time.Now().Unix())
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.PackResInfo(agent, "NotifyInitUnlockingChestID", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) ClearData() bool {
|
|
||||||
p.SaveDataFromDB("")
|
|
||||||
if p.MLeafTimer != nil {
|
|
||||||
p.MLeafTimer.Disabled()
|
|
||||||
p.Mdispatr.ChanTimer <- p.MLeafTimer
|
|
||||||
p.MLeafTimer.Stop()
|
|
||||||
p.MLeafTimer = nil
|
|
||||||
}
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
func (p *PlayerUnlockingChestData) SaveDataFromDB(Key interface{}) bool {
|
|
||||||
|
|
||||||
sqlStruck := db.SqlChestStruct{}
|
|
||||||
sqlStruck.DwUin = p.M_Player.M_DwUin
|
|
||||||
sqlStruck.ChestID = p.Data.ChestID
|
|
||||||
sqlStruck.UnlockStartTime = p.Data.UnlockStartTime
|
|
||||||
|
|
||||||
if p.IsHaveDataDb {
|
|
||||||
db.FormatAllMemUpdateDb(&sqlStruck, "t_player_chest_data", "dwUin")
|
|
||||||
} else {
|
|
||||||
db.FormatAllMemInsertDb(&sqlStruck, "t_player_chest_data")
|
|
||||||
}
|
|
||||||
p.IsHaveDataDb = true
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) ResUnlockingChestID(buf []byte) {
|
|
||||||
update := &msg.ReqUnlockingChestID{}
|
|
||||||
proto.Unmarshal(buf, update)
|
|
||||||
p.Data.ChestID = update.ChestID
|
|
||||||
p.Data.UnlockStartTime = int32(time.Now().Unix())
|
|
||||||
// G_GameLogicPtr.Mlogger.Debug("ResUnlockingChestID1:", p.Data.ChestID, update.MergeID)
|
|
||||||
p.M_Player.GetIFGameData("PlayerEmitDetailData").(*PlayerEmitDetailData).SetMergeIDByChestid(update.ChestID, update.MergeID)
|
|
||||||
// G_GameLogicPtr.Mlogger.Debug("ResUnlockingChestID2:", p.Data.ChestID, update.MergeID)
|
|
||||||
p.RenewData()
|
|
||||||
// G_GameLogicPtr.Mlogger.Debug("ResUnlockingChestID3:", p.Data.ChestID, update.MergeID)
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(&p.Data)
|
|
||||||
G_GameLogicPtr.PackResInfo(agent, "ResUnlockingChestID", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) ResChestUnlockCD(buf []byte) {
|
|
||||||
update := &msg.ReqChestUnlockCD{}
|
|
||||||
proto.Unmarshal(buf, update)
|
|
||||||
|
|
||||||
res := &msg.ResChestUnlockCD{}
|
|
||||||
res.DwUin = p.GetPlayer().M_DwUin
|
|
||||||
res.ChestID = update.ChestID
|
|
||||||
res.Type = update.Type
|
|
||||||
res.CurSvrTime = int32(time.Now().Unix())
|
|
||||||
////ad
|
|
||||||
if res.Type == 3 {
|
|
||||||
p.Data.UnlockStartTime = p.Data.UnlockStartTime - 60*30
|
|
||||||
res.UnlockStartTime = p.Data.UnlockStartTime
|
|
||||||
p.RenewData()
|
|
||||||
}
|
|
||||||
///diamond
|
|
||||||
if res.Type == 2 {
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
p.RenewData()
|
|
||||||
}
|
|
||||||
|
|
||||||
if res.Type == 1 {
|
|
||||||
p.Data.ChestID = 0
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
if p.MLeafTimer != nil {
|
|
||||||
p.MLeafTimer.Disabled()
|
|
||||||
p.Mdispatr.ChanTimer <- p.MLeafTimer
|
|
||||||
p.MLeafTimer.Stop()
|
|
||||||
p.MLeafTimer = nil
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(res)
|
|
||||||
G_GameLogicPtr.PackResInfo(agent, "ResChestUnlockCD", data)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (p *PlayerUnlockingChestData) NotifyUnlockingChestData() {
|
|
||||||
|
|
||||||
chessKey := p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).GetKeyByEmitID(p.Data.ChestID)
|
|
||||||
p.GetPlayer().GetIFGameData("PlayerChessData").(*PlayerChessData).SetValueByKey(chessKey)
|
|
||||||
|
|
||||||
notify := &msg.NotifyUnlockingChestData{}
|
|
||||||
notify.DwUin = p.GetPlayer().M_DwUin
|
|
||||||
notify.ChestID = 0
|
|
||||||
notify.UnlockStartTime = 0
|
|
||||||
p.Data.ChestID = 0
|
|
||||||
p.Data.UnlockStartTime = 0
|
|
||||||
notify.CurSvrTime = int32(time.Now().Unix())
|
|
||||||
|
|
||||||
agent := p.GetPlayer().GetAgentByPlayer()
|
|
||||||
data, _ := proto.Marshal(notify)
|
|
||||||
G_GameLogicPtr.PackResInfo(agent, "NotifyUnlockingChestData", data)
|
|
||||||
|
|
||||||
}
|
|
||||||
File diff suppressed because it is too large
Load Diff
@ -120,15 +120,8 @@ func HandleClientReq(args []interface{}) {
|
|||||||
if ResLogin.DwUin > 0 {
|
if ResLogin.DwUin > 0 {
|
||||||
if OldPlayer, ok := G_GameLogicPtr.M_Players[ResLogin.DwUin]; ok {
|
if OldPlayer, ok := G_GameLogicPtr.M_Players[ResLogin.DwUin]; ok {
|
||||||
G_GameLogicPtr.ReplaceExistPlayerAndAgent(a, OldPlayer)
|
G_GameLogicPtr.ReplaceExistPlayerAndAgent(a, OldPlayer)
|
||||||
OldPlayer.PAMgr.InitActiveMgr(OldPlayer)
|
|
||||||
} else {
|
} else {
|
||||||
player := G_GameLogicPtr.FindOfflinePlayer(ResLogin.DwUin)
|
G_GameLogicPtr.CreateNewPlayer(a, detail.UserName)
|
||||||
if player != nil {
|
|
||||||
G_GameLogicPtr.RebindPlayerAndAgent(a, player)
|
|
||||||
player.PAMgr.InitActiveMgr(player)
|
|
||||||
} else {
|
|
||||||
G_GameLogicPtr.CreateNewPlayer(a, detail.UserName)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -337,7 +337,7 @@ func (o *OrderMod) CreateExtraOrder(AddChess, AddNewEmit, ChessList []int) bool
|
|||||||
}
|
}
|
||||||
//额外订单补充1;CDEG发射器首次合成时,生成其对应2及棋子订单,完成后生成3及,再完成生成4及的;
|
//额外订单补充1;CDEG发射器首次合成时,生成其对应2及棋子订单,完成后生成3及,再完成生成4及的;
|
||||||
if b1 {
|
if b1 {
|
||||||
ChessColor := mergeDataCfg.GetEmitProduceType(OrderEmit)
|
ChessColor := mergeDataCfg.GetEmitProduceChessType(OrderEmit)
|
||||||
ChessId := mergeDataCfg.GetChessIdByLvAndColor(2, ChessColor[0])
|
ChessId := mergeDataCfg.GetChessIdByLvAndColor(2, ChessColor[0])
|
||||||
if ChessId != 0 {
|
if ChessId != 0 {
|
||||||
o.addOrder([]int{ChessId}, diff_low, Preheat_type)
|
o.addOrder([]int{ChessId}, diff_low, Preheat_type)
|
||||||
|
|||||||
@ -94,7 +94,6 @@ func (a *agent) Run() {
|
|||||||
for {
|
for {
|
||||||
data, err := a.conn.ReadMsg()
|
data, err := a.conn.ReadMsg()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("read messagefdsdf: %v", err)
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user