54 lines
1.5 KiB
Python
54 lines
1.5 KiB
Python
import asyncio
|
|
import uuid
|
|
import asyncpg
|
|
import sys
|
|
import os
|
|
|
|
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
|
|
|
from core.config import settings
|
|
|
|
async def main():
|
|
conn = await asyncpg.connect(settings.DATABASE_URL)
|
|
|
|
# Get user
|
|
user = await conn.fetchrow("SELECT id FROM characters ORDER BY created_at DESC LIMIT 1 OFFSET 0")
|
|
if not user:
|
|
print("No user found")
|
|
return
|
|
c_id = user['id']
|
|
print(f"Adding items to character {c_id}")
|
|
|
|
# Items: Greatsword, Full Plate, Kite Shield
|
|
items = [
|
|
{"item_id": "iron_greatsword", "base_durability": 100},
|
|
{"item_id": "steel_plate", "base_durability": 200},
|
|
{"item_id": "iron_kite_shield", "base_durability": 120}
|
|
]
|
|
|
|
for item in items:
|
|
# Create unique item
|
|
unique_id = str(uuid.uuid4())
|
|
await conn.execute(
|
|
"""
|
|
INSERT INTO unique_items (id, item_id, durability, max_durability)
|
|
VALUES ($1, $2, $3, $3)
|
|
""",
|
|
unique_id, item['item_id'], item['base_durability']
|
|
)
|
|
|
|
# Add to inventory
|
|
await conn.execute(
|
|
"""
|
|
INSERT INTO inventory_items (character_id, item_id, quantity, is_equipped, unique_item_id)
|
|
VALUES ($1, $2, 1, false, $3)
|
|
""",
|
|
c_id, item['item_id'], unique_id
|
|
)
|
|
print(f"Added {item['item_id']} ({unique_id}) to inventory.")
|
|
|
|
await conn.close()
|
|
|
|
if __name__ == "__main__":
|
|
asyncio.run(main())
|