Merge branch 'dev' of http://git.legu.cc/liwei_3d/go_dreamfactory into dev
This commit is contained in:
commit
a6ae6bf2cb
@ -59,6 +59,9 @@ func (this *configureComp) LoadGameBlock() {
|
||||
block := make(map[int32]*cfg.GameBlockData)
|
||||
if configure, ok = v.(*cfg.GameBlock); ok {
|
||||
for _, v := range configure.GetDataList() {
|
||||
if v.Belongto == 2 {
|
||||
continue
|
||||
}
|
||||
key := v.Color<<8 + v.Type
|
||||
block[key] = v
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package entertainment
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"errors"
|
||||
"fmt"
|
||||
"go_dreamfactory/comm"
|
||||
@ -9,6 +10,7 @@ import (
|
||||
"go_dreamfactory/pb"
|
||||
"go_dreamfactory/sys/configure"
|
||||
cfg "go_dreamfactory/sys/configure/structs"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
"go.mongodb.org/mongo-driver/bson/primitive"
|
||||
@ -94,14 +96,21 @@ func (this *Room) operateTimeOut(task *timewheel.Task, args ...interface{}) {
|
||||
|
||||
// 随机一个玩法
|
||||
func (this *Room) RandomPlayType() (itype int32) {
|
||||
|
||||
var weight []int32 // 权重
|
||||
// 开始随机玩法
|
||||
list := this.module.configure.GetGameConsumeIntegral()
|
||||
for _, v := range list {
|
||||
weight = append(weight, v.Weight)
|
||||
}
|
||||
itype = list[comm.GetRandW(weight)].Key
|
||||
|
||||
return list[comm.GetRandW(weight)].Key
|
||||
// 临时修改 50% 概率1类型
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(2))
|
||||
if n.Int64() == 0 {
|
||||
itype = 1
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.PlayerData) *Room {
|
||||
@ -134,6 +143,7 @@ func (this *Room) InitRoom(module *Entertainment, p1 *pb.PlayerData, p2 *pb.Play
|
||||
round: 1,
|
||||
MaxRound: this.MaxRound,
|
||||
Status: 0,
|
||||
Playtype: this.Playtype,
|
||||
}
|
||||
|
||||
if err := this.module.SendMsgSyncToSession(string(this.module.GetType()), "enterroom", &pb.EntertainEnterRoomPush{
|
||||
|
@ -51,7 +51,7 @@ func (this *MapData) GetRandType() int32 {
|
||||
}
|
||||
|
||||
// 玩法带入
|
||||
func (this *MapData) CreateGride(index int32) (girde *pb.GirdeData) {
|
||||
func (this *MapData) CreateGride(index int32, bDrop bool) (girde *pb.GirdeData) {
|
||||
var (
|
||||
szWeight []int32
|
||||
szId []int32
|
||||
@ -69,10 +69,13 @@ func (this *MapData) CreateGride(index int32) (girde *pb.GirdeData) {
|
||||
}
|
||||
if this.iType == 4 {
|
||||
for i := 1; i <= 6; i++ { // 6种颜色
|
||||
if conf, err := this.module.configure.GetGameBlock(int32(i), 4); err == nil {
|
||||
//for j := 1; j <= 4; j++ {
|
||||
n1, _ := rand.Int(rand.Reader, big.NewInt(4))
|
||||
if conf, err := this.module.configure.GetGameBlock(int32(i), int32(n1.Int64()+5)); err == nil {
|
||||
szWeight = append(szWeight, conf.Weight)
|
||||
szId = append(szId, conf.Key)
|
||||
}
|
||||
//}
|
||||
|
||||
if conf, err := this.module.configure.GetGameBlock(int32(i), 0); err == nil {
|
||||
szWeight = append(szWeight, conf.Weight)
|
||||
@ -80,8 +83,9 @@ func (this *MapData) CreateGride(index int32) (girde *pb.GirdeData) {
|
||||
}
|
||||
}
|
||||
id = szId[comm.GetRandW(szWeight)]
|
||||
} else if this.iType == 3 { // 创建棋盘的时候此玩法类型执行效率低下 稍后采用同颜色替换模式处理
|
||||
} else if this.iType == 3 && bDrop { // 创建棋盘的时候此玩法类型执行效率低下 稍后采用同颜色替换模式处理
|
||||
// 最多2个
|
||||
|
||||
var count int32
|
||||
for _, v := range this.Plat {
|
||||
if v.Special == 4 {
|
||||
@ -91,11 +95,13 @@ func (this *MapData) CreateGride(index int32) (girde *pb.GirdeData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if count <= 2 {
|
||||
if count < 2 {
|
||||
n, _ := rand.Int(rand.Reader, big.NewInt(6)) // 随机一个颜色
|
||||
if conf, err := this.module.configure.GetGameBlock(int32(n.Int64()+1), 4); err == nil {
|
||||
id = conf.Key
|
||||
}
|
||||
} else {
|
||||
id = this.GetRandType()
|
||||
}
|
||||
|
||||
} else {
|
||||
@ -116,13 +122,28 @@ func (this *MapData) CreateGride(index int32) (girde *pb.GirdeData) {
|
||||
// 初始化地图数据
|
||||
func (this *MapData) InitMap(module *Entertainment, iType int32) {
|
||||
this.module = module
|
||||
this.iType = 1 //iType
|
||||
this.iType = iType
|
||||
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))
|
||||
this.Plat[i] = this.CreateGride(int32(i), false)
|
||||
}
|
||||
if iType == 3 {
|
||||
var pos int64
|
||||
for i := 0; i < 2; i++ {
|
||||
n1, _ := rand.Int(rand.Reader, big.NewInt(Total-1))
|
||||
if pos != n1.Int64() {
|
||||
pos = n1.Int64()
|
||||
}
|
||||
if conf, err := this.module.configure.GetGameBlock(this.Plat[n1.Int64()].Color, 4); err == nil {
|
||||
this.Plat[n1.Int64()].Cid = conf.Key
|
||||
this.Plat[n1.Int64()].Special = conf.Type
|
||||
this.Plat[n1.Int64()].Score = conf.Score
|
||||
}
|
||||
}
|
||||
}
|
||||
this.SetIndelibilityPlat()
|
||||
this.Plat = this.GetPalatData()
|
||||
//this.SetMap() // 方便测试固定地图
|
||||
}
|
||||
|
||||
@ -419,8 +440,8 @@ func (this *MapData) CheckMap(color int32, bSkill bool) (szMap []*pb.MapData, xc
|
||||
}
|
||||
|
||||
if s := this.Plat[id].Special; s != 0 {
|
||||
for k := range this.SpecialElem(id, s) {
|
||||
x[k] = struct{}{}
|
||||
for key := range this.SpecialElem(id, s) {
|
||||
x[key] = struct{}{}
|
||||
}
|
||||
|
||||
}
|
||||
@ -475,7 +496,7 @@ func (this *MapData) DropGirde() bool {
|
||||
}
|
||||
for m := j + add; m < Height; m++ {
|
||||
k1 := i*Width + m
|
||||
this.Plat[k1] = this.CreateGride(int32(k1))
|
||||
this.Plat[k1] = this.CreateGride(int32(k1), true)
|
||||
}
|
||||
break
|
||||
}
|
||||
@ -1095,11 +1116,11 @@ func (this *MapData) SpecialElem(id int, s int32) (x map[int]struct{}) {
|
||||
}
|
||||
}
|
||||
} else if s == BoomType { // 炸弹类型 带走周围一圈+ 上下左右
|
||||
for key := range this.GetBoomElem(id) {
|
||||
for _, key := range this.GetBoomElem(id) {
|
||||
x[key] = struct{}{}
|
||||
}
|
||||
} else if s == FireUp || s == FireDown || s == FireLeft || s == FireRight { // 烟花技能
|
||||
for key := range this.GetFireBoom(id, s) {
|
||||
for _, key := range this.GetFireBoom(id, s) {
|
||||
x[key] = struct{}{}
|
||||
}
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ func Test_Main(t *testing.T) {
|
||||
|
||||
//m.SkillUp(24, 1, 3, 7, true)
|
||||
m.SetMap()
|
||||
b := m.GetFireBoom(1, 7)
|
||||
fmt.Printf("xxxx %d\n", b)
|
||||
var vids int
|
||||
for index := 7 - 1; index >= 0; index-- {
|
||||
for j := 0; j < 7; j++ {
|
||||
|
Loading…
Reference in New Issue
Block a user