chirpnest/sql.go

1629 lines
54 KiB
Go
Raw Normal View History

2019-05-03 05:58:36 +02:00
package main
import (
2019-05-06 16:05:43 +02:00
"errors"
2019-05-10 16:13:14 +02:00
"fmt"
2019-05-03 05:58:36 +02:00
"log"
2019-05-08 12:47:32 +02:00
"regexp"
2019-05-06 06:01:01 +02:00
"strconv"
2019-05-10 11:24:50 +02:00
"time"
2019-05-03 05:58:36 +02:00
)
func initDB() {
log.Println("Setting up database...")
tx, err := db.Begin()
if err != nil {
log.Fatal(err)
}
defer tx.Rollback()
_, err = tx.Exec("set foreign_key_checks = 0")
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : set foreign_key_checks = 0")
2019-05-03 05:58:36 +02:00
var name string
2019-05-10 12:19:38 +02:00
rows, err := db.Query("show tables")
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : show tables")
2019-05-03 05:58:36 +02:00
for rows.Next() {
err = rows.Scan(&name)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : show tables listing")
2019-05-10 12:19:38 +02:00
_, err = tx.Exec("drop table " + name)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : drop table "+name)
2019-05-03 05:58:36 +02:00
}
err = rows.Err()
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : show tables listing end")
2019-05-03 05:58:36 +02:00
rows.Close()
_, err = tx.Exec("set foreign_key_checks = 1")
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : set foreign_key_checks = 1")
2019-05-03 05:58:36 +02:00
err = tx.Commit()
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : commit cleanup")
2019-05-03 05:58:36 +02:00
2019-05-11 09:48:39 +02:00
log.Println("initDB : Database cleaned up")
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`CREATE TABLE code_obj_type (
2019-05-07 13:15:25 +02:00
id SMALLINT UNSIGNED NOT NULL
2019-05-04 10:57:24 +02:00
,intl_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,PRIMARY KEY (id)
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table code_obj_type")
2019-05-11 09:48:39 +02:00
log.Println("initDB : code_obj_type created ...")
2019-05-04 10:57:24 +02:00
2019-05-05 13:29:28 +02:00
_, err = db.Exec(`CREATE TABLE code_obj_sub_type (
2019-05-07 13:15:25 +02:00
id SMALLINT UNSIGNED NOT NULL
,intl_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
2019-05-05 13:29:28 +02:00
,obj_type_id SMALLINT UNSIGNED NOT NULL
,PRIMARY KEY (id)
,FOREIGN KEY (obj_type_id) REFERENCES code_obj_type(id) ON DELETE CASCADE
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table code_obj_sub_type")
2019-05-11 09:48:39 +02:00
log.Println("initDB : code_obj_sub_type created ...")
2019-05-05 13:29:28 +02:00
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`CREATE TABLE obj (
2019-05-06 05:09:31 +02:00
id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT
,obj_type_id SMALLINT UNSIGNED NOT NULL
,obj_sub_type_id SMALLINT UNSIGNED NOT NULL
2019-05-10 11:23:47 +02:00
,timestamp TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
2019-05-04 10:57:24 +02:00
,PRIMARY KEY (id)
2019-05-08 12:36:29 +02:00
,FOREIGN KEY (obj_type_id) REFERENCES code_obj_type(id) ON DELETE CASCADE
,FOREIGN KEY (obj_sub_type_id) REFERENCES code_obj_sub_type(id) ON DELETE CASCADE
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB AUTO_INCREMENT = 0 CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table obj")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj created ...")
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`CREATE TABLE obj_user (
obj_id BIGINT UNSIGNED NOT NULL
2019-05-06 05:03:12 +02:00
,telegram_id BIGINT UNSIGNED NOT NULL
2019-05-04 10:57:24 +02:00
,user_id VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,guild_id BIGINT UNSIGNED
,last_msg TIMESTAMP
,busy_until TIMESTAMP
,role ENUM('commander', 'bartender', 'squire', 'none')
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table obj_user")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_user created ...")
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`CREATE TABLE obj_guild (
2019-05-07 13:15:25 +02:00
obj_id BIGINT UNSIGNED NOT NULL
2019-05-04 10:57:24 +02:00
,tag VARCHAR(32) NOT NULL
,name VARCHAR(80) NOT NULL
,chat_id BIGINT NOT NULL
,deposit_chat_id BIGINT NOT NULL
2019-05-04 11:04:52 +02:00
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table obj_guild")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_guild created ...")
2019-05-04 10:57:24 +02:00
2019-05-07 05:12:03 +02:00
_, err = db.Exec(`CREATE TABLE obj_war (
obj_id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT
2019-05-09 12:36:45 +02:00
,start_time DATETIME NOT NULL
,end_time DATETIME NOT NULL
2019-05-07 05:12:03 +02:00
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_war")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_war created ...")
2019-05-07 05:12:03 +02:00
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`CREATE TABLE obj_msg (
obj_id BIGINT UNSIGNED NOT NULL
,msg_id BIGINT NOT NULL
,chat_id BIGINT NOT NULL
2019-05-06 07:43:15 +02:00
,user_id BIGINT NOT NULL
2019-05-04 10:57:24 +02:00
,sender_user_id BIGINT NOT NULL
2019-05-09 12:36:45 +02:00
,date DATETIME NOT NULL
2019-05-04 10:57:24 +02:00
,text VARCHAR(4096) NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (msg_id, chat_id, sender_user_id)
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : create table obj_msg")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_msg created ...")
2019-05-03 05:58:36 +02:00
2019-05-05 13:29:28 +02:00
_, err = db.Exec(`CREATE TABLE obj_msg_report (
2019-05-06 12:43:42 +02:00
obj_id BIGINT UNSIGNED NOT NULL
2019-05-07 05:12:03 +02:00
,war_id BIGINT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,FOREIGN KEY (war_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_msg_report")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_msg_report created ...")
2019-05-07 05:12:03 +02:00
_, err = db.Exec(`CREATE TABLE obj_war_report (
obj_id BIGINT UNSIGNED NOT NULL
,user_id BIGINT UNSIGNED NOT NULL
,war_id BIGINT UNSIGNED NOT NULL
2019-05-06 12:43:42 +02:00
,attack SMALLINT UNSIGNED NOT NULL
,defense SMALLINT UNSIGNED NOT NULL
,gold SMALLINT UNSIGNED NOT NULL
2019-05-06 15:50:57 +02:00
,stock SMALLINT UNSIGNED NOT NULL
2019-05-05 13:29:28 +02:00
,exp SMALLINT UNSIGNED NOT NULL
2019-05-06 12:43:42 +02:00
,stamina TINYINT NOT NULL
,crit TINYINT NOT NULL
2019-05-05 13:29:28 +02:00
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
2019-05-07 05:12:03 +02:00
,FOREIGN KEY (war_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (user_id, war_id)
2019-05-06 15:48:43 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-11 09:48:39 +02:00
failOnError(err, "initDB : create table obj_war_report")
log.Println("initDB : obj_war_report created ...")
2019-05-05 13:29:28 +02:00
2019-05-09 11:19:02 +02:00
_, err = db.Exec(`CREATE TABLE obj_msg_auction_announce (
2019-05-08 15:39:04 +02:00
obj_id BIGINT UNSIGNED NOT NULL
,lot_id BIGINT UNSIGNED NOT NULL
2019-05-08 15:40:25 +02:00
,item VARCHAR(80)
2019-05-08 15:40:57 +02:00
,cond VARCHAR(32)
2019-05-08 15:40:25 +02:00
,quality VARCHAR(32)
,seller VARCHAR(32)
,buyer VARCHAR(32)
2019-05-09 11:46:29 +02:00
,price SMALLINT NOT NULL
2019-05-08 15:40:25 +02:00
,status VARCHAR(32)
2019-05-09 12:36:45 +02:00
,end DATETIME NOT NULL
2019-05-08 15:39:04 +02:00
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
2019-05-11 09:55:42 +02:00
,KEY (lot_id)
2019-05-08 15:39:04 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-09 11:19:02 +02:00
failOnError(err, "initDB : create table obj_msg_auction_announce")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_msg_auction_announce created ...")
2019-05-08 15:39:04 +02:00
2019-05-10 04:26:37 +02:00
_, err = db.Exec(`CREATE TABLE obj_msg_auction_upd_req (
obj_id BIGINT UNSIGNED NOT NULL
,lot_id BIGINT UNSIGNED NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
2019-05-11 09:45:20 +02:00
,KEY (lot_id)
2019-05-10 04:26:37 +02:00
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_msg_auction_upd_req")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_msg_auction_upd_req created ...")
2019-05-10 04:26:37 +02:00
_, err = db.Exec(`CREATE TABLE obj_msg_auction_upd_ack (
obj_id BIGINT UNSIGNED NOT NULL
,seller VARCHAR(32)
,buyer VARCHAR(32)
,item VARCHAR(80)
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-11 09:48:39 +02:00
failOnError(err, "initDB : create table obj_msg_auction_upd_ack")
log.Println("initDB : obj_msg_auction_upd_ack created ...")
2019-05-10 04:26:37 +02:00
2019-05-07 13:15:25 +02:00
_, err = db.Exec(`CREATE TABLE msg_rules (
id SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT
,prio SMALLINT NOT NULL
,descn VARCHAR(32) NOT NULL
,rule VARCHAR(4096) NOT NULL
2019-05-08 12:13:47 +02:00
,msg_type_id SMALLINT UNSIGNED NOT NULL
2019-05-07 13:15:25 +02:00
,UNIQUE KEY (id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table msg_rules")
2019-05-11 09:48:39 +02:00
log.Println("initDB : msg_rules created ...")
2019-05-07 13:15:25 +02:00
2019-05-09 09:17:59 +02:00
_, err = db.Exec(`CREATE TABLE obj_item (
obj_id BIGINT UNSIGNED NOT NULL
,intl_id VARCHAR(32)
,name VARCHAR(80)
,weight SMALLINT NOT NULL
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
,UNIQUE KEY (intl_id)
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
2019-05-11 08:45:44 +02:00
failOnError(err, "initDB : create table obj_item")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_item created ...")
2019-05-09 09:17:59 +02:00
2019-05-10 11:23:47 +02:00
_, err = db.Exec(`CREATE TABLE obj_job (
obj_id BIGINT UNSIGNED NOT NULL
,priority SMALLINT NOT NULL
,status SMALLINT NOT NULL
,schedule DATETIME NOT NULL
2019-05-11 06:54:12 +02:00
,is_done TINYINT NOT NULL
,in_work TINYINT NOT NULL
2019-05-11 07:00:20 +02:00
,inserted TIMESTAMP
2019-05-11 06:54:12 +02:00
,pulled TIMESTAMP
,started TIMESTAMP
,ended TIMESTAMP
2019-05-10 11:23:47 +02:00
,payload VARCHAR(4000)
,FOREIGN KEY (obj_id) REFERENCES obj(id) ON DELETE CASCADE
) ENGINE = InnoDB CHARSET=utf8mb4 COLLATE utf8mb4_unicode_ci;`)
failOnError(err, "initDB : create table obj_job")
2019-05-11 09:48:39 +02:00
log.Println("initDB : obj_job created ...")
2019-05-10 11:23:47 +02:00
2019-05-04 10:57:24 +02:00
_, err = db.Exec(`INSERT INTO code_obj_type (id, intl_id, name)
2019-05-06 06:01:01 +02:00
VALUES (` + strconv.Itoa(objTypeUser) + `, "user", "User")
,(` + strconv.Itoa(objTypeGuild) + `, "guild", "Guild")
2019-05-07 05:12:03 +02:00
,(` + strconv.Itoa(objTypeMessage) + `, "msg", "Message")
,(` + strconv.Itoa(objTypeWar) + `, "war", "War")
,(` + strconv.Itoa(objTypeWarReport) + `, "war_report", "War Report")
2019-05-07 13:15:25 +02:00
,(` + strconv.Itoa(objTypeJob) + `, "job", "Job")
2019-05-09 09:17:59 +02:00
,(` + strconv.Itoa(objTypeItem) + `, "item", "Item")
2019-05-07 05:12:03 +02:00
;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : populate table code_obj_type")
2019-05-11 09:49:42 +02:00
log.Println("initDB : code_obj_type populated ...")
2019-05-03 05:58:36 +02:00
2019-05-05 13:29:28 +02:00
_, err = db.Exec(`INSERT INTO code_obj_sub_type (id, intl_id, name, obj_type_id)
2019-05-07 13:15:25 +02:00
VALUES (` + strconv.Itoa(objSubTypeMessageUnknown) + `, "unknown", "Unknown", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-07 05:12:03 +02:00
,(` + strconv.Itoa(objSubTypeMessageWar) + `, "war", "War report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "mini_war", "Mini war reprot", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGuildWar) + `, "guild_war", "Guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageReport) + `, "report", "Player war report", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageGReport) + `, "g_report", "Player guilds war report", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-06 07:43:15 +02:00
,(` + strconv.Itoa(objSubTypeMessageQuest) + `, "quest", "Quest result", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageFight) + `, "fight", "Fight result", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageHero) + `, "hero", "Hero summary", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageMe) + `, "me", "Hero short summary", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-07 13:15:25 +02:00
,(` + strconv.Itoa(objSubTypeMessageInventory) + `, "inv", "Inventory", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessagePillageInc) + `, "pillage_inc", "Pillage incoming", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-11 08:24:38 +02:00
,(` + strconv.Itoa(objSubTypeMessageTributeInc) + `, "tribute_inc", "Tribute incoming", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-08 16:34:47 +02:00
,(` + strconv.Itoa(objSubTypeMessagePillageAck) + `, "pillage_ack", "Pillage acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-11 08:24:38 +02:00
,(` + strconv.Itoa(objSubTypeMessageTributeAck) + `, "tribute_ack", "Tribute acknowledged", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-09 04:43:20 +02:00
,(` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "auction_announce", "Auction announce", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-11 08:24:38 +02:00
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdReq) + `, "auction_upd_req", "Auction update request", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageAuctionUpdAck) + `, "auction_upd_ack", "Auction update acknowledgment", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "time_ack", "Time Acknowledgment", ` + strconv.Itoa(objTypeMessage) + `)
,(` + strconv.Itoa(objSubTypeMessageTimeReq) + `, "time_req", "Time Request", ` + strconv.Itoa(objTypeMessage) + `)
2019-05-10 16:19:21 +02:00
,(` + strconv.Itoa(objSubTypeJobPillage) + `, "job_pillage", "Pillage job", ` + strconv.Itoa(objTypeJob) + `)
2019-05-11 05:15:42 +02:00
,(` + strconv.Itoa(objSubTypeJobTribute) + `, "job_tribute", "Tribute job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobWithdrawal) + `, "job_withdraw", "Withdrawal job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobGStock) + `, "job_gstock", "GStock job", ` + strconv.Itoa(objTypeJob) + `)
,(` + strconv.Itoa(objSubTypeJobRescanMsg) + `, "job_rescan_msg", "Rescan message job", ` + strconv.Itoa(objTypeJob) + `)
2019-05-11 06:54:12 +02:00
,(` + strconv.Itoa(objSubTypeJobSetJobDone) + `, "job_set_done", "Set job as done job", ` + strconv.Itoa(objTypeJob) + `)
2019-05-09 09:17:59 +02:00
,(` + strconv.Itoa(objSubTypeItemResource) + `, "item_res", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemAlch) + `, "item_alch", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemMisc) + `, "item_misc", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemRecipe) + `, "item_recipe", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemPart) + `, "item_part", "Time", ` + strconv.Itoa(objTypeItem) + `)
,(` + strconv.Itoa(objSubTypeItemOther) + `, "item_other", "Time", ` + strconv.Itoa(objTypeItem) + `)
;`)
2019-05-06 05:03:12 +02:00
failOnError(err, "initDB : populate table code_obj_sub_type")
2019-05-11 09:49:42 +02:00
log.Println("initDB : code_obj_sub_type populated ...")
2019-05-04 11:15:33 +02:00
2019-05-09 09:17:59 +02:00
_, err = db.Exec(`
2019-05-09 09:50:04 +02:00
INSERT INTO obj (id, obj_type_id, obj_sub_type_id) VALUES
(1, 7, 701),
(2, 7, 701),
(3, 7, 701),
(4, 7, 701),
(5, 7, 701),
(6, 7, 701),
(7, 7, 701),
(8, 7, 701),
(9, 7, 701),
(10, 7, 701),
(11, 7, 706),
(12, 7, 701),
(13, 7, 701),
(14, 7, 701),
(15, 7, 701),
(16, 7, 701),
(17, 7, 701),
(18, 7, 701),
(19, 7, 701),
(20, 7, 701),
(21, 7, 701),
(22, 7, 701),
(23, 7, 701),
(24, 7, 701),
(25, 7, 701),
(26, 7, 701),
(27, 7, 701),
(28, 7, 701),
(29, 7, 701),
(30, 7, 701),
(31, 7, 701),
(32, 7, 701),
(33, 7, 701),
(34, 7, 701),
(35, 7, 701),
(36, 7, 701),
(37, 7, 701),
(38, 7, 701),
(39, 7, 702),
(40, 7, 702),
(41, 7, 702),
(42, 7, 702),
(43, 7, 702),
(44, 7, 702),
(45, 7, 702),
(46, 7, 702),
(47, 7, 702),
(48, 7, 702),
(49, 7, 702),
(50, 7, 702),
(51, 7, 702),
(52, 7, 702),
(53, 7, 702),
(54, 7, 702),
(55, 7, 702),
(56, 7, 702),
(57, 7, 702),
(58, 7, 702),
(59, 7, 702),
(60, 7, 702),
(61, 7, 702),
(62, 7, 702),
(63, 7, 702),
(64, 7, 702),
(65, 7, 702),
(66, 7, 702),
(67, 7, 702),
(68, 7, 702),
(69, 7, 702),
(70, 7, 703),
(71, 7, 703),
(72, 7, 703),
(73, 7, 703),
(74, 7, 703),
(75, 7, 703),
(76, 7, 703),
(77, 7, 703),
(78, 7, 703),
(79, 7, 703),
(80, 7, 703),
(81, 7, 703),
(82, 7, 703),
(83, 7, 703),
(84, 7, 703),
(85, 7, 703),
(86, 7, 703),
(87, 7, 703),
(88, 7, 703),
(89, 7, 703),
(90, 7, 703),
(91, 7, 706),
(92, 7, 706),
(93, 7, 706),
(94, 7, 706),
(95, 7, 706),
(96, 7, 706),
(97, 7, 706),
(98, 7, 706),
(99, 7, 706),
(100, 7, 706),
(101, 7, 706),
(102, 7, 706),
(103, 7, 706),
(104, 7, 706),
(105, 7, 706),
(106, 7, 706),
(107, 7, 706),
(108, 7, 706),
(109, 7, 706),
(110, 7, 706),
(111, 7, 706),
(112, 7, 706),
(113, 7, 706),
(114, 7, 706),
(115, 7, 706),
(116, 7, 706),
(117, 7, 706),
(118, 7, 706),
(119, 7, 706),
(120, 7, 706),
(121, 7, 706),
(122, 7, 706),
(123, 7, 706),
(124, 7, 706),
(125, 7, 706),
(126, 7, 706),
(127, 7, 706),
(128, 7, 706),
(129, 7, 706),
(130, 7, 706),
(131, 7, 706),
(132, 7, 706),
(133, 7, 706),
(134, 7, 706),
(135, 7, 706),
(136, 7, 706),
(137, 7, 706),
(138, 7, 706),
(139, 7, 706),
(140, 7, 706),
(141, 7, 706),
(142, 7, 706),
(143, 7, 706),
(144, 7, 706),
(145, 7, 706),
(146, 7, 706),
(147, 7, 706),
(148, 7, 706),
(149, 7, 706),
(150, 7, 706),
(151, 7, 706),
(152, 7, 706),
(153, 7, 706),
(154, 7, 706),
(155, 7, 706),
(156, 7, 706),
(157, 7, 706),
(158, 7, 706),
(159, 7, 706),
(160, 7, 706),
(161, 7, 706),
(162, 7, 706),
(163, 7, 706),
(164, 7, 706),
(165, 7, 706),
(166, 7, 706),
(167, 7, 706),
(168, 7, 706),
(169, 7, 706),
(170, 7, 706),
(171, 7, 706),
(172, 7, 706),
(173, 7, 706),
(174, 7, 706),
(175, 7, 706),
(176, 7, 706),
(177, 7, 706),
(178, 7, 706),
(179, 7, 706),
(180, 7, 703),
(181, 7, 703),
(182, 7, 706),
(183, 7, 706),
(184, 7, 706),
(185, 7, 706),
(186, 7, 706),
(187, 7, 706),
(188, 7, 706),
(189, 7, 706),
(190, 7, 706),
(191, 7, 706),
(192, 7, 706),
(193, 7, 706),
(194, 7, 706),
(195, 7, 706),
(196, 7, 706),
(197, 7, 706),
(198, 7, 706),
(199, 7, 706),
(200, 7, 706),
(201, 7, 703),
(202, 7, 703),
(203, 7, 703),
(204, 7, 703),
(205, 7, 703),
(206, 7, 703),
(207, 7, 703),
(208, 7, 703),
(209, 7, 705),
(210, 7, 705),
(211, 7, 705),
(212, 7, 705),
(213, 7, 705),
(214, 7, 705),
(215, 7, 705),
(216, 7, 705),
(217, 7, 705),
(218, 7, 705),
(219, 7, 705),
(220, 7, 705),
(221, 7, 705),
(222, 7, 705),
(223, 7, 705),
(224, 7, 705),
(225, 7, 705),
(226, 7, 705),
(227, 7, 705),
(228, 7, 705),
(229, 7, 705),
(230, 7, 705),
(231, 7, 705),
(232, 7, 705),
(233, 7, 705),
(234, 7, 705),
(235, 7, 705),
(236, 7, 705),
(237, 7, 705),
(238, 7, 705),
(239, 7, 705),
(240, 7, 705),
(241, 7, 705),
(242, 7, 705),
(243, 7, 705),
(244, 7, 705),
(245, 7, 705),
(246, 7, 705),
(247, 7, 705),
(248, 7, 705),
(249, 7, 705),
(250, 7, 705),
(251, 7, 705),
(252, 7, 705),
(253, 7, 705),
(254, 7, 705),
(255, 7, 705),
(256, 7, 705),
(257, 7, 705),
(258, 7, 705),
(259, 7, 705),
(260, 7, 705),
(261, 7, 705),
(262, 7, 705),
(263, 7, 705),
(264, 7, 705),
(265, 7, 705),
(266, 7, 705),
(267, 7, 705),
(268, 7, 705),
(269, 7, 705),
(270, 7, 705),
(271, 7, 705),
(272, 7, 705),
(273, 7, 705),
(274, 7, 705),
(275, 7, 705),
(276, 7, 705),
(277, 7, 705),
(278, 7, 705),
(279, 7, 705),
(280, 7, 705),
(281, 7, 705),
(282, 7, 705),
(283, 7, 705),
(284, 7, 705),
(285, 7, 705),
(286, 7, 705),
(287, 7, 705),
(288, 7, 705),
(289, 7, 705),
(290, 7, 705),
(291, 7, 705),
(292, 7, 705),
(293, 7, 705),
(294, 7, 705),
(295, 7, 703),
(296, 7, 703),
(297, 7, 703),
(298, 7, 703),
(299, 7, 703),
(300, 7, 703),
(301, 7, 703),
(302, 7, 703),
(303, 7, 703),
(304, 7, 703),
(305, 7, 703),
(306, 7, 703),
(307, 7, 703),
(308, 7, 703),
(309, 7, 703),
(310, 7, 703),
(311, 7, 703),
(312, 7, 703),
(313, 7, 703),
(314, 7, 703),
(315, 7, 703),
(316, 7, 703),
(317, 7, 704),
(318, 7, 704),
(319, 7, 704),
(320, 7, 704),
(321, 7, 704),
(322, 7, 704),
(323, 7, 704),
(324, 7, 704),
(325, 7, 704),
(326, 7, 704),
(327, 7, 704),
(328, 7, 704),
(329, 7, 704),
(330, 7, 704),
(331, 7, 704),
(332, 7, 704),
(333, 7, 704),
(334, 7, 704),
(335, 7, 704),
(336, 7, 704),
(337, 7, 704),
(338, 7, 704),
(339, 7, 704),
(340, 7, 704),
(341, 7, 704),
(342, 7, 704),
(343, 7, 704),
(344, 7, 704),
(345, 7, 704),
(346, 7, 704),
(347, 7, 704),
(348, 7, 704),
(349, 7, 704),
(350, 7, 704),
(351, 7, 704),
(352, 7, 704),
(353, 7, 704),
(354, 7, 704),
(355, 7, 704),
(356, 7, 704),
(357, 7, 704),
(358, 7, 704),
(359, 7, 704),
(360, 7, 704),
(361, 7, 704),
(362, 7, 704),
(363, 7, 704),
(364, 7, 704),
(365, 7, 704),
(366, 7, 704),
(367, 7, 704),
(368, 7, 704),
(369, 7, 704),
(370, 7, 704),
(371, 7, 704),
(372, 7, 704),
(373, 7, 704),
(374, 7, 704),
(375, 7, 704),
(376, 7, 704),
(377, 7, 704),
(378, 7, 704),
(379, 7, 704),
(380, 7, 704),
(381, 7, 704),
(382, 7, 704),
(383, 7, 704),
(384, 7, 704),
(385, 7, 704),
(386, 7, 704),
(387, 7, 704),
(388, 7, 704),
(389, 7, 704),
(390, 7, 704),
(391, 7, 704),
(392, 7, 704),
(393, 7, 704),
(394, 7, 704),
(395, 7, 704),
(396, 7, 704),
(397, 7, 704),
(398, 7, 704),
(399, 7, 704),
(400, 7, 704),
(401, 7, 704),
(402, 7, 704),
(403, 7, 703),
(404, 7, 703),
(405, 7, 703),
(406, 7, 703),
(407, 7, 703),
(408, 7, 703),
(409, 7, 703),
(410, 7, 703),
(411, 7, 703),
(412, 7, 703),
(413, 7, 703),
(414, 7, 703),
(415, 7, 703),
(416, 7, 703),
(417, 7, 706),
(418, 7, 706),
(419, 7, 706),
(420, 7, 706),
(421, 7, 706),
(422, 7, 706),
(423, 7, 706),
(424, 7, 706),
(425, 7, 706),
(426, 7, 706),
(427, 7, 706),
(428, 7, 706),
(429, 7, 706),
(430, 7, 706),
(431, 7, 706),
(432, 7, 706),
(433, 7, 706),
(434, 7, 706),
(435, 7, 706),
(436, 7, 706),
(437, 7, 706),
(438, 7, 706),
(439, 7, 706),
(440, 7, 706),
(441, 7, 706),
(442, 7, 706),
(443, 7, 706),
(444, 7, 706),
(445, 7, 706),
(446, 7, 706),
(447, 7, 706),
(448, 7, 706),
(449, 7, 706),
(450, 7, 706),
(451, 7, 706),
(452, 7, 706),
(453, 7, 706),
(454, 7, 706),
(455, 7, 706),
(456, 7, 706),
(457, 7, 706),
(458, 7, 706),
(459, 7, 706),
(460, 7, 706),
(461, 7, 706),
(462, 7, 706),
(463, 7, 706),
(464, 7, 706),
(465, 7, 706),
(466, 7, 706),
(467, 7, 706),
(468, 7, 706),
(469, 7, 706),
(470, 7, 706),
(471, 7, 706),
(472, 7, 706);
2019-05-09 09:17:59 +02:00
`)
2019-05-09 09:50:04 +02:00
failOnError(err, "initDB : populate table obj_item #1")
_, err = db.Exec(`
INSERT INTO obj_item (obj_id, intl_id, name, weight) VALUES
(1, '01', 'Thread', 1),
(2, '02', 'Stick', 1),
(3, '03', 'Pelt', 1),
(4, '04', 'Bone', 1),
(5, '05', 'Coal', 1),
(6, '06', 'Charcoal', 1),
(7, '07', 'Powder', 1),
(8, '08', 'Iron Ore', 2),
(9, '09', 'Cloth', 1),
(10, '10', 'Silver Ore', 2),
(11, '100', 'Pouch of Gold', 0),
(12, '11', 'Bauxite', 2),
(13, '12', 'Cord', 2),
(14, '13', 'Magic Stone', 1),
(15, '14', 'Wooden Shaft', 2),
(16, '15', 'Sapphire', 2),
(17, '16', 'Solvent', 2),
(18, '17', 'Ruby', 2),
(19, '18', 'Hardener', 2),
(20, '19', 'Steel', 2),
(21, '20', 'Leather', 1),
(22, '21', 'Bone Powder', 1),
(23, '22', 'String', 1),
(24, '23', 'Coke', 1),
(25, '24', 'Purified Powder', 1),
(26, '25', 'Silver Alloy', 3),
(27, '27', 'Steel Mold', 2),
(28, '28', 'Silver Mold', 2),
(29, '29', 'Blacksmith Frame', 3),
(30, '30', 'Artisan Frame', 3),
(31, '31', 'Rope', 1),
(32, '32', 'Silver Frame', 2),
(33, '33', 'Metal Plate', 2),
(34, '34', 'Metallic Fiber', 2),
(35, '35', 'Crafted Leather', 1),
(36, '36', 'Quality Cloth', 2),
(37, '37', 'Blacksmith Mold', 3),
(38, '38', 'Artisan Mold', 3),
(39, '39', 'Stinky Sumac', 1),
(40, '40', 'Mercy Sassafras', 1),
(41, '41', 'Cliff Rue', 1),
(42, '42', 'Love Creeper', 1),
(43, '43', 'Wolf Root', 1),
(44, '44', 'Swamp Lavender', 1),
(45, '45', 'White Blossom', 1),
(46, '46', 'Ilaves', 1),
(47, '47', 'Ephijora', 1),
(48, '48', 'Storm Hyssop', 1),
(49, '49', 'Cave Garlic', 1),
(50, '50', 'Yellow Seed', 1),
(51, '51', 'Tecceagrass', 1),
(52, '52', 'Spring Bay Leaf', 1),
(53, '53', 'Ash Rosemary', 1),
(54, '54', 'Sanguine Parsley', 1),
(55, '55', 'Sun Tarragon', 1),
(56, '56', 'Maccunut', 1),
(57, '57', 'Dragon Seed', 1),
(58, '58', 'Queen\'s Pepper', 1),
(59, '59', 'Plasma of Abyss', 1),
(60, '60', 'Ultramarine Dust', 1),
(61, '61', 'Ethereal Bone', 1),
(62, '62', 'Itacory', 1),
(63, '63', 'Assassin Vine', 1),
(64, '64', 'Kloliarway', 1),
(65, '65', 'Astrulic', 1),
(66, '66', 'Flammia Nut', 1),
(67, '67', 'Plexisop', 1),
(68, '68', 'Mammoth Dill', 1),
(69, '69', 'Silver Dust', 1),
(70, '501', 'Wrapping', 2),
(71, '502', 'Leash', 2),
(72, '505', 'Wooden Arrow', 10),
(73, '507', 'Bottle of Remedy', -1),
(74, '509', 'Bottle of Poison', -1),
(75, '511', 'Steel Arrow', 10),
(76, '513', 'Silver Arrow', 10),
(77, '515', 'Broad Arrows Pack', -1),
(78, '517', 'Heavy Arrows Pack', -1),
(79, '519', 'Compound Arrows Pack', -1),
(80, '614', 'Gift Coupon: Pig', 1),
(81, '615', 'Gift Coupon: Horse', 1),
(82, '617', 'Gift Coupon: Mouse', 1),
(83, '618', 'Hay', 5),
(84, '619', 'Corn', 5),
(85, '620', 'Hamsters', 5),
(86, '621', 'Cheese', 5),
(87, '623', 'Gift Coupon: Ant', 1),
(88, '624', 'Gift Coupon: Spider', 1),
(89, '625', 'Gift Coupon: Haunted', 1),
(90, '626', 'Gift Coupon: Camel', 1),
(91, 'a01', 'Cloth Jacket', -1),
(92, 'a02', 'Leather Shirt', -1),
(93, 'a03', 'Chain Mail', -1),
(94, 'a04', 'Silver Cuirass', -1),
(95, 'a05', 'Mithril Armor', -1),
(96, 'a06', 'Hat', -1),
(97, 'a07', 'Leather Hood', -1),
(98, 'a08', 'Steel Helmet', -1),
(99, 'a09', 'Silver Helmet', -1),
(100, 'a10', 'Mithril Helmet', -1),
(101, 'a100', 'Assault Cape', -1),
(102, 'a101', 'Craftsman Apron', -1),
(103, 'a102', 'Stoneskin Cloak', -1),
(104, 'a11', 'Sandals', -1),
(105, 'a12', 'Leather Shoes', -1),
(106, 'a13', 'Steel Boots', -1),
(107, 'a14', 'Silver Boots', -1),
(108, 'a15', 'Mithril Boots', -1),
(109, 'a16', 'Gloves (Item)', -1),
(110, 'a17', 'Leather Gloves', -1),
(111, 'a18', 'Steel Gauntlets', -1),
(112, 'a19', 'Silver Gauntlets', -1),
(113, 'a20', 'Mithril Gauntlets', -1),
(114, 'a21', 'Wooden Shield', -1),
(115, 'a22', 'Skeleton Buckler', -1),
(116, 'a23', 'Bronze Shield', -1),
(117, 'a24', 'Silver Shield', -1),
(118, 'a25', 'Mithril Shield', -1),
(119, 'a26', 'Royal Guard Cape', -1),
(120, 'a27', 'Order Armor', -1),
(121, 'a28', 'Order Helmet', 190),
(122, 'a29', 'Order Boots', -1),
(123, 'a30', 'Order Gauntlets', -1),
(124, 'a31', 'Order Shield', -1),
(125, 'a32', 'Hunter Armor', 450),
(126, 'a33', 'Hunter Helmet', 190),
(127, 'a34', 'Hunter Boots', -1),
(128, 'a35', 'Hunter Gloves', 125),
(129, 'a36', 'Clarity Robe', 450),
(130, 'a37', 'Clarity Circlet', 190),
(131, 'a38', 'Clarity Shoes', 125),
(132, 'a39', 'Clarity Bracers', 125),
(133, 'a40', 'Pencil of Truth', 10),
(134, 'a41', 'Bard\'s Cape', -1),
(135, 'a45', 'Crusader Armor', -1),
(136, 'a46', 'Crusader Helmet', -1),
(137, 'a47', 'Crusader Boots', 200),
(138, 'a48', 'Crusader Gauntlets', -1),
(139, 'a49', 'Crusader Shield', 200),
(140, 'a50', 'Royal Armor', -1),
(141, 'a51', 'Royal Helmet', -1),
(142, 'a52', 'Royal Boots', 200),
(143, 'a53', 'Royal Gauntlets', -1),
(144, 'a54', 'Royal Shield', 200),
(145, 'a55', 'Ghost Armor', 480),
(146, 'a56', 'Ghost Helmet', 200),
(147, 'a57', 'Ghost Boots', 90),
(148, 'a58', 'Ghost Gloves', -1),
(149, 'a59', 'Lion Armor', -1),
(150, 'a60', 'Lion Helmet', 200),
(151, 'a61', 'Lion Boots', -1),
(152, 'a62', 'Lion Gloves', -1),
(153, 'a63', 'Demon Robe', 480),
(154, 'a64', 'Demon Circlet', 200),
(155, 'a65', 'Demon Shoes', 140),
(156, 'a66', 'Demon Bracers', 140),
(157, 'a67', 'Divine Robe', 480),
(158, 'a68', 'Divine Circlet', 200),
(159, 'a69', 'Divine Shoes', 140),
(160, 'a70', 'Divine Bracers', 140),
(161, 'a71', 'Storm Cloak', -1),
(162, 'a72', 'Durable Cloak', 30),
(163, 'a73', 'Blessed Cloak', 30),
(164, 'a74', 'Hiking Jar', -1),
(165, 'a75', 'Hiking Bag', -1),
(166, 'a76', 'Stick of Wisdom', 10),
(167, 'a78', 'Council Armor', 510),
(168, 'a79', 'Council Helmet', -1),
(169, 'a80', 'Council Boots', -1),
(170, 'a81', 'Council Gloves', 155),
(171, 'a82', 'Council Shield', -1),
(172, 'a83', 'Griffin Armor', -1),
(173, 'a84', 'Griffin Helmet', -1),
(174, 'a85', 'Griffin Boots', 155),
(175, 'a86', 'Griffin Gloves', 155),
(176, 'a87', 'Celestial Armor', 510),
(177, 'a88', 'Celestial Helmet', 210),
(178, 'a89', 'Celestial Boots', 155),
(179, 'a90', 'Celestial Gloves', 155),
(180, 'ch1', 'Zombie Chest', -1),
(181, 'e1', 'Cocoa Powder', 1),
(182, 'e109', 'Walker Armor (Event Gear)', -1),
(183, 'e110', 'Walker Helmet (Event Gear)', -1),
(184, 'e111', 'Walker Boots (Event Gear)', -1),
(185, 'e112', 'Walker Gauntlets (Event Gear)', -1),
(186, 'e113', 'Walker Shield (Event Gear)', -1),
(187, 'e114', 'Zombie Armor (Event Gear)', 480),
(188, 'e115', 'Zombie Helmet (Event Gear)', -1),
(189, 'e116', 'Zombie Boots (Event Gear)', 140),
(190, 'e117', 'Zombie Gauntlets (Event Gear)', 140),
(191, 'e118', 'Zombie Shield (Event Gear)', -1),
(192, 'e125', 'Demon Shoes (Event Item)', -1),
(193, 'e128', 'Manwolf Helmet (Event Gear)', -1),
(194, 'e130', 'Manwolf Gloves (Event Gear)', -1),
(195, 'e132', 'Werewolf Helmet (Event Gear)', 200),
(196, 'e139', 'Nosferatu Armor (Event Gear)', -1),
(197, 'e144', 'War Club', -1),
(198, 'e147', 'Manwolf Knife (Event Gear)', -1),
(199, 'e150', 'Walker Club (Event Gear)', -1),
(200, 'e153', 'Werewolf Knife (Event Gear)', -1),
(201, 'e2', 'Egg', 1),
(202, 'e3', 'Flour', 1),
(203, 'e4', 'Milk', -1),
(204, 'e5', 'Sugar', -1),
(205, 'est', 'Evil Spirits Totem', 50),
(206, 'hw102', 'Timeless Jade', -1),
(207, 'hw104', 'Shadow Bloodstone', -1),
(208, 'hw107', 'Void Emerald', -1),
(209, 'k01', 'Champion Blade', 10),
(210, 'k02', 'Trident Blade', 10),
(211, 'k03', 'Hunter Shaft', 10),
(212, 'k04', 'War Hammer Head', 10),
(213, 'k05', 'Hunter Blade', 10),
(214, 'k06', 'Order Armor Piece', 10),
(215, 'k07', 'Order Helmet Fragment', 10),
(216, 'k08', 'Order Boots Part', 10),
(217, 'k09', 'Order Gauntlets Part', 10),
(218, 'k10', 'Order Shield Part', 10),
(219, 'k11', 'Hunter Armor Part', 10),
(220, 'k12', 'Hunter Helmet Fragment', 10),
(221, 'k13', 'Hunter Boots Part', 10),
(222, 'k14', 'Hunter Gloves Part', 10),
(223, 'k15', 'Clarity Robe Piece', 10),
(224, 'k16', 'Clarity Circlet Fragment', 10),
(225, 'k17', 'Clarity Shoes Part', 10),
(226, 'k18', 'Clarity Bracers Part', 10),
(227, 'k19', 'Thundersoul Blade', 10),
(228, 'k20', 'Doomblade Blade', -1),
(229, 'k21', 'Eclipse Blade', 10),
(230, 'k22', 'Guard\'s Blade', 10),
(231, 'k23', 'King\'s Defender Blade', 10),
(232, 'k24', 'Raging Lance Blade', 10),
(233, 'k25', 'Composite Bow Shaft', 10),
(234, 'k26', 'Lightning Bow Shaft', -1),
(235, 'k27', 'Hailstorm Bow Shaft', 10),
(236, 'k28', 'Imperial Axe Head', 10),
(237, 'k29', 'Skull Crusher Head', 10),
(238, 'k30', 'Dragon Mace Head', 10),
(239, 'k31', 'Ghost Blade', 10),
(240, 'k32', 'Lion Blade', 10),
(241, 'k33', 'Crusader Armor Piece', -1),
(242, 'k34', 'Crusader Helmet Fragment', -1),
(243, 'k35', 'Crusader Boots Part', -1),
(244, 'k36', 'Crusader Gauntlets Part', -1),
(245, 'k37', 'Crusader Shield Part', 10),
(246, 'k38', 'Royal Armor Piece', -1),
(247, 'k39', 'Royal Helmet Fragment', -1),
(248, 'k40', 'Royal Boots Part', -1),
(249, 'k41', 'Royal Gauntlets Part', -1),
(250, 'k42', 'Royal Shield Part', -1),
(251, 'k43', 'Ghost Armor Part', 10),
(252, 'k44', 'Ghost Helmet Fragment', 10),
(253, 'k45', 'Ghost Boots Part', 10),
(254, 'k46', 'Ghost Gloves Part', 10),
(255, 'k47', 'Lion Armor Part', -1),
(256, 'k48', 'Lion Helmet Fragment', 10),
(257, 'k49', 'Lion Boots Part', 10),
(258, 'k50', 'Lion Gloves Part', 10),
(259, 'k51', 'Demon Robe Piece', 10),
(260, 'k52', 'Demon Circlet Fragment', 10),
(261, 'k53', 'Demon Shoes Part', 10),
(262, 'k54', 'Demon Bracers Part', 10),
(263, 'k55', 'Divine Robe Piece', 10),
(264, 'k56', 'Divine Circlet Fragment', -1),
(265, 'k57', 'Divine Shoes Part', 10),
(266, 'k58', 'Divine Bracers Part', 10),
(267, 'k59', 'Storm Cloak Part', 10),
(268, 'k60', 'Durable Cloak Part', -1),
(269, 'k61', 'Blessed Cloak Part', 10),
(270, 'k78', 'Council Armor Part', 10),
(271, 'k79', 'Council Helmet Part', -1),
(272, 'k80', 'Council Boots Part', -1),
(273, 'k81', 'Council Gloves Part', 10),
(274, 'k82', 'Council Shield Part', -1),
(275, 'k83', 'Griffin Armor Part', -1),
(276, 'k84', 'Griffin Helmet Part', -1),
(277, 'k85', 'Griffin Boots Part', -1),
(278, 'k86', 'Griffin Gloves Part', -1),
(279, 'k87', 'Celestial Armor Part', -1),
(280, 'k88', 'Celestial Helmet Part', -1),
(281, 'k89', 'Celestial Boots Part', -1),
(282, 'k90', 'Celestial Gloves Part', -1),
(283, 'k91', 'Griffin Knife Part', -1),
(284, 'k92', 'Minotaur Sword Part', -1),
(285, 'k93', 'Phoenix Sword Part', -1),
(286, 'k94', 'Heavy Fauchard Part', -1),
(287, 'k95', 'Guisarme Part', -1),
(288, 'k96', 'Meteor Bow Part', -1),
(289, 'k97', 'Nightfall Bow Part', -1),
(290, 'k98', 'Black Morningstar Part', -1),
(291, 'k99', 'Maiming Bulawa Part', -1),
(292, 'k100', 'Assault Cape Part', -1),
(293, 'k101', 'Craftsman Apron Part', -1),
(294, 'k102', 'Stoneskin Cloak Part', -1),
(295, 'p01', 'Vial of Rage', 1),
(296, 'p02', 'Potion of Rage', 1),
(297, 'p03', 'Bottle of Rage', 1),
(298, 'p04', 'Vial of Peace', 1),
(299, 'p05', 'Potion of Peace', 1),
(300, 'p06', 'Bottle of Peace', 1),
(301, 'p07', 'Vial of Greed', 1),
(302, 'p08', 'Potion of Greed', 1),
(303, 'p09', 'Bottle of Greed', 1),
(304, 'p10', 'Vial of Nature', 1),
(305, 'p11', 'Potion of Nature', 1),
(306, 'p12', 'Bottle of Nature', 1),
(307, 'p13', 'Vial of Mana', 1),
(308, 'p14', 'Potion of Mana', 1),
(309, 'p15', 'Bottle of Mana', 1),
(310, 'p16', 'Vial of Twilight', 1),
(311, 'p17', 'Potion of Twilight', 1),
(312, 'p18', 'Bottle of Twilight', 1),
(313, 'p19', 'Vial of Morph', 1),
(314, 'p20', 'Potion of Morph', 1),
(315, 'p21', 'Bottle of Morph', 1),
(316, 'pmp', 'Pumpkin', -1),
(317, 'r01', 'Champion Sword Recipe', 10),
(318, 'r02', 'Trident Recipe', 10),
(319, 'r03', 'Hunter Bow Recipe', 10),
(320, 'r04', 'War Hammer Recipe', 10),
(321, 'r05', 'Hunter Dagger Recipe', 10),
(322, 'r06', 'Order Armor Recipe', 10),
(323, 'r07', 'Order Helmet Recipe', 10),
(324, 'r08', 'Order Boots Recipe', 10),
(325, 'r09', 'Order Gauntlets Recipe', 10),
(326, 'r10', 'Order Shield Recipe', 10),
(327, 'r100', 'Assault Cape Recipe', -1),
(328, 'r101', 'Craftsman Apron Recipe', -1),
(329, 'r102', 'Stoneskin Cloak Recipe', -1),
(330, 'r11', 'Hunter Armor Recipe', 10),
(331, 'r12', 'Hunter Helmet Recipe', 10),
(332, 'r13', 'Hunter Boots Recipe', 10),
(333, 'r14', 'Hunter Gloves Recipe', 10),
(334, 'r15', 'Clarity Robe Recipe', 10),
(335, 'r16', 'Clarity Circlet Recipe', 10),
(336, 'r17', 'Clarity Shoes Recipe', 10),
(337, 'r18', 'Clarity Bracers Recipe', 10),
(338, 'r19', 'Thundersoul Sword Recipe', 10),
(339, 'r20', 'Doomblade Sword Recipe', 10),
(340, 'r21', 'Eclipse Recipe', 10),
(341, 'r22', 'Guard\'s Spear Recipe', 10),
(342, 'r23', 'King\'s Defender Recipe', 10),
(343, 'r24', 'Raging Lance Recipe', 10),
(344, 'r25', 'Composite Bow Recipe', 10),
(345, 'r26', 'Lightning Bow Recipe', 10),
(346, 'r27', 'Hailstorm Bow Recipe', 10),
(347, 'r28', 'Imperial Axe Recipe', 10),
(348, 'r29', 'Skull Crusher Recipe', 10),
(349, 'r30', 'Dragon Mace Recipe', 10),
(350, 'r31', 'Ghost Dagger Recipe', 10),
(351, 'r32', 'Lion Knife Recipe', 10),
(352, 'r33', 'Crusader Armor Recipe', 10),
(353, 'r34', 'Crusader Helmet Recipe', 10),
(354, 'r35', 'Crusader Boots Recipe', 10),
(355, 'r36', 'Crusader Gauntlets Recipe', 10),
(356, 'r37', 'Crusader Shield Recipe', 10),
(357, 'r38', 'Royal Armor Recipe', 10),
(358, 'r39', 'Royal Helmet Recipe', 10),
(359, 'r40', 'Royal Boots Recipe', 10),
(360, 'r41', 'Royal Gauntlets Recipe', 10),
(361, 'r42', 'Royal Shield Recipe', 10),
(362, 'r43', 'Ghost Armor Recipe', 10),
(363, 'r44', 'Ghost Helmet Recipe', 10),
(364, 'r45', 'Ghost Boots Recipe', 10),
(365, 'r46', 'Ghost Gloves Recipe', 10),
(366, 'r47', 'Lion Armor Recipe', 10),
(367, 'r48', 'Lion Helmet Recipe', 10),
(368, 'r49', 'Lion Boots Recipe', 10),
(369, 'r50', 'Lion Gloves Recipe', 10),
(370, 'r51', 'Demon Robe Recipe', 10),
(371, 'r52', 'Demon Circlet Recipe', 10),
(372, 'r53', 'Demon Shoes Recipe', 10),
(373, 'r54', 'Demon Bracers Recipe', 10),
(374, 'r55', 'Divine Robe Recipe', 10),
(375, 'r56', 'Divine Circlet Recipe', 10),
(376, 'r57', 'Divine Shoes Recipe', 10),
(377, 'r58', 'Divine Bracers Recipe', 10),
(378, 'r59', 'Storm Cloak Recipe', 10),
(379, 'r60', 'Durable Cloak Recipe', 10),
(380, 'r61', 'Blessed Cloak Recipe', 10),
(381, 'r78', 'Council Armor Recipe', -1),
(382, 'r79', 'Council Helmet Recipe', -1),
(383, 'r80', 'Council Boots Recipe', -1),
(384, 'r81', 'Council Gloves Recipe', -1),
(385, 'r82', 'Council Shield Recipe', -1),
(386, 'r83', 'Griffin Armor Recipe', -1),
(387, 'r84', 'Griffin Helmet Recipe', -1),
(388, 'r85', 'Griffin Boots Recipe', -1),
(389, 'r86', 'Griffin Gloves Recipe', -1),
(390, 'r87', 'Celestial Armor Recipe', -1),
(391, 'r88', 'Celestial Helmet Recipe', -1),
(392, 'r89', 'Celestial Boots Recipe', -1),
(393, 'r90', 'Celestial Gloves Recipe', -1),
(394, 'r91', 'Griffin Knife Recipe', -1),
(395, 'r92', 'Minotaur Sword Recipe', -1),
(396, 'r93', 'Phoenix Sword Recipe', -1),
(397, 'r94', 'Heavy Fauchard Recipe', -1),
(398, 'r95', 'Guisarme Recipe', -1),
(399, 'r96', 'Meteor Bow Recipe', -1),
(400, 'r97', 'Nightfall Bow Recipe', -1),
(401, 'r98', 'Black Morningstar Recipe', -1),
(402, 'r99', 'Maiming Bulawa Recipe', -1),
(403, 's01', '📕Scroll of Rage', 1),
(404, 's02', '📕Scroll of Peace', 1),
(405, 's03', '📗Scroll of Rage', 1),
(406, 's04', '📗Scroll of Peace', 1),
(407, 's05', '📘Scroll of Rage', 1),
(408, 's06', '📘Scroll of Peace', 1),
(409, 's11', '📕Rare scroll of Rage', 1),
(410, 's12', '📕Rare scroll of Peace', 1),
(411, 's13', '📗Rare scroll of Rage', 1),
(412, 's14', '📗Rare scroll of Peace', 1),
(413, 's15', '📘Rare scroll of Rage', 1),
(414, 's16', '📘Rare scroll of Peace', 1),
(415, 's51', '✒️Sof Engraving', 1),
(416, 'tch', 'Torch', -1),
(417, 'td1', 'Colorless shard', 50),
(418, 'w01', 'Wooden Sword', -1),
(419, 'w02', 'Short Sword', -1),
(420, 'w03', 'Long Sword', 180),
(421, 'w04', 'Widow Sword', -1),
(422, 'w05', 'Knight\'s Sword', -1),
(423, 'w06', 'Elven Sword', -1),
(424, 'w07', 'Rapier', 180),
(425, 'w08', 'Short Spear', -1),
(426, 'w09', 'Long Spear', -1),
(427, 'w10', 'Lance', -1),
(428, 'w11', 'Elven Spear', -1),
(429, 'w12', 'Halberd', -1),
(430, 'w13', 'Kitchen Knife', -1),
(431, 'w14', 'Battle Knife', -1),
(432, 'w15', 'Steel Dagger', -1),
(433, 'w16', 'Silver Dagger', -1),
(434, 'w17', 'Mithril Dagger', 180),
(435, 'w18', 'Short Bow', -1),
(436, 'w19', 'Wooden Bow', -1),
(437, 'w20', 'Long Bow', -1),
(438, 'w21', 'Elven Bow', -1),
(439, 'w22', 'Forest Bow', -1),
(440, 'w23', 'Club', -1),
(441, 'w24', 'Bone Club', -1),
(442, 'w25', 'Heavy Club', -1),
(443, 'w26', 'Steel Axe', -1),
(444, 'w27', 'Mithril Axe', -1),
(445, 'w28', 'Champion Sword', 180),
(446, 'w29', 'Trident', -1),
(447, 'w30', 'Hunter Bow', -1),
(448, 'w31', 'War Hammer', 180),
(449, 'w32', 'Hunter Dagger', 180),
(450, 'w33', 'Thundersoul Sword', 200),
(451, 'w34', 'Doomblade Sword', -1),
(452, 'w35', 'Eclipse', 200),
(453, 'w36', 'Guard\'s Spear', -1),
(454, 'w37', 'King\'s Defender', -1),
(455, 'w38', 'Raging Lance', 200),
(456, 'w39', 'Composite Bow', 200),
(457, 'w40', 'Lightning Bow', 200),
(458, 'w41', 'Hailstorm Bow', 200),
(459, 'w42', 'Imperial Axe', -1),
(460, 'w43', 'Skull Crusher', -1),
(461, 'w44', 'Dragon Mace', 200),
(462, 'w45', 'Ghost Dagger', -1),
(463, 'w46', 'Lion Knife', -1),
(464, 'w91', 'Griffin Knife', -1),
(465, 'w92', 'Minotaur Sword', -1),
(466, 'w93', 'Phoenix Sword', -1),
(467, 'w94', 'Heavy Fauchard', -1),
(468, 'w95', 'Guisarme', -1),
(469, 'w96', 'Meteor Bow', -1),
(470, 'w97', 'Nightfall Bow', -1),
(471, 'w98', 'Black Morningstar', -1),
(472, 'w99', 'Maiming Bulawa', 0);
`)
failOnError(err, "initDB : populate table obj_item #2")
2019-05-11 09:49:42 +02:00
log.Println("initDB : obj_item populated ...")
2019-05-09 09:17:59 +02:00
2019-05-11 09:49:42 +02:00
log.Println("initDB : Database set up")
2019-05-04 11:15:33 +02:00
}
2019-05-11 07:56:51 +02:00
func resetMsgParsingRules() {
_, err := db.Exec(`TRUNCATE TABLE msg_rules;`)
failOnError(err, "resetMsgParsingRules : truncate table msg_rules")
_, err = db.Exec(`INSERT INTO msg_rules (prio, msg_type_id, descn, rule)
2019-05-11 10:59:21 +02:00
VALUES (5000, ` + strconv.Itoa(objSubTypeMessageReport) + `, "Player war report", "^(?P<Castle>[🐉🦅🐺🦈🦌🥔🌑])(\\[(?P<Guild>[A-Z]{3})\\]){0,1}(?P<User>([A-Za-z0-9 ]*)) ⚔:(?P<Attack>[0-9]+)(?P<AttackMod>\\((-|\\+)[0-9]+\\)){0,1} 🛡:(?P<Defense>[0-9]+) Lvl: (?P<Level>[0-9]+)\\nYour result on the battlefield:\\n(🔥Exp: (?P<Exp>[0-9]+)\\n){0,1}(💰Gold: (?P<Gold>\\-{0,1}[0-9]+)\\n){0,1}(📦Stock: (?P<Stock>\\-{0,1}[0-9]+)){0,1}(\\n(?P<Stamina>(🔋Stamina restored))){0,1}(\\n(?P<Crit>(⚡Critical strike))){0,1}$")
2019-05-11 08:43:11 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageAuctionAnnounce) + `, "Auction annouce", "^Lot #(?P<Lot>[0-9]+) : (?P<Item>.*)\\n(Quality: (?P<Quality>.*)\\n){0,1}(Condition: (?P<Cond>.*)\\n){0,1}Seller: (?P<Seller>.*)\\nCurrent price: (?P<Price>[0-9]+) pouch\\(es\\)\\nBuyer: (?P<Buyer>.*)\\nEnd At: (?P<End>.*)\\nStatus: (?P<Status>.*)(\\n)*(?s:.*)")
2019-05-13 03:51:05 +02:00
,(5000, ` + strconv.Itoa(objSubTypeMessageTimeAck) + `, "Time", "^In Chat Wars world now\\n(?P<Time>.*)\\n(?P<Hour>[0-9]{2}):(?P<Minute>[0-9]{2})\\n(?P<Day>[0-9]{2}) (?P<Month>.+) (?P<Year>[0-9]{4})\\n(?s:.*)$")` + /*
,(5000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^Battle results:\\n` +
`(?P<Gardian1>🔱){0,1}(?P<CastleLoot1>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult1>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold1>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock1>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot2>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult2>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold2>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock2>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot3>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult3>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold3>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock3>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot4>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult4>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold4>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock4>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot5>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult5>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold5>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock5>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot6>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult6>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold6>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock6>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<CastleLoot7>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<CastleResult7>(🛡|🛡👌|⚔️|⚔️ ⚡️))( (?P<CastleGold7>(\\-|\\+)[0-9]+)💰){0,1}( (?P<CastleStock7>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`\\n🏆Scores:\\n` +
`(?P<CastleScore1>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score1>\\+[0-9]+)\\n` +
`(?P<CastleScore2>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score2>\\+[0-9]+)\\n` +
`(?P<CastleScore3>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score3>\\+[0-9]+)\\n` +
`(?P<CastleScore4>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score4>\\+[0-9]+)\\n` +
`(?P<CastleScore5>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score5>\\+[0-9]+)\\n` +
`(?P<CastleScore6>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score6>\\+[0-9]+)\\n` +
`(?P<CastleScore7>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Score7>\\+[0-9]+)\\n` +
`\\n` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")` + /*
,(4000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^Battle results:\\n` +
`(?P<Gardian1>🔱){0,1}(?P<Loot1>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result1>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold1>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock1>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian2>🔱){0,1}(?P<Loot2>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result2>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold2>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock2>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian3>🔱){0,1}(?P<Loot3>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result3>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold3>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock3>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian4>🔱){0,1}(?P<Loot4>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result4>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold4>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock4>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian5>🔱){0,1}(?P<Loot5>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result5>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold5>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock5>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian6>🔱){0,1}(?P<Loot6>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result6>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold6>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock6>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?P<Gardian7>🔱){0,1}(?P<Loot7>(🌑Moonlight|🐺Wolfpack|🦌Deerhorn|🐉Dragonscale|🦈Sharkteeth|🥔Potato|🦅Highnest)): (?P<Result7>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold7>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock7>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
`(?s:.*)` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")*/`
2019-05-13 03:38:39 +02:00
,(4000, ` + strconv.Itoa(objSubTypeMessageMiniWar) + `, "Mini War", "^Battle results:\\n` +
2019-05-13 03:51:05 +02:00
`(?P<Gardian1>🔱){0,1}.*(?P<Loot1>(Moonlight|Wolfpack|Deerhorn|Dragonscale|Sharkteeth|Potato|Highnest)): (?P<Result1>[ 🛡👌⚡️⚔️]*)[ ]*((?P<Gold1>(\\-|\\+)[0-9]+)💰){0,1}[ ]*((?P<Stock1>(\\-|\\+)[0-9]+)📦){0,1}\\n` +
2019-05-13 03:38:39 +02:00
`(?s:.*)` +
`Battle (?P<Time>[0-9]{2}/[0-9]{2}/[0-9]{2} [0-9]{2}:[0-9]{2})$")
2019-05-11 12:07:33 +02:00
;`)
2019-05-11 07:56:51 +02:00
failOnError(err, "resetMsgParsingRules : populate table msg_rules")
}
2019-05-05 13:29:28 +02:00
func putUnprocessedMsg(m ChatWarsMessage) (int64, error) {
2019-05-11 09:11:42 +02:00
tx, err := db.Begin()
logOnError(err, "putUnprocessedMsg : start transaction")
if err != nil {
return 0, err
}
res, err := tx.Exec(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
2019-05-08 12:39:33 +02:00
VALUES (` + strconv.Itoa(objTypeMessage) + `,` + strconv.Itoa(objSubTypeMessageUnknown) + `);`)
2019-05-11 09:01:24 +02:00
logOnError(err, "putUnprocessedMsg : exec insert obj")
2019-05-04 10:57:24 +02:00
if err != nil {
2019-05-11 09:11:42 +02:00
err2 := tx.Rollback()
logOnError(err2, "putUnprocessedMsg : rollback insert obj")
2019-05-06 04:56:59 +02:00
return 0, err
2019-05-04 10:57:24 +02:00
}
2019-05-05 13:29:28 +02:00
2019-05-04 10:57:24 +02:00
objId, err := res.LastInsertId()
2019-05-05 13:29:28 +02:00
if err != nil {
2019-05-11 09:11:42 +02:00
err2 := tx.Rollback()
logOnError(err2, "putUnprocessedMsg : rollback get lastInsertId")
2019-05-06 04:56:59 +02:00
return 0, err
2019-05-05 13:29:28 +02:00
}
2019-05-04 10:57:24 +02:00
2019-05-11 09:11:42 +02:00
stmt, err := tx.Prepare(`INSERT INTO obj_msg (obj_id, msg_id, chat_id, user_id, sender_user_id, date, text)
2019-05-09 12:36:45 +02:00
VALUES (?, ?, ?, ?, ?, ?, ?);`)
2019-05-11 09:01:24 +02:00
logOnError(err, "putUnprocessedMsg : prepare insert obj_msg")
2019-05-03 09:15:16 +02:00
if err != nil {
2019-05-11 09:11:42 +02:00
err2 := tx.Rollback()
logOnError(err2, "putUnprocessedMsg : rollback prepare insert obj_msg")
2019-05-06 04:56:59 +02:00
return 0, err
2019-05-03 09:15:16 +02:00
}
2019-05-03 18:08:38 +02:00
defer stmt.Close()
2019-05-03 09:15:16 +02:00
2019-05-06 07:43:15 +02:00
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
2019-05-11 09:01:24 +02:00
logOnError(err, "putUnprocessedMsg : exec insert obj_msg")
2019-05-03 09:15:16 +02:00
if err != nil {
2019-05-11 09:11:42 +02:00
err2 := tx.Rollback()
logOnError(err2, "putUnprocessedMsg : rollback exec insert obj")
2019-05-06 04:56:59 +02:00
return 0, err
2019-05-05 13:29:28 +02:00
}
2019-05-11 09:11:42 +02:00
err = tx.Commit()
logOnError(err, "putUnprocessedMsg : commit")
if err != nil {
return 0, err
}
2019-05-05 13:29:28 +02:00
return objId, nil
}
func getMsg(objId int64) (ChatWarsMessage, error) {
var m ChatWarsMessage
2019-05-09 12:36:45 +02:00
stmt, err := db.Prepare(`SELECT om.msg_id, om.chat_id, om.sender_user_id, om.date, om.text FROM obj_msg om WHERE om.obj_id = ?`)
2019-05-05 13:29:28 +02:00
if err != nil {
2019-05-06 04:56:59 +02:00
return m, err
2019-05-05 13:29:28 +02:00
}
defer stmt.Close()
2019-05-06 04:57:20 +02:00
err = stmt.QueryRow(objId).Scan(&m.ID64, &m.ChatID64, &m.SenderUserID64, &m.Date, &m.Text)
2019-05-05 13:29:28 +02:00
if err != nil {
2019-05-06 04:56:59 +02:00
return m, err
2019-05-03 09:15:16 +02:00
}
2019-05-03 13:24:32 +02:00
2019-05-05 13:29:28 +02:00
return m, nil
2019-05-03 09:15:16 +02:00
}
2019-05-06 12:43:42 +02:00
func getObjSubTypeId(objId int64) (int64, error) {
var objSubTypeId int64
2019-05-08 12:13:47 +02:00
2019-05-09 11:35:24 +02:00
stmt, err := db.Prepare(`SELECT o.obj_sub_type_id FROM obj o WHERE o.id = ?`)
2019-05-06 12:43:42 +02:00
if err != nil {
return 0, err
}
defer stmt.Close()
2019-05-09 11:43:36 +02:00
err = stmt.QueryRow(objId).Scan(&objSubTypeId)
2019-05-06 12:43:42 +02:00
if err != nil {
return 0, err
}
return objSubTypeId, nil
}
2019-05-11 07:41:05 +02:00
func setObjSubTypeId(objId int64, objSubTypeID64 int64) error {
2019-05-11 07:46:39 +02:00
stmt, err := db.Prepare(`UPDATE obj o SET o.obj_sub_type_id = ? WHERE o.id = ?;`)
2019-05-11 07:41:05 +02:00
logOnError(err, "setObjSubTypeId : prepare update")
if err != nil {
return err
}
defer stmt.Close()
2019-05-11 07:42:46 +02:00
_, err = stmt.Exec(objSubTypeID64, objId)
2019-05-11 07:41:05 +02:00
logOnError(err, "setObjSubTypeId : exec update")
return err
}
2019-05-08 17:18:17 +02:00
func insertMsgReport(objId int64, war_date int32, atk int32, def int32, exp int32, gold int32, stock int32, crit bool, stamina bool) error {
objSubTypeId, err := getObjSubTypeId(objId)
if err != nil {
return err
}
if objSubTypeId != objSubTypeMessageUnknown {
return errors.New("Message is not of type Unknown")
}
/*
obj_id BIGINT UNSIGNED NOT NULL
,war_date TIMESTAMP NOT NULL
,attack SMALLINT UNSIGNED NOT NULL
,defense SMALLINT UNSIGNED NOT NULL
,gold SMALLINT UNSIGNED NOT NULL
,stock MALLINT UNSIGNED NOT NULL
,exp SMALLINT UNSIGNED NOT NULL
,stamina TINYINT NOT NULL
,crit TINYINT NOT NULL
stmt, err := db.Prepare(`INSERT INTO obj_msg_report (obj_id, war_date, attack, defense, gold, stock, exp, stamina, crit)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?FROM_UNIXTIME(?), ?);`)
if err != nil {
return err
}
defer stmt.Close()
_, err = stmt.Exec(objId, m.ID64, m.ChatID64, m.UserID64, m.SenderUserID64, m.Date, m.Text)
if err != nil {
return err
}
*/
return nil
}
2019-05-09 11:19:02 +02:00
func insertMsgAuctionAnnounce(m *ChatWarsMessageAuctionAnnounce) error {
2019-05-11 07:42:46 +02:00
objSubTypeId, err := getObjSubTypeId(m.ObjID64)
2019-05-06 16:05:43 +02:00
if err != nil {
return err
}
2019-05-09 11:19:02 +02:00
if objSubTypeId != objSubTypeMessageUnknown && objSubTypeId != objSubTypeMessageAuctionAnnounce {
return errors.New("Message type mismatch")
2019-05-06 16:05:43 +02:00
}
2019-05-06 15:49:55 +02:00
2019-05-09 11:22:39 +02:00
stmt, err := db.Prepare(`INSERT INTO obj_msg_auction_announce (obj_id, lot_id, item, cond, quality, seller, buyer, price, status, end)
2019-05-09 12:36:45 +02:00
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?);`)
2019-05-09 11:19:02 +02:00
if err != nil {
return err
}
defer stmt.Close()
2019-05-06 15:49:55 +02:00
2019-05-11 07:41:05 +02:00
_, err = stmt.Exec(m.ObjID64, m.LotID, m.Item, m.Cond, m.Quality, m.Seller, m.Buyer, m.Price, m.Status, m.End)
2019-05-09 11:19:02 +02:00
if err != nil {
return err
}
2019-05-06 12:43:42 +02:00
return nil
}
2019-05-08 12:13:47 +02:00
2019-05-10 15:57:01 +02:00
func createJob(job_type_id int32, priority int32, schedule time.Time, payload []byte) error {
2019-05-10 16:03:19 +02:00
stmt, err := db.Prepare(`INSERT INTO obj (obj_type_id, obj_sub_type_id)
VALUES (? , ?);`)
logOnError(err, "createJob : prepare insert obj")
if err != nil {
return err
}
defer stmt.Close()
2019-05-10 16:03:47 +02:00
res, err := stmt.Exec(objTypeJob, job_type_id)
2019-05-10 16:14:28 +02:00
s := fmt.Sprintf("createJob, insert obj(%d, %d)", objTypeJob, job_type_id)
2019-05-10 16:12:46 +02:00
logOnError(err, s)
2019-05-10 15:57:01 +02:00
if err != nil {
return err
}
2019-05-10 13:33:29 +02:00
2019-05-10 15:57:01 +02:00
objId, err := res.LastInsertId()
logOnError(err, "createJob : get last insert Id")
if err != nil {
return err
}
2019-05-10 13:33:29 +02:00
2019-05-11 07:00:20 +02:00
stmt, err = db.Prepare(`INSERT INTO obj_job (obj_id, priority, status, schedule, is_done, in_work, inserted, pulled, started, ended, payload)
2019-05-11 06:58:40 +02:00
VALUES (?, ?, ?, ?, 0, 0, ?, NULL, NULL, NULL, ?);`)
2019-05-10 15:57:01 +02:00
logOnError(err, "createJob : prepare insert obj_job")
if err != nil {
return err
}
defer stmt.Close()
2019-05-10 13:33:29 +02:00
2019-05-11 06:54:12 +02:00
_, err = stmt.Exec(objId, priority, objJobStatusNew, schedule, time.Now(), payload)
2019-05-10 15:57:01 +02:00
logOnError(err, "createJob : insert obj_job")
if err != nil {
return err
}
2019-05-10 13:33:29 +02:00
return nil
}
2019-05-11 06:54:12 +02:00
func setJobDone(jobId int64) error {
stmt, err := db.Prepare(`UPDATE obj_job j SET j.is_done = 1, j.in_work = 0, j.ended = ? WHERE j.obj_id = ?;`)
logOnError(err, "setJobDone : prepare update obj_job")
if err != nil {
return err
}
defer stmt.Close()
2019-05-11 06:57:38 +02:00
_, err = stmt.Exec(time.Now(), jobId)
2019-05-11 06:54:12 +02:00
s := fmt.Sprintf("setJobDone, update obj_job(%d)", jobId)
logOnError(err, s)
if err != nil {
return err
}
return nil
}
func setJobStart(jobId int64) error {
2019-05-11 07:41:05 +02:00
stmt, err := db.Prepare(`UPDATE obj_job j SET j.started = ? WHERE j.obj_id = ?;`)
2019-05-11 06:54:12 +02:00
logOnError(err, "setJobStart : prepare update obj_job")
if err != nil {
return err
}
defer stmt.Close()
2019-05-11 06:57:38 +02:00
_, err = stmt.Exec(time.Now(), jobId)
2019-05-11 06:54:12 +02:00
s := fmt.Sprintf("setJobStart, update obj_job(%d)", jobId)
logOnError(err, s)
if err != nil {
return err
}
return nil
}
2019-05-08 13:12:30 +02:00
func loadMsgParsingRules() (m map[int]MessageParsingRule, err error) {
2019-05-08 12:13:47 +02:00
var (
id int32
priority int32
descn string
rule string
msgTypeID int32
)
2019-05-08 12:47:32 +02:00
log.Println("Loading message parsing rules...")
2019-05-08 13:12:30 +02:00
m = make(map[int]MessageParsingRule)
2019-05-08 12:13:47 +02:00
count := int(0)
2019-05-08 13:00:43 +02:00
defer func() {
if rec := recover(); rec != nil {
2019-05-08 13:16:38 +02:00
log.Println("Error parsing rules : ", rec)
2019-05-08 13:14:03 +02:00
err = errors.New("panic")
2019-05-08 13:00:43 +02:00
}
}()
2019-05-08 12:37:53 +02:00
rules, err := db.Query(`SELECT r.id, r.prio, r.descn, r.rule, r.msg_type_id FROM msg_rules r ORDER BY r.prio DESC;`)
2019-05-08 12:13:47 +02:00
if err != nil {
return m, err
}
defer rules.Close()
for rules.Next() {
2019-05-08 12:17:07 +02:00
err = rules.Scan(&id, &priority, &descn, &rule, &msgTypeID)
2019-05-08 12:13:47 +02:00
if err != nil {
return m, err
}
2019-05-08 12:17:07 +02:00
i := new(MessageParsingRule)
i.ID = id
i.Priority = priority
i.Description = descn
i.Rule = rule
i.MsgTypeID = msgTypeID
2019-05-08 13:13:19 +02:00
i.re = regexp.MustCompile(rule)
2019-05-08 12:17:07 +02:00
m[count] = *i
2019-05-08 13:24:12 +02:00
log.Printf("New rule : %s\n", rule)
2019-05-08 12:13:47 +02:00
count++
}
return m, nil
}
2019-05-10 11:23:47 +02:00
func loadCurrentJobs() ([]Job, error) {
var (
objId int64
jobTypeId int32
2019-05-11 06:54:12 +02:00
status int32
2019-05-10 11:23:47 +02:00
payload []byte
jobs []Job
)
tx, err := db.Begin()
logOnError(err, "loadCurrentJobs : begin transaction")
if err != nil {
2019-05-10 11:24:50 +02:00
return jobs, err
2019-05-10 11:23:47 +02:00
}
defer tx.Rollback()
2019-05-11 06:54:12 +02:00
stmt, err := tx.Prepare("SELECT o.id, o.obj_sub_type_id, j.status, j.payload FROM obj_job j, obj o WHERE j.obj_id = o.id AND j.is_done = 0 and j.in_work = 0 AND j.schedule <= ? ORDER BY j.priority ASC, j.obj_id ASC LIMIT ? FOR UPDATE;")
2019-05-10 11:23:47 +02:00
logOnError(err, "loadCurrentJobs : prepare select statement")
2019-05-11 06:54:12 +02:00
rows, err := stmt.Query(time.Now(), SQLJobSliceSize)
2019-05-10 11:23:47 +02:00
logOnError(err, "loadCurrentJobs : query select statement")
for rows.Next() {
2019-05-11 06:54:12 +02:00
err = rows.Scan(&objId, &jobTypeId, &status, &payload)
2019-05-10 11:23:47 +02:00
logOnError(err, "loadCurrentJobs : scan query rows")
job := Job{
ID64: objId,
JobTypeID: jobTypeId,
2019-05-11 06:54:12 +02:00
Status: status,
2019-05-10 11:24:50 +02:00
Payload: payload,
2019-05-10 11:23:47 +02:00
}
jobs = append(jobs, job)
}
err = rows.Err()
logOnError(err, "loadCurrentJobs : scan end rows")
rows.Close()
err = stmt.Close()
logOnError(err, "loadCurrentJobs : close select statement")
2019-05-11 06:54:12 +02:00
stmt, err = tx.Prepare("UPDATE obj_job j SET j.in_work = 1, j.pulled = ? WHERE j.obj_id = ?;")
2019-05-10 11:23:47 +02:00
logOnError(err, "loadCurrentJobs : prepare update statement")
for _, job := range jobs {
2019-05-11 06:54:12 +02:00
_, err = stmt.Exec(time.Now(), job.ID64)
2019-05-10 11:23:47 +02:00
logOnError(err, "loadCurrentJobs : updating row")
}
err = stmt.Close()
logOnError(err, "loadCurrentJobs : close update statement")
err = tx.Commit()
logOnError(err, "loadCurrentJobs : commit")
return jobs, nil
}
2019-05-11 06:54:12 +02:00
func getSQLListID64(q string) []int64 {
2019-05-11 06:56:48 +02:00
var (
id int64
ids []int64
)
2019-05-11 06:54:12 +02:00
rows, err := db.Query(q)
s := fmt.Sprintf("getSQLListID64 : Query(%s)", q)
logOnError(err, s)
for rows.Next() {
err = rows.Scan(&id)
logOnError(err, "getSQLListID64 : scan next val")
ids = append(ids, id)
}
err = rows.Err()
2019-05-11 06:56:58 +02:00
logOnError(err, "getSQLListID64 : query end")
2019-05-11 06:54:12 +02:00
rows.Close()
return ids
}