I am looking to create a "Top Trumps"-style game with my GCSE Computer Science class. I have managed to set up a superhero class, and then created a couple of superheroes from that (Hulk and Thor). I want to be able to pick an attribute from Thor and automatically compare it to Hulk and say which is higher.
Eventually I would like to have a list of, say, 20 superheroes, which are split evenly into 2 lists of lists. From this, the player's card should display for them to choose from then it will compare it to the corresponding attribute in the opponent's list (without it being seen until chosen). The winner will then remove the superhero from one list and place it in another, until one list is depleted.
I just do not know how to get the lists of lists set up and compare the values once selected.
import random
class Superhero (object):
"""A class that makes super hereos."""
def __init__(self, name, beastrating, power, intelligence, specialpower, fightingskills, speed):
self.name = name
self.beastrating = beastrating
self.power = power
self.intelligence = intelligence
self.specialpower = specialpower
self.fightingskills = fightingskills
self.speed = speed
def displaySuperhero(self):
print ("\nName: ", self.name, "\nBeastrating: ", self.beastrating, "\nPower: ", self.power, "\nIntelligence: ", self.intelligence, "\nSpecial Power: ", self.specialpower, "\nFighting Skills: ", self.fightingskills, "\nSpeed: ",self.speed)
Hulk = Superhero("Hulk", 10, 10, 1, 1, 7, 10)
Thor = Superhero("Thor", 1, 8, 8, 7, 8, 9)
Thor.displaySuperhero()
Hulk.displaySuperhero()
print("\n")