def offer_loot(self, offer, s_weapon=None): random_gen = randomgenerator.RandomAssetGenerator('weapon', 3) random_weapons = [] self.player.print_stats() print('Choose a new weapon!') if s_weapon: random_weapons.append(s_weapon) else: for i in range(0, offer): _r = random_gen.generate_random_weapon(self.player.level) random_weapons.append(_r) for i in range(0, len(random_weapons)): print('----Weapon %d ----' % i) _w = random_weapons[i] _w.print_weapon_stats() while True: try: choice = int( input( 'Choose a new weapon, or stay with your weapon by pressing %d' % offer)) break except Exception: print('Invalid Choice!') continue if choice == offer: return new_weapon = random_weapons[choice] self.player.unequip_weapon() self.player.equip_weapon(new_weapon) self.player.print_stats()
def lake_module(self): print('A very dangerous enemy approaches!') random_gen_monster = randomgenerator.RandomAssetGenerator( 'boss_name', 3) random_boss_name = random_gen_monster.generate_boss_name() level_fight = random.randint(self.player.level, self.player.level * 2) boss = player_character.PlayerCharacter(random_boss_name, 1, level_fight) fight_module = basicfight.BasicCombatModule(self.player, boss) outcome = fight_module.fight() if outcome: loot = boss.weapon loot.print_weapon_stats() while True: try: choice = int( input( 'Choose boss weapon with 0, or stay with your weapon by pressing 1' )) break except Exception: print('Invalid Choice!') continue if choice == 0: self.player.unequip_weapon() self.player.equip_weapon(loot) self.player.print_stats() else: return
def __init__(self, child, destination, reward, name=None): self.child = child self.name = name if not name: random_quest_gen = randomgenerator.RandomAssetGenerator('quest_name', 3) self.name = random_quest_gen.generate_quest_name() self.destination = destination self.reward = reward
def __init__(self, name, chartype, level): self.name = name if not name: self.name = randomgenerator.RandomAssetGenerator( 'basic_name', 3).generate_random_title() self.chartype = chartype self.level = level self.maxhealth = 0 self.maxmana = 0 self.health = 0 self.mana = 0 self.weapon = None self.combat_arts = {} self.avaialable_combat_arts = None self.maxstat = 100 self.strength = 1 self.intelligence = 1 self.dexterity = 1 if self.chartype == 1: self.maxhealth = 10 self.maxmana = 10 self.health = self.maxhealth self.mana = self.maxmana #weapon_formula_wand = lambda s, d, i, h, m, r: i #weapon_formula_readable = 'i' #self.weapon = weapon.Weapon('Basic Wand', weapon_formula_wand, weapon_formula_readable, 1, (0, 0, 0)) self.combat_arts = {} #2 : ('Minor Mana Flare', 2, lambda s, d, i, h, m: 1.2 * m ) self.avaialable_combat_arts = OrderedDict([ (2, ('MinorManaFlare', 2, lambda s, d, i, h, m, r: 1.2 * m * r)), (3, ('ManaBurn', 2, lambda s, d, i, h, m, r: i + (1.1 * m * r))) ]) # in format name, mana cost, damage function # damage function in order: str, dex, int, health, mana, random element self.exp = 0 self.reward = random.randint(self.level * 50, self.level * 150) self.nextlevel = 100 for i in range(self.level - 1): r = random.randint(0, 2) if r == 0: self.strength = self.strength + 1 elif r == 1: self.dexterity = self.dexterity + 1 elif r == 2: self.intelligence = self.intelligence + 1 self.maxhealth += self.strength self.health = self.maxhealth self.random_weapon()
def __init__(self, map_size, player): self.map_size = map_size self.player = player self.map = MapModule(self.map_size) self.player_loc = (random.randint(0, self.map_size - 1), random.randint(0, self.map_size - 1)) random_quest_gen = randomgenerator.RandomAssetGenerator( 'quest_name', 3) dest_loc = (random.randint(0, self.map_size - 1), random.randint(0, self.map_size - 1)) self.quest = random_quest_gen.generate_random_quest( self.player.level, dest_loc)
def lake_module(self): print('A very dangerous enemy approaches!') random_gen_monster = randomgenerator.RandomAssetGenerator( 'boss_name', 3) random_boss_name = random_gen_monster.generate_boss_name() level_fight = random.randint(self.player.level, self.player.level * 2) boss = player_character.PlayerCharacter(random_boss_name, 1, level_fight) fight_module = basicfight.BasicCombatModule(self.player, boss) outcome = fight_module.fight() if outcome: loot = boss.weapon self.offer_loot(1, loot)
def main(): #cur_map = mapmodule.MapModule(5) #cur_map.print_map() print("Time to start the game!") name = input("What is your name?") chartype = int(input("What character type are you? (1 only)")) yourcharacter = PlayerCharacter(name, chartype, 1) yourcharacter.print_stats() yourcharacter.add_exp(800) yourcharacter.print_stats() game_player = mapmodule.GamePlayer(5, yourcharacter) game_player.walk_map() game_player.print_map() name_generator = randomgenerator.RandomAssetGenerator('basic_name', 3) enemycharacter = PlayerCharacter(name_generator.generate_random_title(), 1, 3) # slap_combat(yourcharacter, enemycharacter) fight_module = basicfight.BasicCombatModule(yourcharacter, enemycharacter) fight_module.fight()
def evaluate_landing_position(self): biome = self.map.at_position(self.player_loc) if biome == Tiles.CAVE: print('Random Fight!') level_fight = random.randint(1, self.player.level) enemy = player_character.PlayerCharacter(None, 1, level_fight) fight_module = basicfight.BasicCombatModule(self.player, enemy) fight_module.fight() if biome == Tiles.VILLAGE: random_gen = randomgenerator.RandomAssetGenerator('weapon', 3) self.player.print_stats() print('Choose a new weapon!') random_weapons = [] offer = 3 for i in range(0, offer): _r = random_gen.generate_random_weapon(self.player.level) random_weapons.append(_r) print('----Weapon %d ----' % i) _r.print_weapon_stats() while True: try: choice = int( input( 'Choose a new weapon, or stay with your weapon by pressing %d' % offer)) break except Exception: print('Invalid Choice!') continue if choice == offer: return new_weapon = random_weapons[choice] self.player.unequip_weapon() self.player.equip_weapon(new_weapon) self.player.print_stats() if biome == Tiles.LAKE: self.lake_module()
def random_weapon(self): random_generator = randomgenerator.RandomAssetGenerator('weapon', 3) random_weapon = random_generator.generate_random_weapon(self.level) self.equip_weapon(random_weapon)