def setUp(self):
        """Define test variables and initialize app."""
        # binds the app to the current context
        self.app = create_app()
        setup_db(self.app)
        self.client = self.app.test_client
        self.headers = {
            "Authorization": "bearer " + os.environ["VALID_TEST_TOKEN"]
        }

        Monster(
            name="monster_name",
            race="monster_race",
            health_points="100",
            armor_points="100",
            attack_damage="100",
            xp_drop="100",
        ).insert()

        Dungeon(
            level="1",
            rooms="1",
            treasures="1",
            traps="1",
            boss_level=False,
            xp_drop="1000",
        ).insert()
示例#2
0
    def add_monster():
        payload = request.get_json()
        if not payload:
            abort(400)

        name = payload.get("name", None)

        if Monster.find_by(name):
            abort(
                Response(
                    response=f"Monster '{name}' already created.",
                    status=405,
                ))

        race = payload.get("race", None)
        health_points = payload.get("health_points", None)
        armor_points = payload.get("armor_points", None)
        attack_damage = payload.get("attack_damage", None)
        xp_drop = payload.get("xp_drop", None)

        monster = Monster(
            name=name,
            race=race,
            health_points=health_points,
            armor_points=armor_points,
            attack_damage=attack_damage,
            xp_drop=xp_drop,
        )
        monster.insert()
        return jsonify(monster.short())
def create_monster(monster_data, db_session):
    """Create new monster object."""
    monster = Monster(name=monster_data['name'],
                      diet=monster_data['diet'],
                      enjoys=monster_data['enjoys'],
                      creator=monster_data['creator'],
                      picture=monster_data['picture'],
                      intentions=monster_data['intentions'],
                      created_date=datetime.datetime.now())
    create_response = insert_update_monster(monster, db_session, 'insert')
    return create_response
示例#4
0
def main():
    hero = Monster(0, "Hero")
    darkhero = Monster(2, "DarkHero")
    zhero = Monster(3, "Z-Hero")
    enemy = Monster(1, "Shadow")

    hero.attack(enemy)
    hero.itemEquip("圣剑")

    player1 = Master(0, "Zy")
    player2 = Master(1, "Shadow")

    # player1.showMyEquipments()
    # player1.showMyMainBag()
    # player1.showMyPower()

    # npc1 = NPC(0, "Magerita")
    # npc1.Talkto(player1)
    # npc1.Buyfrom(player1)
    # npc1.Sellto(player1)
    # npc1.QuitSession()
    # npc1.Fightto(player1)

    hero.showSkills()
    hero.learnSkill("死从天降")
    hero.showSkills()

    player1.showMyTeam()
    player1.addTeamMember(hero)
    player1.addTeamMember(darkhero)
    player1.addTeamMember(darkhero)
    player1.addTeamMember(darkhero)
    player1.addTeamMember(darkhero)
    player1.addTeamMember(darkhero)
    player1.addTeamMember(zhero)
    player1.showMyTeam()
    player1.showMonsterRepo()
    player1.showItemRepo()
示例#5
0
def main():

    # 创建人物
    print("[{0}] [GAME] 你好, 欢迎来到新心镇, 我姓王, 是你的新邻居, 也是口袋研究所的博士, 你叫什么名字? ")
    while True:
        name = input("输入你的名字: ")
        if len(name) > 0:
            break
    print("[{0}] [GAME] 啊, [{1}], 多么好听的名字, 那么, 请告诉你的性别?".format(NOW(), name))
    while True:
        gender = input("输入你的性别(0: 女孩, 1: 男孩): ")
        if gender == '0' or gender == '1':
            break
    print("[{0}] [GAME] 原来是个{1}孩子!".format(NOW(), GENDER_CN[int(gender)]))
    # 创建角色
    pid = createMaster(1, name, int(gender))
    print("pid: ", pid)
    player = Master(pid, name, int(gender))
    # 场景: 家
    print("[{0}] [家] 妈妈: [{1}], 这里就是你的新家了, 有空去镇子上跟大家打个招呼吧".format(
        NOW(), player.name))
    # 场景: 新心镇
    print("[{0}] [新心镇]".format(NOW()))
    # 场景: 野外
    print("[{0}] [野外]".format(NOW()))
    print("[{0}] [野外] 选择你的初始怪兽!".format(NOW()))
    print("[{0}] [野外] 1: 鼻涕狗; 2: 玩偶喵; 3: 囤囤鼠".format(NOW()))
    while True:
        try:
            choice = int(input("输入你的选择(1/2/3): "))
            if choice in [1, 2, 3]:
                break
        except:
            pass
    GIFT = {1: '哭哭狗', 2: '玩偶喵', 3: '囤囤鼠'}
    print("[{0}] [野外] [{1}]选择了[{2}]".format(NOW(), name, GIFT[choice]))
    # 生成实例
    race = {1: 1, 2: 4, 3: 7}
    raceC = race[choice]
    print("race: ", raceC)
    monster = Monster(raceC, 1, 5)
    print("[{0}] [野外] 你想给它取个名字吗?".format(NOW()))
    mName = input("输入名字: ")
    monster.nickname = mName if mName else EVOLUTION[raceC][-1]
    print("[{0}] [野外] [{1}]? 这名字真不错".format(NOW(), monster.nickname))
    # 存入数据库
    mid = createMonster(monster)
    # 收服怪兽
    player.getMonster(mid)
