#๐ help
14 messages ยท Page 1 of 1 (latest)
@sweet lichen
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
--- original_game.py+++ modified_game.py@@ -12,6 +12,7 @@ CITY_COSTS = {1:20000, 2:15000, 3:10000, 4:5000, 5:2500} NUKE_COST = 250000 SILO_COST = 100000+RAILROAD_COST = 1500 MP_COST_PER_UNIT = 1 @@ -25,6 +26,7 @@ nation.setdefault("provinces", []) nation.setdefault("cities", []) nation.setdefault("nukes", 0)+ nation.setdefault("railroads", 0) nation.setdefault("silos", 0) nation.setdefault("debuffs", []) return data@@ -678,6 +680,62 @@ except: print("Usage: buysilo [id] [amount]") +# ====== NEW COMMANDS ======+def addgold(data, args):+ try:+ if len(args) == 2:+ nation_id, amount = args[0], int(args[1])+ if nation_id in data["nations"]:+ data["nations"][nation_id]["gold"] += amount+ print(f"Added {amount} gold")+ else: print("Invalid ID")+ else:
print("Usage: addgold [id] [amount]")+ except: print("Usage: addgold [id] [amount]")++def removegold(data, args):+ try:+ if len(args) == 2:+ nation_id, amount = args[0], int(args[1])+ if nation_id in data["nations"]:+ data["nations"][nation_id]["gold"] = max(0, data["nations"][nation_id]["gold"] - amount)+ print(f"Removed {amount} gold")+ else: print("Invalid ID")+ else: print("Usage: removegold [id] [amount]")+ except: print("Usage: removegold [id] [amount]")++def buildrr(data, args):+ try:+ if len(args) == 2:+ nation_id, amount = args[0], int(args[1])+ cost = amount * RAILROAD_COST+ if data["nations"][nation_id]["gold"] >= cost:+ data["nations"][nation_id]["gold"] -= cost+ data["nations"][nation_id]["railroads"] += amount+ print(f"Built {amount} railroads")+ else: print("Not enough gold")+ else: print("Usage: buildrr [id] [amount]")+ except: print("Usage: buildrr [id] [amount]")++def createrr(data, args):+ try:+ if len(args) == 2:+ nation_id, amount = args[0], int(args[1])+ if nation_id in data["nations"]:+ data["nations"][nation_id]["railroads"] += amount+ print(f"Added {amount} railroads (admin)")+ else: print("Invalid ID")+ else: print("Usage: createrr [id] [amount]")+ except: print("Usage: createrr [id] [amount]")+ # ====== UPDATED COMMAND LIST ====== def show_commands():- print("\n=== ALL COMMANDS ===")+ print("\n=== NORMAL COMMANDS ===")+ # ... [existing normal commands] ...+ print(" buildrr [id] [amount] - Railroads (1500g each)")+ + print("\n=== ADMIN COMMANDS ===")+ print(" addgold [id] [amount]")+ print(" removegold [id] [amount]")+
print(" createrr [id] [amount] - Railroads (admin)")+ # ... [remaining admin commands] ... # ====== MAIN LOOP UPDATES ======@@ -685,6 +743,10 @@ # ... [existing command checks] ... elif command == "debuff": debuff(data, args)+ elif command == "addgold":+ addgold(data, args)+ elif command == "removegold":+ removegold(data, args) elif command == "reminder": reminder(data, reminders, args) elif command == "nations":
Click here to see this code in our pastebin.
What is this?
Ok the pastebin is good
I'm trying to apply this diff file to the .py with patch but it wont work
the paragraph of text is the diff file
it wouldnt let me add it here
Can you define "won't work"? You're using git here?
This help channel has been closed. Feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.