瀏覽代碼

修改邀请的 bug

xh 9 月之前
父節點
當前提交
c10360730e

+ 11 - 4
game/game_cluster/internal/mdb/models/player.go

@@ -560,14 +560,20 @@ func (p *Player) SetInviteReward() {
 		return
 	}
 	ret2, ok := data.DiscreteRuleConfig.Get(InvitePlayer)
-	c, tok := mhayaString.ToInt(ret2.Condition)
-	if !ok || !tok || c != p.Level {
+	//c, tok := mhayaString.ToInt(ret2.Condition)
+	//if !ok || !tok || c != p.Level {
+	//	return
+	//}
+	if !ok {
 		return
 	}
 
 	ret3, ok := data.DiscreteRuleConfig.Get(InviteVipPlayer)
-	c, tok = mhayaString.ToInt(ret3.Condition)
-	if !ok || !tok || c != p.Level {
+	//c, tok = mhayaString.ToInt(ret3.Condition)
+	//if !ok || !tok || c != p.Level {
+	//	returns
+	//}
+	if !ok {
 		return
 	}
 	var addItem []data.ItemReward
@@ -621,6 +627,7 @@ func (p *Player) SetInviteReward() {
 		p.InviteReward.RewardTime = 0
 	}
 	p.InviteReward.Reward = append(p.InviteReward.Reward, addItem...)
+
 }
 
 func (p *Player) SetInvite(uid string) bool {

+ 3 - 5
game/game_cluster/nodes/game/module/player/actor_player.go

@@ -91,11 +91,7 @@ func (p *actorPlayer) OnInit() {
 	p.Timer().Add(1*time.Minute, p.upatePlayerLevelStat)
 
 	//在线用户定时刷新
-	p.Timer().Add(1*time.Minute, func() {
-		if p.Player != nil {
-			p.Player.InitDaily()
-		}
-	})
+	p.Timer().Add(1*time.Minute, p.initDaily)
 
 	//p.Timer().Add(30*time.Second, p.getAndUpdateAvatar)  //排行榜头像
 
@@ -104,6 +100,7 @@ func (p *actorPlayer) OnInit() {
 func (p *actorPlayer) initDaily() {
 	if p.isOnline {
 		p.Player.InitDaily()
+		p.dirty = true
 	}
 }
 
@@ -132,6 +129,7 @@ func (p *actorPlayer) OnStop() {
 func (p *actorPlayer) setInviteReward() {
 	if p.isOnline {
 		p.Player.SetInviteReward()
+		p.dirty = true
 	}
 }
 

+ 2 - 1
game/game_cluster/nodes/game/module/player/invite.go

@@ -2,6 +2,7 @@ package player
 
 import (
 	"context"
+	"fmt"
 	"github.com/mhaya/game/game_cluster/internal/code"
 	"github.com/mhaya/game/game_cluster/internal/constant"
 	"github.com/mhaya/game/game_cluster/internal/data"
@@ -19,7 +20,7 @@ func (p *actorPlayer) invite(req *param.InviteReq) int32 {
 		return code.InviteEmpoweringOthersError
 	}
 
-	exists := mdb.RDB.Exists(context.Background(), models.GetPlayBaseKey(req.ParentName)).Val()
+	exists := mdb.RDB.Exists(context.Background(), fmt.Sprintf("%v:1:%v", constant.InviteKey, req.ParentName)).Val()
 	if exists > 0 {
 		return code.Error
 	}