示例#6
0
    def load(self, monster_name, count=1):
        # TODO: hey maybe make this more efficient, yeah?

        monster_files = self.get_available_monster_files()
        monsters = []

        for filename in monster_files:
            monster = toml.load(open(filename, 'r'))

            if monster['name'] != monster_name:
                continue

            for i in range(count):
                monsters.append(Monster(**monster))
            break

        return monsters
示例#7
0
def create_all():
    with open('data_monsters.json', 'r') as f:
        monsters = json.loads(f.read())

    for monster in monsters:
        if not monster.get('name'):
            continue

        session.merge(
            Monster(
                str=monster.get('strength', None),
                con=monster.get('constitution', None),
                int=monster.get('intelligence', None),
                wis=monster.get('wisdom', None),
                cha=monster.get('charisma', None),
                dex=monster.get('dexterity', None),
                HP=monster.get('hit_points', None),
                AC=monster.get('armor_class', None),
                speed=monster.get('speed', None),
                name=monster.get('name', None),
                size=monster.get('size', None),
                type=monster.get('type', None),
                subtype=monster.get('subtype', None),
                alignment=monster.get('alignment', None),
                hit_dice=monster.get('hit_dice', None),
                stealth=monster.get('stealth', None),
                damage_vulnerabilities=monster.get('damage_vulnerabilities',
                                                   None),
                damage_resistances=monster.get('damage_resistances', None),
                damage_immunities=monster.get('damage_immunities', None),
                condition_immunities=monster.get('condition_immunities', None),
                senses=monster.get('senses', None),
                languages=monster.get('languages', None),
                challenge_rating=monster.get('challenge_rating', None),
                special_abilities=dict_to_rst(
                    monster.get('special_abilities', [])),
                actions=dict_to_rst(monster.get('actions', [])),
            ))

    session.commit()
示例#8
0
    party = toml.load(fin)

characters = [Character(**x) for x in party.values()]

with open('encounters/lmop1.1.1.toml', 'r') as fin:
    encounter = Encounter(**toml.load(fin))
    print(encounter)

for group in encounter.groups.values():
    available_monster_files = glob.glob('monsters/*.toml')
    monsters = []
    for filename in available_monster_files:
        monster = toml.load(open(filename, 'r'))
        if monster['name'] == group['monster']:
            for i in range(group['count']):
                monsters.append(Monster(**monster))
            break
    for i in range(len(monsters)):
        if 'max_hp' in group and len(group['max_hp']) == len(monsters):
            monsters[i].max_hp = group['max_hp'][i]
            monsters[i].cur_hp = group['max_hp'][i]
        else:
            monsters[i].max_hp = monsters[i]._max_hp
            monsters[i].cur_hp = monsters[i].max_hp
    for monster in monsters:
        tm.add_combatant(monster,
                         roll_dice(1, 20, modifier=monster.initiative_mod))

for character in characters:
    tm.add_combatant(character,
                     roll_dice(1, 20, modifier=character.initiative_mod))
示例#9
0
 def __init__(self, width, height):
     super().__init__(width, height, "Monster Keeper")
     self.background = arcade.load_texture("images/homeee.png")  
     self.Snoopy = Snoopy("images/snoopy.png",0.75)
     self.Monster = Monster("images/cookiemon.png", 0.5, self.Snoopy)
示例#10
0
 def on_key_press(self, key, modifiers):
     self.Snoopy.on_key_press(key, modifiers)
     if key == arcade.key.R:
         if self.Monster.score < 0:
             self.Snoopy = Snoopy("images/snoopy.png",0.75)
             self.Monster = Monster("images/cookiemon.png", 0.5, self.Snoopy)
示例#11
0
 def createMonster(self):
     monster = Monster('Rabid Gnome')
     characterLeveler(monster, self.players[0].lvl)
     self.monsters.append(monster)
     messageDirect('A new monster joins the fray!\n', monster)
示例#12
0
 def new_monster(self, name):
     self.add_monster(Monster(name=name))