This commit is contained in:
liwei1dao 2023-11-02 10:48:22 +08:00
commit 5d77d749b5
10 changed files with 5276 additions and 849 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -241,7 +241,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
}
if this.player1.Energy >= conf.Skillload {
this.player1.Energy = 0 // 清零
if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
if _, m := this.chessboard.SkillUp(req.Curid, color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
szMap = append(szMap, m...)
} else {
szMap = append(szMap, &pb.MapData{
@ -273,7 +273,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
}
if this.player2.Energy >= conf.Skillload {
this.player2.Energy = 0 // 清零
if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
if _, m := this.chessboard.SkillUp(0, color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
szMap = append(szMap, m...)
} else {
szMap = append(szMap, &pb.MapData{

View File

@ -89,11 +89,11 @@ func (this *MapData) SwapGirde(oldId, newId int32) (bSwap bool) {
func (this *MapData) Debugf() {
fmt.Printf("================\n")
//var v int
var v int
for index := Width - 1; index >= 0; index-- {
for j := 0; j < Height; j++ {
// v = index + j*7
fmt.Printf("%d:%d ", this.Plat[index+j*Height].Oid, this.Plat[index+j*Height].Cid)
v = index + j*7
fmt.Printf("%d:%d ", v, this.Plat[index+j*Height].Cid)
}
fmt.Printf("\n")
@ -372,7 +372,7 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc
} else if s == FiveType { // 随机消除
// 获取配置
if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil {
if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 {
if xc, _ := this.SkillUp(0, color, 1, c.Value, false); len(xc) > 0 {
//szMap = append(szMap, sz...)
for key := range xc {
x[key] = struct{}{}
@ -499,56 +499,110 @@ func (this *MapData) AiSwapGirde() (szMap []*pb.MapData, oid1 int32, oid2 int32,
}
// 释放技能 技能id 和参数
func (this *MapData) SkillUp(color int32, skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) {
func (this *MapData) SkillUp(pos int32, color int32, skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) {
var (
skillScore int32 // 技能获得的分数
skillEnergy int32 // 技能获得的能量
ids []int
)
x = make(map[int]struct{})
if skillid == 1 { // 随机消除盘面上X个方块
x = make(map[int]struct{})
ids := utils.RandomNumbers(0, Total-1, int(value))
for _, id := range ids {
s := this.Plat[id].Special
if s != 0 {
if s == FourUType { // 4消上下类型
for i := 0; i < Height; i++ { // id 的一条线位置
x[(id/Width)*Height+i] = struct{}{}
}
} else if s == FourLType { // 左右类型
for i := 0; i < Width; i++ { // id 的一条线位置
x[id%Height+i*Width] = struct{}{}
}
} else if s == FiveType { // 随机消除
// 获取配置
if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil {
if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 { // 递归调用
for key := range xc {
x[key] = struct{}{}
}
ids = utils.RandomNumbers(0, Total-1, int(value))
} else if skillid == 4 { // 找到pos 位置的所有方块
x := int(pos / Width)
y := int(pos % Height)
for i := 1; i < 7; i++ {
if x-i >= 0 && y+i < Height { // 左上
ids = append(ids, (x-i)*Width+(y+i))
}
if x-i >= 0 && y-i >= 0 { // 左下
ids = append(ids, (x-i)*Width+(y-i))
}
if x+i < Width && y+i < Height { // 右上
ids = append(ids, (x+i)*Width+(y+i))
}
if x+i < Width && y-i >= 0 { // 右下
ids = append(ids, (x+i)*Width+(y-i))
}
}
} else if skillid == 3 || skillid == 5 { //选中一个方块,消除周围一圈
x := int(pos / Width)
y := int(pos % Height)
if x-1 >= 0 { // 左
ids = append(ids, (x-1)*Width+(y))
}
if y-1 >= 0 { // 下
ids = append(ids, (x)*Width+(y-1))
}
if y+1 < Height { // 上
ids = append(ids, (x)*Width+(y+1))
}
if x+1 < Width { // 右
ids = append(ids, (x+1)*Width+(y))
}
if x-1 >= 0 && y+1 < Height { // 左上
ids = append(ids, (x-1)*Width+(y+1))
}
if x-1 >= 0 && y-1 >= 0 { // 左下
ids = append(ids, (x-1)*Width+(y-1))
}
if x+1 < Width && y+1 < Height { // 右上
ids = append(ids, (x+1)*Width+(y+1))
}
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)
}
}
for _, id := range ids {
s := this.Plat[id].Special
if s != 0 {
if s == FourUType { // 4消上下类型
for i := 0; i < Height; i++ { // id 的一条线位置
x[(id/Width)*Height+i] = struct{}{}
}
} else if s == FourLType { // 左右类型
for i := 0; i < Width; i++ { // id 的一条线位置
x[id%Height+i*Width] = struct{}{}
}
} else if s == FiveType { // 随机消除
// 获取配置
if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil {
if xc, _ := this.SkillUp(pos, color, 1, c.Value, false); len(xc) > 0 { // 递归调用
for key := range xc {
x[key] = struct{}{}
}
}
}
}
x[id] = struct{}{}
}
if bDrop {
for key := range x {
if this.Plat[key].Color == color {
skillEnergy += 1
}
skillScore += this.Plat[key].Score
this.Plat[key] = &pb.GirdeData{}
x[id] = struct{}{}
}
if bDrop {
for key := range x {
if this.Plat[key].Color == color {
skillEnergy += 1
}
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalatData(),
CurSocre: skillScore,
CurEnergy: skillEnergy,
})
if list, _ := this.CheckMap(color, false); len(list) > 0 {
szMap = append(szMap, list...)
}
skillScore += this.Plat[key].Score
this.Plat[key] = &pb.GirdeData{}
}
if this.DropGirde() {
szMap = append(szMap, &pb.MapData{
Data: this.GetPalatData(),
CurSocre: skillScore,
CurEnergy: skillEnergy,
})
if list, _ := this.CheckMap(color, false); len(list) > 0 {
szMap = append(szMap, list...)
}
}
}

View File

@ -84,6 +84,8 @@ func Test_Main(t *testing.T) {
}()
m := new(entertainment.MapData)
m.InitMap(nil)
m.Debugf()
m.SkillUp(24, 1, 3, 7, true)
// m.SetMap()
b := m.CheckAndRefreshPlat()
fmt.Printf("xxxx%v", b)
@ -112,7 +114,7 @@ func Test_Main(t *testing.T) {
// if bSwap, m := m.AiSwapGirde(); bSwap {
// szMap = append(szMap, m...)
// }
m.SkillUp(1, 1, 7, true)
m.SkillUp(0, 1, 2, 7, true)
m.SwapGirde(1, 8)
//m.CheckMap(1)

View File

@ -20,6 +20,8 @@ type GameBlockData struct {
Icon string
Icon2 string
Weight int32
Effect string
Pointeffect string
Score int32
Type int32
Value int32
@ -54,6 +56,8 @@ func (_v *GameBlockData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; if _v.Icon, _ok_ = _buf["icon"].(string); !_ok_ { err = errors.New("icon error"); return } }
{ var _ok_ bool; if _v.Icon2, _ok_ = _buf["icon2"].(string); !_ok_ { err = errors.New("icon2 error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["weight"].(float64); !_ok_ { err = errors.New("weight error"); return }; _v.Weight = int32(_tempNum_) }
{ var _ok_ bool; if _v.Effect, _ok_ = _buf["effect"].(string); !_ok_ { err = errors.New("effect error"); return } }
{ var _ok_ bool; if _v.Pointeffect, _ok_ = _buf["pointeffect"].(string); !_ok_ { err = errors.New("pointeffect error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["score"].(float64); !_ok_ { err = errors.New("score error"); return }; _v.Score = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["type"].(float64); !_ok_ { err = errors.New("type error"); return }; _v.Type = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["value"].(float64); !_ok_ { err = errors.New("value error"); return }; _v.Value = int32(_tempNum_) }

View File

@ -18,6 +18,7 @@ type GamePlayerInfor_overviewData struct {
Playerhead string
Tujing []int32
Url string
Tips int32
Resources string
Vague string
PvpAnimator string
@ -54,6 +55,7 @@ func (_v *GamePlayerInfor_overviewData)Deserialize(_buf map[string]interface{})
}
{ var _ok_ bool; if _v.Url, _ok_ = _buf["url"].(string); !_ok_ { err = errors.New("url error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["tips"].(float64); !_ok_ { err = errors.New("tips error"); return }; _v.Tips = int32(_tempNum_) }
{ var _ok_ bool; if _v.Resources, _ok_ = _buf["resources"].(string); !_ok_ { err = errors.New("resources error"); return } }
{ var _ok_ bool; if _v.Vague, _ok_ = _buf["vague"].(string); !_ok_ { err = errors.New("vague error"); return } }
{ var _ok_ bool; if _v.PvpAnimator, _ok_ = _buf["pvpAnimator"].(string); !_ok_ { err = errors.New("pvpAnimator error"); return } }

View File

@ -15,9 +15,10 @@ type GameRepeatAllData struct {
Model string
Num int32
Thing string
Upthing int32
Detailthing int32
Cdtxt string
Type []int32
Typeone []int32
Typetwo []*Gameatn
Cd string
Cdtime int32
Reward []*Gameatn
}
@ -33,9 +34,49 @@ func (_v *GameRepeatAllData)Deserialize(_buf map[string]interface{}) (err error)
{ var _ok_ bool; if _v.Model, _ok_ = _buf["model"].(string); !_ok_ { err = errors.New("model error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["num"].(float64); !_ok_ { err = errors.New("num error"); return }; _v.Num = int32(_tempNum_) }
{ var _ok_ bool; if _v.Thing, _ok_ = _buf["thing"].(string); !_ok_ { err = errors.New("thing error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["upthing"].(float64); !_ok_ { err = errors.New("upthing error"); return }; _v.Upthing = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["detailthing"].(float64); !_ok_ { err = errors.New("detailthing error"); return }; _v.Detailthing = int32(_tempNum_) }
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["cdtxt"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Cdtxt error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Cdtxt, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["type"].([]interface{}); !_ok_ { err = errors.New("type error"); return }
_v.Type = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
_v.Type = append(_v.Type, _list_v_)
}
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["typeone"].([]interface{}); !_ok_ { err = errors.New("typeone error"); return }
_v.Typeone = make([]int32, 0, len(_arr_))
for _, _e_ := range _arr_ {
var _list_v_ int32
{ var _ok_ bool; var _x_ float64; if _x_, _ok_ = _e_.(float64); !_ok_ { err = errors.New("_list_v_ error"); return }; _list_v_ = int32(_x_) }
_v.Typeone = append(_v.Typeone, _list_v_)
}
}
{
var _arr_ []interface{}
var _ok_ bool
if _arr_, _ok_ = _buf["typetwo"].([]interface{}); !_ok_ { err = errors.New("typetwo error"); return }
_v.Typetwo = 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.Typetwo = append(_v.Typetwo, _list_v_)
}
}
{var _ok_ bool; var __json_text__ map[string]interface{}; if __json_text__, _ok_ = _buf["cd"].(map[string]interface{}) ; !_ok_ { err = errors.New("_v.Cd error"); return }; { var _ok_ bool; if _, _ok_ = __json_text__["key"].(string); !_ok_ { err = errors.New("key error"); return } }; { var _ok_ bool; if _v.Cd, _ok_ = __json_text__["text"].(string); !_ok_ { err = errors.New("text error"); return } } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["cdtime"].(float64); !_ok_ { err = errors.New("cdtime error"); return }; _v.Cdtime = int32(_tempNum_) }
{
var _arr_ []interface{}

View File

@ -16,7 +16,7 @@ type GameTDMonsterData struct {
MonsterSkillid int32
MonsterType int32
Model string
Multiple int32
Multiple float32
Width float32
Height float32
Hp int32
@ -39,7 +39,7 @@ func (_v *GameTDMonsterData)Deserialize(_buf map[string]interface{}) (err error)
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monster_skillid"].(float64); !_ok_ { err = errors.New("monster_skillid error"); return }; _v.MonsterSkillid = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["monster_type"].(float64); !_ok_ { err = errors.New("monster_type error"); return }; _v.MonsterType = int32(_tempNum_) }
{ var _ok_ bool; if _v.Model, _ok_ = _buf["model"].(string); !_ok_ { err = errors.New("model error"); return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["multiple"].(float64); !_ok_ { err = errors.New("multiple error"); return }; _v.Multiple = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["multiple"].(float64); !_ok_ { err = errors.New("multiple error"); return }; _v.Multiple = float32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["width"].(float64); !_ok_ { err = errors.New("width error"); return }; _v.Width = float32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["height"].(float64); !_ok_ { err = errors.New("height error"); return }; _v.Height = float32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["hp"].(float64); !_ok_ { err = errors.New("hp error"); return }; _v.Hp = int32(_tempNum_) }

View File

@ -301,6 +301,7 @@ type GameGlobalData struct {
ConsumePveTime int32
ConsumeRounds int32
ConsumeIntegralnums *Gameatn
TdHp int32
}
const TypeId_GameGlobalData = 477542761
@ -1185,6 +1186,7 @@ func (_v *GameGlobalData)Deserialize(_buf map[string]interface{}) (err error) {
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["consume_pve_time"].(float64); !_ok_ { err = errors.New("consume_pve_time error"); return }; _v.ConsumePveTime = int32(_tempNum_) }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["consume_rounds"].(float64); !_ok_ { err = errors.New("consume_rounds error"); return }; _v.ConsumeRounds = int32(_tempNum_) }
{ var _ok_ bool; var _x_ map[string]interface{}; if _x_, _ok_ = _buf["consume_integralnums"].(map[string]interface{}); !_ok_ { err = errors.New("consume_integralnums error"); return }; if _v.ConsumeIntegralnums, err = DeserializeGameatn(_x_); err != nil { return } }
{ var _ok_ bool; var _tempNum_ float64; if _tempNum_, _ok_ = _buf["td_Hp"].(float64); !_ok_ { err = errors.New("td_Hp error"); return }; _v.TdHp = int32(_tempNum_) }
return
}