diff --git a/.idea/workspace.xml b/.idea/workspace.xml index 33d6174..9f32f70 100644 --- a/.idea/workspace.xml +++ b/.idea/workspace.xml @@ -5,10 +5,8 @@ - - + - - + + + + + @@ -108,6 +129,7 @@ + @@ -117,5 +139,6 @@ + \ No newline at end of file diff --git a/ha_05/loosen_janniclas_1540907_06.py b/ha_05/loosen_janniclas_1540907_06.py new file mode 100644 index 0000000..4e8b8fd --- /dev/null +++ b/ha_05/loosen_janniclas_1540907_06.py @@ -0,0 +1,100 @@ +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)