Latest game update reflections
This commit is contained in:
parent
7803242588
commit
b57cacb4d4
16
lib/dbmapping/orders_completion.go
Normal file
16
lib/dbmapping/orders_completion.go
Normal 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"`
|
||||||
|
}
|
36
lib/migrations/26_create_orders_competions.go
Normal file
36
lib/migrations/26_create_orders_competions.go
Normal 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
|
||||||
|
}
|
24
lib/migrations/27_add_new_weapon.go
Normal file
24
lib/migrations/27_add_new_weapon.go
Normal 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
|
||||||
|
}
|
@ -36,6 +36,8 @@ func (m *Migrations) Init() {
|
|||||||
goose.AddNamedMigration("23_add_user_type.go", AddUserTypeUp, AddUserTypeDown)
|
goose.AddNamedMigration("23_add_user_type.go", AddUserTypeUp, AddUserTypeDown)
|
||||||
goose.AddNamedMigration("24_create_orders.go", CreateOrdersUp, CreateOrdersDown)
|
goose.AddNamedMigration("24_create_orders.go", CreateOrdersUp, CreateOrdersDown)
|
||||||
goose.AddNamedMigration("25_remove_reusable.go", RemoveReusableUp, RemoveReusableDown)
|
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
|
// Migrate migrates database to current version
|
||||||
|
@ -150,7 +150,7 @@ func (u *Users) ParseProfile(update *tgbotapi.Update, playerRaw *dbmapping.Playe
|
|||||||
if strings.HasPrefix(currentString, "🔫") {
|
if strings.HasPrefix(currentString, "🔫") {
|
||||||
// We need NEXT string!
|
// We need NEXT string!
|
||||||
weaponType := strings.Replace(currentString, "🔫 ", "", 1)
|
weaponType := strings.Replace(currentString, "🔫 ", "", 1)
|
||||||
wnRx := regexp.MustCompile("(.+)(ита)")
|
wnRx := regexp.MustCompile("(.+)(ита|ёры)")
|
||||||
weapon = wnRx.FindString(weaponType)
|
weapon = wnRx.FindString(weaponType)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user