Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
2d0d9aa0c1
@ -145,13 +145,6 @@ func (this *Room) AiOperator() {
|
||||
this.player2.Ps--
|
||||
// 交换元素
|
||||
szMap, oid1, oid2, bAddPs = this.chessboard.AiSwapGirde()
|
||||
for _, v := range szMap { //
|
||||
this.player2.Energy += v.CurEnergy
|
||||
v.CurEnergy = this.player2.Energy
|
||||
curScore += v.CurSocre
|
||||
this.player2.Score += v.CurSocre
|
||||
v.CurSocre = this.player2.Score
|
||||
}
|
||||
|
||||
if bAddPs {
|
||||
this.player2.Ps++
|
||||
@ -165,7 +158,7 @@ func (this *Room) AiOperator() {
|
||||
this.round++
|
||||
}
|
||||
// 校验下次是不是消除
|
||||
if this.chessboard.CheckAndRefreshPlat() {
|
||||
if !this.chessboard.CheckAndRefreshPlat() {
|
||||
this.chessboard.RedsetPlatData()
|
||||
szMap = append(szMap, &pb.MapData{
|
||||
Data: this.chessboard.GetPalatData(),
|
||||
@ -247,7 +240,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(conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
|
||||
if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
|
||||
szMap = append(szMap, m...)
|
||||
} else {
|
||||
szMap = append(szMap, &pb.MapData{
|
||||
@ -279,7 +272,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(conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
|
||||
if _, m := this.chessboard.SkillUp(color, conf.Skilleffect, conf.Skillvalue, true); len(m) > 0 {
|
||||
szMap = append(szMap, m...)
|
||||
} else {
|
||||
szMap = append(szMap, &pb.MapData{
|
||||
@ -342,7 +335,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
}
|
||||
|
||||
// 校验下次是不是消除
|
||||
if this.chessboard.CheckAndRefreshPlat() {
|
||||
if !this.chessboard.CheckAndRefreshPlat() {
|
||||
this.chessboard.RedsetPlatData()
|
||||
szMap = append(szMap, &pb.MapData{
|
||||
Data: this.chessboard.GetPalatData(),
|
||||
|
@ -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 ", v, this.Plat[index+j*Height].Cid)
|
||||
// v = index + j*7
|
||||
fmt.Printf("%d:%d ", this.Plat[index+j*Height].Oid, this.Plat[index+j*Height].Cid)
|
||||
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
@ -351,7 +351,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(1, c.Value, false); len(xc) > 0 {
|
||||
if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 {
|
||||
//szMap = append(szMap, sz...)
|
||||
for key := range xc {
|
||||
x[key] = struct{}{}
|
||||
@ -379,7 +379,7 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc
|
||||
CurSocre: curScore,
|
||||
CurEnergy: energy,
|
||||
})
|
||||
this.Debugf()
|
||||
|
||||
}
|
||||
|
||||
// 检查掉落
|
||||
@ -478,7 +478,12 @@ func (this *MapData) AiSwapGirde() (szMap []*pb.MapData, oid1 int32, oid2 int32,
|
||||
}
|
||||
|
||||
// 释放技能 技能id 和参数
|
||||
func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) {
|
||||
func (this *MapData) SkillUp(color int32, skillid int32, value int32, bDrop bool) (x map[int]struct{}, szMap []*pb.MapData) {
|
||||
var (
|
||||
skillScore int32 // 技能获得的分数
|
||||
skillEnergy int32 // 技能获得的能量
|
||||
)
|
||||
|
||||
if skillid == 1 { // 随机消除盘面上X个方块
|
||||
x = make(map[int]struct{})
|
||||
ids := utils.RandomNumbers(0, Total-1, int(value))
|
||||
@ -496,7 +501,7 @@ func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int]
|
||||
} else if s == FiveType { // 随机消除
|
||||
// 获取配置
|
||||
if c, _ := this.module.configure.GetGameBlock(this.Plat[id].Color, FiveType); c != nil {
|
||||
if xc, _ := this.SkillUp(1, c.Value, false); len(xc) > 0 { // 递归调用
|
||||
if xc, _ := this.SkillUp(color, 1, c.Value, false); len(xc) > 0 { // 递归调用
|
||||
for key := range xc {
|
||||
x[key] = struct{}{}
|
||||
}
|
||||
@ -508,10 +513,21 @@ func (this *MapData) SkillUp(skillid int32, value int32, bDrop bool) (x map[int]
|
||||
}
|
||||
if bDrop {
|
||||
for key := range x {
|
||||
if this.Plat[key].Color == color {
|
||||
skillEnergy += 1
|
||||
}
|
||||
skillScore += this.Plat[key].Score
|
||||
this.Plat[key] = &pb.GirdeData{}
|
||||
}
|
||||
if this.DropGirde() {
|
||||
szMap, _ = this.CheckMap(1, false)
|
||||
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...)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -529,13 +545,13 @@ func (this *MapData) CheckInitPlat() {
|
||||
|
||||
func (this *MapData) SetMap() {
|
||||
sz2 := []int32{
|
||||
1, 1, 2, 5, 1, 5, 2,
|
||||
3, 2, 3, 1, 2, 4, 4,
|
||||
2, 1, 1, 3, 6, 4, 1,
|
||||
4, 1, 1, 4, 3, 6, 3,
|
||||
4, 3, 4, 5, 1, 6, 1,
|
||||
5, 4, 2, 5, 3, 3, 1,
|
||||
4, 1, 5, 3, 2, 3, 4,
|
||||
1, 4, 2, 5, 4, 5, 2,
|
||||
3, 2, 3, 1, 2, 1, 4,
|
||||
2, 1, 5, 4, 6, 4, 1,
|
||||
3, 1, 3, 5, 2, 6, 3,
|
||||
4, 5, 4, 2, 4, 1, 1,
|
||||
5, 3, 1, 5, 3, 3, 4,
|
||||
4, 2, 4, 1, 2, 3, 4,
|
||||
}
|
||||
var pos int
|
||||
for index := Width - 1; index >= 0; index-- {
|
||||
@ -663,8 +679,16 @@ func (this *MapData) SetIndelibilityPlat() {
|
||||
k2 := this.Plat[k+1].Color
|
||||
k3 := this.Plat[k+2].Color
|
||||
if k1 == k2 && k2 == k3 {
|
||||
this.Plat[k+2].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+2].Color = (k3+1)%5 + 1
|
||||
if this.Plat[k+2].Special == 0 {
|
||||
this.Plat[k+2].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+2].Color = (k3+1)%5 + 1
|
||||
} else if this.Plat[k+1].Special == 0 {
|
||||
this.Plat[k+1].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+1].Color = (k3+1)%5 + 1
|
||||
} else if this.Plat[k].Special == 0 {
|
||||
this.Plat[k].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k].Color = (k3+1)%5 + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -674,8 +698,16 @@ func (this *MapData) SetIndelibilityPlat() {
|
||||
k3 := this.Plat[k+2*Width].Color
|
||||
|
||||
if k1 == k2 && k2 == k3 {
|
||||
this.Plat[k+2*Width].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+2*Width].Color = (k3+1)%5 + 1
|
||||
if this.Plat[k+2*Width].Special == 0 {
|
||||
this.Plat[k+2*Width].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+2*Width].Color = (k3+1)%5 + 1
|
||||
} else if this.Plat[k+Width].Special == 0 {
|
||||
this.Plat[k+Width].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k+Width].Color = (k3+1)%5 + 1
|
||||
} else if this.Plat[k].Special == 0 {
|
||||
this.Plat[k].Cid = (k3+1)%5 + 1
|
||||
this.Plat[k].Color = (k3+1)%5 + 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -683,7 +715,6 @@ func (this *MapData) SetIndelibilityPlat() {
|
||||
|
||||
// 重新洗牌
|
||||
func (this *MapData) RedsetPlatData() {
|
||||
|
||||
for i := 0; i < Total-1; i++ {
|
||||
targetId := comm.GetRandNum(0, Total-1)
|
||||
if i == int(targetId) {
|
||||
@ -694,7 +725,6 @@ func (this *MapData) RedsetPlatData() {
|
||||
this.Plat[i] = this.Plat[targetId]
|
||||
this.Plat[targetId] = tmp
|
||||
}
|
||||
this.Debugf()
|
||||
|
||||
this.SetIndelibilityPlat()
|
||||
}
|
||||
|
@ -84,7 +84,7 @@ func Test_Main(t *testing.T) {
|
||||
}()
|
||||
m := new(entertainment.MapData)
|
||||
m.InitMap(nil)
|
||||
m.SetMap()
|
||||
// m.SetMap()
|
||||
b := m.CheckAndRefreshPlat()
|
||||
fmt.Printf("xxxx%v", b)
|
||||
m.RedsetPlatData()
|
||||
@ -112,7 +112,7 @@ func Test_Main(t *testing.T) {
|
||||
// if bSwap, m := m.AiSwapGirde(); bSwap {
|
||||
// szMap = append(szMap, m...)
|
||||
// }
|
||||
m.SkillUp(1, 7, true)
|
||||
m.SkillUp(1, 1, 7, true)
|
||||
m.SwapGirde(1, 8)
|
||||
//m.CheckMap(1)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user