玩法规则带入
This commit is contained in:
parent
da7c4a1bdd
commit
ebee3aaa0c
@ -1,7 +1,6 @@
|
|||||||
package entertainment
|
package entertainment
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"go_dreamfactory/comm"
|
"go_dreamfactory/comm"
|
||||||
@ -10,7 +9,6 @@ import (
|
|||||||
"go_dreamfactory/pb"
|
"go_dreamfactory/pb"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
cfg "go_dreamfactory/sys/configure/structs"
|
cfg "go_dreamfactory/sys/configure/structs"
|
||||||
"math/big"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||||
@ -105,11 +103,6 @@ func (this *Room) RandomPlayType() (itype int32) {
|
|||||||
}
|
}
|
||||||
itype = list[comm.GetRandW(weight)].Key
|
itype = list[comm.GetRandW(weight)].Key
|
||||||
|
|
||||||
// 临时修改 50% 概率1类型
|
|
||||||
n, _ := rand.Int(rand.Reader, big.NewInt(2))
|
|
||||||
if n.Int64() == 0 {
|
|
||||||
itype = 1
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +53,6 @@ func (this *MapData) GetRandType() int32 {
|
|||||||
// 玩法带入
|
// 玩法带入
|
||||||
func (this *MapData) CreateGride(index int32, bDrop bool) (girde *pb.GirdeData) {
|
func (this *MapData) CreateGride(index int32, bDrop bool) (girde *pb.GirdeData) {
|
||||||
var (
|
var (
|
||||||
szWeight []int32
|
|
||||||
szId []int32
|
|
||||||
id int32
|
id int32
|
||||||
conf *cfg.GameBlockData
|
conf *cfg.GameBlockData
|
||||||
err error
|
err error
|
||||||
@ -67,25 +65,29 @@ func (this *MapData) CreateGride(index int32, bDrop bool) (girde *pb.GirdeData)
|
|||||||
Score: 1,
|
Score: 1,
|
||||||
Special: 0,
|
Special: 0,
|
||||||
}
|
}
|
||||||
if this.iType == 4 {
|
if this.iType == 4 && bDrop {
|
||||||
for i := 1; i <= 6; i++ { // 6种颜色
|
var count int32
|
||||||
//for j := 1; j <= 4; j++ {
|
for _, v := range this.Plat {
|
||||||
n1, _ := rand.Int(rand.Reader, big.NewInt(4))
|
if v.Special == 5 || v.Special == 6 ||
|
||||||
if conf, err := this.module.configure.GetGameBlock(int32(i), int32(n1.Int64()+5)); err == nil {
|
v.Special == 7 || v.Special == 8 {
|
||||||
szWeight = append(szWeight, conf.Weight)
|
count++
|
||||||
szId = append(szId, conf.Key)
|
if count >= 2 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if count < 2 {
|
||||||
|
n, _ := rand.Int(rand.Reader, big.NewInt(6)) // 随机一个颜色
|
||||||
|
n1, _ := rand.Int(rand.Reader, big.NewInt(4)) // 随机一个消除类型
|
||||||
|
if conf, err := this.module.configure.GetGameBlock(int32(n.Int64()+1), int32(n1.Int64()+5)); err == nil {
|
||||||
|
id = conf.Key
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
id = this.GetRandType()
|
||||||
}
|
}
|
||||||
//}
|
|
||||||
|
|
||||||
if conf, err := this.module.configure.GetGameBlock(int32(i), 0); err == nil {
|
|
||||||
szWeight = append(szWeight, conf.Weight)
|
|
||||||
szId = append(szId, conf.Key)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
id = szId[comm.GetRandW(szWeight)]
|
|
||||||
} else if this.iType == 3 && bDrop { // 创建棋盘的时候此玩法类型执行效率低下 稍后采用同颜色替换模式处理
|
} else if this.iType == 3 && bDrop { // 创建棋盘的时候此玩法类型执行效率低下 稍后采用同颜色替换模式处理
|
||||||
// 最多2个
|
// 最多2个
|
||||||
|
|
||||||
var count int32
|
var count int32
|
||||||
for _, v := range this.Plat {
|
for _, v := range this.Plat {
|
||||||
if v.Special == 4 {
|
if v.Special == 4 {
|
||||||
@ -128,20 +130,32 @@ func (this *MapData) InitMap(module *Entertainment, iType int32) {
|
|||||||
for i := 0; i < Width*Height; i++ {
|
for i := 0; i < Width*Height; i++ {
|
||||||
this.Plat[i] = this.CreateGride(int32(i), false)
|
this.Plat[i] = this.CreateGride(int32(i), false)
|
||||||
}
|
}
|
||||||
if iType == 3 {
|
if iType > 1 {
|
||||||
var pos int64
|
var sp int32
|
||||||
for i := 0; i < 2; i++ {
|
var mp map[int32]struct{}
|
||||||
|
mp = make(map[int32]struct{}, 0)
|
||||||
|
for {
|
||||||
n1, _ := rand.Int(rand.Reader, big.NewInt(Total-1))
|
n1, _ := rand.Int(rand.Reader, big.NewInt(Total-1))
|
||||||
if pos != n1.Int64() {
|
mp[int32(n1.Int64())] = struct{}{}
|
||||||
pos = n1.Int64()
|
if len(mp) >= 2 {
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if conf, err := this.module.configure.GetGameBlock(this.Plat[n1.Int64()].Color, 4); err == nil {
|
}
|
||||||
this.Plat[n1.Int64()].Cid = conf.Key
|
if iType == 3 {
|
||||||
this.Plat[n1.Int64()].Special = conf.Type
|
sp = 4
|
||||||
this.Plat[n1.Int64()].Score = conf.Score
|
} else if iType == 4 {
|
||||||
|
n1, _ := rand.Int(rand.Reader, big.NewInt(4)) // 随机一个消除类型
|
||||||
|
sp = int32(n1.Int64()) + 5
|
||||||
|
}
|
||||||
|
for key := range mp {
|
||||||
|
if conf, err := this.module.configure.GetGameBlock(this.Plat[key].Color, sp); err == nil {
|
||||||
|
this.Plat[key].Cid = conf.Key
|
||||||
|
this.Plat[key].Special = conf.Type
|
||||||
|
this.Plat[key].Score = conf.Score
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
this.SetIndelibilityPlat()
|
this.SetIndelibilityPlat()
|
||||||
this.Plat = this.GetPalatData()
|
this.Plat = this.GetPalatData()
|
||||||
//this.SetMap() // 方便测试固定地图
|
//this.SetMap() // 方便测试固定地图
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"go_dreamfactory/services"
|
"go_dreamfactory/services"
|
||||||
"go_dreamfactory/sys/configure"
|
"go_dreamfactory/sys/configure"
|
||||||
"go_dreamfactory/sys/db"
|
"go_dreamfactory/sys/db"
|
||||||
|
"math"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strings"
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
@ -83,6 +84,7 @@ func Test_Main(t *testing.T) {
|
|||||||
)
|
)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
print(math.Pow(2, 238))
|
||||||
// sz := utils.RandomNumbers(0, 2, 2)
|
// sz := utils.RandomNumbers(0, 2, 2)
|
||||||
// fmt.Printf("xxxx%v", sz)
|
// fmt.Printf("xxxx%v", sz)
|
||||||
m := new(entertainment.MapData)
|
m := new(entertainment.MapData)
|
||||||
|
Loading…
Reference in New Issue
Block a user