"""Seed a *copy* of a world with rows whose values stress a serialiser:
unicode, emoji, a lone surrogate, quotes, backslashes, newlines, tabs,
control characters, floats (fractional, huge, negative zero), NULLs.
Usage: python research/hesper/turn-cost/seed_awkward.py /tmp/prof.db
"""
import sqlite3
import sys

c = sqlite3.connect(sys.argv[1])
c.execute("PRAGMA foreign_keys=OFF")
bio = "line one\nline \"two\" \\ back\ttab \x01ctrl ünïcödé 日本 \U0001F332"   # a lone surrogate cannot be stored: sqlite3 refuses it
c.execute(
    "INSERT INTO players(player_id,name,kind,model,bio,created_at,coins,reputation,ap_budget,status)"
    " VALUES (?,?,?,?,?,?,?,?,?,?)",
    ("p_unicode", "Ásh \U0001F332", "agent", "x", bio, 1.5, 3, 2.5, 10, "active"))
c.execute(
    "INSERT INTO players(player_id,name,kind,model,bio,created_at,coins,reputation,ap_budget,status)"
    " VALUES (?,?,?,?,?,?,?,?,?,?)",
    ("p_float", "Fl", "human", None, None, 1e308, 0, -0.0, 10, "active"))
c.execute(
    "INSERT INTO things(thing_id,sheet_id,owner_player,x,y,fixed,props_json,state_json,"
    "durability,move_points,created_turn) VALUES (?,?,?,?,?,?,?,?,?,?,?)",
    ("t1", "settler", "p_unicode", 5, 6, 0, '{"a":1}', '{"n":"é"}', 7.25, 4, 1))
c.execute("INSERT INTO inventories(holder_kind,holder_id,item,qty) VALUES ('thing','t1','wood',3)")
c.commit()
print("players", c.execute("select count(*) from players").fetchone()[0],
      "things", c.execute("select count(*) from things").fetchone()[0])
