Добавил возможность сброса матча вручную

This commit is contained in:
Smile Rex
2025-01-25 20:28:59 +03:00
parent 7725f67f3a
commit 1fa5d04510
2 changed files with 19 additions and 0 deletions

View File

@@ -43,6 +43,7 @@ func main() {
b.Handle("/duel", duelController.StartMatch) b.Handle("/duel", duelController.StartMatch)
b.Handle("/accept", duelController.AcceptMatch) b.Handle("/accept", duelController.AcceptMatch)
b.Handle("/clear", duelController.ClearMatch)
b.Start() b.Start()
} }

View File

@@ -103,6 +103,24 @@ func (s *DuelController) AcceptMatch(c tele.Context) error {
return c.Send(fmt.Sprintf("%s принимает участие в дуэли.", s.PlayerTwo.FName)) return c.Send(fmt.Sprintf("%s принимает участие в дуэли.", s.PlayerTwo.FName))
} }
// Clear match
func (s *DuelController) ClearMatch(c tele.Context) error {
if c.Sender().ID == s.PlayerOne.ID {
s.PlayerOne.Counter = 0
s.PlayerTwo.Counter = 0
s.PlayerOne.FName = ""
s.PlayerTwo.FName = ""
s.PlayerOne.ID = 0
s.PlayerTwo.ID = 0
s.Inited = false
s.Summ = 0
return c.Send(fmt.Sprintf("%s отменил дуель!", c.Sender().FirstName))
} else {
return c.Send("Отменить дуель может только инициатор!")
}
}
// Start Game // Start Game
func (s *DuelController) gameProccess(r tele.Recipient) { func (s *DuelController) gameProccess(r tele.Recipient) {
time.Sleep(time.Second * 3) time.Sleep(time.Second * 3)