代码优化
This commit is contained in:
parent
f611eccec9
commit
7a4586b1ef
@ -18,10 +18,10 @@ import (
|
||||
)
|
||||
|
||||
// 活动模块 登录
|
||||
func ActivityLogin(p *Player) {
|
||||
func (p *Player) ActivityLogin() {
|
||||
ItemMod := p.PlayMod.getItemMod()
|
||||
// 挖矿
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_MINING)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_MINING)
|
||||
MiningMod := p.PlayMod.getMiningMod()
|
||||
OldId := MiningMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
@ -29,11 +29,11 @@ func ActivityLogin(p *Player) {
|
||||
ItemNum := ItemMod.GetItem(ItemId)
|
||||
if ItemNum != 0 {
|
||||
ItemMod.AddItem(ItemId, -ItemNum)
|
||||
SendActivityMail(p, ItemId, ItemNum, ActivityId, nil)
|
||||
p.SendActivityMail(ItemId, ItemNum, ActivityId, nil)
|
||||
}
|
||||
}
|
||||
// 猜颜色
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_GUESS_COLOR)
|
||||
ActivityId = p.GetActivityId(activity.ACT_TYPE_GUESS_COLOR)
|
||||
GuessColorMod := p.PlayMod.getGuessColorMod()
|
||||
OldId = GuessColorMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
@ -41,12 +41,12 @@ func ActivityLogin(p *Player) {
|
||||
ItemNum := ItemMod.GetItem(ItemId)
|
||||
if ItemNum != 0 {
|
||||
ItemMod.AddItem(ItemId, -ItemNum)
|
||||
SendActivityMail(p, ItemId, ItemNum, ActivityId, nil)
|
||||
p.SendActivityMail(ItemId, ItemNum, ActivityId, nil)
|
||||
}
|
||||
}
|
||||
|
||||
// 赛跑
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_RACE)
|
||||
ActivityId = p.GetActivityId(activity.ACT_TYPE_RACE)
|
||||
RaceMod := p.PlayMod.getRaceMod()
|
||||
OldId = RaceMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
@ -54,11 +54,11 @@ func ActivityLogin(p *Player) {
|
||||
ItemNum := ItemMod.GetItem(ItemId)
|
||||
if ItemNum != 0 {
|
||||
ItemMod.AddItem(ItemId, -ItemNum)
|
||||
SendActivityMail(p, ItemId, ItemNum, ActivityId, nil)
|
||||
p.SendActivityMail(ItemId, ItemNum, ActivityId, nil)
|
||||
}
|
||||
}
|
||||
// 猫草大作战
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId = p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
OldId = CatnipMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
@ -66,7 +66,7 @@ func ActivityLogin(p *Player) {
|
||||
}
|
||||
|
||||
// 通行证
|
||||
ActivityId = GetActivityId(p, activity.ACT_TYPE_PASS)
|
||||
ActivityId = p.GetActivityId(activity.ACT_TYPE_PASS)
|
||||
PassMod := p.PlayMod.getPassMod()
|
||||
OldId = PassMod.Login(ActivityId)
|
||||
if OldId != 0 {
|
||||
@ -75,12 +75,13 @@ func ActivityLogin(p *Player) {
|
||||
RewardItems, _ := PassMod.GetRewardItems()
|
||||
if ItemNum != 0 {
|
||||
ItemMod.AddItem(ItemId, -ItemNum)
|
||||
SendActivityMail(p, ItemId, ItemNum, ActivityId, RewardItems)
|
||||
p.SendActivityMail(ItemId, ItemNum, ActivityId, RewardItems)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func SendActivityMail(p *Player, ItemId, ItemNum, ActivityId int, RewardItems []*item.Item) {
|
||||
// 发送活动邮件
|
||||
func (p *Player) SendActivityMail(ItemId, ItemNum, ActivityId int, RewardItems []*item.Item) {
|
||||
MailMod := p.PlayMod.getMailMod()
|
||||
ItemName, ItemNameEn := itemCfg.GetItemName(ItemId)
|
||||
ActivityTitle, ActivityTitleEn := activityCfg.GetActivityTitle(ActivityId)
|
||||
@ -91,36 +92,37 @@ func SendActivityMail(p *Player, ItemId, ItemNum, ActivityId int, RewardItems []
|
||||
}
|
||||
|
||||
// 活动模块 零点更新
|
||||
func ActivityZeroUpdate(p *Player) {
|
||||
ActivityLogin(p)
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_MINING)
|
||||
func (p *Player) ActivityZeroUpdate() {
|
||||
p.ActivityLogin()
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_MINING)
|
||||
if ActivityInfo != nil {
|
||||
MiningMod := p.PlayMod.getMiningMod()
|
||||
MiningMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_GUESS_COLOR)
|
||||
ActivityInfo = p.GetActivityInfo(activity.ACT_TYPE_GUESS_COLOR)
|
||||
if ActivityInfo != nil {
|
||||
GuessColorMod := p.PlayMod.getGuessColorMod()
|
||||
GuessColorMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_RACE)
|
||||
ActivityInfo = p.GetActivityInfo(activity.ACT_TYPE_RACE)
|
||||
if ActivityInfo != nil {
|
||||
RaceMod := p.PlayMod.getRaceMod()
|
||||
RaceMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
ActivityInfo = p.GetActivityInfo(activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo != nil {
|
||||
PassMod := p.PlayMod.getPassMod()
|
||||
PassMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
ActivityInfo = GetActivityInfo(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityInfo = p.GetActivityInfo(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityInfo != nil {
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMod.ZeroUpdate(ActivityInfo.Id)
|
||||
}
|
||||
}
|
||||
|
||||
func GetActivityInfo(p *Player, actType int) *ActivityInfo {
|
||||
// 获取活动信息
|
||||
func (p *Player) GetActivityInfo(actType int) *ActivityInfo {
|
||||
for _, v := range p.activity {
|
||||
if v.Type == actType {
|
||||
return v
|
||||
@ -129,7 +131,8 @@ func GetActivityInfo(p *Player, actType int) *ActivityInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetActivityId(p *Player, actType int) int {
|
||||
// 获取活动ID
|
||||
func (p *Player) GetActivityId(actType int) int {
|
||||
for _, v := range p.activity {
|
||||
if v.Type == actType {
|
||||
return v.Id
|
||||
@ -138,7 +141,8 @@ func GetActivityId(p *Player, actType int) int {
|
||||
return 0
|
||||
}
|
||||
|
||||
func GetActivityInfoById(p *Player, Id int) *ActivityInfo {
|
||||
// 根据活动ID获取活动信息
|
||||
func (p *Player) GetActivityInfoById(Id int) *ActivityInfo {
|
||||
for _, v := range p.activity {
|
||||
if v.Id == Id {
|
||||
return v
|
||||
@ -147,8 +151,9 @@ func GetActivityInfoById(p *Player, Id int) *ActivityInfo {
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetActivityStatus(p *Player, actType int) int {
|
||||
ActivityInfo := GetActivityInfo(p, actType)
|
||||
// 获取活动状态
|
||||
func (p *Player) GetActivityStatus(actType int) int {
|
||||
ActivityInfo := p.GetActivityInfo(actType)
|
||||
if ActivityInfo == nil {
|
||||
return ACT_STATUS_NOT_START
|
||||
}
|
||||
@ -163,11 +168,11 @@ func GetActivityStatus(p *Player, actType int) int {
|
||||
}
|
||||
|
||||
func MiningBackData(p *Player) {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_MINING)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_MINING)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_MINING)
|
||||
Status := p.GetActivityStatus(activity.ACT_TYPE_MINING)
|
||||
Template := miningCfg.GetTemplate(ActivityInfo.Id)
|
||||
MiningMod := p.PlayMod.getMiningMod()
|
||||
p.PushClientRes(&msg.ResMining{
|
||||
@ -183,12 +188,12 @@ func MiningBackData(p *Player) {
|
||||
}
|
||||
|
||||
func GuessColorBackData(p *Player) {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_GUESS_COLOR)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_GUESS_COLOR)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_GUESS_COLOR)
|
||||
Status := p.GetActivityStatus(activity.ACT_TYPE_GUESS_COLOR)
|
||||
GuessColorMod := p.PlayMod.getGuessColorMod()
|
||||
MapList := make([]*msg.GuessColorInfo, 0)
|
||||
for _, v := range GuessColorMod.MapList {
|
||||
@ -214,11 +219,11 @@ func GuessColorBackData(p *Player) {
|
||||
}
|
||||
|
||||
func RaceBackData(p *Player) {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_RACE)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_RACE)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_RACE)
|
||||
Status := p.GetActivityStatus(activity.ACT_TYPE_RACE)
|
||||
RaceMod := p.PlayMod.getRaceMod()
|
||||
Opponent := make([]*msg.Raceopponent, 0)
|
||||
for _, v := range RaceMod.Opponent {
|
||||
@ -255,11 +260,11 @@ func RedBackData(p *Player) {
|
||||
}
|
||||
|
||||
func ActPassBackData(p *Player) {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_PASS)
|
||||
Status := p.GetActivityStatus(activity.ACT_TYPE_PASS)
|
||||
Template := passCfg.GetTemplate(ActivityInfo.Id)
|
||||
PassMod := p.PlayMod.getPassMod()
|
||||
p.PushClientRes(&msg.ResActPass{
|
||||
@ -277,8 +282,8 @@ func ActPassBackData(p *Player) {
|
||||
func GetActivityItem(p *Player, ActType []int) []*item.Item {
|
||||
Items := make([]*item.Item, 0)
|
||||
for _, v := range ActType {
|
||||
Status := GetActivityStatus(p, v)
|
||||
ActivityInfo := GetActivityInfo(p, v)
|
||||
Status := p.GetActivityStatus(v)
|
||||
ActivityInfo := p.GetActivityInfo(v)
|
||||
if ActivityInfo == nil {
|
||||
continue
|
||||
}
|
||||
@ -306,12 +311,12 @@ func GetActivityItem(p *Player, ActType []int) []*item.Item {
|
||||
}
|
||||
|
||||
func (p *Player) CatnipBackData() {
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
Status := GetActivityStatus(p, activity.ACT_TYPE_CATNIP)
|
||||
Status := p.GetActivityStatus(activity.ACT_TYPE_CATNIP)
|
||||
if CatnipMod == nil {
|
||||
return
|
||||
}
|
||||
@ -391,7 +396,7 @@ func (p *Player) CatnipBackData() {
|
||||
}
|
||||
|
||||
func (p *Player) SetCatnipGameLock(Uid int, GameId int) error {
|
||||
ActivityInfo := GetActivityInfoById(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityInfo := p.GetActivityInfoById(activity.ACT_TYPE_CATNIP)
|
||||
return G_GameLogicPtr.SetDataSync(int(p.M_DwUin), VAR_OP_CATNIP_LOCK, CatnipLock{
|
||||
Uid: int(p.M_DwUin),
|
||||
Partner: Uid,
|
||||
|
||||
@ -16,7 +16,6 @@ import (
|
||||
MsgMod "server/game/mod/msg"
|
||||
"server/game/mod/piggyBank"
|
||||
"server/game/mod/quest"
|
||||
"server/msg"
|
||||
proto "server/msg"
|
||||
"server/pkg/github.com/name5566/leaf/log"
|
||||
"strings"
|
||||
@ -49,7 +48,7 @@ func ADPetWorkFire(p *Player, ChargeId int) {
|
||||
ChargeMod := p.PlayMod.getChargeMod()
|
||||
Item := ChargeMod.FireAdReward(ChargeId)
|
||||
if Item != nil {
|
||||
err := p.HandleItem(Item, msg.ITEM_POP_LABEL_ActivityGift.String())
|
||||
err := p.HandleItem(Item, proto.ITEM_POP_LABEL_ActivityGift.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
return
|
||||
@ -62,7 +61,7 @@ func ADPetWorkFire(p *Player, ChargeId int) {
|
||||
func ActivityFire(p *Player, ChargeId int) {
|
||||
ActivityMod := p.PlayMod.getActivityMod()
|
||||
ActivityId := activityCfg.GetActivityGiftId(ChargeId)
|
||||
ActivityInfo := GetActivityInfoById(p, ActivityId)
|
||||
ActivityInfo := p.GetActivityInfoById(ActivityId)
|
||||
if ActivityInfo == nil {
|
||||
log.Debug("ActivityFire ActivityInfo nil : player id :%d, charge id:%d", p.M_DwUin, ChargeId)
|
||||
return
|
||||
@ -75,7 +74,7 @@ func ActivityFire(p *Player, ChargeId int) {
|
||||
if Item == nil {
|
||||
return
|
||||
}
|
||||
err = p.HandleItem(Item, msg.ITEM_POP_LABEL_ActivityGift.String())
|
||||
err = p.HandleItem(Item, proto.ITEM_POP_LABEL_ActivityGift.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
return
|
||||
@ -86,11 +85,11 @@ func ActivityFire(p *Player, ChargeId int) {
|
||||
}
|
||||
|
||||
func PassFire(p *Player, ChargeId int) {
|
||||
ActivityStatus := GetActivityStatus(p, activity.ACT_TYPE_PASS)
|
||||
ActivityStatus := p.GetActivityStatus(activity.ACT_TYPE_PASS)
|
||||
if ActivityStatus != ACT_STATUS_START {
|
||||
return
|
||||
}
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo == nil {
|
||||
return
|
||||
}
|
||||
@ -107,7 +106,7 @@ func PassFire(p *Player, ChargeId int) {
|
||||
if len(Items) == 0 {
|
||||
return
|
||||
}
|
||||
err := p.HandleItem(Items, msg.ITEM_POP_LABEL_PassCharge.String())
|
||||
err := p.HandleItem(Items, proto.ITEM_POP_LABEL_PassCharge.String())
|
||||
if err != nil {
|
||||
log.Debug("PassFire err : %s", err)
|
||||
return
|
||||
@ -121,7 +120,7 @@ func PlayroomFire(p *Player, ChargeId int) {
|
||||
if Item == nil {
|
||||
return
|
||||
}
|
||||
err := p.HandleItem(Item, msg.ITEM_POP_LABEL_Playroom.String())
|
||||
err := p.HandleItem(Item, proto.ITEM_POP_LABEL_Playroom.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
}
|
||||
@ -137,7 +136,7 @@ func PiggyBankFire(p *Player, ChargeId int) {
|
||||
if Item == nil {
|
||||
return
|
||||
}
|
||||
err := p.HandleItem(Item, msg.ITEM_POP_LABEL_PiggyBank.String())
|
||||
err := p.HandleItem(Item, proto.ITEM_POP_LABEL_PiggyBank.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
}
|
||||
@ -158,7 +157,7 @@ func ChargeFire(p *Player, ChargeId int) {
|
||||
if Item == nil {
|
||||
return
|
||||
}
|
||||
err := p.HandleItem(Item, msg.ITEM_POP_LABEL_Charge.String())
|
||||
err := p.HandleItem(Item, proto.ITEM_POP_LABEL_Charge.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
}
|
||||
@ -179,7 +178,7 @@ func EndlessFire(p *Player, ChargeId int) {
|
||||
if Item == nil {
|
||||
return
|
||||
}
|
||||
err := p.HandleItem(Item, msg.ITEM_POP_LABEL_Endless.String())
|
||||
err := p.HandleItem(Item, proto.ITEM_POP_LABEL_Endless.String())
|
||||
if err != nil {
|
||||
log.Debug("ChargeFire err : %s", err)
|
||||
}
|
||||
|
||||
@ -283,24 +283,24 @@ func ReqGmCommand_(player *Player, Command string) error {
|
||||
case "miningReload":
|
||||
MiningMod := player.PlayMod.getMiningMod()
|
||||
MiningMod.ZeroUpdate(-1)
|
||||
ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_MINING)
|
||||
ActivityInfo := player.GetActivityInfo(activity.ACT_TYPE_MINING)
|
||||
MiningMod.ZeroUpdate(ActivityInfo.Id)
|
||||
MiningBackData(player)
|
||||
case "catnipReload":
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
CatnipMod.ZeroUpdate(-1)
|
||||
ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityInfo := player.GetActivityInfo(activity.ACT_TYPE_CATNIP)
|
||||
CatnipMod.ZeroUpdate(ActivityInfo.Id)
|
||||
case "guessColorReload":
|
||||
GuessColorMod := player.PlayMod.getGuessColorMod()
|
||||
GuessColorMod.ZeroUpdate(-1)
|
||||
ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_GUESS_COLOR)
|
||||
ActivityInfo := player.GetActivityInfo(activity.ACT_TYPE_GUESS_COLOR)
|
||||
GuessColorMod.ZeroUpdate(ActivityInfo.Id)
|
||||
GuessColorBackData(player)
|
||||
case "raceReload":
|
||||
RaceMod := player.PlayMod.getRaceMod()
|
||||
RaceMod.ZeroUpdate(-1)
|
||||
ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_RACE)
|
||||
ActivityInfo := player.GetActivityInfo(activity.ACT_TYPE_RACE)
|
||||
RaceMod.ZeroUpdate(ActivityInfo.Id)
|
||||
RaceBackData(player)
|
||||
case "raceAdd":
|
||||
|
||||
@ -16,7 +16,7 @@ import (
|
||||
)
|
||||
|
||||
// 限时事件触发器
|
||||
func LimitedTimeEventTrigger(p *Player, AddEventId int) {
|
||||
func (p *Player) LimitedTimeEventTrigger(AddEventId int) {
|
||||
Lv := p.GetPlayerBaseMod().GetLevel()
|
||||
EndTime, TimeoutEvent, AddEvent := p.PlayMod.getLimitedTimeEventMod().Trigger(Lv)
|
||||
remainingTime := GoUtil.NextHourRemain()
|
||||
@ -28,7 +28,7 @@ func LimitedTimeEventTrigger(p *Player, AddEventId int) {
|
||||
p.CallEvent(time.Duration(EndTime)*time.Second, func() {
|
||||
p.lock.Lock()
|
||||
defer p.lock.Unlock()
|
||||
LimitedTimeEventTrigger(p, 0)
|
||||
p.LimitedTimeEventTrigger(0)
|
||||
p.SendClientRes()
|
||||
}, "LimitedTimeEvent")
|
||||
}
|
||||
|
||||
@ -321,7 +321,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_CATNIP_INVITE: // 邀请好友参与猫咪游戏
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsg := m.Extra.(CatnipMsg)
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId != CatnipMsg.ActivityId { // 活动ID不匹配
|
||||
return nil
|
||||
}
|
||||
@ -331,7 +331,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_CATNIP_AGREE: // 同意好友参与猫咪游戏
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsgInfo := m.Extra.(CatnipMsg)
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId != CatnipMsgInfo.ActivityId { // 活动ID不匹配
|
||||
return nil
|
||||
}
|
||||
@ -339,7 +339,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_CATNIP_AGREE_DEL: // 同意好友参与猫咪游戏后删除邀请
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsg := m.Extra.(CatnipMsg)
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId != CatnipMsg.ActivityId { // 活动ID不匹配
|
||||
return nil
|
||||
}
|
||||
@ -347,7 +347,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_CATNIP_REFUSE: // 拒绝好友参与猫咪游戏
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipMsg := m.Extra.(CatnipMsg)
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId != CatnipMsg.ActivityId { // 活动ID不匹配
|
||||
return nil
|
||||
}
|
||||
@ -355,7 +355,7 @@ func handle(p *Player, m *msg.Msg) error {
|
||||
case msg.HANDLE_TYPE_CATNIP_GROWTH:
|
||||
CatnipMod := p.PlayMod.getCatnipMod()
|
||||
CatnipGrowthInfo := m.Extra.(CatnipMsg)
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId != CatnipGrowthInfo.ActivityId { // 活动ID不匹配
|
||||
return nil
|
||||
}
|
||||
@ -508,7 +508,7 @@ func SyncMailMsg(p *Player) {
|
||||
}
|
||||
|
||||
func (p *Player) CatnipGrowthMsg(To, Id, Growth, FriendItems int) error {
|
||||
ActivityId := GetActivityId(p, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := p.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
FriendMgrSend(&msg.Msg{
|
||||
From: int(p.M_DwUin),
|
||||
To: To,
|
||||
|
||||
@ -350,7 +350,7 @@ func (p *Player) ZeroUpdate(a []interface{}) {
|
||||
PlayroomBackData(p)
|
||||
p.PlayMod.getChampshipMod().ZeroUpdate()
|
||||
p.initAcitivity()
|
||||
ActivityZeroUpdate(p)
|
||||
p.ActivityZeroUpdate()
|
||||
p.QuestTrigger(&quest.Trigger{Label: quest.TRIGGER_LABEL_LOGIN})
|
||||
p.PlayMod.save()
|
||||
}
|
||||
@ -387,7 +387,7 @@ func (p *Player) NoonUpdate(a []interface{}) {
|
||||
func (p *Player) Login() {
|
||||
// 添加定时器
|
||||
// 限时事件触发
|
||||
LimitedTimeEventTrigger(p, 0)
|
||||
p.LimitedTimeEventTrigger(0)
|
||||
// 猪猪银行触发
|
||||
LimitedTimePiggyBankTrigger(p)
|
||||
BaseMod := p.PlayMod.getBaseMod()
|
||||
@ -400,7 +400,7 @@ func (p *Player) Login() {
|
||||
LimitedTimePlayroomTrigger(p) // playroom数值变化
|
||||
LimitedTimePlayroomWorkTrigger(p) // playroom打工
|
||||
LimitedTimeEnergyAdd(p) // 能量定时处理
|
||||
ActivityLogin(p) // 活动登录
|
||||
p.ActivityLogin() // 活动登录
|
||||
p.Compensation()
|
||||
SyncMailMsg(p) // 同步邮件
|
||||
Duration := BaseMod.Login()
|
||||
@ -700,7 +700,7 @@ func (p *Player) HandleItem(itemList []*item.Item, Label string) error {
|
||||
Cd: int32(EffectList[1]),
|
||||
})
|
||||
// 触发订单事件 生成超级订单 卡牌节
|
||||
LimitedTimeEventTrigger(p, EffectList[0])
|
||||
p.LimitedTimeEventTrigger(EffectList[0])
|
||||
p.TeLog("time_limited_event_enable", map[string]interface{}{
|
||||
"event_type": limitedTimeEventCfg.GetEventName(EffectList[0]),
|
||||
"enable_type": Label,
|
||||
@ -749,7 +749,7 @@ func (p *Player) HandleItem(itemList []*item.Item, Label string) error {
|
||||
p.PlayerDecoLog("face", Effect[0], Label)
|
||||
BackDataType[item.ITEM_TYPE_FACE] = struct{}{}
|
||||
case item.ITEM_TYPE_ACTIVITY_RACE: // 活动竞速
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_RACE)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_RACE)
|
||||
if ActivityInfo == nil {
|
||||
continue
|
||||
}
|
||||
@ -824,7 +824,7 @@ func (p *Player) HandleItem(itemList []*item.Item, Label string) error {
|
||||
}
|
||||
BackDataType[item.ITEM_TYPE_PLAYROOM_DRESS_SET] = struct{}{}
|
||||
case item.ITEM_TYPE_ACT_PASS: // 活动通行证
|
||||
ActivityInfo := GetActivityInfo(p, activity.ACT_TYPE_PASS)
|
||||
ActivityInfo := p.GetActivityInfo(activity.ACT_TYPE_PASS)
|
||||
if ActivityInfo == nil {
|
||||
continue
|
||||
}
|
||||
@ -1126,7 +1126,7 @@ func (p *Player) BackDataActivity() {
|
||||
}
|
||||
|
||||
func (p *Player) GetRed(AI *ActivityInfo) int {
|
||||
Status := GetActivityStatus(p, AI.Type)
|
||||
Status := p.GetActivityStatus(AI.Type)
|
||||
if Status != ACT_STATUS_START {
|
||||
return 0
|
||||
}
|
||||
@ -1143,8 +1143,8 @@ func (p *Player) GetRed(AI *ActivityInfo) int {
|
||||
}
|
||||
|
||||
func (p *Player) NotifyRed(actType int) {
|
||||
ActivityInfo := GetActivityInfo(p, actType)
|
||||
Status := GetActivityStatus(p, actType)
|
||||
ActivityInfo := p.GetActivityInfo(actType)
|
||||
Status := p.GetActivityStatus(actType)
|
||||
if Status != ACT_STATUS_START {
|
||||
return
|
||||
}
|
||||
|
||||
@ -3430,8 +3430,8 @@ func ReqMiningTake(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
MiningMod := player.PlayMod.getMiningMod()
|
||||
ActivityInfo := GetActivityInfo(player, activity.ACT_TYPE_MINING)
|
||||
Status := GetActivityStatus(player, activity.ACT_TYPE_MINING)
|
||||
ActivityInfo := player.GetActivityInfo(activity.ACT_TYPE_MINING)
|
||||
Status := player.GetActivityStatus(activity.ACT_TYPE_MINING)
|
||||
if Status != ACT_STATUS_START {
|
||||
player.SendErrClienRes(&msg.ResMiningTake{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -3474,7 +3474,7 @@ func ReqMiningTake(player *Player, buf []byte) error {
|
||||
// 领取关卡奖励
|
||||
func ReqMiningReward(player *Player, buf []byte) error {
|
||||
MiningMod := player.PlayMod.getMiningMod()
|
||||
Status := GetActivityStatus(player, activity.ACT_TYPE_MINING)
|
||||
Status := player.GetActivityStatus(activity.ACT_TYPE_MINING)
|
||||
if Status != ACT_STATUS_START {
|
||||
player.SendErrClienRes(&msg.ResMiningReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -3535,7 +3535,7 @@ func ReqGuessColorTake(player *Player, buf []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Status := GetActivityStatus(player, activity.ACT_TYPE_GUESS_COLOR)
|
||||
Status := player.GetActivityStatus(activity.ACT_TYPE_GUESS_COLOR)
|
||||
if Status != ACT_STATUS_START {
|
||||
player.SendErrClienRes(&msg.ResGuessColorTake{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -3575,7 +3575,7 @@ func ReqGuessColorReward(player *Player, buf []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
Status := GetActivityStatus(player, activity.ACT_TYPE_GUESS_COLOR)
|
||||
Status := player.GetActivityStatus(activity.ACT_TYPE_GUESS_COLOR)
|
||||
if Status != ACT_STATUS_START {
|
||||
player.SendErrClienRes(&msg.ResGuessColorReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -4876,7 +4876,7 @@ func ReqActivityReward(player *Player, buf []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ActivityInfo := GetActivityInfo(player, int(req.Id))
|
||||
ActivityInfo := player.GetActivityInfo(int(req.Id))
|
||||
if ActivityInfo == nil {
|
||||
player.SendErrClienRes(&msg.ResActivityReward{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5347,7 +5347,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error {
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipInvite{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5355,7 +5355,7 @@ func ReqCatnipInvite(player *Player, buf []byte) error {
|
||||
})
|
||||
return fmt.Errorf("activity not active")
|
||||
}
|
||||
ActivityInfo := GetActivityInfo(player, ActivityId)
|
||||
ActivityInfo := player.GetActivityInfo(ActivityId)
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
err = CatnipMod.Invite(int(req.Uid), int(req.Id))
|
||||
if err != nil {
|
||||
@ -5395,7 +5395,7 @@ func ReqCatnipAgree(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipAgree{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5449,7 +5449,7 @@ func ReqCatnipMultiply(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipMultiply{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5484,7 +5484,7 @@ func ReqCatnipPlay(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipPlay{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5542,7 +5542,7 @@ func ReqCatnipReward(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipPlay{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5588,7 +5588,7 @@ func ReqCatnipGrandReward(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipPlay{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5630,7 +5630,7 @@ func ReqCatnipRefuse(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipRefuse{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
@ -5655,7 +5655,7 @@ func ReqCatnipRefuse(player *Player, buf []byte) error {
|
||||
Type: MsqMod.HANDLE_TYPE_CATNIP_REFUSE,
|
||||
SendT: GoUtil.Now(),
|
||||
Extra: CatnipMsg{
|
||||
ActivityId: GetActivityId(player, activity.ACT_TYPE_CATNIP),
|
||||
ActivityId: player.GetActivityId(activity.ACT_TYPE_CATNIP),
|
||||
GameId: int(req.Id),
|
||||
},
|
||||
})
|
||||
@ -5736,7 +5736,7 @@ func ReqFriendReplyHandle(player *Player, buf []byte) error {
|
||||
})
|
||||
} else {
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_MINING)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_MINING)
|
||||
UserList, _ := CatnipMod.Agree(GameId, ReplyInfo.Uid)
|
||||
player.TeLog("catnip_agree", map[string]interface{}{
|
||||
"Id": int(GameId),
|
||||
@ -5829,7 +5829,7 @@ func ReqCatnipEmoji(player *Player, buf []byte) error {
|
||||
return err
|
||||
}
|
||||
CatnipMod := player.PlayMod.getCatnipMod()
|
||||
ActivityId := GetActivityId(player, activity.ACT_TYPE_CATNIP)
|
||||
ActivityId := player.GetActivityId(activity.ACT_TYPE_CATNIP)
|
||||
if ActivityId == 0 {
|
||||
player.SendErrClienRes(&msg.ResCatnipEmoji{
|
||||
Code: msg.RES_CODE_FAIL,
|
||||
|
||||
@ -225,6 +225,7 @@ func (c *CatnipMod) GrowthByUid(Uid, Growth int) {
|
||||
for _, v := range c.Game {
|
||||
if v.Partner == Uid {
|
||||
v.Progress += Growth
|
||||
v.PartnerAdd += Growth
|
||||
if v.Progress >= catnipCfg.GetGameNum(v.Id) { // Assuming the game ends when progress reaches a certain threshold
|
||||
v.Status = GAME_STATUS_COMPLETED
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user