def make_player(location, coordinates, landmarks=(), use_web_output=False, postures=()): john = actor.Hero(location=location, name="john", coordinates=coordinates) for p in postures: john.learn_posture(p) my_parser = john.ai assert (isinstance(my_parser, parsing.Parser)) my_parser.web_output = use_web_output john.view_location() john.known_landmarks = set(landmarks) # john.spells_known = {spells.Shock, spells.Fireball} john.spells_known = set() john.body.max_mana = 50 john.body.mana = 50 john.money = 20 sword = game_object.Item( location=john, name=name_object.Name("iron sword"), ) sword.damage_type = "sharp" sword.damage_mult = 6 phrase.QuitPhrase(my_parser, ["quit"]) phrase.InventoryPhrase(my_parser, ["i", "inventory"]) return john
def __init__(self): self.schedule = schedule.Schedule() self.street = location.Location(name="street", description="You are outside.") self.hero = actor.Hero(self.street, name="john", sched=self.schedule) self.parser = self.hero.ai self.hero.spells_known = {spells.Shock, spells.Fireball} phrase.QuitPhrase(self.parser, ["quit", "exit"]) phrase.InventoryPhrase(self.parser, ["i", "inventory"])
monsters = [] for st in ["skinny", "tall", "hairy", "filthy", "pale", "short"]: while True: node = dungeonrooms.choice(reg.node_list) if not isinstance(node.location, dungeonrooms.CaveEntrance): break loc = node.location name = dungeonrooms.Name(st) + "kobold" zom = actor.SquadActor( loc, name=name, sched=my_schedule, ) monsters.append(zom) debug(reg.get_text_map()) john = actor.Hero(start_location, name="john", sched=my_schedule) john.change_location(start_location) john.view_location() # TODO: Can't add this assert (to pass type check) because of # a circular reference # assert(isinstance(john.ai, Parser)) john.ai.visited_locations = {john.location} # type: ignore john.known_landmarks = { john.location.landmark1, john.location.landmark2, } john.spells_known = {spells.Shock, spells.Sleep, spells.Fireball} john.body.mana = 50 john.body.max_mana = 50 sword = dungeonrooms.Item( location=john,
if my_action is None: reason = action_or_routine.reason_for_empty() if reason: self.display(reason) else: self.display("That doesn't make sense. Do something else.") return self.get_action() elif not my_action.is_valid()[0]: self.routine = None return self.invalid_action_fallback(my_action) else: return my_action else: return action_or_routine if __name__ == "__main__": import game_object import actor loc = location.Location() dude = actor.Hero(loc) sword = game_object.Item(location=loc, name="sword", other_names=["iron sword"]) bsword = game_object.Item(location=loc, name="sword", other_names=["bronze sword"]) p = Parser(dude) p.execute_user_input()
return None if self.steps_taken < self.steps_needed: self.steps_taken += 1 vector = self.step quiet = True else: self.complete = True vector = self.landmark.vector_from_thing(self.actor) quiet = False return VectorTravel(self.actor, quiet=quiet, vector=vector) if __name__ == "__main__": import actor import game_object place = location.Location() dude = actor.Hero(location=place) key = game_object.Item(location=dude, name="key") cage = game_object.Cage(location=place, name="cage", key=key) prisoner = actor.Prisoner(location=place) cage.add_prisoner(prisoner) tar = TakeAllRoutine(dude) u = Unlock(dude, cage, key) prisoner.hear_announcement(u) # print_(dude.get_action()) # print_(tar.action_list) # tar.attempt() # print_(dude.get_action())