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
|
||||||
|
|
||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,7 @@ type DuelController struct {
|
|||||||
|
|
||||||
Summ int
|
Summ int
|
||||||
Inited bool
|
Inited bool
|
||||||
|
MatchAccepted bool
|
||||||
Bot *tele.Bot
|
Bot *tele.Bot
|
||||||
DC *DataController
|
DC *DataController
|
||||||
}
|
}
|
||||||
@@ -81,6 +82,10 @@ func (s *DuelController) StartMatch(c tele.Context) error {
|
|||||||
|
|
||||||
// Accept Match
|
// Accept Match
|
||||||
func (s *DuelController) AcceptMatch(c tele.Context) error {
|
func (s *DuelController) AcceptMatch(c tele.Context) error {
|
||||||
|
if s.MatchAccepted {
|
||||||
|
return c.Send("Дождитесь окончания дуэли.")
|
||||||
|
}
|
||||||
|
|
||||||
if !s.Inited {
|
if !s.Inited {
|
||||||
return c.Send("Дуэль еще не началась! Дождитесь старта матча или начните новую дуель с помощью /duel <сумма>")
|
return c.Send("Дуэль еще не началась! Дождитесь старта матча или начните новую дуель с помощью /duel <сумма>")
|
||||||
}
|
}
|
||||||
@@ -101,6 +106,8 @@ func (s *DuelController) AcceptMatch(c tele.Context) error {
|
|||||||
s.Summ *= 2
|
s.Summ *= 2
|
||||||
go s.gameProccess(c.Chat())
|
go s.gameProccess(c.Chat())
|
||||||
|
|
||||||
|
s.MatchAccepted = true
|
||||||
|
|
||||||
return c.Send(fmt.Sprintf("%s принимает участие в дуэли.", s.PlayerTwo.FName))
|
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.PlayerTwo.Counter = 0
|
||||||
s.Summ = 0
|
s.Summ = 0
|
||||||
s.Inited = false
|
s.Inited = false
|
||||||
|
s.MatchAccepted = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user