101 lines
2.7 KiB
Python
101 lines
2.7 KiB
Python
import random
|
|
|
|
|
|
class CeaserChiffre:
|
|
chiffre = {}
|
|
|
|
def __init__(self, chiffre=None):
|
|
if chiffre is not None:
|
|
self.chiffre = chiffre
|
|
else:
|
|
self._create_chiffre()
|
|
|
|
def __str__(self):
|
|
return str(self.chiffre)
|
|
|
|
def _create_chiffre(self):
|
|
codes = {}
|
|
chars = list(range(0, 255))
|
|
for char in range(0, 255):
|
|
rand = random.choice(chars)
|
|
chars.remove(rand)
|
|
codes[chr(char)] = chr(rand)
|
|
self.chiffre = codes
|
|
|
|
def encode(self, text):
|
|
return self._work(text, self.chiffre)
|
|
|
|
def decode(self, text):
|
|
chiffre = {value: key for key, value in self.chiffre.items()}
|
|
return self._work(text, chiffre)
|
|
|
|
def _work(self, text, chiffre):
|
|
result = []
|
|
for i in range(len(text)):
|
|
if text[i] in chiffre:
|
|
result.append(chiffre[text[i]])
|
|
else:
|
|
result.append(text[i])
|
|
return ''.join(result)
|
|
|
|
|
|
class Game:
|
|
scores = {"player": 0, "bot": 0}
|
|
choices = {}
|
|
mode = "easy"
|
|
|
|
def __init__(self, rules, mode="easy"):
|
|
self.rules = rules
|
|
self.choices = {key: 0 for key in self.rules}
|
|
self.mode = mode
|
|
|
|
def reset(self):
|
|
self.scores["player"] = 0
|
|
self.scores["player"] = 0
|
|
|
|
def play(self, players_choice):
|
|
if players_choice not in self.rules:
|
|
raise ValueError("Invalid choice. Please choose from: " + ', '.join(self.rules.keys()))
|
|
|
|
def _god(self, players_choice):
|
|
for choice in self.rules:
|
|
|
|
|
|
def _easy(self, choice):
|
|
|
|
def _hard(self, choice):
|
|
|
|
|
|
text = '''
|
|
Liebe/r Empfänger,
|
|
|
|
Herzliche Grüße aus dem hohen Norden! Ich hoffe, diese Nachricht erreicht dich in guter Verfassung und fügt einen Hauch
|
|
von festlicher Stimmung zu deinem Tag hinzu.
|
|
|
|
Ich wünsche dir Freude, Gelächter und einen festlichen Geist, der dein Herz erwärmt. Genieße die Magie der Feiertage!
|
|
|
|
Herzliche Grüße,
|
|
Rudolph
|
|
'''
|
|
|
|
# ceaser = CeaserChiffre()
|
|
# print(ceaser.decode(ceaser.encode(text)))
|
|
|
|
rock_paper_scissor = {
|
|
"rock": {"rock": 0, "paper": -1, "scissor": 1},
|
|
"paper": {"rock": 1, "paper": 0, "scissor": -1},
|
|
"scissor": {"rock": -1, "paper": 1, "scissor": 0}
|
|
|
|
}
|
|
|
|
rock_paper_scissor_lizard_spock = {
|
|
"rock": {"rock": 0, "paper": -1, "scissor": 1, "lizard": 1, "spock": -1},
|
|
"paper": {"rock": 1, "paper": 0, "scissor": -1, "lizard": -1, "spock": 1},
|
|
"scissor": {"rock": -1, "paper": 1, "scissor": 0, "lizard": 1, "spock": -1},
|
|
"lizard": {"rock": -1, "paper": 1, "scissor": -1, "lizard": 0, "spock": 1},
|
|
"spock": {"rock": 1, "paper": -1, "scissor": 1, "lizard": -1, "spock": 0}
|
|
}
|
|
|
|
game = Game(rock_paper_scissor)
|
|
print(game.choices)
|