猫草大作战
This commit is contained in:
parent
dc2e1d8ea4
commit
745ebaced4
@ -3,6 +3,7 @@ package game
|
||||
import (
|
||||
"server/GoUtil"
|
||||
activityCfg "server/conf/activity"
|
||||
catnipCfg "server/conf/catnip"
|
||||
guesscolorCfg "server/conf/guessColor"
|
||||
itemCfg "server/conf/item"
|
||||
mailCfg "server/conf/mail"
|
||||
@ -55,6 +56,13 @@ func ActivityLogin(p *Player) {
|
||||
SendActivityMail(p, ItemId, ItemNum, ActivityId, nil)
|
||||
}
|
||||
}
|
||||
// 猫草大作战
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
OldId = CatnipMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
// 清空猫草大作战数据无需发邮件
|
||||
}
|
||||
|
||||
// 通行证
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_PASS)
|
||||
@ -99,6 +107,16 @@ func ActivityZeroUpdate(p *Player) {
|
||||
RaceMod := p.PlayMod.getRaceMod()
|
||||
RaceMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo != nil {
|
||||
PassMod := p.PlayMod.getPassMod()
|
||||
PassMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_CATNIP)
|
||||
if ActivityInfo != nil {
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
}
|
||||
|
||||
func GetActivityInfo(p *Player, actType int) *ActivityInfo {
|
||||
@ -287,6 +305,10 @@ func GetActivityItem(p *Player, ActType []int) []*item.Item {
|
||||
}
|
||||
|
||||
func (p *Player) CatnipBackData() {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_CATNIP)
|
||||
if CatnipMod == nil {
|
||||
@ -298,6 +320,7 @@ func (p *Player) CatnipBackData() {
|
||||
Id: int32(v.Id),
|
||||
Progress: int32(v.Progress),
|
||||
Status: int32(v.Status),
|
||||
Reward: GoUtil.SliceIntToInt32(v.Reward),
|
||||
}
|
||||
if v.Partner != 0 {
|
||||
PlayerData := G_getGameLogic().GetResSimplePlayerByUid(v.Partner)
|
||||
@ -305,12 +328,32 @@ func (p *Player) CatnipBackData() {
|
||||
GameInfo.Partner = PlayerData
|
||||
}
|
||||
}
|
||||
InviteList := make([]*msg.CatnipInvite, 0)
|
||||
for _, iv := range v.InviteList {
|
||||
InviteList = append(InviteList, &msg.CatnipInvite{
|
||||
Uid: int64(iv.InviteId),
|
||||
Time: int64(iv.Time),
|
||||
})
|
||||
}
|
||||
GameInfo.InviteList = InviteList
|
||||
BeInvitedList := make([]*msg.CatnipInvite, 0)
|
||||
for _, iv := range v.BeInvitedList {
|
||||
BeInvitedList = append(BeInvitedList, &msg.CatnipInvite{
|
||||
Uid: int64(iv.InviteId),
|
||||
Time: int64(iv.Time),
|
||||
})
|
||||
}
|
||||
GameInfo.BeInviteList = BeInvitedList
|
||||
GameList = append(GameList, GameInfo)
|
||||
}
|
||||
Template := catnipCfg.GetTemplateId(CatnipMod.Id)
|
||||
res := &msg.ResCatnip{
|
||||
Id: int32(CatnipMod.Id),
|
||||
EndTime: int32(ActivityInfo.EndT),
|
||||
Status: int32(Status),
|
||||
Template: int32(Template),
|
||||
GameList: GameList,
|
||||
Multiply: int32(CatnipMod.Mul),
|
||||
}
|
||||
p.PushClientRes(res)
|
||||
}
|
||||
|
||||
@ -5085,7 +5085,7 @@ func ReqCatnipMultiply(player *Player, buf []byte) error {
|
||||
req := &msg.ReqCatnipMultiply{}
|
||||
proto.Unmarshal(buf, req)
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
err := CatnipMod.Multiply(int(req.Id), int(req.Multiply))
|
||||
err := CatnipMod.Multiply(int(req.Multiply))
|
||||
if err != nil {
|
||||
player.SendErrClienRes(&msg.ResCatnipMultiply{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5094,9 +5094,9 @@ func ReqCatnipMultiply(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
player.TeLog("catnip_multiply", map[string]interface{}{
|
||||
"Id": int(req.Id),
|
||||
"Mul": int(req.Multiply),
|
||||
})
|
||||
player.CatnipBackData()
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipMultiply{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
@ -5140,6 +5140,7 @@ func ReqCatnipPlay(player *Player, buf []byte) error {
|
||||
if Growth > 0 {
|
||||
player.CatnipGrowthMsg(PartnerId, int(req.Id), Growth)
|
||||
}
|
||||
player.CatnipBackData()
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipPlay{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
@ -5174,6 +5175,7 @@ func ReqCatnipReward(player *Player, buf []byte) error {
|
||||
"Progress": int(req.Progress),
|
||||
"Items": Items,
|
||||
})
|
||||
player.CatnipBackData()
|
||||
player.PlayMod.save()
|
||||
player.PushClientRes(&msg.ResCatnipReward{
|
||||
Code: msg.RES_CODE_SUCCESS,
|
||||
|
||||
@ -8,9 +8,9 @@ import (
|
||||
)
|
||||
|
||||
type CatnipMod struct {
|
||||
Id int
|
||||
Game map[int]*CatnipGame
|
||||
|
||||
Id int
|
||||
Game map[int]*CatnipGame
|
||||
Mul int // 倍数
|
||||
IsGetGrandReward bool // 是否领取过大丰收奖励
|
||||
}
|
||||
|
||||
@ -25,7 +25,6 @@ type CatnipGame struct {
|
||||
Progress int // 进度
|
||||
PartnerAdd int // 伙伴贡献
|
||||
Reward []int // 已领取阶段奖励
|
||||
Mul int // 倍数
|
||||
Status int // 0: Not Started, 1: In Progress, 2: Completed
|
||||
InviteList map[int]*InviteInfo // 邀请列表,key: 邀请者ID, value: 被邀请者ID
|
||||
BeInvitedList map[int]*InviteInfo // 被邀请列表,key: 被邀请者ID, value: 邀请者ID
|
||||
@ -39,6 +38,7 @@ const (
|
||||
|
||||
func (c *CatnipMod) InitData() {
|
||||
// Initialize Catnip data here
|
||||
// c.Game = nil
|
||||
if c.Game == nil {
|
||||
c.Game = make(map[int]*CatnipGame)
|
||||
}
|
||||
@ -56,13 +56,16 @@ func (c *CatnipMod) Login(Id int) int {
|
||||
c.Id = Id
|
||||
c.IsGetGrandReward = false // Reset grand reward status on login
|
||||
c.Game = make(map[int]*CatnipGame)
|
||||
c.Mul = 1 // Default multiplier
|
||||
GameNum := catnipCfg.GetGameNum(c.Id) // Assuming 1 is the default game ID
|
||||
for i := 1; i <= GameNum; i++ {
|
||||
c.Game[i] = &CatnipGame{
|
||||
Id: i,
|
||||
Partner: 0, // No partner initially
|
||||
Progress: 0, // Initial progress
|
||||
Status: GAME_STATUS_IDLE, // Not started
|
||||
Id: i,
|
||||
Partner: 0, // No partner initially
|
||||
Progress: 0, // Initial progress
|
||||
Status: GAME_STATUS_IDLE, // Not started
|
||||
InviteList: make(map[int]*InviteInfo), // Initialize invite list
|
||||
BeInvitedList: make(map[int]*InviteInfo), // Initialize be invited list
|
||||
}
|
||||
}
|
||||
return c.Id
|
||||
@ -144,12 +147,8 @@ func (c *CatnipMod) DelInvited(Id, Uid int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *CatnipMod) Multiply(Id, Mul int) error {
|
||||
GameInfo, ok := c.Game[Id]
|
||||
if !ok {
|
||||
return fmt.Errorf("game with ID %d does not exist", Id)
|
||||
}
|
||||
GameInfo.Mul = Mul
|
||||
func (c *CatnipMod) Multiply(Mul int) error {
|
||||
c.Mul = Mul
|
||||
return nil
|
||||
}
|
||||
|
||||
@ -170,11 +169,12 @@ func (c *CatnipMod) Play(Id int) (int, int, int, []*item.Item, []*item.Item, err
|
||||
if !ok {
|
||||
return 0, 0, 0, nil, nil, fmt.Errorf("game with ID %d does not exist", Id)
|
||||
}
|
||||
Id, Items, Growth := catnipCfg.GetJackpotItem(GameInfo.Mul)
|
||||
Id, Items, Growth := catnipCfg.GetJackpotItem(c.Mul)
|
||||
if Growth > 0 {
|
||||
c.Growth(Id, Growth)
|
||||
}
|
||||
ItemCost := catnipCfg.GetItemCost(c.Id, GameInfo.Mul)
|
||||
ItemCost := catnipCfg.GetItemCost(c.Id, c.Mul)
|
||||
GameInfo.Progress += Growth
|
||||
return Id, Growth, GameInfo.Partner, Items, ItemCost, nil
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user