def __init__(self): """ Constructor function """ Character.__init__(self) #Load images and rectangles self.jump_l_image, self.jump_l_image_rect = routines.load_png('hero_3/jump_l.png') self.jump_r_image, self.jump_r_image_rect = routines.load_png('hero_3/jump_r.png') self.idle_l_image, self.idle_l_image_rect = routines.load_png('hero_3/idle_l.png') self.idle_r_image, self.idle_r_image_rect = routines.load_png('hero_3/idle_r.png') self.move_1_r_image, self.move_1_r_image_rect = routines.load_png('hero_3/move_1_r.png') self.move_1_l_image, self.move_1_l_image_rect = routines.load_png('hero_3/move_1_l.png') self.move_2_r_image, self.move_2_r_image_rect = routines.load_png('hero_3/move_2_r.png') self.move_2_l_image, self.move_2_l_image_rect = routines.load_png('hero_3/move_2_l.png') self.dead_image, self.dead_image_rect = routines.load_png('hero_3/death.png') #load sounds self.sounds={} self.sounds['jump']=pygame.mixer.Sound('data/sound/jump.wav') self.image = self.idle_l_image self.rect = self.idle_l_image_rect # Set a referance to the image rect. #Setup status self.status = 'idle_r' #idle,move,jump, self.location = 'ground' #ground,air,block Character.set_options(self, 13, 0, 1)
def __init__(self, x, y): self.health = Survivor.START_HEALTH self.current_weapon = Weapon(Weapon.PISTOL) self.direction = Direction.WEST self.img = pygame.image.load('images/survivor/survivor_w.png') Character.__init__(self, x, y)
def __init__(self,level, pName = None, pStr = None, pDex = None, pMnd = None, pLck = None, pWeapon = None, pArmor = None, pInventory = None, pHp = None, pLevel = None, pAp = None, pDescription = None, pAge = None, pMp = None, pPp = None, pManaEnabled = None): if (pName == None and pStr == None and pDex == None and pMnd == None and pLck == None and pWeapon == None and pArmor == None and pInventory == None and pHp == None and pLevel == None and pAp == None and pDescription == None and pAge == None and pMp == None and pPp == None and pManaEnabled == None): self.createEnemy(level) else: Character.__init__(self, pName, pStr, pDex, pMnd, pLck, pWeapon, pArmor, pInventory, pHp, pLevel, pAp, pDescription, pAge, pMp, pPp, pManaEnabled)
def __init__(self, x, y): self.health = Survivor.START_HEALTH self.current_weapon = 0 # 0 -> pistol, 1 -> shotgun, 2 -> automatic self.direction = Direction.WEST self.img = pygame.image.load('images/survivor/survivor_w.png') Character.__init__(self, x, y)
def __init__(self, x, y): self.direction = Direction.WEST self.health = Zombie.START_HEALTH self.img = Zombie.ORIGINAL_ZOMBIE_IMAGE Character.__init__(self, x, y) Zombie.list_.append(self)
def __init__(self, x): idle = SpriteSheet("art/pl_cid.png").images_at( [(0,0,300,400)],colourkey=(0,255,0)) walk = SpriteSheet("art/pl_cid_walk.png").images_at( [(0,0,300,400), (300,0,300,400)],colourkey=(0,255,0)) attack = SpriteSheet("art/pl_cid_attack1.png").images_at( [(0,0,250,400), (250,0,250,400), (500,0,250,400), (750,0,250,400)],colourkey=(0,255,0)) Character.__init__(self, x, idle, walk, attack) self.attack_time = -1
def __init__(self,model,run,walk,startPoint,scale): """Initialise the character. Initialises private fields used to control the character's behaviour. Also see Character.__init__(). Arguments: See Character.__init__(). """ Character.__init__(self, model, run, walk, startPoint, scale) self.prevTurnTime = 0 self.setControl('up',1)
def __init__(self, model, run, walk, startPoint, scale): """Initialise the character. Initialises private fields used to control the character's behaviour. Also see Character.__init__(). Arguments: See Character.__init__(). """ Character.__init__(self, model, run, walk, startPoint, scale) self.prevTurnTime = 0 self.setControl('up', 1)
def __init__(self): Character.__init__(self) self.state = 'normal' #self.wealth = 100 self.health = 10 self.health_max = 10 self.Commands = { 'quit': Player.quit, 'help': Player.help, 'status': Player.status, 'rest': Player.rest, 'explore': Player.explore, 'run': Player.flee, 'attack': Player.attack }
def __init__(self, name, account): self.file_path = Path('./', 'server', 'characters', "{}.dat".format(name)) self.username = account.username self.notifications_buffer = bytes() self.current_room_id = None self.username = "" self.last_commands = list() self.inventory = list() self.account = account self.weapon = None self.hp = 200 self.damage = 5 self.level = 0 self.gold = 0 Character.__init__(self, name)
def __init__(self, name="Zombie", health=20, shield=2, dodge=0, parry=0, criticalHit=1, mana=0, damageMin=2, damageMax=4, armor=0, xp=0, inventory=Inventory()): Character.__init__(self, name, health, shield, dodge, parry, criticalHit, mana, damageMin, damageMax, armor, xp, inventory)
def __init__(self, x, y, director): Character.__init__(self, x, y, "player-alt.png", -1, "coordPlayerAlt2.txt", [3, 3, 3, 3], director, (-4, 10, 4, 6, -2, 4, 2, 8)) self.controller = PlayerController(self, director) self.posIndex = POS_DOWN self.posImageIndex = 1 self.hp = 100 self.atk = 20 self.director = director self.mask = pygame.mask.from_surface(self.sheet.subsurface(self.sheetCoord[self.posIndex][self.posImageIndex])) # Better collisions this way self.rect.inflate_ip(-4, -6) self.atk_speed = PLAYER_ATTACK_SPEED self.selectedWpnNum = 0 self.totalWpns = 0 self.weapons = []
def __init__(self, x): idle = SpriteSheet("art/pl_shana.png").images_at([(0, 0, 300, 400)], colourkey=(0, 255, 0)) walk = SpriteSheet("art/pl_shana_walk.png").images_at( [(0, 0, 300, 400), (300, 0, 300, 400), (600, 0, 300, 400), (900, 0, 300, 400)], colourkey=(0, 255, 0) ) attack = SpriteSheet("art/pl_shana_attack1.png").images_at( [ (0, 0, 400, 400), (400, 0, 400, 400), (800, 0, 400, 400), (1200, 0, 400, 400), (1600, 0, 400, 400), (2000, 0, 400, 400), ], colourkey=(0, 255, 0), ) Character.__init__(self, x, idle, walk, attack) self.attacking = False self.attack_time = 0 self.time_till_attack = 60 self.damage = 20
def __init__(self, display, name, mass=1.75, position=Vector(), is_dummy=False, **kwargs): Character.__init__(self, display, name, is_dummy=is_dummy, mass=mass, position=copy.copy(position), **kwargs) self.width = 60 self.height = 100 self.bounding_shapes[0] = BoundingShape( [self.position.x, self.position.y, self.width, self.height]) self.attacks = [] self.manager = None
def createEnemy(self, level): name = getGnoblinName(level) statsFlag = False while statsFlag == False: STR = randint(1,8)-randint(1,6) DEX = randint(1,8)-randint(1,6) MND = randint(1,8)-randint(1,6) LCK = randint(1,8)-randint(1,6) if STR+DEX+MND >= 0: statsFlag = True armor = ["armor","Unarmored",0,0,0,None] weapon = ["weapon","melee","Unarmed",6,0] inventory = [] hp = [0,0,0,0,0] hp[2] = 6 hp[1] = randint(1,hp[2])+STR hp[0] = hp[1] hp[3] = 1 ap = level*100 + (randint(0,99)) description = "A depressingly small gnoblinoid." age = [randint(8,19),19+randint(1,30)] if MND >=5: manaEnabled = True mpTemp = randint(1,4)+MND mp = [mpTemp,mpTemp,4,1,0] ppTemp = randint(1,4)+MND pp = [ppTemp,ppTemp,4,1,0] else: manaEnabled = False mp = [0,0,0,0,0] pp = [0,0,0,0,0] #Create the foe. Character.__init__(self, name,STR,DEX,MND,LCK,weapon, armor, inventory, hp, level, ap, description, age, mp, pp, manaEnabled) #Stat Assignment for i in range(level): levelSelect = randint(1,5) self.levelUp(levelSelect)
def __init__(self, x, y, imageName, colorkey, coordsName, numImages, player, magicNumbers=(0, 0, 0, 0, 0, 0, 0, 0), director=None, *args): Character.__init__(self, x, y, imageName, colorkey, coordsName, numImages, magicNumbers, director) self.controller = MeleeController(self, player, director) self.rect = pygame.Rect(x, y, 10, 10) self.atk_speed = ENEMY_ATTACK_SPEED self.damageCooldown = 0
def __init__(self, name, description, hp, damage, drops, exp): self.hp = hp self.damage = damage self.drops = drops self.exp = exp Character.__init__(self, name, description)
def __init__(self): Character.__init__(self); self.name = "goblin"; self.health = 6; self.power = 22;
class Monk(Character): def__init__(self, characterLevel, ): Character.__init__(self) self.aliveStatus = True self.attackList = ['attack1', 'attack2', 'attack3'] self.attributes = {'Strength':'', 'Luck':'', 'IQ':'', 'Stealth':'', 'Speed':'', 'Chi':''}
def __init__(self, player): Character.__init__(self) self.name = 'a katappa' self.health = randint(1, player.health)
def __init__(self, unique_id, nickname): Character.__init__(self, unique_id, nickname, 'NWBCTY')
from Character import Character import time; # Give the class a name...Hero class Hero(object): # Call the init method which is built into classes # Pass itself so that we have a "this" to work with def __init__(self): # Define some class properties (attached to self) Character.__init__(self); self.name = "Michael"; self.health = 10; self.power = 5; def alive(self): # this returns a boolean value return self.health > 0; def attack(self, enemy): print "%s attacks %s" % (self.name, enemy.name); enemy.take_damage(self.power); time.sleep(1.5); print "%s has done %d damage to %s" % (self.name, self.power, enemy.name) def take_damage(self, points_of_damage): self.health -= points_of_damage; def power_up(self): self.power += 5; print """%s decides to not attack this turn to contemplate the value of powering up vs attacking as is. %s decides that it is more important to power up this time. %s powers up!""" % (self.name, self.name, self.name); def dance(self): print "%s drops his weapon and starts dancing. Nothing useful comes from this" % (self.name); print """ quu..__ $$$b `---.__ "$$b `--. ___.---uuudP
def __init__(self): Character.__init__(self) self.name = 'goblin'; self.health = 6; self.power = 2;
def __init__(self, x, y): Character.__init__(self, x, y) self.thread = threading.Thread(target=self.run) self.isAlive = False
def __init__(self, Name): Character.__init__(self, randint(20, 25), randint(14, 19), randint(11, 19), randint(20, 22), 5, 30, Name)
def __init__(self): Character.__init__(self) self.name = "Shadow" self.health = 1 self.power = 0
def charCreate(self): global gameState nameFlag = False while nameFlag == False: name = input("What should I call you?\n>") if len(name) > 15: print("That's quite a mouthful. Try shortening it.") else: nameFlag = True genderFlag = False while genderFlag == False: gender = input("Gender: Are you Male(M) or Female(F)?\n>").upper() gender = gender [0:1] if gender == "M" or gender == "F": genderFlag = True else: print("Please choose 'M' or 'F'.") raceFlag = False while raceFlag == False: race = "Human" print("You are a",race) raceFlag = True rollFlag = False rerollFlag = False rerolled = False while rollFlag == False: rolls = [randint(1,8)-randint(1,6),randint(1,8)-randint(1,6),randint(1,8)-randint(1,6)] LCK = randint(1,8)-randint(1,6) if sum(rolls) < 0: continue else: attributes = ["Strength", "Dexterity", "Mind"] statsChosen = [0,0,0] print("There are three stats: " + attributes[0] + ", " + attributes[1] + ", and " + attributes[2] + ".") for i in range(0, len(attributes)-1, 1): flag = False rerollFlag = False while flag == False: print("Your rolls are as follows: ", end="") for j in range(0, len(rolls)-1, 1): print(str(rolls[j]) + ", ", end="") if len(rolls) != 1: print("and ", end="") print(rolls[len(rolls)-1]) statChoiceString = "Which stat would you like to assign to " + attributes[i] + "?" if rerolled == False: statChoiceString = statChoiceString + "\nPress 'r' to reroll your stats.(This can be done only once!)\n>" else: statChoiceString = statChoiceString + "\n>" statChoice = input(statChoiceString) if "r" in statChoice and rerolled == False: rerollFlag = True break else: rerollFlag = False try: statChoice = int(statChoice) except: print("Try again.") continue if statChoice in rolls: rolls.remove(statChoice) statsChosen[i] = statChoice flag = True else: print("That's not one of your stats!") if rerollFlag == True and rerolled == False: break if rerollFlag == True and rerolled == False: rerolled = True continue statsChosen[2] = rolls[0] rolls = None rollFlag = True age = [0,30+randint(1,20)+randint(1,20)+randint(1,20)+randint(1,20)] ageFlag = False while ageFlag ==False: age[0] = input("Your maximum age is "+str(age[1])+". How old are you currently?\n>") try: age[0] = int(age[0]) if age[0]>age[1]: print("You would have died of old age!") elif age[0] < 0: print("I'm not entirely sure you understand how age works.") elif age[0] < 8: print("I'm not giving a sword to a child.\nWell, I'm not giving you a sword anyways, but you get the point.") else: ageFlag = True except: print("An integer, please!") #name already set STR = statsChosen[0] DEX = statsChosen[1] MND = statsChosen[2] #LCK already set #inv type, weap type, name, damage die, to-hit weapon = ["weapon","melee","Unarmed",6,0] #inv type, name, AS, RR, RT, Max Dex armor = ["armor","Unarmored",0,0,0,None] inventory = [None] #Create an HP function here. #Temp,Max,Die,Rolls,Bonus hp = [0,0,0,0,0] hp[2] = 6 hp[1] = randint(1,hp[2])+STR hp[0] = hp[1] hp[3] = 1 level = 1 ap = 0 description = input("How would you describe your character?\n>") #Base attack stat: Default STR BAS = "STR" #Base defense stat: Default DEX BDS = "DEX" dodge = DEX+armor[2] if MND >=5: mpTemp = randint(1,4)+MND #Temp,Max,Die,Rolls,Bonus mp = [mpTemp,mpTemp,4,1,0] ppTemp = randint(1,4)+MND pp = [ppTemp,ppTemp,4,1,0] manaEnabled = True else: mp = [0,0,0,0,0] pp = [0,0,0,0,0] manaEnabled = False global player Character.__init__(self, name,STR,DEX,MND,LCK,weapon, armor, inventory, hp, level, ap, description, age, mp, pp, manaEnabled) print("A hero has risen!") gameState = "Running"
def __init__(self, x, y): Character.__init__(self, x, y)
def __init__(self): Character.__init__(self) self.name = "Incognito" self.health = 10; self.power = 5;
def __init__(self): Character.__init__(self) self.aliveStatus = True self.attributes = {'Strength':'', 'Luck':'', 'IQ':'', 'Stealth':'', 'Speed':'', 'Chi':''}
def __init__(self, Name): Character.__init__(self, randint(35, 40), randint(1, 8), randint(29, 31), randint(1, 6), 5, 30, Name)
def __init__(self, player): Character.__init__(self) self.name = 'a goblin' self.health = randint(1, player.health)
def __init__(self, Name): Character.__init__(self, randint(25, 35), randint(19, 21), randint(20, 22), randint(1, 7), 5, 30, Name)
def __init__(self, ): Character.__init__(self) self.attackList = []
def __init__(self, side): Character.__init__(self, side) self.route = None
def __init__(self, Name): Character.__init__(self, randint(15, 20), randint(28, 30), randint(17, 22), randint(1, 7), 5, 30, Name)
def __init__(self): Character.__init__(self) # Define some class properties (attached to self) self.name = "Incognito" self.health = 10 self.power = 5
def __init__(self, Name): Character.__init__(self, randint(15, 20), randint(32, 34), randint(9, 14), randint(15, 17), 5, 30, Name)
def __init__(self, name="Merchant", health=20, shield=0, dodge=0, parry=0, criticalHit=1, mana=10, damageMin=1, damageMax=2, armor=0, xp=0, inventory=Inventory(), maxHealth=20): Character.__init__(self, name, health, shield, dodge, parry, criticalHit, mana, damageMin, damageMax, armor, xp, inventory)
def __init__(self): Character.__init__(self) self.state = 'normal' self.health = 10 self.health_max = 10