上传道具代码

This commit is contained in:
liwei 2023-07-05 17:14:48 +08:00
parent 2b1c8141ca
commit c0a1f83758
5 changed files with 127 additions and 106 deletions

View File

@ -433,7 +433,7 @@ func (this *ModelItemsComp) addItemToUserPack(uid string, items []*pb.DB_UserIte
if leftnum > 0 { //还没有放完 寻找空的格子填充
index := int32(len(items))
for leftnum > 0 { //需要补充格子
if conf.UpperLimit == 0 || (conf.UpperLimit > 0 && leftnum <= int64(conf.UpperLimit)) {
if conf.UpperLimit == -1 || (conf.UpperLimit > 0 && leftnum <= int64(conf.UpperLimit)) {
grid := &pb.DB_UserItemData{
GridId: primitive.NewObjectID().Hex(),
UId: uid,

View File

@ -0,0 +1,34 @@
package wtask
import (
"go_dreamfactory/comm"
"go_dreamfactory/pb"
)
// 参数校验
func (this *apiComp) FinishCheck(session comm.IUserSession, req *pb.WTaskFinishReq) (errdata *pb.ErrorData) {
return
}
// /获取系统公告
func (this *apiComp) Finish(session comm.IUserSession, req *pb.WTaskFinishReq) (errdata *pb.ErrorData) {
var (
wtask *pb.DBWTask
err error
)
if errdata = this.FinishCheck(session, req); errdata != nil {
return
}
if wtask, err = this.module.modelwtask.getUserWTasks(session.GetUserId()); err != nil {
errdata = &pb.ErrorData{
Code: pb.ErrorCode_DBError,
Title: pb.ErrorCode_DBError.ToString(),
Message: err.Error(),
}
return
}
session.SendMsg(string(this.module.GetType()), "info", &pb.WTaskInfoResp{Activations: wtask.Activations, Completes: wtask.Completes})
return
}

View File

@ -2,6 +2,7 @@ package wtask
import (
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/modules"
"go_dreamfactory/sys/configure"
@ -83,3 +84,21 @@ func (this *configureComp) getcondlTask() map[int32][]*cfg.GameWorldTaskData {
defer this.lock.RUnlock()
return this.condlTask
}
func (this *configureComp) gettaskconfconfigure(tid int32) (conf *cfg.GameWorldTaskData, err error) {
var (
v interface{}
ok bool
)
if v, err = this.GetConfigure(gameWorldTask); err != nil {
return
} else {
if conf, ok = v.(*cfg.GameWorldTask).GetDataMap()[tid]; !ok {
err = comm.NewNotFoundConfErr(modulename, gameWorldTask, tid)
this.module.Errorf("err:%v", err)
return
}
}
return
}

View File

@ -13,6 +13,8 @@ const modulename = "世界任务"
type WTask struct {
modules.ModuleBase
service core.IService
modelSys comm.ISys
api *apiComp
configure *configureComp
modelwtask *ModelWTask
@ -28,6 +30,17 @@ func (this *WTask) GetType() core.M_Modules {
func (this *WTask) Init(service core.IService, module core.IModule, options core.IModuleOptions) (err error) {
err = this.ModuleBase.Init(service, module, options)
this.service = service
return
}
func (this *WTask) Start() (err error) {
err = this.ModuleBase.Start()
var module core.IModule
if module, err = this.service.GetModule(comm.ModuleSys); err != nil {
return
}
this.modelSys = module.(comm.ISys)
return
}
@ -56,7 +69,8 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
award []*pb.UserAssets = make([]*pb.UserAssets, 0)
ok bool
needcheck bool //是否需要校验
err error
err error
)
if utask, err = this.modelwtask.getUserWTasks(uid); err != nil {
this.Error("读取玩家世界任务数据 失败", log.Field{Key: "err", Value: err.Error()})
@ -143,12 +157,36 @@ func (this *WTask) BuriedsNotify(uid string, condis []*pb.ConIProgress) {
//发送进度变化消息
session.SendMsg(string(this.GetType()), "accepttaskchange", &pb.WTaskAccepttaskChangePush{Accepttask: detailstasks})
if len(finishtasks) > 0 {
//发送任务完成推送
session.SendMsg(string(this.GetType()), "autofinsh", &pb.WTaskAutoFinshPush{Completes: finishtasks, Award: award})
utask.Completes = append(utask.Completes, finishtasks...)
this.inquireActivations(session, utask, 1, []string{})
}
// 完成任务
func (this *WTask) fishtask(session comm.IUserSession, wtask *pb.DBWTask, finishtasks []int32) {
var (
opencmdMap map[string]int32
opencmd []string
user *pb.DBUser
errdata *pb.ErrorData
)
if len(finishtasks) == 0 {
return
}
if opencmdMap, errdata = this.modelSys.QueryOpenCondData(session.GetUserId()); errdata != nil {
this.Error("查询用户功能是否开启表 失败!", log.Field{Key: "key", Value: errdata})
return
}
opencmd = make([]string, 0)
for k, v := range opencmdMap {
if v == 2 {
opencmd = append(opencmd, k)
}
}
if user = this.ModuleUser.GetUser(session.GetUserId()); user != nil {
this.Error("获取用户信息失败!", log.Field{Key: "uid", Value: session.GetUserId()})
return
}
this.inquireActivations(session, wtask, user.Lv, opencmd)
}
// 查询可接取任务列表
@ -186,12 +224,17 @@ func (this *WTask) inquireActivations(session comm.IUserSession, wtask *pb.DBWTa
if v.Des == 5 { //商队任务不主动触发
continue
}
wtask.Activations = append(wtask.Activations, v.Key)
change = true
if v.AutoAccept == 0 {
wtask.Activations = append(wtask.Activations, v.Key)
change = true
} else if v.AutoAccept == 1 { //自动接取任务
wtask.Accepttask = append(wtask.Accepttask, v.Key)
}
}
if change {
session.SendMsg(string(this.GetType()), "autofinsh", &pb.WTaskActivationsPush{Activations: wtask.Activations})
session.SendMsg(string(this.GetType()), "activations", &pb.WTaskActivationsPush{Activations: wtask.Activations})
}
return
}

View File

@ -618,62 +618,6 @@ func (x *WTaskAccepttaskChangePush) GetAccepttask() []*DBWTaskItem {
return nil
}
//任务自动完成 推送
type WTaskAutoFinshPush struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
Completes []int32 `protobuf:"varint,1,rep,packed,name=completes,proto3" json:"completes"` //可接取任务列表
Award []*UserAssets `protobuf:"bytes,2,rep,name=award,proto3" json:"award"` //奖励
}
func (x *WTaskAutoFinshPush) Reset() {
*x = WTaskAutoFinshPush{}
if protoimpl.UnsafeEnabled {
mi := &file_wtask_wtask_msg_proto_msgTypes[12]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *WTaskAutoFinshPush) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*WTaskAutoFinshPush) ProtoMessage() {}
func (x *WTaskAutoFinshPush) ProtoReflect() protoreflect.Message {
mi := &file_wtask_wtask_msg_proto_msgTypes[12]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use WTaskAutoFinshPush.ProtoReflect.Descriptor instead.
func (*WTaskAutoFinshPush) Descriptor() ([]byte, []int) {
return file_wtask_wtask_msg_proto_rawDescGZIP(), []int{12}
}
func (x *WTaskAutoFinshPush) GetCompletes() []int32 {
if x != nil {
return x.Completes
}
return nil
}
func (x *WTaskAutoFinshPush) GetAward() []*UserAssets {
if x != nil {
return x.Award
}
return nil
}
var File_wtask_wtask_msg_proto protoreflect.FileDescriptor
var file_wtask_wtask_msg_proto_rawDesc = []byte{
@ -729,13 +673,8 @@ var file_wtask_wtask_msg_proto_rawDesc = []byte{
0x6e, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x2c, 0x0a, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70,
0x74, 0x74, 0x61, 0x73, 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0c, 0x2e, 0x44, 0x42,
0x57, 0x54, 0x61, 0x73, 0x6b, 0x49, 0x74, 0x65, 0x6d, 0x52, 0x0a, 0x61, 0x63, 0x63, 0x65, 0x70,
0x74, 0x74, 0x61, 0x73, 0x6b, 0x22, 0x55, 0x0a, 0x12, 0x57, 0x54, 0x61, 0x73, 0x6b, 0x41, 0x75,
0x74, 0x6f, 0x46, 0x69, 0x6e, 0x73, 0x68, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1c, 0x0a, 0x09, 0x63,
0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x09,
0x63, 0x6f, 0x6d, 0x70, 0x6c, 0x65, 0x74, 0x65, 0x73, 0x12, 0x21, 0x0a, 0x05, 0x61, 0x77, 0x61,
0x72, 0x64, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x41,
0x73, 0x73, 0x65, 0x74, 0x73, 0x52, 0x05, 0x61, 0x77, 0x61, 0x72, 0x64, 0x42, 0x06, 0x5a, 0x04,
0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
0x74, 0x74, 0x61, 0x73, 0x6b, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70,
0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -750,7 +689,7 @@ func file_wtask_wtask_msg_proto_rawDescGZIP() []byte {
return file_wtask_wtask_msg_proto_rawDescData
}
var file_wtask_wtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 13)
var file_wtask_wtask_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_wtask_wtask_msg_proto_goTypes = []interface{}{
(*WTaskInfoReq)(nil), // 0: WTaskInfoReq
(*WTaskInfoResp)(nil), // 1: WTaskInfoResp
@ -764,27 +703,25 @@ var file_wtask_wtask_msg_proto_goTypes = []interface{}{
(*WTaskFinishResp)(nil), // 9: WTaskFinishResp
(*WTaskActivationsPush)(nil), // 10: WTaskActivationsPush
(*WTaskAccepttaskChangePush)(nil), // 11: WTaskAccepttaskChangePush
(*WTaskAutoFinshPush)(nil), // 12: WTaskAutoFinshPush
(*DBWTaskItem)(nil), // 13: DBWTaskItem
(*BattleFormation)(nil), // 14: BattleFormation
(*BattleInfo)(nil), // 15: BattleInfo
(*BattleReport)(nil), // 16: BattleReport
(*UserAssets)(nil), // 17: UserAssets
(*DBWTaskItem)(nil), // 12: DBWTaskItem
(*BattleFormation)(nil), // 13: BattleFormation
(*BattleInfo)(nil), // 14: BattleInfo
(*BattleReport)(nil), // 15: BattleReport
(*UserAssets)(nil), // 16: UserAssets
}
var file_wtask_wtask_msg_proto_depIdxs = []int32{
13, // 0: WTaskInfoResp.accepttask:type_name -> DBWTaskItem
13, // 1: WTaskAcceptResp.task:type_name -> DBWTaskItem
14, // 2: WTaskBattleStartReq.battle:type_name -> BattleFormation
15, // 3: WTaskBattleStartResp.info:type_name -> BattleInfo
16, // 4: WTaskBattleFinishReq.report:type_name -> BattleReport
17, // 5: WTaskFinishResp.award:type_name -> UserAssets
13, // 6: WTaskAccepttaskChangePush.accepttask:type_name -> DBWTaskItem
17, // 7: WTaskAutoFinshPush.award:type_name -> UserAssets
8, // [8:8] is the sub-list for method output_type
8, // [8:8] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
12, // 0: WTaskInfoResp.accepttask:type_name -> DBWTaskItem
12, // 1: WTaskAcceptResp.task:type_name -> DBWTaskItem
13, // 2: WTaskBattleStartReq.battle:type_name -> BattleFormation
14, // 3: WTaskBattleStartResp.info:type_name -> BattleInfo
15, // 4: WTaskBattleFinishReq.report:type_name -> BattleReport
16, // 5: WTaskFinishResp.award:type_name -> UserAssets
12, // 6: WTaskAccepttaskChangePush.accepttask:type_name -> DBWTaskItem
7, // [7:7] is the sub-list for method output_type
7, // [7:7] is the sub-list for method input_type
7, // [7:7] is the sub-list for extension type_name
7, // [7:7] is the sub-list for extension extendee
0, // [0:7] is the sub-list for field type_name
}
func init() { file_wtask_wtask_msg_proto_init() }
@ -940,18 +877,6 @@ func file_wtask_wtask_msg_proto_init() {
return nil
}
}
file_wtask_wtask_msg_proto_msgTypes[12].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*WTaskAutoFinshPush); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
@ -959,7 +884,7 @@ func file_wtask_wtask_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_wtask_wtask_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 13,
NumMessages: 12,
NumExtensions: 0,
NumServices: 0,
},