From 862a7b8f8b42b3f7581f5dfd4bfc5f1c6fdf1eba Mon Sep 17 00:00:00 2001 From: liwei1dao Date: Thu, 22 Sep 2022 21:20:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E9=A2=9C=E8=89=B2=E8=A1=A8?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../{game_color.json => game_gamecolor.json} | 0 modules/comp_configure.go | 27 +++++++++--- modules/equipment/api_upgrade.go | 6 ++- sys/configure/structs/Game.Color.go | 42 ------------------- sys/configure/structs/Game.GameColor.go | 42 +++++++++++++++++++ ...ame.ColorData.go => Game.GameColorData.go} | 14 +++---- sys/configure/structs/Tables.go | 6 +-- 7 files changed, 78 insertions(+), 59 deletions(-) rename bin/json/{game_color.json => game_gamecolor.json} (100%) delete mode 100644 sys/configure/structs/Game.Color.go create mode 100644 sys/configure/structs/Game.GameColor.go rename sys/configure/structs/{Game.ColorData.go => Game.GameColorData.go} (70%) diff --git a/bin/json/game_color.json b/bin/json/game_gamecolor.json similarity index 100% rename from bin/json/game_color.json rename to bin/json/game_gamecolor.json diff --git a/modules/comp_configure.go b/modules/comp_configure.go index 888547613..241077592 100644 --- a/modules/comp_configure.go +++ b/modules/comp_configure.go @@ -13,12 +13,13 @@ import ( ) const ( - game_global = "game_global.json" //全局配置表 - game_initial = "game_initial.json" //初始化表 - game_playerlv = "game_playerlv.json" //玩家等级 - game_facemod = "game_facemod.json" // 形象配置表 - game_drop = "game_drop.json" //掉落 - game_comatn = "game_comatn.json" //atn配置表 + game_global = "game_global.json" //全局配置表 + game_initial = "game_initial.json" //初始化表 + game_gamecolor = "game_gamecolor.json" //颜色表 + game_playerlv = "game_playerlv.json" //玩家等级 + game_facemod = "game_facemod.json" //形象配置表 + game_drop = "game_drop.json" //掉落 + game_comatn = "game_comatn.json" //atn配置表 ) ///配置管理基础组件 @@ -231,3 +232,17 @@ func (this *MCompConfigure) GetDropReward(dropId int32, Items []*cfg.Gameatn) { return } +func (this *MCompConfigure) GetColor(id int32) (item *cfg.GameGameColorData, err error) { + var ( + v interface{} + ok bool + ) + if v, err = this.GetConfigure(game_gamecolor); err != nil { + return + } else { + if item, ok = v.(*cfg.GameGameColor).GetDataMap()[id]; !ok { + err = fmt.Errorf("on found color:%d", id) + } + } + return +} diff --git a/modules/equipment/api_upgrade.go b/modules/equipment/api_upgrade.go index 9e594f758..7b35d95ae 100644 --- a/modules/equipment/api_upgrade.go +++ b/modules/equipment/api_upgrade.go @@ -2,6 +2,7 @@ package equipment import ( "crypto/rand" + "fmt" "go_dreamfactory/comm" "go_dreamfactory/lego/sys/log" "go_dreamfactory/pb" @@ -182,7 +183,10 @@ func (this *apiComp) Upgrade(session comm.IUserSession, req *pb.EquipmentUpgrade this.module.ModuleRtask.SendToRtask(session, comm.Rtype47, 1) //聊天系统通知 if user = this.module.ModuleUser.GetUser(session.GetUserId()); user != nil { - this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, user.Name, conf.Name) + var color *cfg.GameGameColorData + if color, err = this.module.configure.GetColor(conf.Color); err == nil { + this.module.chat.SendSysChatToWorld(comm.EquipmentUpgradeNotice, equipment, equipment.Lv, fmt.Sprintf("[color=%s]%s[/color]", color.Color, user.Name), conf.Name) + } } else { this.module.Errorf("no found userdata uid:%s", session.GetUserId()) } diff --git a/sys/configure/structs/Game.Color.go b/sys/configure/structs/Game.Color.go deleted file mode 100644 index c56c99427..000000000 --- a/sys/configure/structs/Game.Color.go +++ /dev/null @@ -1,42 +0,0 @@ -//------------------------------------------------------------------------------ -// -// This code was generated by a tool. -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -package cfg - -type GameColor struct { - _dataMap map[int32]*GameColorData - _dataList []*GameColorData -} - -func NewGameColor(_buf []map[string]interface{}) (*GameColor, error) { - _dataList := make([]*GameColorData, 0, len(_buf)) - dataMap := make(map[int32]*GameColorData) - for _, _ele_ := range _buf { - if _v, err2 := DeserializeGameColorData(_ele_); err2 != nil { - return nil, err2 - } else { - _dataList = append(_dataList, _v) - dataMap[_v.Star] = _v - } - } - return &GameColor{_dataList:_dataList, _dataMap:dataMap}, nil -} - -func (table *GameColor) GetDataMap() map[int32]*GameColorData { - return table._dataMap -} - -func (table *GameColor) GetDataList() []*GameColorData { - return table._dataList -} - -func (table *GameColor) Get(key int32) *GameColorData { - return table._dataMap[key] -} - - diff --git a/sys/configure/structs/Game.GameColor.go b/sys/configure/structs/Game.GameColor.go new file mode 100644 index 000000000..0941665da --- /dev/null +++ b/sys/configure/structs/Game.GameColor.go @@ -0,0 +1,42 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +package cfg + +type GameGameColor struct { + _dataMap map[int32]*GameGameColorData + _dataList []*GameGameColorData +} + +func NewGameGameColor(_buf []map[string]interface{}) (*GameGameColor, error) { + _dataList := make([]*GameGameColorData, 0, len(_buf)) + dataMap := make(map[int32]*GameGameColorData) + for _, _ele_ := range _buf { + if _v, err2 := DeserializeGameGameColorData(_ele_); err2 != nil { + return nil, err2 + } else { + _dataList = append(_dataList, _v) + dataMap[_v.Star] = _v + } + } + return &GameGameColor{_dataList:_dataList, _dataMap:dataMap}, nil +} + +func (table *GameGameColor) GetDataMap() map[int32]*GameGameColorData { + return table._dataMap +} + +func (table *GameGameColor) GetDataList() []*GameGameColorData { + return table._dataList +} + +func (table *GameGameColor) Get(key int32) *GameGameColorData { + return table._dataMap[key] +} + + diff --git a/sys/configure/structs/Game.ColorData.go b/sys/configure/structs/Game.GameColorData.go similarity index 70% rename from sys/configure/structs/Game.ColorData.go rename to sys/configure/structs/Game.GameColorData.go index 520da4e3a..ba5249457 100644 --- a/sys/configure/structs/Game.ColorData.go +++ b/sys/configure/structs/Game.GameColorData.go @@ -10,25 +10,25 @@ package cfg import "errors" -type GameColorData struct { +type GameGameColorData struct { Star int32 Color string } -const TypeId_GameColorData = -608833871 +const TypeId_GameGameColorData = -304680737 -func (*GameColorData) GetTypeId() int32 { - return -608833871 +func (*GameGameColorData) GetTypeId() int32 { + return -304680737 } -func (_v *GameColorData)Deserialize(_buf map[string]interface{}) (err error) { +func (_v *GameGameColorData)Deserialize(_buf map[string]interface{}) (err error) { { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["star"].(float64); !_ok_ { err = errors.New("star error"); return }; _v.Star = int32(_tempNum_) } { var _ok_ bool; if _v.Color, _ok_ = _buf["color"].(string); !_ok_ { err = errors.New("color error"); return } } return } -func DeserializeGameColorData(_buf map[string]interface{}) (*GameColorData, error) { - v := &GameColorData{} +func DeserializeGameGameColorData(_buf map[string]interface{}) (*GameGameColorData, error) { + v := &GameGameColorData{} if err := v.Deserialize(_buf); err == nil { return v, nil } else { diff --git a/sys/configure/structs/Tables.go b/sys/configure/structs/Tables.go index 729b17c0b..23d7c30e7 100644 --- a/sys/configure/structs/Tables.go +++ b/sys/configure/structs/Tables.go @@ -98,7 +98,7 @@ type Tables struct { LibraryFavor *GameLibraryFavor Robot *GameRobot Ip *GameIp - Color *GameColor + GameColor *GameGameColor } func NewTables(loader JsonLoader) (*Tables, error) { @@ -628,10 +628,10 @@ func NewTables(loader JsonLoader) (*Tables, error) { if tables.Ip, err = NewGameIp(buf) ; err != nil { return nil, err } - if buf, err = loader("game_color") ; err != nil { + if buf, err = loader("game_gamecolor") ; err != nil { return nil, err } - if tables.Color, err = NewGameColor(buf) ; err != nil { + if tables.GameColor, err = NewGameGameColor(buf) ; err != nil { return nil, err } return tables, nil