feat: add tournoment

This commit is contained in:
2026-07-07 15:17:33 +03:30
parent bcfaf35d73
commit e58c50d6e5
10 changed files with 744 additions and 1 deletions
+14
View File
@@ -172,9 +172,23 @@ func main() {
r.Post("/shop/purchase", ecoH.Purchase)
r.Post("/rewards/daily", ecoH.Daily)
r.Post("/rewards/ad", ecoH.AdReward)
// تورنومنت‌ها
r.Get("/tournaments", ecoH.Tournaments)
r.Get("/tournaments/standings", ecoH.TournamentStandings)
r.Post("/tournaments/join", ecoH.JoinTournament)
})
})
// تسویه‌ی خودکارِ تورنومنت‌های پایان‌یافته (هر دقیقه).
go func() {
t := time.NewTicker(time.Minute)
defer t.Stop()
for range t.C {
eco.SettleTournaments(context.Background())
}
}()
srv := &http.Server{
Addr: cfg.Addr,
Handler: r,
+3 -1
View File
@@ -68,9 +68,11 @@ func (g gameSettler) RecordCut(userID int64) {
g.eco.RecordCut(context.Background(), userID)
}
// RecordGameResult آمار پایان بازی (برد/باخت) را ثبت می‌کند.
// RecordGameResult آمار پایان بازی (برد/باخت) را ثبت می‌کند و امتیازِ تورنومنت
// را (برای تورنومنت‌های فعالی که کاربر عضوشان است) به‌روزرسانی می‌کند.
func (g gameSettler) RecordGameResult(userID int64, won bool) {
g.eco.RecordGameResult(context.Background(), userID, won)
g.eco.AddTournamentPoints(context.Background(), userID, won)
}
// PlayerProfile سکه، نشانِ رتبه و آواتارِ بازیکن را برای نمایش سرِ میز برمی‌گرداند.