auto trade and auto bandit

This commit is contained in:
2026-05-01 01:54:09 +03:00
parent 2a73e46a7b
commit 2921dff257
6 changed files with 630 additions and 7 deletions

24
db.py
View File

@@ -68,6 +68,30 @@ def init_db():
)
''')
# Bot settings — per-player config for bootcamp & rural-trade auto-loops
c.execute('''
CREATE TABLE IF NOT EXISTS bot_settings (
player_id TEXT PRIMARY KEY,
bootcamp_enabled INTEGER NOT NULL DEFAULT 0,
bootcamp_use_def INTEGER NOT NULL DEFAULT 0,
rural_trade_enabled INTEGER NOT NULL DEFAULT 0,
rural_trade_ratio INTEGER NOT NULL DEFAULT 3, -- 1=0.25 2=0.5 3=0.75 4=1.0 5=1.25
updated_at TEXT NOT NULL DEFAULT (datetime('now'))
)
''')
# Bot logs — ring buffer of last 50 entries per player per feature
c.execute('''
CREATE TABLE IF NOT EXISTS bot_logs (
id INTEGER PRIMARY KEY AUTOINCREMENT,
player_id TEXT NOT NULL,
feature TEXT NOT NULL, -- 'bootcamp' | 'rural_trade'
message TEXT NOT NULL,
created_at TEXT NOT NULL DEFAULT (datetime('now'))
)
''')
c.execute('CREATE INDEX IF NOT EXISTS idx_bot_logs_player_feature ON bot_logs(player_id, feature)')
# Migration: add new columns if upgrading an existing database
for _col in [
'ALTER TABLE town_state ADD COLUMN player_id TEXT',