fix одновременное принятие дуэли
This commit is contained in:
2
main.go
2
main.go
@@ -11,7 +11,7 @@ import (
|
||||
)
|
||||
|
||||
// //////////////////////
|
||||
var isTest bool = false
|
||||
var isTest bool = true
|
||||
|
||||
////////////////////////
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user