def generate_npc( species=None, job=None, gender=None, rank=None, team=None ): if not species: species = random.choice( characters.PC_SPECIES ) if not gender: gender = random.randint(0,1) if not rank: rank = random.randint(1,10) npc = characters.Character( species=species(), gender=gender ) npc.roll_stats() npc.team = team if not job: choices = chargen.get_possible_levels( npc ) + chargen.get_possible_levels( npc, NPC_CLASSES ) job = random.choice( choices ) if not job.can_take_level( npc ): tries = 100 while ( tries > 0 ) and not job.can_take_level( npc ): npc.roll_stats() tries += -1 ji = job( rank=rank, pc=npc ) npc.levels.append( ji ) chargen.give_starting_equipment( npc ) npc.tags.append( context.CHAR_NPC ) npc.name = gen_monster_name(npc) npc.choose_random_spells() return npc
def generate_npc( species=None, job=None, gender=None, rank=None, team=None, upgrade=False, fac=None ): if not species: species = choose_faction_appropriate( fac, characters.PC_SPECIES ) if not gender: gender = random.randint(0,1) if not rank: rank = min(random.randint(1,10),random.randint(1,10)) npc = base.NPCharacter( species=species(), gender=gender ) npc.roll_stats() npc.team = team if not job: choices = chargen.get_possible_levels( npc ) + chargen.get_possible_levels( npc, NPC_CLASSES ) job = choose_faction_appropriate( fac, choices ) if not job.can_take_level( npc ): tries = 100 while ( tries > 0 ) and not job.can_take_level( npc ): npc.roll_stats() tries += -1 ji = job( rank=rank, pc=npc ) npc.levels.append( ji ) chargen.give_starting_equipment( npc ) npc.tags.append( context.CHAR_NPC ) npc.name = gen_monster_name(npc) npc.choose_random_spells() npc.gold = treasuretype.gold_for_rank( rank ) if upgrade: upgrade_equipment( npc, rank ) return npc
def create_pc(self, job): """Create a PC with the given job.""" oldpc = None # Munchkins can change the number "5" to something obscene. for t in xrange(5): species = random.choice(characters.PC_SPECIES) gender = random.randint(0, 1) newpc = characters.Character(species=species(), gender=gender) tries = 1000 while (tries > 0) and not job.can_take_level(newpc): newpc.roll_stats() tries += -1 newpc.levels.append(job(1, newpc)) if self.newpc_is_better(newpc, oldpc): oldpc = newpc chargen.give_starting_equipment(newpc) newpc.name = monsters.gen_monster_name(newpc) oldpc.choose_random_spells() return oldpc
def create_pc( self, job ): """Create a PC with the given job.""" oldpc = None # Munchkins can change the number "5" to something obscene. for t in xrange( 5 ): species = random.choice( characters.PC_SPECIES ) gender = random.randint(0,1) newpc = characters.Character( species=species(), gender=gender ) tries = 1000 while ( tries > 0 ) and not job.can_take_level( newpc ): newpc.roll_stats() tries += -1 newpc.levels.append( job(1,newpc) ) if self.newpc_is_better( newpc, oldpc ): oldpc = newpc chargen.give_starting_equipment( newpc ) newpc.name = monsters.gen_monster_name(newpc) oldpc.choose_random_spells() return oldpc