Esempio n. 1
0
    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.shopkeeper.money = 2000

        sword = game_object.Item(name="spear", location=self)
        sword.price = 100
        sword.damage_mult = 6
        sword.damage_type = "sharp"
        sword.owner = self.shopkeeper

        armor = game_object.Item(name="armor", location=self)
        armor.price = 150
        armor.traits.add(trait.armor())
        armor.damage_reduction = 2
        armor.owner = self.shopkeeper
Esempio n. 2
0
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
Esempio n. 3
0
    def create_bandit(self):
        if random() < 0.5:
            weapon_kind = "sword"
            damage_type = "sharp"
            damage_mult = 4 + int(self.power) // 5
            title = "bandit swordsman"
        else:
            weapon_kind = "mace"
            damage_type = "blunt"
            damage_mult = 4 + int(self.power) // 5
            title = "bandit maceman"
        given_name = namemaker.make_name()
        name_and_title = given_name.add(title, template="{}, {}")
        bandit = actor.Humanoid(location=None, name=name_and_title)
        bandit.ai = ai.SquadAI(bandit)
        # TODO: Replace this with selection from a world-level posture list
        stance = posture.random_posture(posture.Stance)
        guard = posture.random_posture(posture.Guard)
        for p in (stance, guard):
            bandit.learn_posture(p)
            bandit.adopt_posture(p)

        weapon = game_object.Item(location=bandit, name=Name(weapon_kind))
        weapon.damage_type = damage_type
        weapon.damage_mult = damage_mult
        return bandit
Esempio n. 4
0
    def build_actors(self):
        for adjective in self.adjectives:
            kobold = actor.SquadActor(location=None,
                                      name=Name(adjective) + "kobold")
            self.actors.append(kobold)

        boss = actor.Person(
            location=None,
            name=Name("kobold leader"),
        )
        self.actors.append(boss)
        boss.ai = ai.WanderingMonsterAI(boss)
        sword = game_object.Item(location=boss, name=Name("crude sword"))
        sword.damage_type = "sharp"
        sword.damage_mult = 6
        self.location_functions[boss] = self.boss_location_function
Esempio n. 5
0
    def build(self):
        for kobold in self.create_random_creatures():
            self.actors.append(kobold)

        boss = actor.Person(
            location=None,
            name=Name("kobold leader"),
        )
        boss.traits.add(trait.kobold())
        boss.ai = ai.WanderingMonsterAI(boss)
        boss.combat_skill = 75
        sword = game_object.Item(location=boss, name=Name("crude sword"))
        sword.damage_type = "sharp"
        sword.damage_mult = 6
        self.location_functions[boss] = self.boss_location_function
        self.actors.append(boss)
Esempio n. 6
0
            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()
Esempio n. 7
0
 def create_head(self):
     game_object.Item(location=self.location,
                      name=self.name_object + Name("head"))
Esempio n. 8
0
            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())
Esempio n. 9
0
 def load_stage(self, stage_num):
     for r in range(ROW_COUNT):
         for c in range(COL_COUNT):
             if gd.stages[stage_num][r][c] == '.':
                 file_name = gd.img_world[0]
                 if c < COL_COUNT-1:
                     self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                     self.move_grid[r][c] = 1
                 else:  # cannot be here except the beginning of stage
                     if r < stage_num:
                         self.plat_grid[r][c] = gobj.Platform(gd.img_fruit[r], r, c)
                     else:
                         self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                     self.move_grid[r][c] = 0
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '2':
                 file_name = gd.img_world[1]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 2
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '3':
                 file_name = gd.img_world[2]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 3
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '4':
                 file_name = gd.img_world[3]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 4
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '5':
                 file_name = gd.img_world[4]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 5
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '6':
                 file_name = gd.img_world[5]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 6
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == '7':
                 file_name = gd.img_world[6]
                 self.plat_grid[r][c] = gobj.Platform(file_name, r, c)
                 self.move_grid[r][c] = 7
                 self.kill_grid[r][c] = True
             elif gd.stages[stage_num][r][c] == '#':
                 file_name1 = gd.img_fruit[stage_num]
                 file_name2 = gd.img_world[0]
                 self.plat_grid[r][c] = gobj.Item(file_name1, file_name2, r, c)
                 self.move_grid[r][c] = 8
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == 'a':
                 file_name1 = gd.img_world[7]
                 file_name2 = gd.img_world[0]
                 self.plat_grid[r][c] = gobj.Item(file_name1, file_name2, r, c)
                 self.move_grid[r][c] = 9
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == 'b':
                 file_name1 = gd.img_world[7]
                 file_name2 = gd.img_world[0]
                 self.plat_grid[r][c] = gobj.Item(file_name1, file_name2, r, c)
                 self.move_grid[r][c] = 10
                 self.kill_grid[r][c] = False
             elif gd.stages[stage_num][r][c] == 'c':
                 file_name1 = gd.img_world[7]
                 file_name2 = gd.img_world[0]
                 self.plat_grid[r][c] = gobj.Item(file_name1, file_name2, r, c)
                 self.move_grid[r][c] = 11
                 self.kill_grid[r][c] = False
                 # Enemy1 is hidden inside this; it always appear on the right of the bonus bag
                 self.enemy_list.append(gobj.Enemy1(gd.enemy_speeds[stage_num][4], r, c+1))