add clearstats method
This commit is contained in:
@@ -38,6 +38,17 @@ func NewDuel(bot *tele.Bot, dc *DataController) *DuelController {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (s *DuelController) ClearStats() {
|
||||||
|
s.Inited = false
|
||||||
|
s.PlayerOne.Counter = 0
|
||||||
|
s.PlayerTwo.Counter = 0
|
||||||
|
s.PlayerOne.FName = ""
|
||||||
|
s.PlayerTwo.FName = ""
|
||||||
|
s.Summ = 0
|
||||||
|
s.PlayerOne.ID = 0
|
||||||
|
s.PlayerTwo.ID = 0
|
||||||
|
}
|
||||||
|
|
||||||
// Start Match
|
// Start Match
|
||||||
func (s *DuelController) StartMatch(c tele.Context) error {
|
func (s *DuelController) StartMatch(c tele.Context) error {
|
||||||
if s.Inited {
|
if s.Inited {
|
||||||
@@ -48,19 +59,22 @@ func (s *DuelController) StartMatch(c tele.Context) error {
|
|||||||
|
|
||||||
if strings.Contains(c.Text(), " ") {
|
if strings.Contains(c.Text(), " ") {
|
||||||
text = strings.Split(c.Text(), " ")[1]
|
text = strings.Split(c.Text(), " ")[1]
|
||||||
fmt.Println("new command", text)
|
fmt.Println("Ставка текст", text)
|
||||||
} else {
|
} else {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("Некоректная команда, используйте /duel <сумма>")
|
return c.Send("Некоректная команда, используйте /duel <сумма>")
|
||||||
}
|
}
|
||||||
|
|
||||||
summ, err := strconv.Atoi(text)
|
summ, err := strconv.Atoi(text)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("Некорректная команда, используйте /duel <сумма>")
|
return c.Send("Некорректная команда, используйте /duel <сумма>")
|
||||||
} else {
|
} else {
|
||||||
s.Summ = summ
|
s.Summ = summ
|
||||||
}
|
}
|
||||||
|
|
||||||
if summ <= 0 {
|
if summ <= 0 {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("Некорректная сумма, используйте положительное значение!")
|
return c.Send("Некорректная сумма, используйте положительное значение!")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,6 +85,7 @@ func (s *DuelController) StartMatch(c tele.Context) error {
|
|||||||
user := s.DC.GetUser(s.PlayerOne.ID)
|
user := s.DC.GetUser(s.PlayerOne.ID)
|
||||||
|
|
||||||
if user.DickSize < summ {
|
if user.DickSize < summ {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,6 +95,7 @@ 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.Inited {
|
if !s.Inited {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("Дуэль еще не началась! Дождитесь старта матча или начните новую дуель с помощью /duel <сумма>")
|
return c.Send("Дуэль еще не началась! Дождитесь старта матча или начните новую дуель с помощью /duel <сумма>")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -89,10 +105,12 @@ func (s *DuelController) AcceptMatch(c tele.Context) error {
|
|||||||
user := s.DC.GetUser(s.PlayerTwo.ID)
|
user := s.DC.GetUser(s.PlayerTwo.ID)
|
||||||
|
|
||||||
if user.DickSize < s.Summ {
|
if user.DickSize < s.Summ {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
||||||
}
|
}
|
||||||
|
|
||||||
if s.PlayerTwo.ID == s.PlayerOne.ID {
|
if s.PlayerTwo.ID == s.PlayerOne.ID {
|
||||||
|
s.ClearStats()
|
||||||
return c.Send("Вы не можете принять участие в своей же дуэли!")
|
return c.Send("Вы не можете принять участие в своей же дуэли!")
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +181,5 @@ func (s *DuelController) CheckWin(r tele.Recipient) {
|
|||||||
s.Bot.Send(r, "Ничья!")
|
s.Bot.Send(r, "Ничья!")
|
||||||
}
|
}
|
||||||
|
|
||||||
s.PlayerOne.Counter = 0
|
s.ClearStats()
|
||||||
s.PlayerTwo.Counter = 0
|
|
||||||
s.Summ = 0
|
|
||||||
s.Inited = false
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user