Сообщения теперь заменяются
This commit is contained in:
@@ -42,8 +42,6 @@ func NewDuel(bot *tele.Bot, dc *DataController) *DuelController {
|
||||
func (s *DuelController) StartMatch(c tele.Context) error {
|
||||
if s.Inited {
|
||||
return c.Send(fmt.Sprintf("Дуэль уже началась!\nИгрок: %s\nСтавка: %d", s.PlayerOne.FName, s.Summ))
|
||||
} else {
|
||||
s.Inited = true
|
||||
}
|
||||
|
||||
var text string
|
||||
@@ -53,27 +51,24 @@ func (s *DuelController) StartMatch(c tele.Context) error {
|
||||
text = strings.Split(c.Text(), " ")[1]
|
||||
fmt.Println("Ставка", text)
|
||||
} else {
|
||||
s.Inited = false
|
||||
return c.Send("Некоректная команда, используйте /duel <сумма>")
|
||||
}
|
||||
|
||||
summ, err := strconv.Atoi(text)
|
||||
if err != nil {
|
||||
s.Inited = false
|
||||
return c.Send("Некорректная команда, используйте /duel <сумма>")
|
||||
} else {
|
||||
if user.DickSize < summ {
|
||||
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
||||
}
|
||||
}
|
||||
|
||||
if summ > 0 {
|
||||
s.Summ = summ
|
||||
} else {
|
||||
s.Inited = false
|
||||
return c.Send("Некорректная сумма, используйте положительное значение!")
|
||||
}
|
||||
if user.DickSize < summ {
|
||||
s.Inited = false
|
||||
return c.Send("У вас недостаточно длинный пенис для состязания!")
|
||||
}
|
||||
|
||||
s.PlayerOne.ID = c.Sender().ID
|
||||
s.PlayerOne.FName = c.Sender().FirstName
|
||||
s.Inited = true
|
||||
|
||||
return c.Send(fmt.Sprintf("%s начал дуель, ставка: %d", s.PlayerOne.FName, summ))
|
||||
}
|
||||
@@ -109,44 +104,38 @@ func (s *DuelController) AcceptMatch(c tele.Context) error {
|
||||
|
||||
// Start Game
|
||||
func (s *DuelController) gameProccess(r tele.Recipient) {
|
||||
time.Sleep(time.Second * 3)
|
||||
s.Bot.Send(r, fmt.Sprintf("Дуэль началась!\nНа кону: %d", s.Summ))
|
||||
s.RoundOne(r)
|
||||
}
|
||||
msg, _ := s.Bot.Send(r, fmt.Sprintf("Дуэль началась!\nНа кону: %d", s.Summ))
|
||||
|
||||
// Round One
|
||||
func (s *DuelController) RoundOne(r tele.Recipient) {
|
||||
// round 1
|
||||
time.Sleep(time.Second * 3)
|
||||
|
||||
s.PlayerOne.Counter += rand.Intn(11) + 1
|
||||
s.PlayerTwo.Counter += rand.Intn(11) + 1
|
||||
s.Bot.Send(r,
|
||||
s.Bot.Edit(msg,
|
||||
fmt.Sprintf("Результаты первого раунда\n%s: %d очков.\n%s: %d очков.",
|
||||
s.PlayerOne.FName, s.PlayerOne.Counter, s.PlayerTwo.FName, s.PlayerTwo.Counter),
|
||||
)
|
||||
s.RoundTwo(r)
|
||||
}
|
||||
|
||||
// Round Two
|
||||
func (s *DuelController) RoundTwo(r tele.Recipient) {
|
||||
// round 2
|
||||
time.Sleep(time.Second * 3)
|
||||
|
||||
s.PlayerOne.Counter += rand.Intn(11) + 1
|
||||
s.PlayerTwo.Counter += rand.Intn(11) + 1
|
||||
s.Bot.Send(r,
|
||||
s.Bot.Edit(msg,
|
||||
fmt.Sprintf("Результаты второго раунда\n%s: %d очков.\n%s: %d очков.",
|
||||
s.PlayerOne.FName, s.PlayerOne.Counter, s.PlayerTwo.FName, s.PlayerTwo.Counter),
|
||||
)
|
||||
s.RoundThree(r)
|
||||
}
|
||||
|
||||
// Round Three
|
||||
func (s *DuelController) RoundThree(r tele.Recipient) {
|
||||
// round 3
|
||||
time.Sleep(time.Second * 3)
|
||||
|
||||
s.PlayerOne.Counter += rand.Intn(11) + 1
|
||||
s.PlayerTwo.Counter += rand.Intn(11) + 1
|
||||
s.Bot.Send(r,
|
||||
s.Bot.Edit(msg,
|
||||
fmt.Sprintf("Результаты третьего раунда\n%s: %d очков.\n%s: %d очков.",
|
||||
s.PlayerOne.FName, s.PlayerOne.Counter, s.PlayerTwo.FName, s.PlayerTwo.Counter),
|
||||
)
|
||||
|
||||
s.CheckWin(r)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user