This commit is contained in:
liwei1dao 2022-11-21 16:48:17 +08:00
commit 194912c71f
7 changed files with 268 additions and 8 deletions

View File

@ -26,6 +26,7 @@ const (
FriendSubTypeAssistlist = "assistlist"
FriendSubTypeGetreward = "getreward"
FriendSubTypeAssistHeroList = "assistherolist"
FriendSubTypeRelation = "getrelation"
)
type apiComp struct {

View File

@ -0,0 +1,58 @@
package friend
import (
"go_dreamfactory/comm"
"go_dreamfactory/lego/sys/log"
"go_dreamfactory/pb"
"go_dreamfactory/utils"
"google.golang.org/protobuf/proto"
)
// 获取好友关系
func (this *apiComp) GetRelationCheck(session comm.IUserSession, req *pb.FriendGetRelationReq) (code pb.ErrorCode) {
if req.TargetUid == "" {
code = pb.ErrorCode_ReqParameterError
this.moduleFriend.Error("参数错误", log.Fields{"uid": session.GetUserId(), "params": req})
}
return
}
func (this *apiComp) GetRelation(session comm.IUserSession, req *pb.FriendGetRelationReq) (code pb.ErrorCode, data proto.Message) {
if code = this.GetRelationCheck(session, req); code != pb.ErrorCode_Success {
return
}
self := this.moduleFriend.modelFriend.GetFriend(session.GetUserId())
if self == nil {
code = pb.ErrorCode_FriendSelfNoData
return
}
target := this.moduleFriend.modelFriend.GetFriend(req.TargetUid)
if target == nil {
code = pb.ErrorCode_FriendTargetNoData
return
}
var status bool
// 已申请目标玩家
if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok {
status = true
}
//目标玩家已是好友
if _, ok := utils.Findx(self.FriendIds, req.TargetUid); ok {
status = true
}
resp := &pb.FriendGetRelationResp{
TargetUid: req.TargetUid,
Status: status,
}
if err := session.SendMsg(string(this.moduleFriend.GetType()), FriendSubTypeRelation, resp); err != nil {
code = pb.ErrorCode_SystemError
return
}
return
}

View File

@ -45,6 +45,11 @@ func (this *apiComp) List(session comm.IUserSession, req *pb.FriendListReq) (cod
if target == nil {
continue
}
// 申请过的在线好友,设置申请状态
if _, ok := utils.Findx(target.ApplyIds, self.Uid); ok {
base.IsApplied = true
}
if _, ok := utils.Findx(target.ZanIds, self.Uid); ok {
base.IsZaned = true
}

View File

@ -10,8 +10,7 @@ import (
)
const (
game_gourmet = "game_gourmet.json"
game_gourmetskill = "game_gourmetskill.json"
game_gourmet = "game_gourmet.json"
)
///配置管理基础组件

View File

@ -108,6 +108,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
}
}
} else { // 所有阵营抽卡都走这里
drawCount += req.DrawCount
if req.DrawCount == 1 {
switch req.DrawType {
case 1:
@ -197,6 +198,12 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
if v, ok := _data[int32(star)]; ok {
if int32(len(v)) > randomIndex {
if star == 5 { // 抽出5星英雄后A次抽奖内不会再抽到5星英雄普通卡池+阵营卡池)
curDrawCount := drawCount - req.DrawCount
newID := this.module.ContinuousRestriction(session.GetUserId(), v[randomIndex].Id, curDrawCount+int32(index), strPool[index])
szCards = append(szCards, newID)
continue
}
szCards = append(szCards, v[randomIndex].Id)
}
}
@ -215,6 +222,7 @@ func (this *apiComp) DrawCard(session comm.IUserSession, req *pb.HeroDrawCardReq
return
}
for _, heroId := range szCards {
_mapAddHero[heroId]++
}
code = this.module.CreateRepeatHeros(session, _mapAddHero, true)

View File

@ -457,6 +457,58 @@ func (this *Hero) NoLoginDay(uid string, day int32) {
}
}
// 连续抽卡最多连续出A个相同阵营的英雄普通卡池
/*
heroCid 抽到的5星英雄ID
drawCount 当前抽卡次数
poll 当前卡池
返回值 newCid不满足抽卡要求替换其他5星英雄
*/
func (this *Hero) ContinuousRestriction(uid string, heroCid string, drawCount int32, pool string) (newCid string) {
var (
update map[string]interface{}
)
record, err := this.modelRecord.GetHeroRecord(uid)
if err != nil {
return heroCid
}
for heroid, index := range record.Star5Hero {
if heroid == heroCid {
conf := this.configure.GetGlobalConf() //.
iMaxCOunt := conf.DrawCardContinuousRestrictionStar5
if drawCount-index <= iMaxCOunt { // 连续n次还获得该英雄 直接替换其他英雄
_data := this.configure.GetPollByType(pool)
if _data == nil {
return heroCid
}
sz := make([]int32, 0)
for _, v := range _data[5] {
sz = append(sz, v.Weight)
}
//randomIndex := this.modelHero.GetRandW(sz)
for i := 0; i < len(_data[5]); i++ {
if v, ok := _data[5]; ok {
if int32(len(v)) > int32(i) {
newCid = v[i].Id
if newCid == heroid {
continue
}
record.Star5Hero[heroid] = drawCount
update["star5Hero"] = record.Star5Hero
this.modelRecord.ChangeHeroRecord(uid, update) // 更新信息
return
}
}
}
}
}
}
return heroCid
}
// 检查充值和未登录天数之内抽卡是否抽中
func (this *Hero) CheckCondition(uid string) bool {
var (

View File

@ -2008,6 +2008,109 @@ func (x *FriendAssistHeroListResp) GetFriends() []*FriendBase {
return nil
}
// 查询是否已申请目标玩家为好友或目标玩家是否已是好友
type FriendGetRelationReq struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TargetUid string `protobuf:"bytes,1,opt,name=targetUid,proto3" json:"targetUid"` //目标玩家ID
}
func (x *FriendGetRelationReq) Reset() {
*x = FriendGetRelationReq{}
if protoimpl.UnsafeEnabled {
mi := &file_friend_friend_msg_proto_msgTypes[40]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FriendGetRelationReq) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FriendGetRelationReq) ProtoMessage() {}
func (x *FriendGetRelationReq) ProtoReflect() protoreflect.Message {
mi := &file_friend_friend_msg_proto_msgTypes[40]
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 FriendGetRelationReq.ProtoReflect.Descriptor instead.
func (*FriendGetRelationReq) Descriptor() ([]byte, []int) {
return file_friend_friend_msg_proto_rawDescGZIP(), []int{40}
}
func (x *FriendGetRelationReq) GetTargetUid() string {
if x != nil {
return x.TargetUid
}
return ""
}
type FriendGetRelationResp struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
TargetUid string `protobuf:"bytes,1,opt,name=targetUid,proto3" json:"targetUid"`
Status bool `protobuf:"varint,2,opt,name=status,proto3" json:"status"` //已是好友或已申请返回true
}
func (x *FriendGetRelationResp) Reset() {
*x = FriendGetRelationResp{}
if protoimpl.UnsafeEnabled {
mi := &file_friend_friend_msg_proto_msgTypes[41]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *FriendGetRelationResp) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*FriendGetRelationResp) ProtoMessage() {}
func (x *FriendGetRelationResp) ProtoReflect() protoreflect.Message {
mi := &file_friend_friend_msg_proto_msgTypes[41]
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 FriendGetRelationResp.ProtoReflect.Descriptor instead.
func (*FriendGetRelationResp) Descriptor() ([]byte, []int) {
return file_friend_friend_msg_proto_rawDescGZIP(), []int{41}
}
func (x *FriendGetRelationResp) GetTargetUid() string {
if x != nil {
return x.TargetUid
}
return ""
}
func (x *FriendGetRelationResp) GetStatus() bool {
if x != nil {
return x.Status
}
return false
}
var File_friend_friend_msg_proto protoreflect.FileDescriptor
var file_friend_friend_msg_proto_rawDesc = []byte{
@ -2159,8 +2262,16 @@ var file_friend_friend_msg_proto_rawDesc = []byte{
0x48, 0x65, 0x72, 0x6f, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x73, 0x70, 0x12, 0x25, 0x0a, 0x07,
0x66, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e,
0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x42, 0x61, 0x73, 0x65, 0x52, 0x07, 0x66, 0x72, 0x69, 0x65,
0x6e, 0x64, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f,
0x74, 0x6f, 0x33,
0x6e, 0x64, 0x73, 0x22, 0x34, 0x0a, 0x14, 0x46, 0x72, 0x69, 0x65, 0x6e, 0x64, 0x47, 0x65, 0x74,
0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x12, 0x1c, 0x0a, 0x09, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09,
0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x22, 0x4d, 0x0a, 0x15, 0x46, 0x72, 0x69,
0x65, 0x6e, 0x64, 0x47, 0x65, 0x74, 0x52, 0x65, 0x6c, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x65,
0x73, 0x70, 0x12, 0x1c, 0x0a, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x09, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x55, 0x69, 0x64,
0x12, 0x16, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x08,
0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62,
0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -2175,7 +2286,7 @@ func file_friend_friend_msg_proto_rawDescGZIP() []byte {
return file_friend_friend_msg_proto_rawDescData
}
var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 40)
var file_friend_friend_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 42)
var file_friend_friend_msg_proto_goTypes = []interface{}{
(*FriendBase)(nil), // 0: FriendBase
(*FriendListReq)(nil), // 1: FriendListReq
@ -2217,7 +2328,9 @@ var file_friend_friend_msg_proto_goTypes = []interface{}{
(*FriendAssistHeroUpdatePush)(nil), // 37: FriendAssistHeroUpdatePush
(*FriendAssistHeroListReq)(nil), // 38: FriendAssistHeroListReq
(*FriendAssistHeroListResp)(nil), // 39: FriendAssistHeroListResp
(*AssistRecord)(nil), // 40: AssistRecord
(*FriendGetRelationReq)(nil), // 40: FriendGetRelationReq
(*FriendGetRelationResp)(nil), // 41: FriendGetRelationResp
(*AssistRecord)(nil), // 42: AssistRecord
}
var file_friend_friend_msg_proto_depIdxs = []int32{
0, // 0: FriendListResp.list:type_name -> FriendBase
@ -2227,7 +2340,7 @@ var file_friend_friend_msg_proto_depIdxs = []int32{
0, // 4: FriendBlackListResp.friends:type_name -> FriendBase
0, // 5: FriendZanlistResp.list:type_name -> FriendBase
0, // 6: FriendAssistlistResp.list:type_name -> FriendBase
40, // 7: FriendAssistlistResp.record:type_name -> AssistRecord
42, // 7: FriendAssistlistResp.record:type_name -> AssistRecord
0, // 8: FriendAssistHeroUpdatePush.friend:type_name -> FriendBase
0, // 9: FriendAssistHeroListResp.friends:type_name -> FriendBase
10, // [10:10] is the sub-list for method output_type
@ -2724,6 +2837,30 @@ func file_friend_friend_msg_proto_init() {
return nil
}
}
file_friend_friend_msg_proto_msgTypes[40].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FriendGetRelationReq); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
file_friend_friend_msg_proto_msgTypes[41].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*FriendGetRelationResp); 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{
@ -2731,7 +2868,7 @@ func file_friend_friend_msg_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_friend_friend_msg_proto_rawDesc,
NumEnums: 0,
NumMessages: 40,
NumMessages: 42,
NumExtensions: 0,
NumServices: 0,
},