数据结构调整

This commit is contained in:
meixiongfeng 2024-01-08 17:17:49 +08:00
parent 5930911cf8
commit aeaf559be2
4 changed files with 92 additions and 17 deletions

View File

@ -80,9 +80,9 @@ func (this *MapData) CreateGride(count int) (girdes []*pb.GirdeData) {
func (this *MapData) SetMap() {
sz2 := []int32{
3, 1, 2, 2, 1, 3, 1,
5, 1, 2, 3, 1, 2, 2,
5, 1, 2, 4, 1, 2, 2,
2, 4, 3, 4, 3, 1, 6,
1, 3, 3, 4, 2, 3, 6,
1, 3, 4, 4, 4, 3, 6,
1, 5, 2, 5, 6, 1, 4,
6, 6, 3, 26, 3, 1, 3,
3, 3, 1, 3, 3, 2, 5,
@ -1385,17 +1385,89 @@ func (this *MapData) HitCrossElem(color int32, curid int32) (szMap []*pb.MapData
}
// 检测一个元素
func (this *MapData) CheckElem(pos int32) {
func (this *MapData) CheckElem(pos int) (xc []int) {
var (
color int32
x int32
y int32
x int
y int
tmp []int
)
color = this.Plat[pos].Color
x = pos / Width
y = pos % Height
this.module.Debugf("color:%d, x:%d, y:%d", color, x, y)
for i := 0; i < Height; i++ {
for i := 1; i < Height; i++ {
if y+i < Height {
tagPos := x*Width + (y + i)
tagColor := this.Plat[tagPos].Color
if tagColor == color {
tmp = append(tmp, tagPos)
} else {
break
}
} else {
break
}
}
if len(tmp) >= 2 {
xc = append(xc, tmp...)
}
tmp = []int{}
for i := 1; i < Height; i++ {
if y-i >= 0 {
tagPos := x*Width + (y - i)
tagColor := this.Plat[tagPos].Color
if tagColor == color {
tmp = append(tmp, tagPos)
} else {
break
}
} else {
break
}
}
if len(tmp) >= 2 {
xc = append(xc, tmp...)
}
tmp = []int{}
for i := 1; i < Width; i++ {
if x-i >= 0 {
tagPos := (x-i)*Width + (y)
tagColor := this.Plat[tagPos].Color
if tagColor == color {
tmp = append(tmp, tagPos)
} else {
break
}
} else {
break
}
}
if len(tmp) >= 2 {
xc = append(xc, tmp...)
}
tmp = []int{}
for i := 1; i < Width; i++ {
if x+i < Width {
tagPos := (x+i)*Width + (y)
tagColor := this.Plat[tagPos].Color
if tagColor == color {
tmp = append(tmp, tagPos)
} else {
break
}
} else {
break
}
}
if len(tmp) >= 2 {
xc = append(xc, tmp...)
}
if len(xc) > 0 {
xc = append(xc, pos)
}
return
}

View File

@ -2,6 +2,7 @@ package hunting
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
@ -55,9 +56,9 @@ func (this *ModelRank) getHuntingRank(uid string) *pb.DBHuntingRecord {
func (this *ModelRank) querySRankUser(bossid int) (ranks []string, err error) {
var (
result []string
tableName string
)
tableName := this.TableName + strconv.Itoa(int(bossid))
tableName = fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(bossid)))
if result, err = this.Redis.ZRevRange(tableName, 0, comm.MinRankList).Result(); err != nil {
//this.module.Errorln(err)
return
@ -172,7 +173,7 @@ func (this *ModelRank) CheckRank(uid string, boosID int32, difficulty int32, lin
score int32
)
score = difficulty*10000 + (10000 - costTime)
tableName = this.TableName + strconv.Itoa(int(boosID))
tableName = fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(boosID)))
menbers = &redis.Z{Score: float64(score), Member: uid}
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {

View File

@ -2,6 +2,7 @@ package viking
import (
"context"
"fmt"
"go_dreamfactory/comm"
"go_dreamfactory/lego/core"
"go_dreamfactory/lego/sys/mgo"
@ -56,8 +57,8 @@ func (this *ModelRank) querySRankUser(bossid int) (ranks []string, err error) {
var (
result []string
)
tableName := this.TableName + strconv.Itoa(int(bossid))
tableName := fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(bossid)))
//tableName := this.TableName + strconv.Itoa(int(bossid))
if result, err = this.Redis.ZRevRange(tableName, 0, comm.MinRankList).Result(); err != nil {
//this.module.Errorln(err)
return
@ -172,7 +173,7 @@ func (this *ModelRank) CheckRank(uid string, boosID int32, difficulty int32, lin
score int32
)
score = difficulty*10000 + (10000 - costTime)
tableName = this.TableName + strconv.Itoa(int(boosID))
tableName = fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(boosID)))
menbers = &redis.Z{Score: float64(score), Member: uid}
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {

View File

@ -206,7 +206,8 @@ func (this *ModelSRank) CheckSeasonRank(uid string, boosID int32, difficulty int
score int32
)
score = difficulty*10000 + (10000 - huihe)
tableName = this.TableName + strconv.Itoa(int(boosID))
//tableName = this.TableName + strconv.Itoa(int(boosID))
tableName = fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(boosID)))
menbers = &redis.Z{Score: float64(score), Member: uid}
if cmd := pipe.ZAdd(tableName, menbers); cmd != nil {
@ -252,10 +253,10 @@ func (this *ModelSRank) raceSettlement() {
for iBossType := 1; iBossType <= 3; iBossType++ {
mailCid = fmt.Sprintf("SeasonViking%dReward", iBossType)
tableName := this.TableName + strconv.Itoa(int(iBossType))
//tableName := this.TableName + strconv.Itoa(int(iBossType))
szReward = this.moduleViking.configure.GetVikingRewardConf()
if result, err = this.DBModel.Redis.ZRevRange(fmt.Sprintf("%s-%s", this.DBModel, tableName), 0, comm.MaxRankList).Result(); err != nil {
tableName := fmt.Sprintf("%s-%s", db.CrossTag(), this.TableName+strconv.Itoa(int(iBossType)))
if result, err = this.DBModel.Redis.ZRevRange(tableName, 0, comm.MaxRankList).Result(); err != nil {
this.moduleViking.Errorln(err)
return
}