This commit is contained in:
1
2025-09-23 15:08:12 +00:00
8 changed files with 57 additions and 32 deletions

View File

@@ -1,7 +1,5 @@
go 1.20 go 1.20
toolchain go1.21.4
use ( use (
./common ./common
./common/contrib/drivers/mysql ./common/contrib/drivers/mysql

View File

@@ -109,11 +109,16 @@ func (h Controller) Complete_Task(data *task.CompleteTaskInboundInfo, c *player.
*/ */
func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *player.Player) (result *task.GetTaskBufOutboundInfo, err errorcode.ErrorCode) { func (h Controller) Get_Task_Buf(data *task.GetTaskBufInboundInfo, c *player.Player) (result *task.GetTaskBufOutboundInfo, err errorcode.ErrorCode) {
result = &task.GetTaskBufOutboundInfo{} result = &task.GetTaskBufOutboundInfo{}
<<<<<<< HEAD
c.Service.Task(data.TaskId, func(te *model.TaskEX)bool { c.Service.Task(data.TaskId, func(te *model.TaskEX)bool {
result.TaskId = te.TaskID result.TaskId = te.TaskID
result.TaskList = te.Data result.TaskList = te.Data
return false return false
}) })
=======
result.TaskId = data.TaskId
result.TaskList = info.Data
>>>>>>> ea1148039e70e6b1dadf6c892b49e547d0f10ac7
return result, 0 return result, 0
} }

View File

@@ -41,11 +41,11 @@ func (f *FightC) GetInputByPlayer(c common.PlayerI, isOpposite bool) *input.Inpu
// 判断当前玩家是否为我方玩家 // 判断当前玩家是否为我方玩家
isOurPlayer := c == f.Our.Player isOurPlayer := c == f.Our.Player
// 逻辑简化:当"是否为我方玩家"与"是否需要对方"状态一致时,返回对方输入,否则返回我方输入 // 当isOurPlayer与isOpposite值不同时返回我方相同时返回对方
if isOurPlayer == isOpposite { if isOurPlayer != isOpposite {
return f.Opp
}
return f.Our return f.Our
}
return f.Opp
} }
func (f *FightC) GetInputByAction(c BattleActionI, isOpposite bool) *input.Input { func (f *FightC) GetInputByAction(c BattleActionI, isOpposite bool) *input.Input {
@@ -320,9 +320,9 @@ func (f *FightC) battleLoop() {
switch { switch {
case faction.ItemID >= 30001 && faction.ItemID <= 300010: //胶囊 case faction.ItemID >= 30001 && faction.ItemID <= 300010: //胶囊
f.Broadcast(func(ff *input.Input) {
//todo 将血量和技能pp传回enterturn //todo 将血量和技能pp传回enterturn
tt, ok := ff.Player.(*player.Player) tt, ok := f.Our.Player.(*player.Player)
mo, ism := f.Opp.Player.(*player.AI_player) mo, ism := f.Opp.Player.(*player.AI_player)
if ok && ism && mo.CanCapture { //如果获取玩家 if ok && ism && mo.CanCapture { //如果获取玩家
@@ -334,7 +334,7 @@ func (f *FightC) battleLoop() {
CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime), CatchTime: uint32(f.Opp.CurrentPet.Info.CatchTime),
PetId: uint32(f.Opp.CurrentPet.ID), PetId: uint32(f.Opp.CurrentPet.ID),
}) })
ff.Player.SendFightEndInfo(info.FightOverInfo{ tt.SendFightEndInfo(info.FightOverInfo{
WinnerId: f.ownerID, WinnerId: f.ownerID,
}) })
@@ -348,7 +348,6 @@ func (f *FightC) battleLoop() {
} }
})
// 当 ItemID 在 30001-300010 之间时执行的逻辑 // 当 ItemID 在 30001-300010 之间时执行的逻辑
fmt.Println("ItemID 在范围内") fmt.Println("ItemID 在范围内")
case faction.ItemID == 300001: case faction.ItemID == 300001:
@@ -465,6 +464,9 @@ func (f *FightC) processSkillAttack(attacker, defender *input.Input, a *SelectSk
func (f *FightC) enterturn(fattack, sattack BattleActionI) { func (f *FightC) enterturn(fattack, sattack BattleActionI) {
if f.closefight { //战斗结束
return
}
f.initAttackers(fattack) //初始化先后手 f.initAttackers(fattack) //初始化先后手
var attacker, defender *input.Input var attacker, defender *input.Input

View File

@@ -28,7 +28,7 @@ type Input struct {
func NewInput(c common.FightI, p common.PlayerI) *Input { func NewInput(c common.FightI, p common.PlayerI) *Input {
ret := &Input{FightC: c, Player: p} ret := &Input{FightC: c, Player: p}
t := NodeM[1000000] t, _ := ret.GetDamageEffect(1)
ret.AddEffect(deepcopy.Copy(t).(Effect)) //添加默认基类,实现继承 ret.AddEffect(deepcopy.Copy(t).(Effect)) //添加默认基类,实现继承
p.SetFightC(c) //给玩家设置战斗容器 p.SetFightC(c) //给玩家设置战斗容器
return ret return ret

View File

@@ -44,8 +44,13 @@ func (f *FightC) ChangePet(c common.PlayerI, id uint32) {
BaseAction: NewBaseAction(c.GetInfo().UserID), BaseAction: NewBaseAction(c.GetInfo().UserID),
} }
f.Switch = append(f.Switch, ret) f.Switch = append(f.Switch, ret)
if c.GetInfo().UserID == f.ownerID {
f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id) f.GetInputByPlayer(c, false).CurrentPet, ret.Reason = f.GetInputByPlayer(c, false).GetPet(id)
} else {
f.GetInputByPlayer(c, true).CurrentPet, ret.Reason = f.GetInputByPlayer(c, true).GetPet(id)
}
f.actionChan <- ret f.actionChan <- ret
} }

View File

@@ -17,7 +17,7 @@ func NewPlayer(opts ...PlayerOption) *Player {
p.StopChan = make(chan struct{}) p.StopChan = make(chan struct{})
// 启动刷怪协程 // 启动刷怪协程
go func(stopChan chan struct{}, currentMap int) { go func(stopChan chan struct{}) {
ticker := time.NewTicker(10 * time.Second) ticker := time.NewTicker(10 * time.Second)
defer ticker.Stop() defer ticker.Stop()
@@ -35,7 +35,7 @@ func NewPlayer(opts ...PlayerOption) *Player {
} }
} }
}(p.StopChan, int(p.Info.MapID)) }(p.StopChan)
for _, opt := range opts { for _, opt := range opts {
opt(p) opt(p)
} }

View File

@@ -61,6 +61,11 @@ type PetEX struct {
} }
type PetS struct {
Pet
Data []PetInfo `orm:"data" dc:"资源规格"`
}
func LastFourElements[T any](s []T) []T { func LastFourElements[T any](s []T) []T {
n := len(s) n := len(s)
if n <= 4 { if n <= 4 {

View File

@@ -15,10 +15,20 @@ type Task struct {
Data string `gorm:"type:text;not null;comment:'全部数据'" json:"data"` Data string `gorm:"type:text;not null;comment:'全部数据'" json:"data"`
} }
<<<<<<< HEAD
// TaskEX 单个任务的详细信息,包含任务步骤状态和整体状态 // TaskEX 单个任务的详细信息,包含任务步骤状态和整体状态
type TaskEX struct { type TaskEX struct {
Task Task
Data []uint32 `struc:"[20]byte" orm:"data" json:"data"` Data []uint32 `struc:"[20]byte" orm:"data" json:"data"`
=======
// TaskInfo 单个任务的详细信息,包含任务步骤状态和整体状态
type TaskInfo struct {
Task
// TaskInfo 任务步骤信息,
// struc:"[20]byte" 确保二进制序列化时固定20字节长度json标签指定JSON字段名
//TaskID uint32 `json:"task_id"` //区分是每日任务还是常规任务,常规为0,每日为1
Data []uint32 `orm:"data" struc:"[20]byte" json:"task_info"`
>>>>>>> ea1148039e70e6b1dadf6c892b49e547d0f10ac7
//LastResetTime time.Time `gorm:"not null;comment:'上次重置时间UTC'" json:"last_reset_time"` //这里是每天重置 //LastResetTime time.Time `gorm:"not null;comment:'上次重置时间UTC'" json:"last_reset_time"` //这里是每天重置
// Status 任务整体状态0-未接受1-已接受2-已完成未领取3-已完成已领取 // Status 任务整体状态0-未接受1-已接受2-已完成未领取3-已完成已领取
// json标签指定JSON字段名与业务状态说明保持一致 // json标签指定JSON字段名与业务状态说明保持一致