Merge branch 'sdk' into online

This commit is contained in:
hahwu 2025-01-22 11:11:00 +08:00
commit 11e922799e
7 changed files with 80 additions and 44 deletions

View File

@ -12,10 +12,12 @@ const (
const (
ENERGY_SHOP_MUL = "energy_shop_mul"
ENERGY_CFG = "BaseEnergy"
)
func init() {
gamedata.InitCfg(CFG_BASE)
gamedata.InitCfg(ENERGY_CFG)
}
func GetEnergyByMul(T int) float64 {
@ -35,5 +37,20 @@ func GetEnergyByMul(T int) float64 {
} else {
return 0
}
}
func GetMaxEnergyMul(Lv int, Energy int) int {
Mul := 0
for i := 1; i < 999; i++ {
data, err := gamedata.GetDataByIntKey(ENERGY_CFG, i)
if err != nil {
break
}
UnlockLv := gamedata.GetIntValue(data, "UnlockLv")
if Lv < UnlockLv || Energy < gamedata.GetIntValue(data, "NeedEnergy") {
break
}
Mul = i - 1
}
return Mul
}

View File

@ -530,11 +530,12 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
n := Num - 10
x := n / 2
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
for i := 0; i < n-x; i++ {
Last := Num - len(r)
for i := 0; i < Last; i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(20, 240)), GroupId))
}
case 3:
@ -546,11 +547,10 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
n := Num - 10
x := n / 3
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.15); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)
@ -564,14 +564,13 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
r = append(r, CreateRobot(float64(GoUtil.RandNum(2781, 4630)), GroupId))
n := Num - 4
x := n / 4
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.2); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)
@ -584,17 +583,16 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
r = append(r, CreateRobot(float64(GoUtil.RandNum(4631, 7530)), GroupId))
n := Num - 3
x := n / 5
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(2781, 4630)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.2); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)
@ -606,20 +604,19 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
r = append(r, CreateRobot(float64(GoUtil.RandNum(7531, 12180)), GroupId))
n := Num - 2
x := n / 6
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(4631, 7530)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(2781, 4630)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.25); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)
@ -629,23 +626,22 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
case 7:
r = append(r, CreateRobot(float64(GoUtil.RandNum(12181, 21680)), GroupId))
n := Num - 1
x := n / 7
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(7531, 12180)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(4631, 7530)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(2781, 4630)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.2); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)
@ -657,26 +653,26 @@ func CreateRobotList(G, Num, GroupId int) []*ChampshipRobot {
if M10 == 1 {
r = append(r, CreateRobot(float64(GoUtil.RandNum(35131, 64980)), GroupId))
}
x := Num / 8
for i := 0; i < x; i++ {
n := Num
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(12181, 21680)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(7531, 12180)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.05); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(4631, 7530)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(2781, 4630)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.1); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(1731, 2780)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.15); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(581, 1730)), GroupId))
}
for i := 0; i < x; i++ {
for i := 0; i < int(float64(n)*0.2); i++ {
r = append(r, CreateRobot(float64(GoUtil.RandNum(241, 580)), GroupId))
}
Last := Num - len(r)

View File

@ -597,7 +597,7 @@ func (ad *GameLogic) CreateDailyLogFile() {
if ad.Mlogger != nil {
ad.Mlogger.Close()
}
ad.Mlogger, ad.MloggerErr = log.NewDailyLog(now, "Debug", "log", l.LstdFlags)
ad.Mlogger, ad.MloggerErr = log.NewDailyLog(now, "Debug", conf.Server.LogPath, l.LstdFlags)
if ad.MloggerErr != nil {
log.Debug(ad.MloggerErr.Error())
return

View File

@ -55,6 +55,11 @@ func ReqGmCommand(args []interface{}) error {
num, _ := strconv.Atoi(arg[1])
player.GetPlayerBaseMod().AddExp(player, num)
player.PushClientRes(&player.GetPlayerBaseMod().Data)
case "addDailyActive":
num, _ := strconv.Atoi(arg[1])
DailyMod := player.PlayMod.getDailyTaskMod()
DailyMod.Active = num
player.PushClientRes(DailyMod.BackData())
case "setlv":
num, _ := strconv.Atoi(arg[1])
player.PlayMod.getBaseMod().Level = num

View File

@ -4,6 +4,7 @@ import (
"fmt"
"math"
"server/GoUtil"
baseCfg "server/conf/base"
userCfg "server/conf/user"
"server/game/mod/card"
"server/game/mod/item"
@ -38,8 +39,9 @@ func LimitedTimeEventTrigger(p *Player, AddEventId int) {
})
switch v {
case limitedTimeEvent.EVENT_TYPE_HIGH_ROLLER:
EnergyMul := p.PlayMod.getBaseMod().GetEnergyMul()
MaxEnergyMul := p.GetPlayerBaseMod().GetMaxEnergyMul(p)
BaseMod := p.PlayMod.getBaseMod()
EnergyMul := BaseMod.GetEnergyMul()
MaxEnergyMul := baseCfg.GetMaxEnergyMul(BaseMod.GetLevel(), BaseMod.GetEnergy())
p.PlayMod.getBaseMod().ResetEnergyMul(MaxEnergyMul)
NewEnergyMul := p.PlayMod.getBaseMod().GetEnergyMul()
OrderMod := p.PlayMod.getOrderMod()

View File

@ -5,6 +5,7 @@ import (
"database/sql"
"errors"
"server/MergeConst"
baseCfg "server/conf/base"
userCfg "server/conf/user"
"server/db"
"server/game/mod/item"
@ -148,9 +149,9 @@ func (p *PlayerBaseData) SaveDataFromDB(Key interface{}) bool {
func (p *PlayerBaseData) GetMaxEnergyMul(player *Player) int {
BaseMod := player.PlayMod.getBaseMod()
MaxEnergyMul := userCfg.GetEnergyMulByLv(BaseMod.Level)
MaxEnergyMul := baseCfg.GetMaxEnergyMul(BaseMod.GetLevel(), BaseMod.GetEnergy())
if player.PlayMod.getLimitedTimeEventMod().CheckExist(limitedTimeEvent.EVENT_TYPE_HIGH_ROLLER) {
MaxEnergyMul = 10
MaxEnergyMul = 11
}
return MaxEnergyMul
}

View File

@ -55,11 +55,20 @@ func (p *PlayerChessData) UpdatePlayerChessData(player *Player, buf []byte) erro
update := &msg.UpdatePlayerChessData{}
proto.Unmarshal(buf, update)
err := p.HandleChess(player, update.MChessHandle)
LastMap := player.PlayMod.getChessMod().ChessMap
if err != nil {
res := &msg.ResUpdatePlayerChessData{
Code: msg.RES_CODE_FAIL,
Msg: err.Error(),
}
HandleStr := ""
sort.Slice(update.MChessHandle, func(i, j int) bool {
return update.MChessHandle[i].Id < update.MChessHandle[j].Id
})
for _, v := range update.MChessHandle {
HandleStr += fmt.Sprintf("%v-%v-%v,", v.Id, v.ChessId, v.Type)
}
log.Debug("棋子操作队列错误, %v===%v===%v===%v", HandleStr, LastMap, p.Data.MChessData, player.PlayMod.getChessMod().GetChessList())
player.SendErrClienRes(res)
return err
}
@ -67,13 +76,19 @@ func (p *PlayerChessData) UpdatePlayerChessData(player *Player, buf []byte) erro
Code: msg.RES_CODE_SUCCESS,
})
p.Data.MChessData = update.MChessData
if !p.checkChessEqual(player) {
res := &msg.ResUpdatePlayerChessData{
Code: msg.RES_CODE_FAIL,
Msg: "棋子数据不一致",
}
log.Debug("棋子数据不一致, %v---%v", p.Data.MChessData, player.PlayMod.getChessMod().GetChessList())
HandleStr := ""
sort.Slice(update.MChessHandle, func(i, j int) bool {
return update.MChessHandle[i].Id < update.MChessHandle[j].Id
})
for _, v := range update.MChessHandle {
HandleStr += fmt.Sprintf("%v-%v-%v,", v.Id, v.ChessId, v.Type)
}
log.Debug("棋子数据不一致, %v===%v===%v===%v", HandleStr, LastMap, p.Data.MChessData, player.PlayMod.getChessMod().GetChessList())
player.SendErrClienRes(res)
return fmt.Errorf("棋子数据不一致")
}