From 65a99e6ab91ede36289a9a15df56ed71aac5f4ed Mon Sep 17 00:00:00 2001 From: Smile Rex Date: Tue, 11 Mar 2025 00:04:19 +0300 Subject: [PATCH] =?UTF-8?q?fix=20=D0=BE=D0=B4=D0=BD=D0=BE=D0=B2=D1=80?= =?UTF-8?q?=D0=B5=D0=BC=D0=B5=D0=BD=D0=BD=D0=BE=D0=B5=20=D0=BF=D1=80=D0=B8?= =?UTF-8?q?=D0=BD=D1=8F=D1=82=D0=B8=D0=B5=20=D0=B4=D1=83=D1=8D=D0=BB=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 2 +- src/controllers/duelController.go | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/main.go b/main.go index c87b7c9..4b80430 100644 --- a/main.go +++ b/main.go @@ -11,7 +11,7 @@ import ( ) // ////////////////////// -var isTest bool = false +var isTest bool = true //////////////////////// diff --git a/src/controllers/duelController.go b/src/controllers/duelController.go index 1411f4c..28f7671 100644 --- a/src/controllers/duelController.go +++ b/src/controllers/duelController.go @@ -24,10 +24,11 @@ type DuelController struct { FName string } - Summ int - Inited bool - Bot *tele.Bot - DC *DataController + Summ int + Inited bool + MatchAccepted bool + Bot *tele.Bot + DC *DataController } // Controller Init @@ -81,6 +82,10 @@ func (s *DuelController) StartMatch(c tele.Context) error { // Accept Match func (s *DuelController) AcceptMatch(c tele.Context) error { + if s.MatchAccepted { + return c.Send("Дождитесь окончания дуэли.") + } + if !s.Inited { return c.Send("Дуэль еще не началась! Дождитесь старта матча или начните новую дуель с помощью /duel <сумма>") } @@ -101,6 +106,8 @@ func (s *DuelController) AcceptMatch(c tele.Context) error { s.Summ *= 2 go s.gameProccess(c.Chat()) + s.MatchAccepted = true + return c.Send(fmt.Sprintf("%s принимает участие в дуэли.", s.PlayerTwo.FName)) } @@ -190,4 +197,5 @@ func (s *DuelController) CheckWin(msg *tele.Message) { s.PlayerTwo.Counter = 0 s.Summ = 0 s.Inited = false + s.MatchAccepted = false }