+1 oy
Python kategorisinde (300 puan) tarafından soruldu
class Hero():
   def __init__(self, gender, race, strength, dexterity, constitution, \
				   intelligence, wisdom, charisma, alignment, BestWeapon):
  	   self.gender = gender
  	   self.race = race
  	   self.strength = strength
  	   self.dexterity = dexterity
  	   self.constitution = constitution
  	   self.intelligence = intelligence
  	   self.wisdom = wisdom
  	   self.charisma = charisma
  	   self.alignment = alignment
  	   self.BestWeapon = BestWeapon

class Fighter(Hero):
   pass

class Wizard(Hero):
   pass

class Sorcerer(Hero):
   pass

class Cleric(Hero):
   pass

class Druid(Hero):
   pass

class Rogue(Hero):
   pass

class Bard(Hero):
   pass

class Barbarian(Hero):
   pass

class Monk(Hero):
   pass

class Paladin(Hero):
   pass

class Ranger(Hero):
   pass

def ShowStats(PlayerClass):
       
   if PlayerClass == "fighter":
       print("Class: Fighter\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
            \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(fighter.gender, fighter.race, fighter.strength, \
              fighter.dexterity, fighter.constitution, fighter.intelligence, fighter.wisdom, fighter.charisma, fighter.alignment, \
              fighter.BestWeapon))
             
   elif PlayerClass == "wizard":
       print("Class: Wizard\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
            \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(wizard.gender, wizard.race, wizard.strength, \
              wizard.dexterity, wizard.constitution, wizard.intelligence, wizard.wisdom, wizard.charisma, wizard.alignment, \
              wizard.BestWeapon))

   elif PlayerClass == "sorcerer":
       print("Class: Sorcerer\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
                    \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(sorcerer.gender, sorcerer.race, sorcerer.strength, \
                      sorcerer.dexterity, sorcerer.constitution, sorcerer.intelligence, sorcerer.wisdom,\
                      sorcerer.charisma, sorcerer.alignment, sorcerer.BestWeapon))       

   elif PlayerClass == "cleric":
       print("Class: Cleric\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
                \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(cleric.gender, cleric.race, cleric.strength, \
                  cleric.dexterity, cleric.constitution, cleric.intelligence, cleric.wisdom, cleric.charisma, cleric.alignment,\
                  cleric.BestWeapon))

   elif PlayerClass == "druid":
       print("Class: Druid\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(druid.gender, druid.race, druid.strength, \
                druid.dexterity, druid.constitution, druid.intelligence, druid.wisdom, druid.charisma, druid.alignment,\
                druid.BestWeapon))
           
   elif PlayerClass == "rogue":
       print("Class: Rogue\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
          \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(rogue.gender, rogue.race, rogue.strength, \
            rogue.dexterity, rogue.constitution, rogue.intelligence, rogue.wisdom, rogue.charisma, rogue.alignment,\
            rogue.BestWeapon))

   elif PlayerClass == "bard":
       print("Class: Bard\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(bard.gender, bard.race, bard.strength, \
                bard.dexterity, bard.constitution, bard.intelligence, bard.wisdom, bard.charisma, bard.alignment,\
                bard.BestWeapon))

   elif PlayerClass == "barbarian":
       print("Class: Barbarian\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(barbarian.gender, barbarian.race, barbarian.strength, \
                barbarian.dexterity, barbarian.constitution, barbarian.intelligence, barbarian.wisdom, barbarian.charisma, \
                barbarian.alignment, barbarian.BestWeapon))

   elif PlayerClass == "monk":
       print("Class: Monk\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(monk.gender, monk.race, monk.strength, \
                monk.dexterity, monk.constitution, monk.intelligence, monk.wisdom, monk.charisma, monk.alignment,\
                monk.BestWeapon))

   elif PlayerClass == "paladin":
       print("Class: Paladin\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(paladin.gender, paladin.race, paladin.strength, \
                paladin.dexterity, paladin.constitution, paladin.intelligence, paladin.wisdom, paladin.charisma, paladin.alignment,\
                paladin.BestWeapon))

   elif PlayerClass == "ranger":
       print("Class: Ranger\nGender: {}\nRace: {}\nStrength: {}\nDexterity: {}\nConstitution: {}\nIntelligence: {}\
              \nWisdom: {}\nCharisma: {}\nAlignment: {}\nBest weapon: {}".format(ranger.gender, ranger.race, ranger.strength, \
                ranger.dexterity, ranger.constitution, ranger.intelligence, ranger.wisdom, ranger.charisma, ranger.alignment,\
                ranger.BestWeapon))

fighter = Fighter("Female", "Dwarf", 16, 11, 16, 9, 9, 9, "Lawful Good", "Katana +1")
wizard = Wizard("Male", "Elf", 10, 12, 13, 18, 19, 9, "Chaotic Evil", "Dagger +1")
sorcerer = Sorcerer("Male", "Half-elf", 10, 14, 15, 9, 9, 16, "Lawful Good", "Kukri +1")
cleric = Cleric("Female", "Human", 14, 10, 13, 9, 16, 9, "Lawful Evil", "Mace +1")
druid = Druid("Female", "Human", 13, 11, 13, 9, 16, 9, "True Neutral", "Scimitar +1")
rogue = Rogue("Female", "Halfling", 14, 16, 15, 10, 9, 9, "Chaotic Good", "Dagger +1")
bard = Bard("Female", "Human", 10, 16, 9, 15, 9, 12, "Neutral Good", "Longbow +1")
barbarian = Barbarian("Male", "Half Orc", 16, 14, 14, 9, 9, 9, "Neutral Good", "Double Axe +1")
monk = Monk("Female", "Dwarf", 13, 13, 13, 10, 16, 9, "Lawful Good", "Unarmed +1")
paladin = Paladin("Male", "Human", 16, 11, 16, 9, 9, 9, "Lawful Good", "Long Sword +1")
ranger = Ranger("Male", "Human", 12, 13, 13, 15, 9, 9, "Lawful Neutral", "Long Sword +1")

while True:
   ClassSelector = input("Please enter a class in lowercase, like 'monk'.\n\
Available classes are: 'fighter, wizard, sorcerer, cleric, druid, bard, barbarian, monk, paladin, \
 and ranger'. To quit, type 'quit': ")
   if ClassSelector not in ["fighter", "wizard", "sorcerer", "cleric", "druid", "bard", "barbarian", "monk", \
                             "paladin", "ranger"] and ClassSelector != 'quit':
       continue
   elif ClassSelector == "quit":
	   break
   else:
       ShowStats(ClassSelector)
            
z = input("To close the program, please press <ENTER>")

Merhaba, yukarıda görünen kodlar ile temel RPG karakterlerinin sahip olacağı özellikleri kazanması için Hero isimli bir sınıf oluşturdum ve diğer sınıfları buradan dönüştürdüm. Görüş ve önerilerinizi beklerim.

1 cevap

+2 oy
(6.5k puan) tarafından cevaplandı
Güzel olmuş. Teşekkürler.
...