python - Comparing values in lists from classes -
i looking create "top trumps"-style game gcse computer science class. have managed set superhero class, , created couple of superheroes (hulk , thor). want able pick attribute thor , automatically compare hulk , higher.
eventually have list of, say, 20 superheroes, split evenly 2 lists of lists. this, player's card should display them choose compare corresponding attribute in opponent's list (without being seen until chosen). winner remove superhero 1 list , place in another, until 1 list depleted.
i not know how lists of lists set , compare values once selected.
import random class superhero (object): """a class 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")
deck_of_cards = [thor, hulk, <etc>] player_1_cards = deck_of_cards [:len(deck_of_cards)/2] player_2_cards = deck_of_cards [len(deck_of_cards)/2:]
something that. want shuffle deck first this, shuffling list of objects in python
Comments
Post a Comment