Pre-menu-integration snapshot: combat, crafting, status effects, gamedata updates
This commit is contained in:
53
api/give_gear.py
Normal file
53
api/give_gear.py
Normal file
@@ -0,0 +1,53 @@
|
||||
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())
|
||||
Reference in New Issue
Block a user