add achievements
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
Timofey.Kovalev
2021-06-22 02:34:22 +03:00
parent 3302634f61
commit 4d5b25a761
4 changed files with 249 additions and 96 deletions

View File

@ -49,7 +49,7 @@ func (c *joinCommand) run(ctx context.Context) {
log := getLogger(ctx)
pb := getDPlayersBoard(ctx)
mess := tgbotapi.NewMessage(cfg.ChatID, fmt.Sprintf("%s вошел в матрицу", c.name))
mess := tgbotapi.NewMessage(cfg.ChatID, fmt.Sprintf("%s подключился", c.name))
m, err := botApi.Send(mess)
if err != nil {
log.Error(err)
@ -77,7 +77,9 @@ func (c *joinCommand) run(ctx context.Context) {
}
}
err = pb.getPlayerBoard(p.id).setOnline(true).updatePlayerInfo(ctx)
pb.getPlayerBoard(p.id).setOnline(true)
err = pb.update(ctx, achievementVeryLongOnline)
if err != nil {
log.Error(err)
}
@ -95,7 +97,7 @@ func (c *quitCommand) run(ctx context.Context) {
log := getLogger(ctx)
pb := getDPlayersBoard(ctx)
mess := tgbotapi.NewMessage(cfg.ChatID, fmt.Sprintf("%s покинул матрицу", c.name))
mess := tgbotapi.NewMessage(cfg.ChatID, fmt.Sprintf("%s отключился", c.name))
m, err := botApi.Send(mess)
if err != nil {
log.Error(err)
@ -115,7 +117,9 @@ func (c *quitCommand) run(ctx context.Context) {
return
}
err = pb.getPlayerBoard(p.id).setOnline(false).updatePlayerInfo(ctx)
pb.getPlayerBoard(p.id).setOnline(false)
err = pb.update(ctx, achievementVeryLongOnline)
if err != nil {
log.Error(err)
}
@ -143,7 +147,7 @@ func (c *deathCommand) run(ctx context.Context) {
return
}
err = pb.getPlayerBoard(p.id).updatePlayerInfo(ctx)
err = pb.update(ctx, achievementDeathless, achievementBestFeeder)
if err != nil {
log.Error(err)
}
@ -182,7 +186,7 @@ func (c *killCommand) run(ctx context.Context) {
return
}
err = pb.getPlayerBoard(p.id).updatePlayerInfo(ctx)
err = pb.update(ctx, achievementMaxFrags, achievementPeaceable)
if err != nil {
log.Error(err)
}
@ -210,9 +214,8 @@ func (c *changeLevelCommand) run(ctx context.Context) {
return
}
err = pb.getPlayerBoard(p.id).updatePlayerInfo(ctx)
err = pb.update(ctx, achievementMaxLevel)
if err != nil {
log.Error(err)
}
}