diff --git a/modules/hero/api.go b/modules/hero/api.go index 1e682f6fe..53d8e8809 100644 --- a/modules/hero/api.go +++ b/modules/hero/api.go @@ -26,6 +26,7 @@ const ( //消息回复的头名称 Awaken = "awaken" // 英雄觉醒 HeroLock = "lock" // 英雄锁定 DrawCard = "drawcard" // 抽卡 + DrawCardFloor = "drawcardfloor" // 抽卡保底 ) //组件初始化接口 diff --git a/modules/hero/api_drawCard.go b/modules/hero/api_drawCard.go index 0f8dc29f7..bb1812152 100644 --- a/modules/hero/api_drawCard.go +++ b/modules/hero/api_drawCard.go @@ -71,21 +71,33 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq } if cfgDraw.BasePoolStar4 != 0 { sz = append(sz, cfgDraw.BasePoolStar4) - } if cfgDraw.BasePoolStar5 != 0 { sz = append(sz, cfgDraw.BasePoolStar5) - } starIndex := this.module.modelHero.GetRandW(sz) + heroRecord.Star4++ + heroRecord.Star5++ if starIndex == 1 { + heroRecord.Star4 = 0 star4Max++ } else if starIndex == 2 { star5Max++ + heroRecord.Star5 = 0 } if star4Max >= cfgDraw.Draw10Star4Max || star5Max >= cfgDraw.Draw10Star5Max { starIndex = 0 } + + // 普通卡池保底 + if cfgDraw.DrawFloorStar4 <= heroRecord.Star4 { + heroRecord.Star4 = 0 + starIndex = 1 + } + if cfgDraw.DrawFloorStar5 <= heroRecord.Star5 { + heroRecord.Star5 = 0 + starIndex = 2 + } szStar = append(szStar, starIndex+3) if len(szStar) >= int(req.DrawCount) { break @@ -188,7 +200,8 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq if req.DrawType == 0 { update := map[string]interface{}{} - //drawCount += req.DrawCount + update["star4"] = heroRecord.Star4 + update["star5"] = heroRecord.Star5 update["drawcount"] = drawCount this.module.modelRecord.ChangeHeroRecord(session.GetUserId(), update) } diff --git a/modules/hero/api_drawCardFloor.go b/modules/hero/api_drawCardFloor.go new file mode 100644 index 000000000..86cd35a1f --- /dev/null +++ b/modules/hero/api_drawCardFloor.go @@ -0,0 +1,23 @@ +package hero + +import ( + "go_dreamfactory/comm" + "go_dreamfactory/pb" + + "google.golang.org/protobuf/proto" +) + +func (this *apiComp) DrawCardFloorCheck(session comm.IUserSession, req *pb.HeroDrawCardFloorReq) (code pb.ErrorCode) { + + return +} + +//抽卡 +func (this *apiComp) DrawCardFloor(session comm.IUserSession, req *pb.HeroDrawCardFloorReq) (code pb.ErrorCode, data proto.Message) { + rsp := &pb.HeroDrawCardFloorResp{} + heroRecord, _ := this.module.modelRecord.GetHeroRecord(session.GetUserId()) + rsp.Star4 = heroRecord.Star4 + rsp.Star5 = heroRecord.Star5 + session.SendMsg(string(this.module.GetType()), DrawCardFloor, rsp) + return +} diff --git a/pb/hero_msg.pb.go b/pb/hero_msg.pb.go index 115d9c365..066a55286 100644 --- a/pb/hero_msg.pb.go +++ b/pb/hero_msg.pb.go @@ -1592,6 +1592,100 @@ func (x *HeroChangePush) GetList() []*DBHero { return nil } +type HeroDrawCardFloorReq struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields +} + +func (x *HeroDrawCardFloorReq) Reset() { + *x = HeroDrawCardFloorReq{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[30] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroDrawCardFloorReq) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroDrawCardFloorReq) ProtoMessage() {} + +func (x *HeroDrawCardFloorReq) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[30] + 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 HeroDrawCardFloorReq.ProtoReflect.Descriptor instead. +func (*HeroDrawCardFloorReq) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{30} +} + +// 获取抽卡保底次数 +type HeroDrawCardFloorResp struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Star4 int32 `protobuf:"varint,1,opt,name=star4,proto3" json:"star4"` + Star5 int32 `protobuf:"varint,2,opt,name=star5,proto3" json:"star5"` +} + +func (x *HeroDrawCardFloorResp) Reset() { + *x = HeroDrawCardFloorResp{} + if protoimpl.UnsafeEnabled { + mi := &file_hero_hero_msg_proto_msgTypes[31] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HeroDrawCardFloorResp) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HeroDrawCardFloorResp) ProtoMessage() {} + +func (x *HeroDrawCardFloorResp) ProtoReflect() protoreflect.Message { + mi := &file_hero_hero_msg_proto_msgTypes[31] + 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 HeroDrawCardFloorResp.ProtoReflect.Descriptor instead. +func (*HeroDrawCardFloorResp) Descriptor() ([]byte, []int) { + return file_hero_hero_msg_proto_rawDescGZIP(), []int{31} +} + +func (x *HeroDrawCardFloorResp) GetStar4() int32 { + if x != nil { + return x.Star4 + } + return 0 +} + +func (x *HeroDrawCardFloorResp) GetStar5() int32 { + if x != nil { + return x.Star5 + } + return 0 +} + var File_hero_hero_msg_proto protoreflect.FileDescriptor var file_hero_hero_msg_proto_rawDesc = []byte{ @@ -1735,8 +1829,14 @@ var file_hero_hero_msg_proto_rawDesc = []byte{ 0x03, 0x28, 0x09, 0x52, 0x06, 0x68, 0x65, 0x72, 0x6f, 0x65, 0x73, 0x22, 0x2d, 0x0a, 0x0e, 0x48, 0x65, 0x72, 0x6f, 0x43, 0x68, 0x61, 0x6e, 0x67, 0x65, 0x50, 0x75, 0x73, 0x68, 0x12, 0x1b, 0x0a, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x07, 0x2e, 0x44, 0x42, - 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, - 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x48, 0x65, 0x72, 0x6f, 0x52, 0x04, 0x6c, 0x69, 0x73, 0x74, 0x22, 0x16, 0x0a, 0x14, 0x48, 0x65, + 0x72, 0x6f, 0x44, 0x72, 0x61, 0x77, 0x43, 0x61, 0x72, 0x64, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x52, + 0x65, 0x71, 0x22, 0x43, 0x0a, 0x15, 0x48, 0x65, 0x72, 0x6f, 0x44, 0x72, 0x61, 0x77, 0x43, 0x61, + 0x72, 0x64, 0x46, 0x6c, 0x6f, 0x6f, 0x72, 0x52, 0x65, 0x73, 0x70, 0x12, 0x14, 0x0a, 0x05, 0x73, + 0x74, 0x61, 0x72, 0x34, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, + 0x34, 0x12, 0x14, 0x0a, 0x05, 0x73, 0x74, 0x61, 0x72, 0x35, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, + 0x52, 0x05, 0x73, 0x74, 0x61, 0x72, 0x35, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, + 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, } var ( @@ -1751,7 +1851,7 @@ func file_hero_hero_msg_proto_rawDescGZIP() []byte { return file_hero_hero_msg_proto_rawDescData } -var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 32) +var file_hero_hero_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 34) var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroInfoReq)(nil), // 0: HeroInfoReq (*HeroInfoResp)(nil), // 1: HeroInfoResp @@ -1783,30 +1883,32 @@ var file_hero_hero_msg_proto_goTypes = []interface{}{ (*HeroDrawCardReq)(nil), // 27: HeroDrawCardReq (*HeroDrawCardResp)(nil), // 28: HeroDrawCardResp (*HeroChangePush)(nil), // 29: HeroChangePush - nil, // 30: HeroPropertyPush.PropertyEntry - nil, // 31: HeroPropertyPush.AddPropertyEntry - (*DBHero)(nil), // 32: DBHero + (*HeroDrawCardFloorReq)(nil), // 30: HeroDrawCardFloorReq + (*HeroDrawCardFloorResp)(nil), // 31: HeroDrawCardFloorResp + nil, // 32: HeroPropertyPush.PropertyEntry + nil, // 33: HeroPropertyPush.AddPropertyEntry + (*DBHero)(nil), // 34: DBHero } var file_hero_hero_msg_proto_depIdxs = []int32{ - 32, // 0: HeroInfoResp.base:type_name -> DBHero - 32, // 1: HeroListResp.list:type_name -> DBHero + 34, // 0: HeroInfoResp.base:type_name -> DBHero + 34, // 1: HeroListResp.list:type_name -> DBHero 5, // 2: HeroStrengthenUplvReq.expCards:type_name -> MapStringInt32 - 32, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero + 34, // 3: HeroStrengthenUplvResp.hero:type_name -> DBHero 8, // 4: HeroStrengthenUpStarReq.hero:type_name -> CostCardData 8, // 5: HeroStrengthenUpStarReq.heroRace:type_name -> CostCardData - 32, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero - 32, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero - 32, // 8: HeroResonanceResp.hero:type_name -> DBHero - 32, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero - 32, // 10: HeroResonanceResetResp.hero:type_name -> DBHero + 34, // 6: HeroStrengthenUpStarResp.hero:type_name -> DBHero + 34, // 7: HeroStrengthenUpSkillResp.hero:type_name -> DBHero + 34, // 8: HeroResonanceResp.hero:type_name -> DBHero + 34, // 9: HeroResonanceResp.upStarCard:type_name -> DBHero + 34, // 10: HeroResonanceResetResp.hero:type_name -> DBHero 17, // 11: HeroResonanceUseEnergyReq.energy:type_name -> EnergyData - 32, // 12: HeroResonanceUseEnergyResp.hero:type_name -> DBHero - 32, // 13: HeroAwakenResp.hero:type_name -> DBHero - 30, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry - 31, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry - 32, // 16: HeroLockResp.hero:type_name -> DBHero - 32, // 17: HeroGetSpecifiedResp.hero:type_name -> DBHero - 32, // 18: HeroChangePush.list:type_name -> DBHero + 34, // 12: HeroResonanceUseEnergyResp.hero:type_name -> DBHero + 34, // 13: HeroAwakenResp.hero:type_name -> DBHero + 32, // 14: HeroPropertyPush.property:type_name -> HeroPropertyPush.PropertyEntry + 33, // 15: HeroPropertyPush.addProperty:type_name -> HeroPropertyPush.AddPropertyEntry + 34, // 16: HeroLockResp.hero:type_name -> DBHero + 34, // 17: HeroGetSpecifiedResp.hero:type_name -> DBHero + 34, // 18: HeroChangePush.list:type_name -> DBHero 19, // [19:19] is the sub-list for method output_type 19, // [19:19] is the sub-list for method input_type 19, // [19:19] is the sub-list for extension type_name @@ -2181,6 +2283,30 @@ func file_hero_hero_msg_proto_init() { return nil } } + file_hero_hero_msg_proto_msgTypes[30].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroDrawCardFloorReq); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_hero_hero_msg_proto_msgTypes[31].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HeroDrawCardFloorResp); 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{ @@ -2188,7 +2314,7 @@ func file_hero_hero_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_hero_hero_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 32, + NumMessages: 34, NumExtensions: 0, NumServices: 0, },