Добавил возможность сброса матча вручную
This commit is contained in:
1
main.go
1
main.go
@@ -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()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user