diff --git a/bin/json/game_smithytask.json b/bin/json/game_smithytask.json
index 66763c29c..092b1cafb 100644
--- a/bin/json/game_smithytask.json
+++ b/bin/json/game_smithytask.json
@@ -8,11 +8,6 @@
},
"type_id": 2018001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 10
- },
{
"a": "attr",
"t": "diamond",
@@ -29,11 +24,6 @@
},
"type_id": 2024001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 11
- },
{
"a": "attr",
"t": "diamond",
@@ -50,11 +40,6 @@
},
"type_id": 2047001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 12
- },
{
"a": "attr",
"t": "diamond",
@@ -71,11 +56,6 @@
},
"type_id": 2064001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 13
- },
{
"a": "attr",
"t": "diamond",
@@ -92,11 +72,6 @@
},
"type_id": 2012001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 14
- },
{
"a": "attr",
"t": "diamond",
@@ -113,11 +88,6 @@
},
"type_id": 2130001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 15
- },
{
"a": "attr",
"t": "diamond",
@@ -134,11 +104,6 @@
},
"type_id": 3018001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 16
- },
{
"a": "attr",
"t": "diamond",
@@ -155,11 +120,6 @@
},
"type_id": 3024001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 17
- },
{
"a": "attr",
"t": "diamond",
@@ -176,11 +136,6 @@
},
"type_id": 3047001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 18
- },
{
"a": "attr",
"t": "diamond",
@@ -197,11 +152,6 @@
},
"type_id": 3064001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 19
- },
{
"a": "attr",
"t": "diamond",
@@ -218,11 +168,6 @@
},
"type_id": 3012001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 20
- },
{
"a": "attr",
"t": "diamond",
@@ -239,11 +184,6 @@
},
"type_id": 3105001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 21
- },
{
"a": "attr",
"t": "diamond",
@@ -260,11 +200,6 @@
},
"type_id": 3104001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 22
- },
{
"a": "attr",
"t": "diamond",
@@ -281,11 +216,6 @@
},
"type_id": 3130001,
"reword": [
- {
- "a": "attr",
- "t": "gold",
- "n": 23
- },
{
"a": "attr",
"t": "diamond",
diff --git a/comm/const.go b/comm/const.go
index c561e9c38..8af666b23 100644
--- a/comm/const.go
+++ b/comm/const.go
@@ -142,7 +142,8 @@ const (
TableSeasonRecord = "seasonRecord" // 赛季塔记录
/// 美食馆
TableSmithy = "smithy"
- TableSmithyTrade = "trade"
+ TableSmithyTrade = "smithytrade"
+ TableSmithyTask = "smithytask"
/// 赛季塔数据表
TableSeasonPagoda = "seasonpagoda"
//
diff --git a/modules/smithy/api_receive.go b/modules/smithy/api_receive.go
new file mode 100644
index 000000000..222afe047
--- /dev/null
+++ b/modules/smithy/api_receive.go
@@ -0,0 +1,27 @@
+package smithy
+
+import (
+ "go_dreamfactory/comm"
+ "go_dreamfactory/pb"
+
+ "google.golang.org/protobuf/proto"
+)
+
+// 图鉴任务奖励领取
+func (this *apiComp) TaskAwardCheck(session comm.IUserSession, req *pb.SmithyTaskAwardReq) (code pb.ErrorCode) {
+ if req.TaskId == 0 {
+ return pb.ErrorCode_ReqParameterError
+ }
+ return
+}
+
+func (this *apiComp) TaskAward(session comm.IUserSession, req *pb.SmithyTaskAwardReq) (code pb.ErrorCode, data proto.Message) {
+ if code = this.TaskAwardCheck(session, req); code != pb.ErrorCode_Success {
+ return
+ }
+
+ resp:= &pb.SmithyTaskAwardResp{}
+
+ session.SendMsg(string(this.module.GetType()),"taskaward", resp)
+ return
+}
diff --git a/modules/smithy/api_refuse.go b/modules/smithy/api_refuse.go
new file mode 100644
index 000000000..3439578dd
--- /dev/null
+++ b/modules/smithy/api_refuse.go
@@ -0,0 +1,34 @@
+package smithy
+
+import (
+ "go_dreamfactory/comm"
+ "go_dreamfactory/pb"
+
+ "google.golang.org/protobuf/proto"
+)
+
+func (this *apiComp) RefuseCheck(session comm.IUserSession, req *pb.SmithyRefuseReq) (code pb.ErrorCode) {
+ if req.CustomerId == 0 {
+ code = pb.ErrorCode_ReqParameterError
+ }
+ return
+}
+
+func (this *apiComp) Refuse(session comm.IUserSession, req *pb.SmithyRefuseReq) (code pb.ErrorCode, data proto.Message) {
+ if code = this.RefuseCheck(session, req); code != pb.ErrorCode_Success {
+ return
+ }
+
+ cus, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
+ if err != nil {
+ code = pb.ErrorCode_DBError
+ return
+ }
+
+ resp := &pb.SmithyRefuseResp{
+ Customers: cus.Customers,
+ }
+
+ session.SendMsg(string(this.module.GetType()), "refuse", resp)
+ return
+}
diff --git a/modules/smithy/api_trade.go b/modules/smithy/api_trade.go
index 725f7f014..9b2160a5e 100644
--- a/modules/smithy/api_trade.go
+++ b/modules/smithy/api_trade.go
@@ -32,7 +32,11 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (cod
this.module.ModuleEquipment.RecycleEquipments(session, req.EquipIds, this.module.modelStove.StoveToolsSellUp(session.GetUserId()))
- _ = this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
+ cus, err := this.module.modelTrade.updateCustomer(session.GetUserId(), req.CustomerId)
+ if err != nil {
+ code = pb.ErrorCode_DBError
+ return
+ }
conf := this.module.configure.GetSmithyCustomerConf(req.CustomerId)
if conf == nil {
@@ -46,6 +50,7 @@ func (this *apiComp) Sell(session comm.IUserSession, req *pb.SmithySellReq) (cod
rsp := &pb.SmithySellResp{
CustomerId: req.CustomerId,
EquipIds: req.EquipIds,
+ Customers: cus.Customers,
}
session.SendMsg(string(this.module.GetType()), "sell", rsp)
diff --git a/modules/smithy/comp_configure.go b/modules/smithy/comp_configure.go
index f6adcef32..e7edce6f6 100644
--- a/modules/smithy/comp_configure.go
+++ b/modules/smithy/comp_configure.go
@@ -21,6 +21,7 @@ const (
game_smithyatlas = "game_smithyatlas.json" // 收藏图鉴
game_smithyatlaslv = "game_smithyatlaslv.json" // 收藏等级积分
game_smithyatlasscore = "game_smithyatlasscore.json" // 图鉴积分
+ game_smithytask = "game_smithytask.json" //图鉴任务
)
// /配置管理基础组件
@@ -70,7 +71,7 @@ func (this *configureComp) Init(service core.IService, module core.IModule, comp
err = this.LoadConfigure(game_smithyatlas, cfg.NewGameSmithyAtlas)
err = this.LoadConfigure(game_smithyatlaslv, cfg.NewGameSmithyAtlasLv)
err = this.LoadConfigure(game_smithyatlasscore, cfg.NewGameSmithyAtlasScore)
-
+ err = this.LoadConfigure(game_smithytask, cfg.NewGameSmithyTask)
return
}
@@ -290,3 +291,15 @@ func (this *configureComp) LoadSmithyAtlasScoreConf() {
log.Errorf("get LoadSmithyAtlasScoreConf conf err:%v", err)
}
}
+
+// 获取图鉴任务配置
+func(this *configureComp) GetSmithyTask(taskId int32) (data *cfg.GameSmithyTaskData) {
+ if v, err := this.GetConfigure(game_smithytask); err == nil {
+ if configure, ok := v.(*cfg.GameSmithyTask); ok {
+ data = configure.Get(taskId)
+ return
+ }
+ }
+ this.module.Errorf("GetSmithyTask notfound taskId:%d", taskId)
+ return
+}
\ No newline at end of file
diff --git a/modules/smithy/model_task.go b/modules/smithy/model_task.go
new file mode 100644
index 000000000..87ea1aef2
--- /dev/null
+++ b/modules/smithy/model_task.go
@@ -0,0 +1,73 @@
+package smithy
+
+import (
+ "go_dreamfactory/comm"
+ "go_dreamfactory/lego/core"
+ "go_dreamfactory/modules"
+ "go_dreamfactory/pb"
+
+ "go.mongodb.org/mongo-driver/mongo"
+ "go.mongodb.org/mongo-driver/x/bsonx"
+)
+
+type modelTask struct {
+ modules.MCompModel
+ module *Smithy
+}
+
+func (this *modelTask) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
+ this.TableName = string(comm.TableSmithyTask)
+ err = this.MCompModel.Init(service, module, comp, options)
+ this.module = module.(*Smithy)
+ this.DB.CreateIndex(core.SqlTable(this.TableName), mongo.IndexModel{
+ Keys: bsonx.Doc{{Key: "uid", Value: bsonx.Int32(1)}},
+ })
+ return
+}
+
+func (this *modelTask) getTaskRecord(uid string) (*pb.DBTujianTask, error) {
+ tt := &pb.DBTujianTask{}
+ if err := this.Get(uid, tt); err != nil {
+ return tt, err
+ }
+ return tt, nil
+}
+
+func (this *modelTask) updateTaskRecord(uid string, taskId int32) error {
+ if !this.CheckTaskStatus(uid, taskId) {
+ return comm.NewCustomError(pb.ErrorCode_SmithyTaskNoFinished)
+ }
+ dt, err := this.getTaskRecord(uid)
+ if err != nil {
+ return err
+ }
+
+ if dt.Uid == "" {
+ this.Add(uid, &pb.DBTujianTask{Uid: uid, TaskId: taskId, Received: 2})
+ } else {
+ // 已存在 重复领取
+ if dt.Received == 2 {
+ return comm.NewCustomError(pb.ErrorCode_SmithyTaskReceived)
+ } else {
+ update := map[string]interface{}{
+ "received": 2,
+ }
+ if err := this.Change(uid, update); err != nil {
+ return err
+ }
+ }
+ }
+ return nil
+}
+
+// 检查任务状态
+func (this *modelTask) CheckTaskStatus(uid string, taskId int32) bool {
+ conf := this.module.configure.GetSmithyTask(taskId)
+ if conf == nil {
+ return false
+ }
+ if ec := this.module.ModuleRtask.CheckCondi(uid, conf.TypeId); ec != pb.ErrorCode_Success {
+ return false
+ }
+ return true
+}
diff --git a/modules/smithy/model_trade.go b/modules/smithy/model_trade.go
index 9af59a2ad..94c8c599c 100644
--- a/modules/smithy/model_trade.go
+++ b/modules/smithy/model_trade.go
@@ -119,16 +119,16 @@ func (s *modelTrade) removeCustomer(cus *pb.DBCustomer, customerId int32) *pb.DB
}
// 随机新顾客
-func (s *modelTrade) updateCustomer(uid string, customerId int32) error {
+func (s *modelTrade) updateCustomer(uid string, customerId int32) (*pb.DBCustomer, error) {
cus, err := s.getDBCustomer(uid)
if err == nil {
cus = s.removeCustomer(cus, customerId)
cus.Total++
//上限
- limit := 20
- left := limit - int(cus.Total)
+ limit := s.module.modelStove.StoveSkillAddCustomer(uid)
+ left := limit - cus.Total
if left <= 0 {
- return comm.NewCustomError(pb.ErrorCode_SmithyCustomerLimit)
+ return nil, comm.NewCustomError(pb.ErrorCode_SmithyCustomerLimit)
}
cus.Customers = append(cus.Customers, &pb.CustomerInfo{
@@ -143,10 +143,10 @@ func (s *modelTrade) updateCustomer(uid string, customerId int32) error {
"lastRefreshTime": cus.LastRefreshTime,
}
if err := s.Change(uid, update); err != nil {
- return err
+ return nil, err
}
}
- return nil
+ return cus, nil
}
// 返回概率下的套装
@@ -166,8 +166,8 @@ func (s *modelTrade) GetSuitRandom(uid string) (suiteId int32) {
}
//获取玩家已有装备
ec, suites := s.module.ModuleEquipment.GetActionableSuit(uid)
- if ec!=pb.ErrorCode_Success {
- s.module.Error("获取玩家已有装备:", log.Field{Key:"code",Value: ec})
+ if ec != pb.ErrorCode_Success {
+ s.module.Error("获取玩家已有装备:", log.Field{Key: "code", Value: ec})
return
}
var ownerSuiteItems []*WeightItem
diff --git a/sys/configure/structs/Game.SmithyTask.go b/sys/configure/structs/Game.SmithyTask.go
new file mode 100644
index 000000000..7331b44ff
--- /dev/null
+++ b/sys/configure/structs/Game.SmithyTask.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 GameSmithyTask struct {
+ _dataMap map[int32]*GameSmithyTaskData
+ _dataList []*GameSmithyTaskData
+}
+
+func NewGameSmithyTask(_buf []map[string]interface{}) (*GameSmithyTask, error) {
+ _dataList := make([]*GameSmithyTaskData, 0, len(_buf))
+ dataMap := make(map[int32]*GameSmithyTaskData)
+ for _, _ele_ := range _buf {
+ if _v, err2 := DeserializeGameSmithyTaskData(_ele_); err2 != nil {
+ return nil, err2
+ } else {
+ _dataList = append(_dataList, _v)
+ dataMap[_v.Key] = _v
+ }
+ }
+ return &GameSmithyTask{_dataList:_dataList, _dataMap:dataMap}, nil
+}
+
+func (table *GameSmithyTask) GetDataMap() map[int32]*GameSmithyTaskData {
+ return table._dataMap
+}
+
+func (table *GameSmithyTask) GetDataList() []*GameSmithyTaskData {
+ return table._dataList
+}
+
+func (table *GameSmithyTask) Get(key int32) *GameSmithyTaskData {
+ return table._dataMap[key]
+}
+
+
diff --git a/sys/configure/structs/Game.SmithyTaskData.go b/sys/configure/structs/Game.SmithyTaskData.go
new file mode 100644
index 000000000..83bc2e71e
--- /dev/null
+++ b/sys/configure/structs/Game.SmithyTaskData.go
@@ -0,0 +1,56 @@
+//------------------------------------------------------------------------------
+//
+// 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
+
+import "errors"
+
+type GameSmithyTaskData struct {
+ Key int32
+ IdList int32
+ TaskDisplay string
+ TypeId int32
+ Reword []*Gameatn
+}
+
+const TypeId_GameSmithyTaskData = -1483471039
+
+func (*GameSmithyTaskData) GetTypeId() int32 {
+ return -1483471039
+}
+
+func (_v *GameSmithyTaskData)Deserialize(_buf map[string]interface{}) (err error) {
+ { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["key"].(float64); !_ok_ { err = errors.New("key error"); return }; _v.Key = int32(_tempNum_) }
+ { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["id_list"].(float64); !_ok_ { err = errors.New("id_list error"); return }; _v.IdList = int32(_tempNum_) }
+ {var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["task_display"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.TaskDisplay error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.TaskDisplay, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
+ { var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type_id"].(float64); !_ok_ { err = errors.New("type_id error"); return }; _v.TypeId = int32(_tempNum_) }
+ {
+ var _arr_ []interface{}
+ var _ok_ bool
+ if _arr_, _ok_ = _buf["reword"].([]interface{}); !_ok_ { err = errors.New("reword error"); return }
+
+ _v.Reword = 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.Reword = append(_v.Reword, _list_v_)
+ }
+ }
+
+ return
+}
+
+func DeserializeGameSmithyTaskData(_buf map[string]interface{}) (*GameSmithyTaskData, error) {
+ v := &GameSmithyTaskData{}
+ if err := v.Deserialize(_buf); err == nil {
+ return v, nil
+ } else {
+ return nil, err
+ }
+}