def __init__(self): self.wf = Weapon_Factory() self.cf = Creature_Factory() self.af = Armor_Factory() # self.player.add_weapon(self.wf.generate_by_quality(2)) # self.player = self.cf.generate_player_stats(self.player) # self.player.primary_weapon().proc.append(Leech_Proc(50,20)) # self.player.add_armor(self.af.generate_high_quality()) self.reset(1)
class Test: def __init__(self): self.wf = Weapon_Factory() self.cf = Creature_Factory() self.af = Armor_Factory() # self.player.add_weapon(self.wf.generate_by_quality(2)) # self.player = self.cf.generate_player_stats(self.player) # self.player.primary_weapon().proc.append(Leech_Proc(50,20)) # self.player.add_armor(self.af.generate_high_quality()) self.reset(1) def fight(self, diff): self.reset(diff) while self.player.hp > 0 and self.gen.hp > 0: self.arena.attack() print "Gen: HP = %s" % self.gen.hp, "/%s" % self.gen.max_hp, print "OS = %s" % self.gen.OS, "DS = %s" % self.gen.DS, print "WPN Score = %s" % self.gen.primary_weapon().score print "PLR: HP = %s" % self.player.hp, "/%s" % self.player.max_hp, print "OS = %s" % self.player.OS, "DS = %s" % self.player.DS, print "WPN Score = %s" % self.player.primary_weapon().score if self.player.hp > 0: print "Player WIN" else: print "Player LOSS" def temp(self): wpn = self.wf.generate_by_type(random.randint(0, 3), random.randint(0, 2)) agi_high = 0 agi_low = 10 str_high = 0 str_low = 10 cnt = 0 while cnt < 1000: if wpn.required_agility > agi_high: agi_high = wpn.required_agility if wpn.required_agility < agi_low: agi_low = wpn.required_agility if wpn.required_strength > str_high: str_high = wpn.required_strength if wpn.required_strength < str_low: str_low = wpn.required_strength wpn = self.wf.generate_by_type(random.randint(0, 3), random.randint(0, 2)) cnt += 1 print agi_low, agi_high, str_low, str_high def reset(self, diff): self.player = Adventurer("Valna", 300) self.player.add_weapon(self.wf.generate_by_quality(2)) self.player.add_armor(self.af.generate_by_quality(2)) self.gen = self.cf.generate_difficulty(diff) # self.player.primary_weapon().proc.append(Poison_Proc(50,1,10)) # self.gen.add_effect(DOT_Effect(3,200)) self.arena = Arena(self.player, self.gen)
def generate(self): #description item and gold description = self.get_room_description() gold = random.randrange(101) #generate creature chance = random.randrange(1000) if( chance > 300 ): cf = Creature_Factory() creature = cf.generate() else: creature = None #generate items items = list() itf = Item_Factory() items.append( itf.generate() ) wf = Weapon_Factory() items.append( wf.generate() ) af = Armor_Factory() items.append( af.generate() ) return Room( description, creature, items, gold )
def execute(self): #allow these commands regardless creature = self.level.get_current_room().creature if( self.command == "help" ): self.execute_help() elif( self.command == "vhelp" ): self.execute_vhelp() elif( self.command == "map" ): self.execute_map() elif( self.command == "look-around" ): self.execute_lookaround() elif( self.command == "study" ): self.execute_study() elif( self.command[0:9] == "inventory" ): self.execute_inventory() elif( self.command[0:7] == "inspect" ): self.execute_inspect() elif( self.command == "switch-weapon" ): self.execute_switch_weapon() elif( self.command == "switch-armor" ): self.execute_switch_armor() elif( self.command == "status" ): self.execute_status() #if there are NO creatures in the room, then allow these #command elif( self.level.get_current_room().creature == None ): if( self.command == "pickup" ): self.execute_pickup() elif( self.command[0:4] == "drop" ): self.execute_drop() elif( self.command == 'use-potion' ): self.execute_use_potion() elif( self.command == 'buy-attribute' ): self.execute_buy_attribute() #possibly generate mob since there is no creature in a room if( creature == None and self.level.mob_size > 0): if( random.randrange(100) > 80 ): cf = Creature_Factory() c = cf.generate() self.level.get_current_room().creature = c self.level.mob_size -= 1 print c.name + " entered the room!" #if there is a creature in the room, then allow these commands elif( self.level.get_current_room().creature != None ): if( self.command == "flee" ): self.execute_flee() elif( self.command == "attack" ): self.execute_attack() elif( self.command == "magic-attack" ): self.execute_magic_attack() elif(self.command == 'use-potion' ): self.execute_use_potion() #check if the creature or the player is dead if(creature != None): if( creature.hp <= 0 ): diff = creature.level - self.player.level xp = 0 if diff >= 0: xp = creature.calc_experience() * (diff+1) else: tmp = (diff * -20) // 100 xp = int(creature.calc_experience() * tmp) self.player.grant_xp(xp) print "You gained %s XP for slaying the" % xp, print creature.name + "." print "You collected %s gold coins from the corpse." % creature.gold self.player.gold += creature.gold tf = Treasure() treasure = tf.generate(creature.level) for t in treasure: self.level.get_current_room().item.append(t) for p in creature.all_equipment(): self.level.get_current_room().item.append(p) self.level.get_current_room().creature = None if(self.player.hp <= 0): print "Game Over! You died sucka!" sys.exit()