Archived
1

Latest game update reflections

This commit is contained in:
Vladimir Hodakov 2017-11-26 19:38:25 +04:00
parent 7803242588
commit b57cacb4d4
5 changed files with 79 additions and 1 deletions

View File

@ -0,0 +1,16 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package dbmapping
import (
"time"
)
// OrderCompletion is a struct, which represents `orders_completions` table item in databse.
type OrderCompletion struct {
ID int `db:"id"`
OrderID int `db:"order_id"`
ExecutorID int `db:"executor_id"`
CreatedAt time.Time `db:"created_at"`
}

View File

@ -0,0 +1,36 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package migrations
import (
"database/sql"
)
// CreateOrdersCompletionsUp creates `orders_completions` table
func CreateOrdersCompletionsUp(tx *sql.Tx) error {
request := "CREATE TABLE `orders_completions` ("
request += "`id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID приказа',"
request += "`order_id` int(11) NOT NULL COMMENT 'Выполненный приказ',"
request += "`executor_id` int(11) NOT NULL COMMENT 'ID выполнившего приказ',"
request += "`created_at` datetime NOT NULL COMMENT 'Добавлен в базу',"
request += "PRIMARY KEY (`id`),"
request += "UNIQUE KEY `id` (`id`),"
request += "KEY `orders_completions_created_at` (`created_at`)"
request += ") ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb4 COMMENT='Исполнение приказов'"
_, err := tx.Exec(request)
if err != nil {
return err
}
return nil
}
// CreateOrdersCompletionsDown drops `orders_completions` table
func CreateOrdersCompletionsDown(tx *sql.Tx) error {
_, err := tx.Exec("DROP TABLE `orders_completions`")
if err != nil {
return err
}
return nil
}

View File

@ -0,0 +1,24 @@
// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package migrations
import (
// stdlib
"database/sql"
)
// AddNewWeaponUp adds new weapon, presented on 26.11.2017
func AddNewWeaponUp(tx *sql.Tx) error {
_, err := tx.Exec("INSERT INTO `weapons` VALUES(NULL, 'Буханка из пятёры', 1000000, 5000000, NOW())")
if err != nil {
return err
}
return nil
}
// AddNewWeaponDown does nothing
func AddNewWeaponDown(tx *sql.Tx) error {
return nil
}

View File

@ -36,6 +36,8 @@ func (m *Migrations) Init() {
goose.AddNamedMigration("23_add_user_type.go", AddUserTypeUp, AddUserTypeDown)
goose.AddNamedMigration("24_create_orders.go", CreateOrdersUp, CreateOrdersDown)
goose.AddNamedMigration("25_remove_reusable.go", RemoveReusableUp, RemoveReusableDown)
goose.AddNamedMigration("26_create_orders_completions.go", CreateOrdersCompletionsUp, CreateOrdersCompletionsDown)
goose.AddNamedMigration("27_add_new_weapon.go", AddNewWeaponUp, AddNewWeaponDown)
}
// Migrate migrates database to current version

View File

@ -150,7 +150,7 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
if strings.HasPrefix(currentString, "🔫") {
// We need NEXT string!
weaponType := strings.Replace(currentString, "🔫 ", "", 1)
wnRx := regexp.MustCompile("(.+)(ита)")
wnRx := regexp.MustCompile("(.+)(ита|ёры)")
weapon = wnRx.FindString(weaponType)
}