agoara update
This commit is contained in:
43
db.py
43
db.py
@@ -85,6 +85,7 @@ def init_db():
|
||||
CREATE TABLE IF NOT EXISTS bot_logs (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
player_id TEXT NOT NULL,
|
||||
world_id TEXT NOT NULL DEFAULT '',
|
||||
feature TEXT NOT NULL, -- 'bootcamp' | 'rural_trade'
|
||||
message TEXT NOT NULL,
|
||||
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
||||
@@ -92,6 +93,46 @@ def init_db():
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_bot_logs_player_feature ON bot_logs(player_id, feature)')
|
||||
|
||||
# Celebrations — active celebration state per town, pushed by the bot
|
||||
# One row per town_id + celebration_type. Upserted on every state push.
|
||||
# finished_at = 0 means no active celebration of that type.
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS celebrations (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
player_id TEXT NOT NULL,
|
||||
world_id TEXT NOT NULL,
|
||||
town_id TEXT NOT NULL,
|
||||
town_name TEXT,
|
||||
celebration_type TEXT NOT NULL, -- 'party' | 'triumph'
|
||||
finished_at INTEGER NOT NULL DEFAULT 0, -- unix timestamp (0 = not running)
|
||||
updated_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
UNIQUE(player_id, world_id, town_id, celebration_type)
|
||||
)
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_celebrations_player_world ON celebrations(player_id, world_id)')
|
||||
|
||||
# Culture log — immutable audit log of every Αγορά command fired from the dashboard
|
||||
# Records what was fired, what it cost, and whether the bot confirmed success.
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS culture_log (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
player_id TEXT NOT NULL,
|
||||
world_id TEXT NOT NULL,
|
||||
town_id TEXT NOT NULL,
|
||||
town_name TEXT,
|
||||
celebration_type TEXT NOT NULL, -- 'party' | 'triumph'
|
||||
cost_wood INTEGER NOT NULL DEFAULT 0,
|
||||
cost_stone INTEGER NOT NULL DEFAULT 0,
|
||||
cost_iron INTEGER NOT NULL DEFAULT 0,
|
||||
cost_battle_pts INTEGER NOT NULL DEFAULT 0,
|
||||
status TEXT NOT NULL DEFAULT 'pending', -- pending | success | failed
|
||||
result_msg TEXT,
|
||||
fired_at TEXT NOT NULL DEFAULT (datetime('now')),
|
||||
confirmed_at TEXT
|
||||
)
|
||||
''')
|
||||
c.execute('CREATE INDEX IF NOT EXISTS idx_culture_log_player_world ON culture_log(player_id, world_id)')
|
||||
|
||||
# Blueprints - assigns a blueprint to a specific town
|
||||
c.execute('''
|
||||
CREATE TABLE IF NOT EXISTS town_blueprints (
|
||||
@@ -184,6 +225,8 @@ def init_db():
|
||||
"ALTER TABLE clan_members ADD COLUMN features TEXT NOT NULL DEFAULT 'farm,admin'",
|
||||
'ALTER TABLE clan_members ADD COLUMN world_id TEXT',
|
||||
'ALTER TABLE users ADD COLUMN clan_id INTEGER REFERENCES clans(id)',
|
||||
# bot_logs gained world_id for per-world isolation
|
||||
"ALTER TABLE bot_logs ADD COLUMN world_id TEXT NOT NULL DEFAULT ''",
|
||||
]:
|
||||
try:
|
||||
c.execute(_col)
|
||||
|
||||
Reference in New Issue
Block a user