# Purpose: Summoner Wars Dice Roller
# %------------------------------------------ Packages -------------------------------------------% #
importrandom# %------------------------------------------ Classes ------------------------------------------% #
classSummonerWars():def__init__(self)->None:"""
* Summoner Wars Dice Faces:
M = Melee | R = Range | S = Lightning
(M, R, S) = (bool, bool, bool)
1) MR : (True, True, False)
2) MR : (True, True, False)
3) MR : (True, True, False)
4) MS : (True, False, True)
5) RS : (False, True, True)
6) M : (True, False, False)
"""self.dice_symbol_map={(True,True,False):"🗡️ | 🏹",(True,False,True):"🗡️ | ⚡",(False,True,True):"🏹 | ⚡",(True,False,False):"🗡️"}self.dice_faces=[(True,True,False),(True,True,False),(True,True,False),(True,False,True),(False,True,True),(True,False,False)]self.game_stats={'M':0,'R':0,'S':0}# Purpose: Roll n dice and return the results
defplay(self):whileTrue:# Get user input
user_input=input("Enter the number of dice to roll (or 'q' to quit): ")# Check if the user wants to quit
ifuser_input.lower()=='q':print("Game over!")break# Check if the user wants to quit
n=int(user_input)ifn<1:print("Please enter a positive integer.")continue# Roll the dice
result=self.roll_n_dice(n)SummonerWars.print_result(result)# Print the final game stats
print(f'{"Final Game Stats":-^{50}}')SummonerWars.print_result(self.game_stats)# Purpose: Roll n dice
defroll_n_dice(self,n):result={'M':0,'R':0,'S':0}for_inrange(n):face=random.choice(self.dice_faces)print(f" - {self.dice_symbol_map.get(face,'❓')}")ifface[0]:result['M']+=1self.game_stats['M']+=1ifface[1]:result['R']+=1self.game_stats['R']+=1ifface[2]:result['S']+=1self.game_stats['S']+=1returnresult@staticmethoddefprint_result(result):print(f"Total Melee: {result['M']},\nTotal Range: {result['R']},\nTotal Lightning: {result['S']}\n")# %-------------------------------------------- Main ---------------------------------------------% #
defmain():game=SummonerWars()game.play()# %--------------------------------------------- Run ---------------------------------------------% #
if__name__=='__main__':print(f'{"Start":-^{50}}')main()print(f'{"End":-^{50}}')