Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
4139e2e36c
@ -823,7 +823,7 @@
|
||||
"HeroCount": 5,
|
||||
"readyScene": "scenesfight_role_interface_02",
|
||||
"battleScenes": [
|
||||
"bossfight_spinymandrilla_03"
|
||||
"bossfight_spinymandrilla_02"
|
||||
],
|
||||
"BGMusic": "",
|
||||
"LoadingId": 0,
|
||||
|
@ -776,7 +776,7 @@
|
||||
"n": 0
|
||||
},
|
||||
"fight_ps": 3,
|
||||
"player_bodychange": 20010,
|
||||
"player_bodychange": 0,
|
||||
"mryl_reward": [
|
||||
{
|
||||
"a": "attr",
|
||||
|
@ -4411,7 +4411,7 @@
|
||||
"OverlayTimes": 0,
|
||||
"SameID": false,
|
||||
"golbalbufficon": "",
|
||||
"buffIcon": "ty_zd_buff_z006",
|
||||
"buffIcon": "",
|
||||
"buffeffect": "",
|
||||
"buffpos": "根节点",
|
||||
"forbidFloat": 0
|
||||
|
@ -1,27 +1,74 @@
|
||||
package entertainment
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/modules"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"sync"
|
||||
|
||||
"go_dreamfactory/lego/core"
|
||||
)
|
||||
|
||||
const (
|
||||
dragon_trainlv = "game_trainlv.json"
|
||||
dragon_play = "game_dragonplay.json"
|
||||
game_buzkashimount = "game_buzkashimount.json"
|
||||
game_dragonlvitem = "game_dragonlvitem.json"
|
||||
game_block = "game_block.json"
|
||||
)
|
||||
|
||||
// /配置管理组件
|
||||
type configureComp struct {
|
||||
modules.MCompConfigure
|
||||
module *Entertainment
|
||||
lock sync.RWMutex
|
||||
block map[int32]*cfg.GameBlockData
|
||||
}
|
||||
|
||||
// 组件初始化接口
|
||||
func (this *configureComp) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
err = this.MCompConfigure.Init(service, module, comp, options)
|
||||
this.module = module.(*Entertainment)
|
||||
err = this.LoadMultiConfigure(map[string]interface{}{
|
||||
game_block: cfg.NewGameBlock,
|
||||
})
|
||||
|
||||
configure.RegisterConfigure(game_block, cfg.NewGameBlock, this.LoadGameBlock)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) LoadGameBlock() {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.GameBlock
|
||||
err error
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_block); err != nil {
|
||||
this.module.Errorln(err)
|
||||
return
|
||||
}
|
||||
block := make(map[int32]*cfg.GameBlockData)
|
||||
if configure, ok = v.(*cfg.GameBlock); ok {
|
||||
for _, v := range configure.GetDataList() {
|
||||
key := v.Color<<8 + v.Type
|
||||
block[key] = v
|
||||
}
|
||||
}
|
||||
this.lock.Lock()
|
||||
this.block = block
|
||||
this.lock.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) GetGameBlock(color int32, iType int32) (conf *cfg.GameBlockData, err error) {
|
||||
var (
|
||||
ok bool
|
||||
key int32
|
||||
)
|
||||
key = color<<8 + iType
|
||||
this.lock.RLock()
|
||||
defer this.lock.RUnlock()
|
||||
if conf, ok = this.block[key]; !ok {
|
||||
err = comm.NewNotFoundConfErr(string(this.module.GetType()), game_block, fmt.Sprintf("color:%d,itype:%d", color, key))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
@ -12,9 +12,10 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MaxPs = 2 // 最大体力
|
||||
MaxRound = 7 // 最大回合数
|
||||
MaxTime = 180 // 游戏操作时间
|
||||
MaxPs = 2 // 最大体力
|
||||
MaxRound = 7 // 最大回合数
|
||||
MaxTime = 1800 // 游戏操作时间
|
||||
AITime = 4 // AI延迟操作时间操作时间 随机+-3
|
||||
)
|
||||
|
||||
//游戏房间
|
||||
@ -54,7 +55,7 @@ func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
Data: this.chessboard.Plat,
|
||||
})
|
||||
//this.module.Debugf("超时%d", configure.Now().Unix())
|
||||
if err := this.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
if err := this.module.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
Mpadata: szMap,
|
||||
Power: this.power,
|
||||
Score: 0,
|
||||
@ -68,7 +69,7 @@ func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
|
||||
func (this *Room) InitRoom(module *Entertainment, s1 comm.IUserSession, s2 comm.IUserSession, p1 *pb.PlayerData, p2 *pb.PlayerData) *Room {
|
||||
this.chessboard = new(MapData)
|
||||
this.chessboard.InitMap() // 初始化棋盘
|
||||
this.chessboard.InitMap(module) // 初始化棋盘
|
||||
|
||||
this.szSession = append(this.szSession, s1.Clone())
|
||||
if p2.Uid != "999" { // 是否是机器人
|
||||
@ -103,6 +104,7 @@ func (this *Room) AiTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
if this.aiTimer != nil {
|
||||
timewheel.Remove(this.aiTimer)
|
||||
}
|
||||
|
||||
// 交换元素
|
||||
bSwap := this.chessboard.AiSwapGirde() // 交换格子
|
||||
if !bSwap {
|
||||
@ -123,7 +125,7 @@ func (this *Room) AiTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
}
|
||||
this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut) // 开启新的定时器
|
||||
// 广播消息
|
||||
if err := this.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
if err := this.module.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
Mpadata: szMap,
|
||||
Power: this.power,
|
||||
Score: curScore,
|
||||
@ -177,7 +179,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
if this.aiTimer != nil {
|
||||
timewheel.Remove(this.aiTimer)
|
||||
}
|
||||
this.aiTimer = timewheel.Add(time.Second*MaxTime, this.AiTimeOut)
|
||||
this.aiTimer = timewheel.Add(time.Second*AITime, this.AiTimeOut)
|
||||
}
|
||||
this.round++
|
||||
}
|
||||
@ -195,7 +197,7 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
}
|
||||
|
||||
// 广播消息
|
||||
if err := this.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
if err := this.module.SendMsgToSession(string(this.module.GetType()), "operatorrst", &pb.EntertainOperatorRstPush{
|
||||
Mpadata: szMap,
|
||||
Power: this.power,
|
||||
Score: curScore,
|
||||
@ -206,9 +208,22 @@ func (this *Room) ReceiveMessage(session comm.IUserSession, stype string, msg pr
|
||||
this.Errorln(err)
|
||||
}
|
||||
case "ready":
|
||||
this.StartGame()
|
||||
if len(this.szSession) == 1 { // AI对战的话直接开始游戏
|
||||
if err := this.module.SendMsgToSession(string(this.module.GetType()), "startgame", &pb.EntertainStartGamePush{
|
||||
User1: this.player1,
|
||||
User2: this.player2,
|
||||
Mpadata: &pb.MapData{
|
||||
Data: this.chessboard.Plat,
|
||||
},
|
||||
Power: this.power,
|
||||
Round: this.round,
|
||||
}, session); err != nil {
|
||||
this.Errorln(err)
|
||||
}
|
||||
|
||||
this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut)
|
||||
}
|
||||
|
||||
this.operatetimer = timewheel.Add(time.Second*MaxTime, this.operateTimeOut)
|
||||
}
|
||||
|
||||
return
|
||||
@ -224,7 +239,7 @@ func (this *Room) Opertor(uid string, iType int32, old int32, new int32) (errdat
|
||||
|
||||
func (this *Room) StartGame() (errdata *pb.ErrorData) {
|
||||
|
||||
if err := this.SendMsgToSession(string(this.module.GetType()), "startgame", &pb.EntertainStartGamePush{
|
||||
if err := this.module.SendMsgToSession(string(this.module.GetType()), "startgame", &pb.EntertainStartGamePush{
|
||||
User1: this.player1,
|
||||
User2: this.player2,
|
||||
Mpadata: &pb.MapData{
|
||||
@ -246,7 +261,7 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
|
||||
if this.operatetimer != nil {
|
||||
timewheel.Remove(this.operatetimer)
|
||||
}
|
||||
this.SendMsgToSession(string(this.module.GetType()), "gameover", &pb.EntertainGameOverPush{
|
||||
this.module.SendMsgToSession(string(this.module.GetType()), "gameover", &pb.EntertainGameOverPush{
|
||||
User1: this.player1,
|
||||
User2: this.player2,
|
||||
Mpadata: &pb.MapData{
|
||||
|
@ -3,7 +3,6 @@ package entertainment
|
||||
import (
|
||||
"crypto/rand"
|
||||
"fmt"
|
||||
"go_dreamfactory/lego/core"
|
||||
"go_dreamfactory/pb"
|
||||
"math/big"
|
||||
)
|
||||
@ -12,6 +11,10 @@ const (
|
||||
Width = 7
|
||||
Height = 7
|
||||
Total = Width * Height
|
||||
|
||||
FiveType = 3 // 5消类型
|
||||
FourUType = 1 // 4消上下类型
|
||||
FourLType = 2 // 4消左右类型
|
||||
)
|
||||
|
||||
// type Girde struct {
|
||||
@ -31,17 +34,9 @@ type Girde struct {
|
||||
|
||||
//地图数据
|
||||
type MapData struct {
|
||||
//Data map[int32]*pb.GirdeData // 地图数据
|
||||
|
||||
Plat []*pb.GirdeData // 地图
|
||||
|
||||
oid int32 // 唯一id
|
||||
}
|
||||
|
||||
func (this *MapData) Init(service core.IService, module core.IModule, comp core.IModuleComp, options core.IModuleOptions) (err error) {
|
||||
// this.Data = make(map[int32]*pb.GirdeData, Width*Height)
|
||||
this.Plat = make([]*pb.GirdeData, Width*Height)
|
||||
return
|
||||
Plat []*pb.GirdeData // 地图
|
||||
oid int32 // 唯一id
|
||||
module *Entertainment
|
||||
}
|
||||
|
||||
// 1~6随机一个数
|
||||
@ -59,20 +54,19 @@ func (this *MapData) CreateGride(index int32) *pb.GirdeData {
|
||||
Color: t,
|
||||
Cid: GetRandType(),
|
||||
Score: 1,
|
||||
Special: 1,
|
||||
Special: 0,
|
||||
}
|
||||
}
|
||||
|
||||
// 初始化地图数据
|
||||
func (this *MapData) InitMap() {
|
||||
func (this *MapData) InitMap(module *Entertainment) {
|
||||
this.module = module
|
||||
this.oid = 1000 // 方便观察 从1000开始
|
||||
this.Plat = make([]*pb.GirdeData, Width*Height)
|
||||
for i := 0; i < Width*Height; i++ {
|
||||
|
||||
this.Plat[i] = this.CreateGride(int32(i)) //(int32(i/Width), int32(i%Height))
|
||||
this.Plat[i] = this.CreateGride(int32(i))
|
||||
}
|
||||
|
||||
//this.Debugf()
|
||||
this.SetMap() // 方便测试固定地图
|
||||
}
|
||||
|
||||
// 交换2个元素(参数 oid )
|
||||
@ -91,8 +85,6 @@ func (this *MapData) SwapGirde(oldId, newId int32) bool {
|
||||
this.Plat[newId] = this.Plat[oldId]
|
||||
this.Plat[oldId] = tmp
|
||||
}
|
||||
|
||||
this.Debugf()
|
||||
return bSwap
|
||||
}
|
||||
|
||||
@ -111,27 +103,22 @@ func (this *MapData) SetMap() {
|
||||
for j := 0; j < Height; j++ {
|
||||
this.Plat[index+j*Height].Color = sz2[pos]
|
||||
pos++
|
||||
//fmt.Printf(" x:%d y:%d c:%d ", this.Plat[index+j*7].X, this.Plat[index+j*7].Y, this.Plat[index+j*7].Color)
|
||||
//fmt.Printf("%d ", this.Plat[index+j*7].Color)
|
||||
}
|
||||
//fmt.Printf("\n")
|
||||
}
|
||||
this.Debugf()
|
||||
}
|
||||
func (this *MapData) Debugf() {
|
||||
fmt.Printf("================\n")
|
||||
for index := Width - 1; index >= 0; index-- {
|
||||
|
||||
for j := 0; j < Height; j++ {
|
||||
fmt.Printf("%d:%d ", this.Plat[index+j*Height].Oid, this.Plat[index+j*Height].Color)
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 检查5消
|
||||
func (this *MapData) Check5X() (bEliminate bool, score int32) {
|
||||
var xiaochu []int // 即将消除的key
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
continue
|
||||
@ -143,22 +130,21 @@ func (this *MapData) Check5X() (bEliminate bool, score int32) {
|
||||
k3 := this.Plat[k+2].Color
|
||||
k4 := this.Plat[k+3].Color
|
||||
k5 := this.Plat[k+4].Color
|
||||
if k5 == 0 || k2 == 0 || k3 == 0 || k4 == 0 {
|
||||
continue
|
||||
}
|
||||
if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 {
|
||||
score += this.Plat[k].Score
|
||||
score += this.Plat[k+1].Score
|
||||
score += this.Plat[k+2].Score
|
||||
score += this.Plat[k+3].Score
|
||||
score += this.Plat[k+4].Score
|
||||
this.Plat[k] = &pb.GirdeData{}
|
||||
this.Plat[k+1] = &pb.GirdeData{}
|
||||
this.Plat[k+2] = &pb.GirdeData{}
|
||||
this.Plat[k+3] = &pb.GirdeData{}
|
||||
this.Plat[k+4] = &pb.GirdeData{}
|
||||
bEliminate = true
|
||||
|
||||
if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 {
|
||||
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
conf, _ := this.module.configure.GetGameBlock(k1, FiveType)
|
||||
this.Plat[k+2] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 3, k + 4}...)
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
if k+4*Width < Total {
|
||||
@ -167,29 +153,59 @@ func (this *MapData) Check5X() (bEliminate bool, score int32) {
|
||||
k3 := this.Plat[k+2*Width].Color
|
||||
k4 := this.Plat[k+3*Width].Color
|
||||
k5 := this.Plat[k+4*Width].Color
|
||||
if k5 == 0 || k2 == 0 || k3 == 0 || k4 == 0 {
|
||||
continue
|
||||
}
|
||||
|
||||
if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 {
|
||||
score += this.Plat[k].Score
|
||||
score += this.Plat[k+Width].Score
|
||||
score += this.Plat[k+2*Width].Score
|
||||
score += this.Plat[k+3*Width].Score
|
||||
score += this.Plat[k+4*Width].Score
|
||||
this.Plat[k] = &pb.GirdeData{}
|
||||
this.Plat[k+Width] = &pb.GirdeData{}
|
||||
this.Plat[k+2*Width] = &pb.GirdeData{}
|
||||
this.Plat[k+3*Width] = &pb.GirdeData{}
|
||||
this.Plat[k+4*Width] = &pb.GirdeData{}
|
||||
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
conf, _ := this.module.configure.GetGameBlock(k1, FiveType)
|
||||
this.Plat[k+2*Width] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 3*Width, k + 4*Width}...)
|
||||
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
var next []int
|
||||
for _, id := range xiaochu {
|
||||
if s := this.Plat[id].Special; s != 0 {
|
||||
if s == FourUType { // 4消上下类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id/Height == i/Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
next = append(next, 1)
|
||||
} else if s == FourLType { // 左右类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id%Height == i%Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
} else if s == FiveType { // 随机消除
|
||||
|
||||
} else { // 普通类型 直接消除
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *MapData) Check4X() (bEliminate bool, score int32) {
|
||||
var xiaochu []int // 即将消除的key
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
continue
|
||||
@ -197,22 +213,25 @@ func (this *MapData) Check4X() (bEliminate bool, score int32) {
|
||||
x := int32(k % Height) // x
|
||||
|
||||
if x+3 < Height {
|
||||
k1 := this.Plat[x].Color
|
||||
k2 := this.Plat[x+1].Color
|
||||
k3 := this.Plat[x+2].Color
|
||||
k4 := this.Plat[x+3].Color
|
||||
if k2 == 0 || k3 == 0 || k4 == 0 {
|
||||
continue
|
||||
}
|
||||
k1 := this.Plat[k].Color
|
||||
k2 := this.Plat[k+1].Color
|
||||
k3 := this.Plat[k+2].Color
|
||||
k4 := this.Plat[k+3].Color
|
||||
|
||||
if k1 == k2 && k3 == k4 && k2 == k3 {
|
||||
score += this.Plat[x].Score
|
||||
score += this.Plat[x+1].Score
|
||||
score += this.Plat[x+2].Score
|
||||
score += this.Plat[x+3].Score
|
||||
this.Plat[x] = &pb.GirdeData{}
|
||||
this.Plat[x+1] = &pb.GirdeData{}
|
||||
this.Plat[x+2] = &pb.GirdeData{}
|
||||
this.Plat[x+3] = &pb.GirdeData{}
|
||||
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
conf, _ := this.module.configure.GetGameBlock(k1, FourUType) // 上下类型
|
||||
this.Plat[k+1] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
xiaochu = append(xiaochu, []int{k, k + 2, k + 3}...)
|
||||
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
@ -221,27 +240,59 @@ func (this *MapData) Check4X() (bEliminate bool, score int32) {
|
||||
k2 := this.Plat[k+Width].Color
|
||||
k3 := this.Plat[k+2*Width].Color
|
||||
k4 := this.Plat[k+3*Width].Color
|
||||
if k2 == 0 || k3 == 0 || k4 == 0 {
|
||||
continue
|
||||
}
|
||||
if k1 == k2 && k3 == k4 && k2 == k3 {
|
||||
score += this.Plat[k].Score
|
||||
score += this.Plat[k+Width].Score
|
||||
score += this.Plat[k+2*Width].Score
|
||||
score += this.Plat[k+3*Width].Score
|
||||
|
||||
this.Plat[k] = &pb.GirdeData{}
|
||||
this.Plat[k+Width] = &pb.GirdeData{}
|
||||
this.Plat[k+2*Width] = &pb.GirdeData{}
|
||||
this.Plat[k+3*Width] = &pb.GirdeData{}
|
||||
if k1 == k2 && k3 == k4 && k2 == k3 {
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
conf, _ := this.module.configure.GetGameBlock(k1, FourLType) // 左右类型
|
||||
this.Plat[k+1*Width] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
xiaochu = append(xiaochu, []int{k, k + 2*Width, k + 3*Width}...)
|
||||
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var next []int
|
||||
for _, id := range xiaochu {
|
||||
if s := this.Plat[id].Special; s != 0 {
|
||||
if s == FourUType { // 4消上下类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id/Height == i/Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
next = append(next, 1)
|
||||
} else if s == FourLType { // 左右类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id%Height == i%Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
} else if s == FiveType { // 随机消除
|
||||
|
||||
} else { // 普通类型 直接消除
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *MapData) Check3X() (bEliminate bool, score int32) {
|
||||
var xiaochu []int // 即将消除的key
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
continue
|
||||
@ -252,16 +303,9 @@ func (this *MapData) Check3X() (bEliminate bool, score int32) {
|
||||
k1 := this.Plat[k].Color
|
||||
k2 := this.Plat[k+1].Color
|
||||
k3 := this.Plat[k+2].Color
|
||||
if k2 == 0 || k3 == 0 {
|
||||
continue
|
||||
}
|
||||
if k1 == k2 && k2 == k3 {
|
||||
score += this.Plat[k].Score
|
||||
score += this.Plat[k+1].Score
|
||||
score += this.Plat[k+2].Score
|
||||
this.Plat[k] = &pb.GirdeData{}
|
||||
this.Plat[k+1] = &pb.GirdeData{}
|
||||
this.Plat[k+2] = &pb.GirdeData{}
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 2}...)
|
||||
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
@ -270,21 +314,43 @@ func (this *MapData) Check3X() (bEliminate bool, score int32) {
|
||||
k1 := this.Plat[k].Color
|
||||
k2 := this.Plat[k+Width].Color
|
||||
k3 := this.Plat[k+2*Width].Color
|
||||
if k2 == 0 || k3 == 0 {
|
||||
continue
|
||||
}
|
||||
if k1 == k2 && k2 == k3 {
|
||||
score += this.Plat[k].Score
|
||||
score += this.Plat[k+Width].Score
|
||||
score += this.Plat[k+2*Width].Score
|
||||
|
||||
this.Plat[k] = &pb.GirdeData{}
|
||||
this.Plat[k+Width] = &pb.GirdeData{}
|
||||
this.Plat[k+2*Width] = &pb.GirdeData{}
|
||||
if k1 == k2 && k2 == k3 {
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 2}...)
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var next []int
|
||||
for _, id := range xiaochu {
|
||||
if s := this.Plat[id].Special; s != 0 {
|
||||
if s == FourUType { // 4消上下类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id/Height == i/Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
next = append(next, 1)
|
||||
} else if s == FourLType { // 左右类型
|
||||
for i := 0; i < Total; i++ {
|
||||
if id%Height == i%Height {
|
||||
next = append(next, i)
|
||||
}
|
||||
}
|
||||
} else if s == FiveType { // 随机消除
|
||||
|
||||
} else { // 普通类型 直接消除
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
@ -308,7 +374,6 @@ func (this *MapData) CheckMap() (score int32, szMap []*pb.MapData) {
|
||||
if curScore == 0 {
|
||||
break
|
||||
}
|
||||
//szMap = append(szMap, this.DropGirde()...)
|
||||
this.DropGirde()
|
||||
|
||||
szMap = append(szMap, &pb.MapData{
|
||||
@ -316,8 +381,6 @@ func (this *MapData) CheckMap() (score int32, szMap []*pb.MapData) {
|
||||
CurSocre: curScore,
|
||||
})
|
||||
}
|
||||
|
||||
//this.Debugf()
|
||||
return
|
||||
}
|
||||
|
||||
@ -336,11 +399,6 @@ func (this *MapData) DropGirde() {
|
||||
index++
|
||||
add++
|
||||
}
|
||||
// if this.Plat[k1].Color != 0 {
|
||||
// tmp := new(pb.GirdeData)
|
||||
// *tmp = *this.Plat[k1]
|
||||
// sz = append(sz, tmp)
|
||||
// }
|
||||
}
|
||||
for m := j + add; m < Height; m++ {
|
||||
k1 := i*Width + m
|
||||
@ -354,6 +412,8 @@ func (this *MapData) DropGirde() {
|
||||
this.Debugf()
|
||||
return
|
||||
}
|
||||
|
||||
// ai操作
|
||||
func (this *MapData) AiSwapGirde() bool {
|
||||
var (
|
||||
bSwap bool // 能否交换
|
||||
@ -367,7 +427,7 @@ func (this *MapData) AiSwapGirde() bool {
|
||||
}
|
||||
}
|
||||
if pos/Width+1 < Width {
|
||||
if this.SwapGirde(int32(pos), int32(pos+1)) {
|
||||
if this.SwapGirde(int32(pos), int32(pos+Width)) {
|
||||
bSwap = true
|
||||
break
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ func NewService(ops ...rpcx.Option) core.IService {
|
||||
func Test_Main(t *testing.T) {
|
||||
|
||||
m := new(entertainment.MapData)
|
||||
m.InitMap()
|
||||
m.InitMap(nil)
|
||||
m.SetMap()
|
||||
m.SwapGirde(1, 8)
|
||||
|
||||
|
@ -68,6 +68,7 @@ func (this *apiComp) Login(session comm.IUserSession, req *pb.UserLoginReq) (err
|
||||
}
|
||||
return
|
||||
}
|
||||
firstLogin = true
|
||||
expand = &pb.DBUserExpand{}
|
||||
}
|
||||
// 玩家是否已在线
|
||||
|
Loading…
Reference in New Issue
Block a user