This commit is contained in:
meixiongfeng 2023-10-26 14:51:29 +08:00
commit 8dcbf2edb0
6 changed files with 2067 additions and 1892 deletions

View File

@ -0,0 +1,62 @@
[
{
"id": 1,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 1000
}
]
},
{
"id": 2,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 1200
}
]
},
{
"id": 3,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 1400
}
]
},
{
"id": 4,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 1600
}
]
},
{
"id": 5,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 1800
}
]
},
{
"id": 6,
"reward": [
{
"a": "attr",
"t": "gold",
"n": 2000
}
]
}
]

View File

@ -3,21 +3,37 @@ package whackamole
import ( import (
"go_dreamfactory/comm" "go_dreamfactory/comm"
"go_dreamfactory/pb" "go_dreamfactory/pb"
cfg "go_dreamfactory/sys/configure/structs"
) )
// 参数校验 // 参数校验
func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.TreasuremapAwardReq) (errdata *pb.ErrorData) { func (this *apiComp) AwardCheck(session comm.IUserSession, req *pb.WhackamoleAwardReq) (errdata *pb.ErrorData) {
return return
} }
// /获取系统公告 // /获取系统公告
func (this *apiComp) Award(session comm.IUserSession, req *pb.TreasuremapAwardReq) (errdata *pb.ErrorData) { func (this *apiComp) Award(session comm.IUserSession, req *pb.WhackamoleAwardReq) (errdata *pb.ErrorData) {
var () var (
conf *cfg.GameTDRewardData
award []*pb.UserAtno
err error
)
if errdata = this.AwardCheck(session, req); errdata != nil { if errdata = this.AwardCheck(session, req); errdata != nil {
return return
} }
session.SendMsg(string(this.module.GetType()), "award", &pb.TreasuremapAwardResp{Id: req.Id}) if conf, err = this.module.configure.getGameTDRewardData(req.Id); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_ConfigNoFound,
Message: err.Error(),
}
return
}
if errdata, award = this.module.DispenseAtno(session, conf.Reward, true); errdata != nil {
return
}
session.SendMsg(string(this.module.GetType()), "award", &pb.WhackamoleAwardResp{Id: req.Id, Award: award})
return return
} }

View File

@ -9,9 +9,7 @@ import (
) )
const ( const (
game_gcolorgetfraction = "game_gcolorgetfraction.json" game_tdreward = "game_tdreward.json"
game_gcolorreward = "game_gcolorreward.json"
game_gcolorttmedecay = "game_gcolorttmedecay.json"
) )
type configureComp struct { type configureComp struct {
@ -23,21 +21,21 @@ type configureComp struct {
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) { func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
err = this.MCompConfigure.Init(service, module, comp, options) err = this.MCompConfigure.Init(service, module, comp, options)
this.module = module.(*Whackamole) this.module = module.(*Whackamole)
err = this.LoadConfigure(game_tdreward, cfg.NewGameTDReward)
return return
} }
// 获取奖励列表 // 获取奖励列表
func (this *configureComp) getGameGColorRewardData(id int32) (conf *cfg.GameGColorRewardData, err error) { func (this *configureComp) getGameTDRewardData(id int32) (conf *cfg.GameTDRewardData, err error) {
var ( var (
v interface{} v interface{}
ok bool ok bool
) )
if v, err = this.GetConfigure(game_gcolorreward); err != nil { if v, err = this.GetConfigure(game_tdreward); err != nil {
return return
} }
if conf, ok = v.(*cfg.GameGColorReward).GetDataMap()[id]; !ok { if conf, ok = v.(*cfg.GameTDReward).GetDataMap()[id]; !ok {
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_gcolorreward, id) err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_tdreward, id)
this.module.Errorln(err) this.module.Errorln(err)
return return
} }

View File

@ -0,0 +1,42 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
type GameTDReward struct {
_dataMap map[int32]*GameTDRewardData
_dataList []*GameTDRewardData
}
func NewGameTDReward(_buf []map[string]interface{}) (*GameTDReward, error) {
_dataList := make([]*GameTDRewardData, 0, len(_buf))
dataMap := make(map[int32]*GameTDRewardData)
for _, _ele_ := range _buf {
if _v, err2 := DeserializeGameTDRewardData(_ele_); err2 != nil {
return nil, err2
} else {
_dataList = append(_dataList, _v)
dataMap[_v.Id] = _v
}
}
return &GameTDReward{_dataList:_dataList, _dataMap:dataMap}, nil
}
func (table *GameTDReward) GetDataMap() map[int32]*GameTDRewardData {
return table._dataMap
}
func (table *GameTDReward) GetDataList() []*GameTDRewardData {
return table._dataList
}
func (table *GameTDReward) Get(key int32) *GameTDRewardData {
return table._dataMap[key]
}

View File

@ -0,0 +1,50 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
package cfg
import "errors"
type GameTDRewardData struct {
Id int32
Reward []*Gameatn
}
const TypeId_GameTDRewardData = 8107621
func (*GameTDRewardData) GetTypeId() int32 {
return 8107621
}
func (_v *GameTDRewardData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id"].(float64); !_ok_ { err = errors.New("id error"); return }; _v.Id = int32(_tempNum_) }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["reward"].([]interface{}); !_ok_ { err = errors.New("reward error"); return }
_v.Reward = make([]*Gameatn, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ *Gameatn
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _e_.(map[string]interface{}); !_ok_ { err = errors.New("_list_v_ error"); return }; if _list_v_, err = DeserializeGameatn(_x_); err != nil { return } }
_v.Reward = append(_v.Reward, _list_v_)
}
}
return
}
func DeserializeGameTDRewardData(_buf map[string]interface{}) (*GameTDRewardData, error) {
v := &GameTDRewardData{}
if err := v.Deserialize(_buf); err == nil {
return v, nil
} else {
return nil, err
}
}

File diff suppressed because it is too large Load Diff