Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
cbad03e203
@ -41,6 +41,7 @@ func (this *apiComp) Reward(session comm.IUserSession, req *pb.EntertainRewardRe
|
||||
Code: pb.ErrorCode_UserRepeadReward,
|
||||
Title: pb.ErrorCode_UserRepeadReward.ToString(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if _, ok := list.Reward[conf.Key]; !ok {
|
||||
if errdata, atno = this.module.DispenseAtno(session, conf.Rewards, true); errdata != nil {
|
||||
|
@ -3,6 +3,7 @@ package entertainment
|
||||
import (
|
||||
"go_dreamfactory/comm"
|
||||
"go_dreamfactory/pb"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
)
|
||||
|
||||
//参数校验
|
||||
@ -21,11 +22,41 @@ func (this *apiComp) Match(session comm.IUserSession, req *pb.EntertainMatchReq)
|
||||
var (
|
||||
user *pb.DBUser
|
||||
err error
|
||||
conf *cfg.GameConsumeHeroData
|
||||
)
|
||||
user, err = this.module.ModuleUser.GetUser(session.GetUserId())
|
||||
if err != nil {
|
||||
|
||||
return
|
||||
}
|
||||
if conf, err = this.module.configure.GetGameConsumeHero(req.Idcard); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_ConfigNoFound,
|
||||
Title: pb.ErrorCode_ConfigNoFound.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
if conf.Type != 1 { // 校验数量够不够
|
||||
if list, err := this.module.model.getEntertainmList(session.GetUserId()); err != nil {
|
||||
errdata = &pb.ErrorData{
|
||||
Code: pb.ErrorCode_DBError,
|
||||
Title: pb.ErrorCode_DBError.ToString(),
|
||||
Message: err.Error(),
|
||||
}
|
||||
return
|
||||
} else {
|
||||
if list.Card[req.Idcard] <= 0 { // 需要购买
|
||||
if errdata = this.module.ConsumeRes(session, conf.Consume, true); errdata != nil {
|
||||
return
|
||||
}
|
||||
list.Card[req.Idcard] += 1
|
||||
this.module.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
|
||||
"card": list.Card,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.module.match.MatchReq(&pb.DBXXLMatch{
|
||||
Userinfo: &pb.BaseUserInfo{
|
||||
Uid: user.Uid,
|
||||
|
@ -95,9 +95,11 @@ func (this *configureComp) GetGameConsumeHero(heroid string) (conf *cfg.GameCons
|
||||
func (this *configureComp) GetGameConsumeintegral(key int32) (conf *cfg.GameIntegralData, err error) {
|
||||
var (
|
||||
v interface{}
|
||||
configure *cfg.GameIntegral
|
||||
ok bool
|
||||
)
|
||||
if v, err = this.GetConfigure(game_integral); err == nil {
|
||||
if configure, ok := v.(*cfg.GameIntegral); ok {
|
||||
if configure, ok = v.(*cfg.GameIntegral); ok {
|
||||
|
||||
for pos, v := range configure.GetDataList() {
|
||||
if v.Key >= key {
|
||||
@ -111,6 +113,10 @@ func (this *configureComp) GetGameConsumeintegral(key int32) (conf *cfg.GameInte
|
||||
}
|
||||
}
|
||||
}
|
||||
if configure.GetDataList()[len(configure.GetDataList())-1].Key < key { // 设置最大值
|
||||
conf = configure.GetDataList()[len(configure.GetDataList())-1]
|
||||
return
|
||||
}
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_integral, key)
|
||||
return
|
||||
}
|
||||
@ -143,3 +149,19 @@ func (this *configureComp) GetGameConsumeintegralReward(key int32) (conf *cfg.Ga
|
||||
err = comm.NewNotFoundConfErr(moduleName, game_integral, key)
|
||||
return
|
||||
}
|
||||
|
||||
func (this *configureComp) GetInitGameConsumeHero() (cardid []string) {
|
||||
|
||||
if v, err := this.GetConfigure(game_consumehero); err == nil {
|
||||
if configure, ok := v.(*cfg.GameConsumeHero); ok {
|
||||
for _, v := range configure.GetDataList() {
|
||||
if v.Type == 1 {
|
||||
cardid = append(cardid, v.Key)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
@ -34,7 +34,11 @@ func (this *modelComp) getEntertainmList(uid string) (result *pb.DBXXLData, err
|
||||
var (
|
||||
dbModel *db.DBModel
|
||||
)
|
||||
result = &pb.DBXXLData{}
|
||||
result = &pb.DBXXLData{
|
||||
|
||||
Reward: map[int32]int32{},
|
||||
Card: map[string]int32{},
|
||||
}
|
||||
if db.IsCross() {
|
||||
if tag, _, b := utils.UIdSplit(uid); b {
|
||||
if conn, err := db.ServerDBConn(tag); err == nil {
|
||||
@ -56,6 +60,10 @@ func (this *modelComp) getEntertainmList(uid string) (result *pb.DBXXLData, err
|
||||
result.Reward = make(map[int32]int32)
|
||||
result.Card = make(map[string]int32, 0)
|
||||
}
|
||||
// 初始化默认获得类型为1的卡片
|
||||
for _, v := range this.module.configure.GetInitGameConsumeHero() {
|
||||
result.Card[v] = 1
|
||||
}
|
||||
}
|
||||
err = nil
|
||||
return result, err
|
||||
|
@ -84,9 +84,36 @@ func (this *Entertainment) AddXxlCard(session comm.IUserSession, cards map[strin
|
||||
})
|
||||
|
||||
if bPush {
|
||||
session.SendMsg(string(this.GetType()), "titlelist", &pb.EntertainChangePush{
|
||||
session.SendMsg(string(this.GetType()), "change", &pb.EntertainChangePush{
|
||||
Card: result.Card,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 消耗一张卡
|
||||
func (this *Entertainment) ConsumXxlCard(session comm.IUserSession, card string) (errdata *pb.ErrorData) {
|
||||
|
||||
var (
|
||||
result *pb.DBXXLData
|
||||
err error
|
||||
)
|
||||
|
||||
if result, err = this.model.getEntertainmList(session.GetUserId()); err != nil {
|
||||
return
|
||||
}
|
||||
if _, ok := result.Card[card]; ok {
|
||||
if result.Card[card] <= 0 {
|
||||
return
|
||||
}
|
||||
result.Card[card] -= 1
|
||||
this.model.modifyEntertainmList(session.GetUserId(), map[string]interface{}{
|
||||
"card": result.Card,
|
||||
})
|
||||
}
|
||||
|
||||
session.SendMsg(string(this.GetType()), "titlelist", &pb.EntertainChangePush{
|
||||
Card: result.Card,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
@ -478,11 +478,12 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
|
||||
winindex int32
|
||||
bReward bool
|
||||
res []*cfg.Gameatn
|
||||
winner string
|
||||
lostPlayer *pb.PlayerData // 输的玩家
|
||||
)
|
||||
if this.operatetimer != nil {
|
||||
timewheel.Remove(this.operatetimer)
|
||||
}
|
||||
var winner string
|
||||
winner = this.player1.Userinfo.Uid
|
||||
bReward = true
|
||||
if this.player1.Score < this.player2.Score {
|
||||
@ -492,6 +493,7 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
|
||||
bReward = false
|
||||
}
|
||||
}
|
||||
|
||||
if bReward { // 发奖
|
||||
if user, err := this.module.ModuleUser.GetUser(winner); err == nil {
|
||||
if conf, err := this.module.configure.GetGameConsumeintegral(user.Consumeexp); err == nil {
|
||||
@ -505,6 +507,26 @@ func (this *Room) GameOver() (errdata *pb.ErrorData) {
|
||||
}
|
||||
}
|
||||
|
||||
// 失败的一方扣除卡
|
||||
if this.player1.Userinfo.Uid != winner {
|
||||
lostPlayer = this.player1
|
||||
} else {
|
||||
lostPlayer = this.player2
|
||||
}
|
||||
// 失败卡类型
|
||||
if conf, err := this.module.configure.GetGameConsumeHero(lostPlayer.Cardid); err == nil && lostPlayer.Userinfo.Uid != "999" {
|
||||
if conf.Type != 1 { //卡片类型不为1
|
||||
if list, err := this.module.model.getEntertainmList(lostPlayer.Userinfo.Uid); err == nil {
|
||||
if list.Card[lostPlayer.Cardid] > 1 {
|
||||
list.Card[lostPlayer.Cardid] -= 1
|
||||
this.module.model.modifyEntertainmList(lostPlayer.Userinfo.Uid, map[string]interface{}{
|
||||
"card": list.Card,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.module.SendMsgSyncToSession(string(this.module.GetType()), "gameover", &pb.EntertainGameOverPush{
|
||||
User1: this.player1,
|
||||
User2: this.player2,
|
||||
|
@ -86,11 +86,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].Color)
|
||||
//v = index + j*7
|
||||
fmt.Printf("%d:%d ", this.Plat[index+j*Height].Cid, this.Plat[index+j*Height].Color)
|
||||
|
||||
}
|
||||
fmt.Printf("\n")
|
||||
@ -98,10 +98,11 @@ func (this *MapData) Debugf() {
|
||||
}
|
||||
|
||||
// 检查5消
|
||||
func (this *MapData) Check5X(color int32) (bEliminate bool, score int32, count int32) {
|
||||
var xiaochu []int // 即将消除的key
|
||||
func (this *MapData) Check5X() (bEliminate bool, xiaochu []int, s map[int]int) {
|
||||
//var xiaochu []int // 即将消除的key
|
||||
s = make(map[int]int)
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
if v.Cid == 0 {
|
||||
continue
|
||||
}
|
||||
x := int32(k % Height) // x
|
||||
@ -113,23 +114,13 @@ func (this *MapData) Check5X(color int32) (bEliminate bool, score int32, count i
|
||||
k5 := this.Plat[k+4].Color
|
||||
|
||||
if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 {
|
||||
if k1 == color {
|
||||
count++
|
||||
}
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err == nil {
|
||||
this.Plat[k+2] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
} else {
|
||||
xiaochu = append(xiaochu, k+2)
|
||||
}
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 3, k + 4}...)
|
||||
s[k+2] = FiveType
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 2, k + 3, k + 4}...)
|
||||
this.Plat[k].Cid = 0
|
||||
this.Plat[k+1].Cid = 0
|
||||
this.Plat[k+2].Cid = 0
|
||||
this.Plat[k+3].Cid = 0
|
||||
this.Plat[k+4].Cid = 0
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
@ -141,79 +132,30 @@ func (this *MapData) Check5X(color int32) (bEliminate bool, score int32, count i
|
||||
k5 := this.Plat[k+4*Width].Color
|
||||
|
||||
if k1 == k2 && k3 == k4 && k5 == k1 && k2 == k3 {
|
||||
if k1 == color {
|
||||
count++
|
||||
}
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
if conf, err := this.module.configure.GetGameBlock(k1, FiveType); err == nil {
|
||||
this.Plat[k+2*Width] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
} else {
|
||||
xiaochu = append(xiaochu, k+2*Width)
|
||||
}
|
||||
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 3*Width, k + 4*Width}...)
|
||||
|
||||
s[k+2*Width] = FiveType
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width, k + 3*Width, k + 4*Width}...)
|
||||
this.Plat[k].Cid = 0
|
||||
this.Plat[k+Width].Cid = 0
|
||||
this.Plat[k+2*Width].Cid = 0
|
||||
this.Plat[k+3*Width].Cid = 0
|
||||
this.Plat[k+4*Width].Cid = 0
|
||||
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 { // 普通类型 直接消除
|
||||
if this.Plat[id].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(id))
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
if this.Plat[v].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count int32) {
|
||||
func (this *MapData) Check4X() (bEliminate bool, xiaochu []int, s map[int]int) {
|
||||
var (
|
||||
newElem int // 生成的一个新的元素CID
|
||||
)
|
||||
s = make(map[int]int)
|
||||
|
||||
fmt.Printf("=====开始检测消除4x===========\n")
|
||||
|
||||
var xiaochu []int // 即将消除的key
|
||||
//var xiaochu []int // 即将消除的key
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
if v.Cid == 0 {
|
||||
continue
|
||||
}
|
||||
x := int32(k % Height) // x
|
||||
@ -239,27 +181,11 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
|
||||
if newElem == 0 {
|
||||
newElem = k + 2 // 给个默认值
|
||||
}
|
||||
this.oid++
|
||||
// 生成一个新的类型元素
|
||||
|
||||
if conf, err := this.module.configure.GetGameBlock(k1, FourUType); err == nil { // 上下类型
|
||||
this.Plat[newElem] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
if k1 == color {
|
||||
count++
|
||||
}
|
||||
} else {
|
||||
xiaochu = append(xiaochu, newElem)
|
||||
}
|
||||
if newElem == k+1 {
|
||||
xiaochu = append(xiaochu, []int{k, k + 2, k + 3}...)
|
||||
} else {
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 3}...)
|
||||
s[newElem] = FourUType
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 2, k + 3}...)
|
||||
for _, v := range xiaochu {
|
||||
this.Plat[v].Cid = 0
|
||||
}
|
||||
bEliminate = true
|
||||
}
|
||||
@ -286,77 +212,24 @@ func (this *MapData) Check4X(color int32) (bEliminate bool, score int32, count i
|
||||
newElem = k + 2*Width // 给个默认值
|
||||
}
|
||||
|
||||
this.oid++
|
||||
|
||||
// 生成一个新的类型元素
|
||||
if conf, err := this.module.configure.GetGameBlock(k1, FourLType); err == nil { // 左右类型
|
||||
this.Plat[newElem] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: k1,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
if k1 == color {
|
||||
count++
|
||||
}
|
||||
} else {
|
||||
s[newElem] = FourLType
|
||||
xiaochu = append(xiaochu, k+Width)
|
||||
}
|
||||
if newElem == k+Width {
|
||||
xiaochu = append(xiaochu, []int{k, k + 2*Width, k + 3*Width}...)
|
||||
} else {
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 3*Width}...)
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width, k + 3*Width}...)
|
||||
for _, v := range xiaochu {
|
||||
this.Plat[v].Cid = 0
|
||||
}
|
||||
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 { // 普通类型 直接消除
|
||||
if this.Plat[id].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(id))
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
if this.Plat[v].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *MapData) Check3X(color int32) (bEliminate bool, score int32, count int32) {
|
||||
var xiaochu []int // 即将消除的key
|
||||
func (this *MapData) Check3X() (bEliminate bool, xiaochu []int) {
|
||||
//var xiaochu []int // 即将消除的key
|
||||
for k, v := range this.Plat {
|
||||
if v.Color == 0 {
|
||||
if v.Cid == 0 {
|
||||
continue
|
||||
}
|
||||
x := int32(k % Height) // x
|
||||
@ -367,6 +240,9 @@ func (this *MapData) Check3X(color int32) (bEliminate bool, score int32, count i
|
||||
k3 := this.Plat[k+2].Color
|
||||
if k1 == k2 && k2 == k3 {
|
||||
xiaochu = append(xiaochu, []int{k, k + 1, k + 2}...)
|
||||
this.Plat[k].Cid = 0
|
||||
this.Plat[k+1].Cid = 0
|
||||
this.Plat[k+2].Cid = 0
|
||||
bEliminate = true
|
||||
}
|
||||
}
|
||||
@ -378,74 +254,101 @@ func (this *MapData) Check3X(color int32) (bEliminate bool, score int32, count i
|
||||
|
||||
if k1 == k2 && k2 == k3 {
|
||||
xiaochu = append(xiaochu, []int{k, k + Width, k + 2*Width}...)
|
||||
this.Plat[k].Cid = 0
|
||||
this.Plat[k+Width].Cid = 0
|
||||
this.Plat[k+2*Width].Cid = 0
|
||||
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 { // 普通类型 直接消除
|
||||
if this.Plat[id].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(id))
|
||||
}
|
||||
}
|
||||
|
||||
for _, v := range next {
|
||||
if this.Plat[v].Color == color {
|
||||
count++
|
||||
}
|
||||
score += this.Plat[v].Score
|
||||
this.Plat[v] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(v))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// 校验地图可消除的 判断各组上面2个和右边两个是否三个相等
|
||||
// xc 判断用来是否加体力
|
||||
func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc bool) {
|
||||
var curScore int32
|
||||
var energy int32
|
||||
var (
|
||||
//tXiaochu []int
|
||||
tXiaochu map[int]struct{}
|
||||
curScore int32
|
||||
energy int32
|
||||
new map[int]int
|
||||
x map[int]struct{}
|
||||
)
|
||||
|
||||
for {
|
||||
new = make(map[int]int)
|
||||
x = make(map[int]struct{})
|
||||
tXiaochu = make(map[int]struct{})
|
||||
curScore = 0
|
||||
energy = 0
|
||||
if bRet, s, c := this.Check5X(color); bRet {
|
||||
curScore += s
|
||||
energy += c
|
||||
if bEliminate, xiaochu, s := this.Check5X(); bEliminate {
|
||||
for _, v := range xiaochu {
|
||||
tXiaochu[v] = struct{}{}
|
||||
}
|
||||
for k, v := range s {
|
||||
new[k] = v
|
||||
}
|
||||
xc = true // 只要有 4x 5x 就标记ture
|
||||
}
|
||||
if bRet, s, c := this.Check4X(color); bRet {
|
||||
curScore += s
|
||||
energy += c
|
||||
xc = true
|
||||
if bEliminate, xiaochu, s := this.Check4X(); bEliminate {
|
||||
for _, v := range xiaochu {
|
||||
tXiaochu[v] = struct{}{}
|
||||
}
|
||||
for k, v := range s {
|
||||
new[k] = v
|
||||
}
|
||||
xc = true // 只要有 4x 5x 就标记ture
|
||||
}
|
||||
if bEliminate, xiaochu := this.Check3X(); bEliminate {
|
||||
for _, v := range xiaochu {
|
||||
tXiaochu[v] = struct{}{}
|
||||
}
|
||||
if bRet, s, c := this.Check3X(color); bRet {
|
||||
curScore += s
|
||||
energy += c
|
||||
}
|
||||
|
||||
for id := range tXiaochu {
|
||||
if _, ok := new[id]; ok {
|
||||
if this.Plat[id].Color == color {
|
||||
energy++
|
||||
}
|
||||
curScore += this.Plat[id].Score
|
||||
if conf, err := this.module.configure.GetGameBlock(this.Plat[id].Color, int32(new[id])); err == nil {
|
||||
this.oid++ // 生成一个新的类型元素
|
||||
this.Plat[id] = &pb.GirdeData{
|
||||
Oid: this.oid,
|
||||
Color: this.Plat[id].Color,
|
||||
Cid: conf.Key,
|
||||
Score: conf.Score,
|
||||
Special: conf.Type,
|
||||
}
|
||||
}
|
||||
continue
|
||||
}
|
||||
|
||||
if s := this.Plat[id].Special; 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 { // 随机消除
|
||||
|
||||
}
|
||||
}
|
||||
x[id] = struct{}{}
|
||||
}
|
||||
for id := range x {
|
||||
if this.Plat[id].Color == color {
|
||||
energy++
|
||||
}
|
||||
curScore += this.Plat[id].Score
|
||||
this.Plat[id] = &pb.GirdeData{}
|
||||
this.operElem = append(this.operElem, int32(id))
|
||||
}
|
||||
if this.DropGirde() {
|
||||
if !bSkill {
|
||||
energy = 0
|
||||
@ -455,6 +358,7 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc
|
||||
CurSocre: curScore,
|
||||
CurEnergy: energy,
|
||||
})
|
||||
this.Debugf()
|
||||
}
|
||||
|
||||
// 检查掉落
|
||||
@ -472,12 +376,12 @@ func (this *MapData) DropGirde() bool {
|
||||
for i := 0; i < Width; i++ {
|
||||
for j := 0; j < Height; j++ {
|
||||
index := i*Width + j
|
||||
if this.Plat[index].Color == 0 { // 说明这列有空
|
||||
if this.Plat[index].Cid == 0 { // 说明这列有空
|
||||
bDrop = true
|
||||
var add int
|
||||
for m := j + 1; m < Height; m++ {
|
||||
k1 := i*Width + m
|
||||
if this.Plat[k1].Color != 0 {
|
||||
if this.Plat[k1].Cid != 0 {
|
||||
this.Plat[index] = this.Plat[k1]
|
||||
index++
|
||||
add++
|
||||
@ -491,7 +395,7 @@ func (this *MapData) DropGirde() bool {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//this.Debugf()
|
||||
return bDrop
|
||||
}
|
||||
func (this *MapData) GetPalatData() (data []*pb.GirdeData) {
|
||||
|
@ -84,22 +84,26 @@ func Test_Main(t *testing.T) {
|
||||
}()
|
||||
m := new(entertainment.MapData)
|
||||
m.InitMap(nil)
|
||||
for i := 0; i < 100; i++ {
|
||||
m := new(entertainment.MapData)
|
||||
m.InitMap(nil)
|
||||
//m.SetMap()
|
||||
m.SetIndelibilityPlat()
|
||||
d, _ := m.CheckMap(0, true)
|
||||
if len(d) > 0 {
|
||||
fmt.Println("===========有消除")
|
||||
m.SetMap()
|
||||
m.SwapGirde(1, 8)
|
||||
m.CheckMap(1, false)
|
||||
m.Debugf()
|
||||
}
|
||||
// for i := 0; i < 100; i++ {
|
||||
// m := new(entertainment.MapData)
|
||||
// m.InitMap(nil)
|
||||
// //m.SetMap()
|
||||
// m.SetIndelibilityPlat()
|
||||
// d, _ := m.CheckMap(0, true)
|
||||
// if len(d) > 0 {
|
||||
// fmt.Println("===========有消除")
|
||||
// m.Debugf()
|
||||
// }
|
||||
|
||||
if m.CheckAndRefreshPlat() {
|
||||
m.Debugf()
|
||||
fmt.Println("xxxx")
|
||||
}
|
||||
}
|
||||
// if m.CheckAndRefreshPlat() {
|
||||
// m.Debugf()
|
||||
// fmt.Println("xxxx")
|
||||
// }
|
||||
// }
|
||||
|
||||
//var szMap []*pb.MapData
|
||||
// if bSwap, m := m.AiSwapGirde(); bSwap {
|
||||
|
Loading…
Reference in New Issue
Block a user