mirror of
https://github.com/Lyxminxx/binarian.git
synced 2026-10-11 12:51:48 +02:00
Finished the two main gamemodes and added a menu system
This commit is contained in:
1 parent
767d49b6be
commit
a69b711289
6 files changed
+189
-32
No files matched your search
+2
-1
@@ -1,2 +1,3 @@
|
||||
__pychace__
|
||||
*.pyc
|
||||
*.pyc
|
||||
.venv
|
||||
+12
-1
@@ -1,7 +1,6 @@
|
||||
from alphabet import alphabet
|
||||
from os import system, name
|
||||
|
||||
|
||||
def binarian(word):
|
||||
wordBin = ""
|
||||
word = word.lower()
|
||||
@@ -14,6 +13,18 @@ def binarian(word):
|
||||
wordBin += letter
|
||||
return wordBin
|
||||
|
||||
import re
|
||||
|
||||
def unbinarian(encoded_text):
|
||||
from alphabet import alphabet
|
||||
|
||||
reverse_alphabet = {v: k for k, v in alphabet.items()}
|
||||
|
||||
decoded = re.sub(r"\(\d{5}\)", lambda m: reverse_alphabet.get(m.group(), m.group()), encoded_text)
|
||||
|
||||
return decoded
|
||||
|
||||
|
||||
def clear():
|
||||
|
||||
# for windows
|
||||
|
||||
+17
-6
@@ -5,10 +5,7 @@ from functions import binarian
|
||||
from functions import clear
|
||||
|
||||
def norToBin(level):
|
||||
wordsInLevel = []
|
||||
for word, word_level in words.items():
|
||||
if word_level == level:
|
||||
wordsInLevel.append(word)
|
||||
wordsInLevel = words[level].copy()
|
||||
word = random.choice(wordsInLevel)
|
||||
correctTranslation = binarian(word)
|
||||
|
||||
@@ -18,6 +15,20 @@ def norToBin(level):
|
||||
if userIn == correctTranslation:
|
||||
print(f'Yes the word {word} does translate to {userIn}!')
|
||||
else:
|
||||
print(f'No, the word {word} translates to {correctTranslation}. Better study some more!')
|
||||
print(f'No, the word {word} translates to {correctTranslation}, not {userIn}. Better study some more!')
|
||||
input("Hit ENTER to continue")
|
||||
|
||||
norToBin(2)
|
||||
def binToNor(level):
|
||||
wordsInLevel = words[level].copy()
|
||||
word = random.choice(wordsInLevel)
|
||||
correctTranslation = word
|
||||
word = binarian(word)
|
||||
|
||||
print(f'Translate {word} into english!')
|
||||
userIn = input("Write anwser\n>")
|
||||
clear()
|
||||
if userIn == correctTranslation:
|
||||
print(f'Yes the word {word} does translate to {userIn}!')
|
||||
else:
|
||||
print(f'No, the word {word} translates to {correctTranslation}, not {userIn}. Better study some more!')
|
||||
input("Hit ENTER to continue")
|
||||
@@ -1,4 +1,40 @@
|
||||
from functions import binarian
|
||||
from alphabet import alphabet
|
||||
from functions import unbinarian
|
||||
from submenus import entoBin
|
||||
from submenus import binToEn
|
||||
from functions import clear
|
||||
import readchar
|
||||
|
||||
print(binarian("I am making duolingo for binary"))
|
||||
def main_menu():
|
||||
options = ["Translate from English to Binarian", "Translate from Binarian to English", "Exit"]
|
||||
selected = 0
|
||||
|
||||
while True:
|
||||
clear()
|
||||
print("Use arrow keys to navigate and Enter to select:\n")
|
||||
|
||||
for i, option in enumerate(options):
|
||||
prefix = "> " if i == selected else " "
|
||||
print(f"{prefix}{option}")
|
||||
|
||||
key = readchar.readkey()
|
||||
|
||||
if key == readchar.key.UP and selected > 0:
|
||||
selected -= 1
|
||||
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||
selected += 1
|
||||
elif key == readchar.key.ENTER:
|
||||
if options[selected] == "Exit":
|
||||
print("Exiting...")
|
||||
clear()
|
||||
break
|
||||
elif options[selected] == "Translate from English to Binarian":
|
||||
entoBin()
|
||||
elif option[selected == "Translate from Binarian to English"]:
|
||||
binToEn()
|
||||
else:
|
||||
print(f"Selected: {options[selected]}")
|
||||
input("Press Enter to return to menu...")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main_menu()
|
||||
+85
@@ -0,0 +1,85 @@
|
||||
import readchar
|
||||
from gamemodes import norToBin
|
||||
from gamemodes import binToNor
|
||||
from functions import clear
|
||||
def entoBin():
|
||||
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"]
|
||||
selected = 0
|
||||
|
||||
while True:
|
||||
clear()
|
||||
print("Select a level to start translating!")
|
||||
print("Use arrow keys to navigate and Enter to select:\n")
|
||||
|
||||
for i, option in enumerate(options):
|
||||
prefix = "> " if i == selected else " "
|
||||
print(f"{prefix}{option}")
|
||||
|
||||
key = readchar.readkey()
|
||||
|
||||
if key == readchar.key.UP and selected > 0:
|
||||
selected -= 1
|
||||
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||
selected += 1
|
||||
elif key == readchar.key.ENTER:
|
||||
if options[selected] == "Level 1":
|
||||
clear()
|
||||
norToBin(1)
|
||||
elif options[selected] == "Level 2":
|
||||
clear()
|
||||
norToBin(2)
|
||||
elif options[selected] == "Level 3":
|
||||
clear()
|
||||
norToBin(3)
|
||||
elif options[selected] == "Level 4":
|
||||
clear()
|
||||
norToBin(4)
|
||||
elif options[selected] == "Level 5":
|
||||
clear()
|
||||
norToBin(5)
|
||||
elif options[selected] == "Back to main menu":
|
||||
print("Exiting...")
|
||||
break
|
||||
else:
|
||||
print(f"Selected: {options[selected]}")
|
||||
|
||||
def binToEn():
|
||||
options = ["Level 1", "Level 2", "Level 3","Level 4", "Level 5" , "Back to main menu"]
|
||||
selected = 0
|
||||
|
||||
while True:
|
||||
clear()
|
||||
print("Select a level to start translating!")
|
||||
print("Use arrow keys to navigate and Enter to select:\n")
|
||||
|
||||
for i, option in enumerate(options):
|
||||
prefix = "> " if i == selected else " "
|
||||
print(f"{prefix}{option}")
|
||||
|
||||
key = readchar.readkey()
|
||||
|
||||
if key == readchar.key.UP and selected > 0:
|
||||
selected -= 1
|
||||
elif key == readchar.key.DOWN and selected < len(options) - 1:
|
||||
selected += 1
|
||||
elif key == readchar.key.ENTER:
|
||||
if options[selected] == "Level 1":
|
||||
clear()
|
||||
binToNor(1)
|
||||
elif options[selected] == "Level 2":
|
||||
clear()
|
||||
binToNor(2)
|
||||
elif options[selected] == "Level 3":
|
||||
clear()
|
||||
binToNor(3)
|
||||
elif options[selected] == "Level 4":
|
||||
clear()
|
||||
binToNor(4)
|
||||
elif options[selected] == "Level 5":
|
||||
clear()
|
||||
binToNor(5)
|
||||
elif options[selected] == "Back to main menu":
|
||||
print("Exiting...")
|
||||
break
|
||||
else:
|
||||
print(f"Selected: {options[selected]}")
|
||||
+35
-22
@@ -1,24 +1,37 @@
|
||||
words = {
|
||||
"cat": 1,
|
||||
"dog": 1,
|
||||
"fish": 1,
|
||||
"apple": 1,
|
||||
"ball": 1,
|
||||
"house": 2,
|
||||
"school": 2,
|
||||
"tree": 2,
|
||||
"friend": 2,
|
||||
"computer": 3,
|
||||
"programming": 3,
|
||||
"language": 3,
|
||||
"chicken": 3,
|
||||
"celebrate": 4,
|
||||
"dinosaur": 4,
|
||||
"philosophy": 4,
|
||||
"challenge": 4,
|
||||
"understanding": 5,
|
||||
"universe": 5,
|
||||
"consciousness": 5,
|
||||
"mathematics": 5,
|
||||
"microprocessor": 5
|
||||
1: [
|
||||
"aa", "add", "all", "ass", "bell", "book", "boss", "call", "cell", "cool",
|
||||
"deed", "door", "doll", "egg", "fall", "feed", "fool", "good", "hall", "hill",
|
||||
"jazz", "kiss", "lass", "look", "mall", "mess", "mood", "moon", "pass", "pool",
|
||||
"quiz", "reed", "root", "seed", "sell", "soon", "tall", "tool", "wall", "wood",
|
||||
"yell", "zoom", "beer", "boil", "bull", "cull", "dull", "fell", "gull", "will"
|
||||
],
|
||||
2: [
|
||||
"apple", "badge", "beast", "brass", "bread", "bribe", "broom", "cabin", "camel", "candy",
|
||||
"cello", "chalk", "charm", "chess", "clerk", "cloak", "clown", "crash", "demon", "drain",
|
||||
"drink", "dwarf", "eagle", "earth", "fable", "flame", "frost", "glove", "grand", "grape",
|
||||
"haunt", "hotel", "hover", "image", "jelly", "juice", "latch", "lemon", "magic", "mango",
|
||||
"merry", "music", "ocean", "onion", "penny", "plaza", "rider", "robot", "shadow", "spine"
|
||||
],
|
||||
3: [
|
||||
"ankle", "arise", "arrow", "baker", "basil", "beech", "bison", "blaze", "bloom", "brittle",
|
||||
"bubble", "cactus", "canvas", "carrot", "cedar", "cherry", "circle", "coral", "cotton", "dancer",
|
||||
"detour", "donkey", "dragon", "drawer", "eclair", "elixir", "fencer", "fiddle", "frozen", "guitar",
|
||||
"hazard", "helmet", "insect", "island", "jigsaw", "ladder", "lawyer", "legend", "marble", "mirror",
|
||||
"needle", "nickel", "orchid", "pencil", "pirate", "planet", "prince", "puzzle", "rescue", "rocket"
|
||||
],
|
||||
4: [
|
||||
"abstract", "alchemy", "bachelor", "blueprint", "brisket", "cascade", "chopper", "clarity", "compass", "complex",
|
||||
"cosmos", "crystal", "dolphin", "emerald", "fathom", "feather", "flamingo", "furnace", "gazelle", "gorilla",
|
||||
"harpoon", "horizon", "iceberg", "incisor", "jasmine", "juggler", "kangaroo", "lantern", "lobster", "luminous",
|
||||
"meadow", "midnight", "nebula", "nomadic", "obelisk", "octagon", "paradox", "parrot", "phoenix", "pioneer",
|
||||
"porcupine", "quasar", "radiant", "rhapsody", "sapphire", "satchel", "sheriff", "spectrum", "tempest", "vortex"
|
||||
],
|
||||
5: [
|
||||
"abundance", "adventure", "arithmetic", "blacksmith", "butterfly", "catastrophe", "chandelier", "chromatic", "conductor", "constellation",
|
||||
"delirious", "dynamism", "elaborate", "electricity", "ephemeral", "excursion", "firebrand", "fossilized", "geography", "handcrafted",
|
||||
"illuminate", "inevitable", "jeopardize", "journalist", "labyrinth", "magnificent", "metaphor", "momentous", "nightshade", "noteworthy",
|
||||
"opportunity", "philosophy", "quintuplet", "resilience", "silhouette", "sophisticated", "subterranean", "symmetry", "tapestries", "thunderbolt",
|
||||
"trapezoidal", "translucent", "ubiquitous", "vulnerability", "wanderlust", "whimsical", "wilderness", "xylophone", "zephyr", "zoological"
|
||||
]
|
||||
}
|
||||
Reference in new issue
Block a user