diff --git a/modules/entertainment/xxlPlat.go b/modules/entertainment/xxlPlat.go index 6c9321e9e..a2ca566da 100644 --- a/modules/entertainment/xxlPlat.go +++ b/modules/entertainment/xxlPlat.go @@ -721,9 +721,17 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, ids []int ) x = make(map[int]struct{}) - if skillid == 1 { // 随机消除盘面上X个方块 + + switch skillid { + case 1: ids = utils.RandomNumbers(0, Total-1, int(value)) - } else if skillid == 4 { // 找到pos 位置的所有方块 + case 2: + for i := 0; i < Height; i++ { + ids = append(ids, 3*Width+i) + } + case 3: // 将随机6个宝石染成当前盘面上颜色最多的宝石 + this.SkillChangeColor(value) + case 4: x := int(pos / Width) y := int(pos % Height) for i := 1; i < 7; i++ { @@ -742,7 +750,7 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, ids = append(ids, (x+i)*Width+(y-i)) } } - } else if skillid == 5 { //选中一个方块,消除周围一圈 + case 5: ids = append(ids, int(pos)) // 包含自己 x := int(pos / Width) y := int(pos % Height) @@ -771,16 +779,16 @@ func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, if x+1 < Width && y-1 >= 0 { // 右下 ids = append(ids, (x+1)*Width+(y-1)) } - } else if skillid == 2 { // 消除中间的一列宝石 - for i := 0; i < Height; i++ { - ids = append(ids, 3*Width+i) - } - } else if skillid == 3 { // 四周蔓延 第一次100% 第二次 60% 第三次 30% 第四次 10% 最多4次 - for k := range this.Skill3(pos, 0) { + case 8: + for k := range this.SkillManYan(pos, 0) { ids = append(ids, k) // 转换成最终消除的坐标 } ids = append(ids, int(pos)) // 包含自己 + default: + this.module.Errorf("not found skill:%d", skillid) + return } + for _, id := range ids { if s := this.Plat[id].Special; s != 0 { for k := range this.SpecialElem(id, s) { @@ -1085,7 +1093,7 @@ func (this *MapData) RedsetPlatData() { } //四周蔓延 第一次100% 第二次 60% 第三次 30% 第四次 10% 最多4次 -func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) { +func (this *MapData) SkillManYan(pos int32, count int32) (m map[int]struct{}) { m = make(map[int]struct{}, 0) var sz []int var percent int32 @@ -1125,12 +1133,8 @@ func (this *MapData) Skill3(pos int32, count int32) (m map[int]struct{}) { } count++ - // for _, v := range cur { - // fmt.Printf("=======蔓延的id:%d====,count=%d====\n", v, count) - // } - // fmt.Printf("=======count=%d====\n", count) for _, k := range cur { - for k1 := range this.Skill3(int32(k), count) { // 递归蔓延 + for k1 := range this.SkillManYan(int32(k), count) { // 递归蔓延 m[k1] = struct{}{} } } @@ -1471,3 +1475,31 @@ func (this *MapData) CheckElem(pos int) (xc []int) { } return } + +// 将随机6个宝石染成当前盘面上颜色最多的宝石 (count 替换的数量) +func (this *MapData) SkillChangeColor(count int32) { + var ( + // 替换成的颜色 + color int32 + elemCount map[int32]int32 + ) + elemCount = make(map[int32]int32, 0) + for _, v := range this.Plat { + elemCount[v.Color] += 1 + } + + for k := range elemCount { + if color < k { + color = k + } + } + for i := 0; i < int(count); i++ { + targetId := comm.GetRandNum(0, Total-1) + if this.Plat[targetId].Color == color { + i-- + } else { + this.Plat[targetId].Color = color // 变更颜色 + } + } + return +} diff --git a/modules/entertainment/xxl_test.go b/modules/entertainment/xxl_test.go index 1fe4c8552..bba8cb090 100644 --- a/modules/entertainment/xxl_test.go +++ b/modules/entertainment/xxl_test.go @@ -119,7 +119,7 @@ func Test_Main(t *testing.T) { m.SetMap() m.Debugf() - fmt.Printf("xxxx %v\n", m.Skill3(24, 0)) + fmt.Printf("xxxx %v\n", m.SkillManYan(24, 0)) //m.SkillUp(24, 1, 3, 7, true) b := m.GetFireBoom(1, 7) @@ -139,12 +139,12 @@ func Test_Main(t *testing.T) { } var mids map[int]struct{} mids = make(map[int]struct{}, 0) - m.Skill3(35, 0) + m.SkillManYan(35, 0) for i := 0; i < 4; i++ { - dd := m.Skill3(24, int32(i)) + dd := m.SkillManYan(24, int32(i)) for k := range dd { - for s := range m.Skill3(int32(k), int32(i)) { + for s := range m.SkillManYan(int32(k), int32(i)) { mids[s] = struct{}{} } } diff --git a/modules/stonehenge/api_taskreceive.go b/modules/stonehenge/api_taskreceive.go index bec0c90ef..12cd8c37a 100644 --- a/modules/stonehenge/api_taskreceive.go +++ b/modules/stonehenge/api_taskreceive.go @@ -85,7 +85,7 @@ func (this *apiComp) TaskReceive(session comm.IUserSession, req *pb.StonehengeTa return } - session.SendMsg(string(this.module.GetType()), "taskreceive", &pb.StonehengeTaskReceiveResp{Task: info.Task, Award: award}) + session.SendMsg(string(this.module.GetType()), "taskreceive", &pb.StonehengeTaskReceiveResp{Taskid: req.Taskid, Award: award}) if len(award) > 0 { go this.module.AsynHandleSession(session.Clone(), func(session comm.IUserSession) { this.module.WriteUserLog(session.GetUserId(), req, comm.GMResAddType, "StonehengeTaskReceiveReq", award) diff --git a/pb/stonehenge_msg.pb.go b/pb/stonehenge_msg.pb.go index 3fbbda5b7..5181fe46b 100644 --- a/pb/stonehenge_msg.pb.go +++ b/pb/stonehenge_msg.pb.go @@ -1637,8 +1637,8 @@ type StonehengeTaskReceiveResp struct { sizeCache protoimpl.SizeCache unknownFields protoimpl.UnknownFields - Task map[int32]bool `protobuf:"bytes,1,rep,name=task,proto3" json:"task" protobuf_key:"varint,1,opt,name=key,proto3" protobuf_val:"varint,2,opt,name=value,proto3"` //已领取的任务 - Award []*UserAssets `protobuf:"bytes,2,rep,name=award,proto3" json:"award"` //奖励 + Taskid int32 `protobuf:"varint,1,opt,name=taskid,proto3" json:"taskid"` + Award []*UserAssets `protobuf:"bytes,2,rep,name=award,proto3" json:"award"` //奖励 } func (x *StonehengeTaskReceiveResp) Reset() { @@ -1673,11 +1673,11 @@ func (*StonehengeTaskReceiveResp) Descriptor() ([]byte, []int) { return file_stonehenge_stonehenge_msg_proto_rawDescGZIP(), []int{29} } -func (x *StonehengeTaskReceiveResp) GetTask() map[int32]bool { +func (x *StonehengeTaskReceiveResp) GetTaskid() int32 { if x != nil { - return x.Task + return x.Taskid } - return nil + return 0 } func (x *StonehengeTaskReceiveResp) GetAward() []*UserAssets { @@ -1990,26 +1990,21 @@ var file_stonehenge_stonehenge_msg_proto_rawDesc = []byte{ 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x32, 0x0a, 0x18, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x71, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, 0x22, 0xb1, 0x01, 0x0a, 0x19, - 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, - 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x38, 0x0a, 0x04, 0x74, 0x61, 0x73, - 0x6b, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x24, 0x2e, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, - 0x65, 0x6e, 0x67, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, 0x65, 0x69, 0x76, 0x65, 0x52, - 0x65, 0x73, 0x70, 0x2e, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52, 0x04, 0x74, - 0x61, 0x73, 0x6b, 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, 0x1a, 0x37, 0x0a, 0x09, 0x54, 0x61, 0x73, 0x6b, 0x45, 0x6e, - 0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, - 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, - 0x20, 0x01, 0x28, 0x08, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, - 0x32, 0x0a, 0x16, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, - 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, 0x07, 0x65, 0x76, 0x65, - 0x6e, 0x74, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x65, 0x76, 0x65, 0x6e, - 0x74, 0x69, 0x64, 0x22, 0x39, 0x0a, 0x17, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, - 0x65, 0x52, 0x65, 0x73, 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x12, 0x1e, - 0x0a, 0x0a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x62, 0x75, 0x66, 0x66, 0x18, 0x01, 0x20, 0x03, - 0x28, 0x05, 0x52, 0x0a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x62, 0x75, 0x66, 0x66, 0x42, 0x06, - 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, 0x22, 0x56, 0x0a, 0x19, 0x53, + 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, 0x65, 0x54, 0x61, 0x73, 0x6b, 0x52, 0x65, 0x63, + 0x65, 0x69, 0x76, 0x65, 0x52, 0x65, 0x73, 0x70, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x73, 0x6b, + 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x06, 0x74, 0x61, 0x73, 0x6b, 0x69, 0x64, + 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, 0x22, 0x32, 0x0a, 0x16, 0x53, 0x74, 0x6f, 0x6e, 0x65, 0x68, 0x65, 0x6e, 0x67, + 0x65, 0x52, 0x65, 0x73, 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x52, 0x65, 0x71, 0x12, 0x18, 0x0a, + 0x07, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, + 0x65, 0x76, 0x65, 0x6e, 0x74, 0x69, 0x64, 0x22, 0x39, 0x0a, 0x17, 0x53, 0x74, 0x6f, 0x6e, 0x65, + 0x68, 0x65, 0x6e, 0x67, 0x65, 0x52, 0x65, 0x73, 0x65, 0x74, 0x42, 0x75, 0x66, 0x66, 0x52, 0x65, + 0x73, 0x70, 0x12, 0x1e, 0x0a, 0x0a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x62, 0x75, 0x66, 0x66, + 0x18, 0x01, 0x20, 0x03, 0x28, 0x05, 0x52, 0x0a, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x62, 0x75, + 0x66, 0x66, 0x42, 0x06, 0x5a, 0x04, 0x2e, 0x3b, 0x70, 0x62, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x33, } var ( @@ -2024,7 +2019,7 @@ func file_stonehenge_stonehenge_msg_proto_rawDescGZIP() []byte { return file_stonehenge_stonehenge_msg_proto_rawDescData } -var file_stonehenge_stonehenge_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 41) +var file_stonehenge_stonehenge_msg_proto_msgTypes = make([]protoimpl.MessageInfo, 40) var file_stonehenge_stonehenge_msg_proto_goTypes = []interface{}{ (*StonehengeGetListReq)(nil), // 0: StonehengeGetListReq (*StonehengeGetListResp)(nil), // 1: StonehengeGetListResp @@ -2066,55 +2061,53 @@ var file_stonehenge_stonehenge_msg_proto_goTypes = []interface{}{ nil, // 37: StonehengeActivateTalentResp.TalentpropertyEntry nil, // 38: StonehengeWeekAwardResp.WeeklyrewardEntry nil, // 39: StonehengeTaskInfoResp.TaskEntry - nil, // 40: StonehengeTaskReceiveResp.TaskEntry - (*DBStonehenge)(nil), // 41: DBStonehenge - (*DBStoneBoss)(nil), // 42: DBStoneBoss - (*RoomData)(nil), // 43: RoomData - (*BattleReport)(nil), // 44: BattleReport - (*UserAtno)(nil), // 45: UserAtno - (*BattleFormation)(nil), // 46: BattleFormation - (*BattleInfo)(nil), // 47: BattleInfo - (StonehengePrivilege)(0), // 48: StonehengePrivilege - (*DBStonehengeBook)(nil), // 49: DBStonehengeBook - (*UserAssets)(nil), // 50: UserAssets - (*BattleRole)(nil), // 51: BattleRole + (*DBStonehenge)(nil), // 40: DBStonehenge + (*DBStoneBoss)(nil), // 41: DBStoneBoss + (*RoomData)(nil), // 42: RoomData + (*BattleReport)(nil), // 43: BattleReport + (*UserAtno)(nil), // 44: UserAtno + (*BattleFormation)(nil), // 45: BattleFormation + (*BattleInfo)(nil), // 46: BattleInfo + (StonehengePrivilege)(0), // 47: StonehengePrivilege + (*DBStonehengeBook)(nil), // 48: DBStonehengeBook + (*UserAssets)(nil), // 49: UserAssets + (*BattleRole)(nil), // 50: BattleRole } var file_stonehenge_stonehenge_msg_proto_depIdxs = []int32{ - 41, // 0: StonehengeGetListResp.data:type_name -> DBStonehenge - 42, // 1: StonehengeGetListResp.boss:type_name -> DBStoneBoss + 40, // 0: StonehengeGetListResp.data:type_name -> DBStonehenge + 41, // 1: StonehengeGetListResp.boss:type_name -> DBStoneBoss 32, // 2: StonehengeEnterLevelResp.hero:type_name -> StonehengeEnterLevelResp.HeroEntry - 43, // 3: StonehengeEnterLevelResp.room:type_name -> RoomData - 43, // 4: StonehengeGotoRoomResp.room:type_name -> RoomData - 44, // 5: StonehengeEventReq.report:type_name -> BattleReport - 43, // 6: StonehengeEventResp.room:type_name -> RoomData - 45, // 7: StonehengeEventResp.reward:type_name -> UserAtno + 42, // 3: StonehengeEnterLevelResp.room:type_name -> RoomData + 42, // 4: StonehengeGotoRoomResp.room:type_name -> RoomData + 43, // 5: StonehengeEventReq.report:type_name -> BattleReport + 42, // 6: StonehengeEventResp.room:type_name -> RoomData + 44, // 7: StonehengeEventResp.reward:type_name -> UserAtno 33, // 8: StonehengeEventResp.hero:type_name -> StonehengeEventResp.HeroEntry 34, // 9: StonehengeEventResp.userbuff:type_name -> StonehengeEventResp.UserbuffEntry - 43, // 10: StonehengeGetRoomInfoResp.room:type_name -> RoomData - 41, // 11: StonehengeFinishResp.data:type_name -> DBStonehenge - 45, // 12: StonehengeFinishResp.reward:type_name -> UserAtno - 46, // 13: StonehengeBattleReq.battle:type_name -> BattleFormation - 47, // 14: StonehengeBattleResp.info:type_name -> BattleInfo - 43, // 15: StonehengeStoryResp.room:type_name -> RoomData + 42, // 10: StonehengeGetRoomInfoResp.room:type_name -> RoomData + 40, // 11: StonehengeFinishResp.data:type_name -> DBStonehenge + 44, // 12: StonehengeFinishResp.reward:type_name -> UserAtno + 45, // 13: StonehengeBattleReq.battle:type_name -> BattleFormation + 46, // 14: StonehengeBattleResp.info:type_name -> BattleInfo + 42, // 15: StonehengeStoryResp.room:type_name -> RoomData 35, // 16: StonehengeStoreResp.shop:type_name -> StonehengeStoreResp.ShopEntry - 43, // 17: StonehengeStoreResp.room:type_name -> RoomData + 42, // 17: StonehengeStoreResp.room:type_name -> RoomData 36, // 18: StonehengeActivateTalentResp.talent:type_name -> StonehengeActivateTalentResp.TalentEntry 37, // 19: StonehengeActivateTalentResp.talentproperty:type_name -> StonehengeActivateTalentResp.TalentpropertyEntry - 48, // 20: StonehengeActivateTalentResp.privilege:type_name -> StonehengePrivilege - 49, // 21: StonehengeBookInfoResp.info:type_name -> DBStonehengeBook - 50, // 22: StonehengeBookAwardResp.award:type_name -> UserAssets + 47, // 20: StonehengeActivateTalentResp.privilege:type_name -> StonehengePrivilege + 48, // 21: StonehengeBookInfoResp.info:type_name -> DBStonehengeBook + 49, // 22: StonehengeBookAwardResp.award:type_name -> UserAssets 38, // 23: StonehengeWeekAwardResp.weeklyreward:type_name -> StonehengeWeekAwardResp.WeeklyrewardEntry - 50, // 24: StonehengeWeekAwardResp.award:type_name -> UserAssets + 49, // 24: StonehengeWeekAwardResp.award:type_name -> UserAssets 39, // 25: StonehengeTaskInfoResp.task:type_name -> StonehengeTaskInfoResp.TaskEntry - 40, // 26: StonehengeTaskReceiveResp.task:type_name -> StonehengeTaskReceiveResp.TaskEntry - 50, // 27: StonehengeTaskReceiveResp.award:type_name -> UserAssets - 51, // 28: StonehengeEnterLevelResp.HeroEntry.value:type_name -> BattleRole - 51, // 29: StonehengeEventResp.HeroEntry.value:type_name -> BattleRole - 30, // [30:30] is the sub-list for method output_type - 30, // [30:30] is the sub-list for method input_type - 30, // [30:30] is the sub-list for extension type_name - 30, // [30:30] is the sub-list for extension extendee - 0, // [0:30] is the sub-list for field type_name + 49, // 26: StonehengeTaskReceiveResp.award:type_name -> UserAssets + 50, // 27: StonehengeEnterLevelResp.HeroEntry.value:type_name -> BattleRole + 50, // 28: StonehengeEventResp.HeroEntry.value:type_name -> BattleRole + 29, // [29:29] is the sub-list for method output_type + 29, // [29:29] is the sub-list for method input_type + 29, // [29:29] is the sub-list for extension type_name + 29, // [29:29] is the sub-list for extension extendee + 0, // [0:29] is the sub-list for field type_name } func init() { file_stonehenge_stonehenge_msg_proto_init() } @@ -2518,7 +2511,7 @@ func file_stonehenge_stonehenge_msg_proto_init() { GoPackagePath: reflect.TypeOf(x{}).PkgPath(), RawDescriptor: file_stonehenge_stonehenge_msg_proto_rawDesc, NumEnums: 0, - NumMessages: 41, + NumMessages: 40, NumExtensions: 0, NumServices: 0, },