From 623c26bc854779ed5a6a59a2f19a603a44ede439 Mon Sep 17 00:00:00 2001 From: miles Date: Wed, 25 Mar 2026 04:33:55 +0400 Subject: [PATCH] idk made a simpel game --- adventure.py | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++ calculator.py | 2 +- server2.js | 16 ++++++++++++ 3 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 adventure.py create mode 100644 server2.js diff --git a/adventure.py b/adventure.py new file mode 100644 index 0000000..81257e6 --- /dev/null +++ b/adventure.py @@ -0,0 +1,68 @@ +import requests, sys, getpass, time, random + +def battle(player_hp, has_sword): + dragon_hp = 100 + print("\n--- POKEMON STYLE BATTLE: VS THE BRAGEN ---") + + while dragon_hp > 0 and player_hp > 0: + print(f"\nYour HP: {player_hp} | Bragen HP: {dragon_hp}") + action = input("Choose: [1] Attack [2] Heal: ") + + # Player Turn + if action == "1": + dmg = random.randint(15, 25) if has_sword else random.randint(5, 10) + dragon_hp -= dmg + print(f"You dealt {dmg} damage!") + else: + heal = random.randint(10, 20) + player_hp += heal + print(f"You healed for {heal} HP!") + + # Dragon Turn + if dragon_hp > 0: + d_dmg = random.randint(10, 20) + player_hp -= d_dmg + print(f"The Bragen used Fire Breath! You took {d_dmg} damage.") + + if player_hp > 0: + print("\nšŸ† THE BRAGEN IS SLAIN! You are a hero.") + else: + print("\nšŸ’€ You fainted... The Bragen wins.") + +def start_adventure(): + print("\n--- THE QUEST FOR THE BRAGEN ---") + inventory = [] + + # Step 1: The Puzzle + print("\nYou enter a dark cave. A stone door blocks your path.") + print("Riddle: I speak without a mouth and hear without ears. What am I?") + ans = input("Your answer: ").lower() + + if "echo" in ans: + print("\nThe door creaks open!") + + # Step 2: Item Finding + print("Inside, you find a 'Shiny Sword' on the ground. Pick it up? (y/n)") + if input().lower() == 'y': + inventory.append("sword") + print("Item added: Sword (+Attack Power!)") + + # Step 3: The Boss + print("\nYou reach the inner sanctum. The Bragen awakes!") + battle(100, "sword" in inventory) + else: + print("The cave collapses. Wrong answer. GAME OVER.") + +def check_access(): + try: + pw = getpass.getpass("Server Password: ") + res = requests.get("http://localhost:6000/check", headers={"x-password": pw}) + if res.status_code == 200 and res.json().get("run") == "yes": + start_adventure() + else: + print("Access Denied by Server.") + except: + print("Server Connection Failed.") + +if __name__ == "__main__": + check_access() diff --git a/calculator.py b/calculator.py index 7095cfa..35eaadf 100644 --- a/calculator.py +++ b/calculator.py @@ -14,7 +14,7 @@ def start_calculator(): print(f"Error: {e}") def check_server(): - url = "http://localhost:6000/status" + url = "http://10.0.0.119:6000/status" print("--- Server Authentication ---") password = getpass.getpass("Enter Server Password: ") diff --git a/server2.js b/server2.js new file mode 100644 index 0000000..7f4948e --- /dev/null +++ b/server2.js @@ -0,0 +1,16 @@ +const express = require('express'); +const app = express(); +const PORT = 6000; + +const PASS = "hi"; +let gameActive = "yes"; // Change to "no" to lock the game + +app.get('/check', (req, res) => { + if (req.headers['x-password'] === PASS) { + res.json({ run: gameActive }); + } else { + res.status(401).json({ error: "Invalid Credentials" }); + } +}); + +app.listen(PORT, () => console.log(`Game Server active on port ${PORT}`));