赛跑活动

This commit is contained in:
hahwu 2025-03-31 15:53:25 +08:00
parent 71eafdecb0
commit 69dc7d638a
2 changed files with 24 additions and 10 deletions

View File

@ -17,6 +17,7 @@ import (
mergeDataCfg "server/conf/mergeData"
miningCfg "server/conf/mining"
"server/db"
"server/game/mod/activity"
"server/game/mod/item"
"server/game/mod/limitedTimeEvent"
MsgMod "server/game/mod/msg"
@ -639,8 +640,13 @@ func (p *Player) HandleItem(itemList []*item.Item, Label string) error {
})
BackDataType[item.ITEM_TYPE_FACE] = struct{}{}
case item.ITEM_TYPE_ACTIVITY_RACE: // 活动竞速
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_RACE)
if ActivityInfo == nil {
continue
}
RaceMod := p.PlayMod.getRaceMod()
RaceMod.AddCoin(v.Num)
RaceBackData(p)
case item.ITEM_TYPE_PLAYROOM_VISIT: // 拜访玩家
Target := GetVisitorPlayer(p)
playroomMod := p.PlayMod.getPlayroomMod()

View File

@ -55,14 +55,9 @@ func (r *RaceMod) StartGame() error {
return fmt.Errorf("the game has started")
}
r.StartTime = GoUtil.Now()
Opponent := make([]*Opponent, 0)
OpponentNum := raceCfg.GetRaceNum(r.Pass)
names := randnameCfg.GetRandNames(OpponentNum)
for i := 0; i < OpponentNum; i++ {
Opponent = append(Opponent, randOpponent(i, names[i]))
}
r.EndTime = r.StartTime + int64(raceCfg.GetCD(r.Id))
r.Opponent = Opponent
r.Opponent = randOpponents(OpponentNum)
return nil
}
@ -93,17 +88,30 @@ func (r *RaceMod) GetReward() ([]*item.Item, error) {
Items = append(Items, ExtraReward...)
}
r.Pass++
r.Progress -= Need
MaxPass := raceCfg.GetMaxPass(r.Id)
if r.Pass > MaxPass {
r.Pass = 1
}
r.StartTime = 0
r.EndTime = 0
r.Progress -= Need
r.Opponent = nil
} else {
r.StartTime = Now
r.EndTime = Now + int64(raceCfg.GetCD(r.Id))
r.Opponent = randOpponents(raceCfg.GetRaceNum(r.Pass))
}
return Items, nil
}
func randOpponents(OpponentNum int) []*Opponent {
Opponent := make([]*Opponent, 0)
names := randnameCfg.GetRandNames(OpponentNum)
for i := 0; i < OpponentNum; i++ {
Opponent = append(Opponent, randOpponent(i, names[i]))
}
return Opponent
}
func randOpponent(Id int, name string) *Opponent {
return &Opponent{
Id: Id,