コード例 #1
0
def main():
    seed(datetime.now())

    orcs = [
        Character("Orc-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2,
                  randrange(4)) for i in range(5)
    ]
    orcs += [
        Tank("Orc Tank" + str(i + 1),
             Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2, randrange(4))
        for i in range(5)
    ]
    night_elves = [
        Character("Night Elf" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 3,
                  randrange(3)) for i in range(3)
    ]
    night_elves += [
        Mage("Night Elf Mage" + str(i + 1),
             Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2, randrange(4))
        for i in range(5)
    ]

    a = Arena(orcs, night_elves)
    a.play()
コード例 #2
0
ファイル: main.py プロジェクト: RodersB/RPG
def get_items():
    helm = Equipment(1, 'Leather Cap', 'head', 1, {'armor': 5})
    sword = Equipment(1, 'Rusted Sword', 'main_hand', 1, {
        'attack_speed': 1,
        'damage_range': [5, 10]
    })
    ring = Equipment(1, 'Iron Ring', 'finger', 1, {"hp": 10})
    amulet = Equipment(1, 'Bronze Amulet', 'neck', 1,
                       {'increased_attack_speed': 5})
    return [helm, sword, ring, amulet]
コード例 #3
0
def main():
    seed(datetime.now())
    orcs = [
        Character("Orc-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 2,
                  randrange(4)) for i in range(5)
    ]
    night_elves = [
        Character("Night-Elf-" + str(i + 1),
                  Equipment(uniform(1.1, 1.5), uniform(1.1, 1.3)), 3,
                  randrange(3)) for i in range(5)
    ]

    arena = Arena(orcs, night_elves)
    arena.play()
コード例 #4
0
def wretch(x, y):
    fighter_component = Fighter(current_hp=4,
                                max_hp=4,
                                damage_dice=1,
                                damage_sides=3,
                                armour=0,
                                strength=14,
                                dexterity=10,
                                vitality=12,
                                intellect=8,
                                perception=10,
                                xp=30,
                                dodges=True)
    equipment_component = Equipment(())
    inventory_component = Inventory(10)
    ai_component = AimlessWanderer()
    monster = Entity(
        x,
        y,
        'w',
        libtcod.darker_red,
        'Wretch',
        'A stunted human swaddled in filthy rags and long since driven feral by the SludgeWorks.',
        blocks=True,
        render_order=RenderOrder.ACTOR,
        fighter=fighter_component,
        ai=ai_component,
        inventory=inventory_component,
        equipment=equipment_component,
        regenerates=True,
        faction='Scavengers',
        errasticity=25)
    monster.inventory.spawn_with(monster, iron_dagger(monster.x, monster.y))
    return monster
コード例 #5
0
ファイル: menu.py プロジェクト: TatterTott/CS3030-Fall2019
    def buildCharacterSheet(self, character):
        backgroundList = self.getBGs()

        #get player name
        print("Please enter the name of the player")
        playerName = input()

        #get character name
        print("Please enter the name of the character")
        characterName = input()

        #setting variables like this for now in case we want to put it in a try/except for
        #error handling later
        character.player_name = playerName
        character.char_name = characterName

        #race class will handle all race attributes
        race = Race()

        charClass = CharClass()

        startingEquipment = StartingEquipment()

        equipment = Equipment()

        charBackground = CharBackground(backgroundList)

        #race will be filled in depending on menu selection
        if self.quick == True:
            race.chooseRace(character, menuOption='quick')
            charClass.chooseClass(character, menuOption='quick')
            bg = charBackground.chooseBackground(character, menuOption='quick')
            character.background = bg
        else:
            race.chooseRace(character, menuOption='detailed')
            charClass.chooseClass(character, menuOption='detailed')
            bg = charBackground.chooseBackground(character,
                                                 menuOption='detailed')
            character.background = bg

        startingEquipment.chooseStartingEquipment(character)

        equipment.getEquipmentStats(character)
        self.startingEquipString(character)

        StatRoller.rollForStats(character)

        StatCalculator.update(character)

        self.getPersonalInformation(character)

        charDict = CharacterDictBuilder.builder(character)
        outFile = characterName + '_char_sheet.pdf'

        write_fillable_pdf('.\\CharacterSheetTemplate.pdf', outFile, charDict)

        Sending.email(outFile)

        print("Good day to you Sir/Madam!")
コード例 #6
0
def loadEquipment(equipmentData):
    """Returns an Equipment object for the given data"""
    e = Equipment()
    e.equipmentId = equipmentData["equipmentId"]
    e.name = equipmentData["name"]
    if "abbreviation" in equipmentData:
        e.abbreviation = equipmentData["abbreviation"]
    return e
コード例 #7
0
 def __init__(self, parent = None):
     """
     Constructor
     """
     QMainWindow.__init__(self, parent)
     self.setupUi(self)
     # TODO: temporally load always an instrument
     self._load_equipment(Equipment(self.EQUIPMENT_PATH + "/sidamon.json"))
コード例 #8
0
 def __init__(self, strength, dexterity, attack, defense, hp, x, y):
     super(Hero, self).__init__(attack, defense, Damage(0.5, 1.0, 5, 2),
                                Armor(0.0, 0), hp, x, y)
     self._equipment = Equipment(self)
     self._strength = strength
     self._dexterity = dexterity
     self._experience = 0
     self._skill_points = 0
コード例 #9
0
def post_equipment():
    post_data = request.get_json()
    id = post_data['id']
    produce_name = post_data['produce_name']
    weight = post_data['weight']
    type = post_data['type']
    new_equipment = Equipment(produce_name, weight, type)
    my_dict[id] = new_equipment
    return 'Posted  ' + str(my_dict(id).produceName)
コード例 #10
0
 def get_equipment(weapon_id, shield_id, boots_id, headgear_id,
                   cuirasses_id, gauntlets_id):
     return Equipment(
         weapon=PlayerRepository.get_weapon(weapon_id),
         shield=PlayerRepository.get_shield(shield_id),
         boots=PlayerRepository.get_boots(boots_id),
         headgear=PlayerRepository.get_headgear(headgear_id),
         cuirasses=PlayerRepository.get_cuirasses(cuirasses_id),
         gauntlets=PlayerRepository.get_gauntlets(gauntlets_id))
コード例 #11
0
 def on_action_Open_triggered(self):
     filename = QFileDialog.getOpenFileName(
                                         None,
                                         self.trUtf8("Select an equipment description file"),
                                         QString(self.EQUIPMENT_PATH),
                                         self.trUtf8(self.FILEDIALOG_FILTER),
                                         None)
     if filename:
         self._load_equipment(Equipment(str(filename)))
コード例 #12
0
def get_dummy_actor():
    dummy_actor = Composite()
    dummy_actor.set_child(DoNothingActor())
    dummy_actor.set_child(Equipment())
    dummy_actor.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn))
    dummy_actor.set_child(DataPoint(DataTypes.OFFENCIVE_ATTACK_CHANCE, 0.0))
    dummy_actor.set_child(DataPoint(DataTypes.COUNTER_ATTACK_CHANCE, 0.0))
    dummy_actor.set_child(DataPoint(DataTypes.DEFENCIVE_ATTACK_CHANCE, 0.0))
    dummy_actor.set_child(DataPoint(DataTypes.CRIT_CHANCE, 0.0))

    return dummy_actor
コード例 #13
0
def main():
    # name, port = input("<name> <port>\n").split()
    # port = int(port)
    name = input("<name>\n")
    port = 8888

    equipment = Equipment(name, port)

    while True:
        try:
            print(">>")
            s = input()
            if s == "h":
                print("q => Quitter")
                print("i => Informations de l'équipement")
                print("s => Insertion en tant que server")
                print("c => Insertion en tant que client")
                print("r => Liste des équipements sur le réseau domestique")
                print("certs => Liste des certificats connus")
            elif s == "q":
                break
            elif s == "i":
                print(equipment)
            elif s == "s":
                equipment.server()
            elif s == "c":
                # server_name, server_port = input("<server_name> <server_port>\n").split()
                # server_port = int(server_port)
                server_name, server_port = "localhost", 8888
                equipment.client(server_name, server_port)
            elif s == "r":
                equipment.show_certs_couple()
            elif s == "certs":
                equipment.show_certs()
            else:
                print("Unknown command")
        except NotValidCertificate:
            print(
                "client or server fail the hand_shake because of an invalid certificate. Try again"
            )

        except KeyboardInterrupt:
            print(
                "\nThe user interrupted the process. You can quit by pressing q"
            )

        except Exception as e:
            # If something else happens, does not crash the programm, just resume
            print("##" * 10 + " AN ERROR OCCURED (see log below) " + "##" * 10)
            print(e)
            print("##" * 10 + " AN ERROR OCCURED (see log above) " + "##" * 10)

    print("Main loop finished")
コード例 #14
0
def createEquipment(equipmentData):
    #check that equipmentData is valid
    if not ("name" in equipmentData and type(equipmentData["name"]) == str
            and len(equipmentData["name"]) > 0):
        raise errors.BadRequestError(
            "Equipment must have attribute 'name' (type=str and length>0)")
    #construct the equipment
    e = Equipment()
    e.name = equipmentData["name"]
    if "abbreviation" in equipmentData:
        e.abbreviation = equipmentData["abbreviation"]
    #create the equipment
    EquipmentTable.put_item(Item=e.toDynamo())
    return e
コード例 #15
0
ファイル: PBM_main.py プロジェクト: managadze/cooking
 def __init__(self, equipment_data, recipes):
     self.equipment = Equipment(equipment_data)
     self.recipes = recipes
     self.is_cooking_paused = False
     # все заказы за текущий сеанс работы, {id: BaseOrder}
     self.current_orders_proceed = {}
     # все неприготовленые блюда
     self.current_dishes_proceed = {}
     self.time_to_cook_all_dishes_left = 0
     self.orders_requested_for_delivery = {}
     self.is_free = True
     self.main_queue = asyncio.Queue()
     self.delivety_queue = asyncio.Queue()
     self.maintain_queue = asyncio.Queue()
コード例 #16
0
    def draw(self):
        while True:
            self.clock.tick(30)
            # リストボックスの描画
            self.option_listbox.draw(False)
            self.file_listbox.draw()
            self.Select_Stage(self.file_id)     #ステージ選択処理
            self.messagebox.draw()
            pygame.display.update()
            for event in pygame.event.get():
                # リストボックスに入力
                file_id = self.file_listbox.process(event)
                option_num = self.option_listbox.process(event)
                if event.type == KEYDOWN:
                    self.Key_Event(event)       #押されたキーによって異なる処理
                    if event.key == K_RETURN and self.select_num == 1 and self.file_id != None:
                        return self.Return_Stage(self.stage_path[self.stage_num])
                if event.type == QUIT:
                    return EXIT, None

                if file_id != None:
                    # ファイルが選択されたとき
                    self.file_id = file_id
                    self.stage_path = glob(self.path[self.file_id] + '/*')
                    
                    self.stage_text = self.stage_path
                    self.stage_said_text = []

                    for i, _ in enumerate(self.stage_text):
                        self.stage_said_text.append("Stage" + str(i+1))

                    self.select_num += 1
                    # file_listboxからターゲットを外す
                    self.file_listbox.process(event)
                    self.stage_num = 0

                if option_num != None:
                    # オプションが選択されたとき
                    if option_num == 0:
                        return None, '0'
                    elif option_num == 1:
                        Shop(self.screen, self.data).do()
                        break
                    elif option_num == 2:
                        if Equipment(self.screen, self.data).do() == EXIT:
                            return EXIT, None
                        break
                
            self.screen.fill((0,0,0))
コード例 #17
0
ファイル: monster.py プロジェクト: zhaozhixiangz/TheLastRogue
def set_monster_components(monster, game_state):
    monster.set_child(DataPoint(DataTypes.ENERGY, -gametime.single_turn))
    monster.set_child(DataPoint(DataTypes.GAME_PIECE_TYPE, GamePieceTypes.ENTITY))
    #monster.set_child(DataPoint(DataTypes.CRIT_CHANCE, 0.15))
    monster.set_child(DataPoint(DataTypes.UNARMED_CRIT_CHANCE, 0.15))
    monster.set_child(DataPoint(DataTypes.MOVEMENT_SPEED, gametime.single_turn))
    monster.set_child(DataPoint(DataTypes.MELEE_SPEED, gametime.single_turn))
    monster.set_child(DataPoint(DataTypes.THROW_SPEED, gametime.single_turn))
    monster.set_child(DataPoint(DataTypes.SHOOT_SPEED, gametime.single_turn))
    monster.set_child(DataPoint(DataTypes.SIGHT_RADIUS, constants.COMMON_SIGHT_RADIUS))
    monster.set_child(DataPoint(DataTypes.FACTION, Factions.MONSTER))
    monster.set_child(DataPoint(DataTypes.GAME_STATE, game_state))
    monster.set_child(DataPoint(DataTypes.INTELLIGENCE, IntelligenceLevel.NORMAL))
    monster.set_child(DataPoint(DataTypes.SKIP_ACTION_CHANCE, IntelligenceLevel.NORMAL))

    monster.set_child(Position())
    monster.set_child(CharPrinter())
    monster.set_child(DungeonLevel())
    monster.set_child(StatusDescriptionBar())

    monster.set_child(Mover())
    monster.set_child(CautiousStepper())

    monster.set_child(HealthModifier())
    monster.set_child(Dodger())
    monster.set_child(ArmorChecker())
    monster.set_child(ResistanceChecker())
    monster.set_child(AwarenessChecker())
    monster.set_child(DungeonMask())
    monster.set_child(Vision())
    monster.set_child(Path())

    monster.set_child(ChasePlayerActor())
    monster.set_child(MonsterActorState())
    monster.set_child(HuntPlayerIfHurtMe())
    monster.set_child(StartHuntOnAttack())

    monster.set_child(Equipment())
    monster.set_child(Inventory())
    monster.set_child(EffectQueue())
    monster.set_child(UnarmedAttacker())
    monster.set_child(RemoveEntityOnDeath())
    monster.set_child(PrintDeathMessageOnDeath())
    monster.set_child(MonsterWeightedStepAction(100))
    monster.set_child(StatusFlags([]))
コード例 #18
0
ファイル: views.py プロジェクト: maximfreerider/Lab_1_Java
def add_equipment():
    id = request.json['id']
    type = request.json['type']
    produce_name = request.json['produce_name']
    weight = request.json['weight']
    amort = request.json['amort']

    new_equipment = Equipment()
    new_equipment.id = id
    new_equipment.type = type
    new_equipment.produce_name = produce_name
    new_equipment.weight = weight
    new_equipment.amort = amort

    db.session.add(new_equipment)  # adding to DB elements
    db.session.commit()  # have to write with session.add

    return str(new_equipment.__str__())
コード例 #19
0
    def new_game():
        Game.state = 'playing'
        Game.dungeon_level = 1
        Game.game_msgs = []
        Game.mouse = libtcod.Mouse()
        Game.key = libtcod.Key()
        Game.inventory = []
        Game.panel = libtcod.console_new(Game.SCREEN_WIDTH, Game.PANEL_HEIGHT)
        Game.map = Map(Game.MAP_WIDTH, Game.MAP_HEIGHT)

        libtcod.console_clear(Game.main_console)

        _fighter_component = Components.Fighter(
            hp=100,
            dexterity=4,
            accuracy=20,
            power=4,
            xp=0,
            death_function=Components.player_death)
        Game.player = Object(Game.map.origin[0],
                             Game.map.origin[1],
                             '@',
                             'Drew',
                             libtcod.pink,
                             blocks=True,
                             fighter=_fighter_component)
        Game.player.level = 1
        Game.map.add_object(Game.player)

        _equipment_component = Equipment(slot='right hand', power_bonus=2)
        _obj = Object(0,
                      0,
                      '-',
                      'dagger',
                      libtcod.sky,
                      equipment=_equipment_component)
        Game.inventory.append(_obj)
        _equipment_component.equip()

        Game.message(
            'Welcome stranger! Prepare to perish in the Tombs of the Ancient Kings.',
            libtcod.light_green)
コード例 #20
0
def extract(filepath):
    lines = []
    with open(filepath, 'r') as f:
        for line in f:
            lines.append(line)

    n = int(lines[0].replace(' ', '').replace('\n', ''))

    emplacements = []
    equipments = []

    i = 0
    for line in lines:
        if len(line) > n:
            if i < n:
                emplacements.append(Emplacement(i, line, n))
            else:
                equipments.append(Equipment(i - n, line, n))
            i += 1

    return emplacements, equipments
コード例 #21
0
def get_game_variables(constants):
    fighter_component = Fighter(hp=100, defense=1, power=2)
    inventory_component = Inventory(26)
    level_component = Level()
    equipment_component = Equipment()
    player = Entity(0,
                    0,
                    '@',
                    libtcod.white,
                    'Player',
                    blocks=True,
                    render_order=RenderOrder.ACTOR,
                    fighter=fighter_component,
                    inventory=inventory_component,
                    level=level_component,
                    equipment=equipment_component)
    entities = [player]

    equippable_component = Equippable(EquipmentSlots.MAIN_HAND, power_bonus=2)
    dagger = Entity(0,
                    0,
                    '-',
                    libtcod.sky,
                    'Dagger',
                    equippable=equippable_component)
    player.inventory.add_item(dagger)
    player.equipment.toggle_equip(dagger)

    game_map = GameMap(constants['map_width'], constants['map_height'])
    game_map.make_map(constants['max_rooms'], constants['room_min_size'],
                      constants['room_max_size'], constants['map_width'],
                      constants['map_height'], player, entities)

    message_log = MessageLog(constants['message_x'],
                             constants['message_width'],
                             constants['message_height'])

    game_state = GameStates.PLAYERS_TURN

    return player, entities, game_map, message_log, game_state
コード例 #22
0
def cleansing_hand_purifier(x, y):
    fighter_component = Fighter(current_hp=32,
                                max_hp=32,
                                damage_dice=1,
                                damage_sides=5,
                                armour=0,
                                strength=24,
                                dexterity=14,
                                vitality=16,
                                intellect=10,
                                perception=14,
                                xp=425,
                                dodges=True)
    equipment_component = Equipment(())
    inventory_component = Inventory(10)
    ai_component = AimlessWanderer()
    monster = Entity(
        x,
        y,
        'P',
        libtcod.dark_yellow,
        'Cleansing Hand Purifier',
        'The purifier breathes deeply and calmly as his mail-clad fists tighten around the hilt of his '
        'terrifying, studded morningstar. Although you cannot see any human flesh underneath his plated and '
        'visored form you can be assured that what lies within is utterly untouched by the corrupting '
        'influence of the SludgeWorks, and utterly devoted to preventing further horrific incursions into '
        'Cleansing Hand territory. Never again will the last bastion of purity be defiled by such entropy.',
        blocks=True,
        render_order=RenderOrder.ACTOR,
        fighter=fighter_component,
        ai=ai_component,
        equipment=equipment_component,
        inventory=inventory_component,
        regenerates=True,
        faction='Cleansing Hand',
        errasticity=14)
    monster.inventory.spawn_with(monster, steel_cuirass(x, y))
    monster.inventory.spawn_with(monster, steel_mace(x, y))
    monster.inventory.spawn_with(monster, steel_greatshield(x, y))
    return monster
コード例 #23
0
def cleansing_hand_crusader(x, y):
    fighter_component = Fighter(current_hp=22,
                                max_hp=22,
                                damage_dice=1,
                                damage_sides=4,
                                armour=0,
                                strength=22,
                                dexterity=16,
                                vitality=14,
                                intellect=12,
                                perception=12,
                                xp=350,
                                dodges=True)
    equipment_component = Equipment(())
    inventory_component = Inventory(10)
    ai_component = AimlessWanderer()
    monster = Entity(
        x,
        y,
        'C',
        libtcod.yellow,
        'Cleansing Hand Crusader',
        'The staple foot soldier of the Cleansing Hand. With his bucket helm, emblazoned tabard and well-'
        'maintained platemail it is easy to see how these defenders of the faith are commonly known as '
        'crusaders. Their tactics, however, as anything but medieval - intimidatingly rigorous discipline '
        'combined with years of experience slaying deformed monstrosities leaves the crusaders fully able '
        'to hold their own against many daily challenges experienced within the SludgeWorks.',
        blocks=True,
        render_order=RenderOrder.ACTOR,
        fighter=fighter_component,
        ai=ai_component,
        equipment=equipment_component,
        inventory=inventory_component,
        regenerates=True,
        faction='Cleansing Hand',
        errasticity=67)
    monster.inventory.spawn_with(monster, steel_cuirass(x, y))
    monster.inventory.spawn_with(monster, steel_longsword(x, y))
    monster.inventory.spawn_with(monster, steel_greatshield(x, y))
    return monster
コード例 #24
0
ファイル: player.py プロジェクト: mazsak/elements_game
    def __init__(self):
        super().__init__()
        self.master = window.Window.get_instance()

        self.keyMap = {
            self.master.bind[Bind.FWD.value]: False,
            self.master.bind[Bind.BWD.value]: False,
            self.master.bind[Bind.RIGHT.value]: False,
            self.master.bind[Bind.LEFT.value]: False,
            self.master.bind[Bind.UP.value]: False,
            self.master.bind[Bind.DOWN.value]: False,
            self.master.bind[Bind.SPACE.value]: False
        }
        self.equipment = Equipment(self)

        self.rotation = [-70, 140]

        height = 2.5
        radius = 0.4
        character_shape = BulletCapsuleShape(radius, height - 2 * radius, ZUp)
        self.player_node = BulletCharacterControllerNode(
            character_shape, 0.4, 'Player')
        self.player_node_path = self.master.world_node.attachNewNode(
            self.player_node)
        self.player_node_path.setPos(90, 31, 395)
        self.player_node_path.setCollideMask(BitMask32.allOn())

        self.master.camera.reparentTo(self.player_node_path)
        self.master.camera.setY(self.master.camera, -5)

        self.camera_model = self.master.loader.loadModel(
            "mesh/models/person/person")
        self.camera_model.reparentTo(self.player_node_path)

        self.bind()

        self.master.taskMgr.add(self.camera_control, "Camera Control")

        self.master.world.attachCharacter(self.player_node_path.node())
コード例 #25
0
def eternal_kidnapper(x, y):
    fighter_component = Fighter(current_hp=10,
                                max_hp=10,
                                damage_dice=2,
                                damage_sides=4,
                                armour=0,
                                strength=20,
                                dexterity=10,
                                vitality=12,
                                intellect=10,
                                perception=18,
                                xp=200,
                                dodges=True)
    equipment_component = Equipment(())
    inventory_component = Inventory(10)
    ai_component = AimlessWanderer()
    monster = Entity(
        x,
        y,
        'k',
        libtcod.light_fuchsia,
        'Eternal Cult Kidnapper',
        'By far the most notorious member of the Cult of Eternity and arguably serving the most '
        'necessary role within their hierarchy. Their mission is simple: Kidnap the most virginal '
        'entrants into the SludgeWorks so that the flow of flesh into the Palace of Hedonism is '
        'constant and plentiful. The way they creep through the caverns with their threatening iron '
        'blackjack makes this intention undeniably clear.',
        blocks=True,
        render_order=RenderOrder.ACTOR,
        fighter=fighter_component,
        ai=ai_component,
        equipment=equipment_component,
        inventory=inventory_component,
        regenerates=True,
        faction='Cultists',
        errasticity=67)
    monster.inventory.spawn_with(monster, leather_armour(x, y))
    monster.inventory.spawn_with(monster, iron_buckler(x, y))
    return monster
コード例 #26
0
ファイル: player.py プロジェクト: SanbyB/LD48
 def __init__(self, world, onPlayerDead):
     super().__init__(
         (TILE_MAP_WIDTH / 2) * TILE_SIZE,
         -100,
         40,
         64
     )
     self.onPlayerDead = onPlayerDead
     self.invtry = []
     self.world = world
     self.didJump = False
     self.hp = 20
     self.theta = None  # angle of attack
     self.atk_counter = 0
     self.atk_speed = 25
     self.atk_strength = 3
     self.atk_range = 30000
     self.isFlipped = False
     self.hitCount = 0
     self.equipment = Equipment(world, self)
     self.too_fast = 0  # Fall damage
     self.score = 0
     self.stepFreq = 0
コード例 #27
0
    def test_gen_good_chain_line(self):
        """
        tests weither equipment A can create a chain to B via C

        B -> C -> A
        """
        equipmentA = Equipment(name="name", port=8888)

        chain = set()
        kp_B = KeyPair()
        kp_C = KeyPair()
        kp_A = equipmentA.key_pair

        cert_BC = X509Certificate(
            issuer="B",
            subject="C",
            public_key=kp_C.public_key(),
            private_key=kp_B.private_key(),
            validity_days=10,
        )

        cert_CA = X509Certificate(
            issuer="C",
            subject="A",
            public_key=kp_A.public_key(),
            private_key=kp_C.private_key(),
            validity_days=10,
        )

        equipmentA.DA.add(
            AutorityProof(issuer_key=kp_B.public_key(), cert_from_issuer=cert_BC)
        )
        equipmentA.DA.add(
            AutorityProof(issuer_key=kp_C.public_key(), cert_from_issuer=cert_CA)
        )

        assert equipmentA.create_cert_chain(kp_B.public_key()) == [cert_BC, cert_CA]
コード例 #28
0
def get_game_variables(
) -> Tuple[Entity, List[Entity], GameMap, MessageLog, GameStates]:
    player = Entity(0,
                    0,
                    '@',
                    tcod.white,
                    'Player',
                    blocks=True,
                    render_order=RenderOrder.ACTOR,
                    fighter=Fighter(hp=100, defense=1, power=2),
                    inventory=Inventory(26),
                    equipment=Equipment(),
                    level=Level())
    entities = [player]

    dagger = Entity(0,
                    0,
                    '-',
                    tcod.sky,
                    'Dagger',
                    render_order=RenderOrder.ITEM,
                    equippable=Equippable(EquipmentSlots.MAIN_HAND,
                                          power_bonus=2))
    player.inventory.add_item(dagger)
    player.equipment.toggle_equip(dagger)

    game_map = GameMap(constants.map_width, constants.map_height)
    game_map.make_map(constants.max_rooms, constants.room_min_size,
                      constants.room_max_size, player, entities)

    message_log = MessageLog(constants.message_x, constants.message_width,
                             constants.message_height)

    game_state = GameStates.PLAYERS_TURN

    return player, entities, game_map, message_log, game_state
コード例 #29
0
f = Functions()
u = User()
l = Log()
e = Employees()
n = Notification()
ins = InsepectionAndAcceptanceReceipt()
pOrd = PurchaseOrder()
preq = PurchaseRequest()
propAR = PropertyAcceptanceReceipt()
reqQ = RequestForQuotation()
pord = PurchaseOrder()
off = Offices()
kp = KeyPositions()
suppl = Suppliers()
itemC = Items()
equip = Equipment()
ris_Class = RequisitionAndIssuanceSlip()
supplyC = Supply()
waste_Class = Waste()
abc = AbstractOfCanvass()

templateFolder = 'inventory_office'
urlHead = '/inventory_office_sup_off'


def index(request):
    return setReponse(request, templateFolder + '/home_new_again.html', [], [],
                      [], [], [
                          ('inventory_office/base.html', ),
                      ])
コード例 #30
0
def check_deaths():
    for p in range(len(players)):
        if players[p].is_dead():
            print("\n{} was defeated.".format(players[p].get_name()))
            sleep(delay)

            del players[p]

    for e in range(len(enemies)):
        if enemies[e].is_dead():
            print("\n{} was defeated.".format(enemies[e].get_name()))
            sleep(delay)

            for player in players:
                # Experience gain
                player.change_exp(enemies[e].get_exp())
                print("{} gained {} EXP.".format(player.get_name(),
                                                 enemies[e].get_exp()))
                sleep(delay)
                while player.check_lvl():
                    player.lvl_up()
                    print("{} leveled up to level {}.".format(
                        player.get_name(), player.get_lvl()))
                    sleep(delay)

                # Rolls for items
                with open("enemy_data/{}.txt".format(
                        enemies[e].get_name().lower().replace(' ',
                                                              '_'))) as f_in:
                    enemy = f_in.readlines()
                    if len(
                            enemy
                    ) > 1:  # Item drops of enemy are stored after first line of enemy file
                        for item_drop in enemy[1:]:
                            if randint(1, 100) <= int(
                                    item_drop.split()[1]):  # Rolls for item
                                with open("item_data/{}.txt".format(
                                        item_drop.split()[0])) as f_in2:
                                    item_type = f_in2.readline().strip()

                                    # For equipment items
                                    if item_type == "equipment":
                                        new_item = f_in2.readline().split()

                                        # If player does not already have an equipment item of the same type
                                        if player.check_equipment_type(
                                                new_item[1]) == -1:
                                            potential_equip = Equipment(
                                                new_item[0].replace('_', ' '),
                                                new_item[1], int(new_item[2]),
                                                int(new_item[3]),
                                                int(new_item[4]),
                                                int(new_item[5]))
                                            print("{} found {}.".format(
                                                player.get_name(),
                                                potential_equip.get_name()))
                                            sleep(delay)
                                            potential_equip.display()
                                            sleep(delay)

                                            while True:
                                                p_input = input(
                                                    "'T' to take equipment, 'D' to discard equipment."
                                                )
                                                if p_input.lower() == 't':
                                                    player.add_equipment(
                                                        potential_equip)
                                                    print("{} took {}.".format(
                                                        player.get_name(),
                                                        potential_equip.
                                                        get_name()))
                                                    sleep(delay)
                                                    break
                                                elif p_input.lower() == 'd':
                                                    print(
                                                        "{} discarded {}.".
                                                        format(
                                                            player.get_name(),
                                                            potential_equip.
                                                            get_name()))
                                                    sleep(delay)
                                                    break
                                                else:
                                                    print(
                                                        "Invalid response: Expected 'T' or 'D'."
                                                    )
                                                    sleep(delay)

                                        # Else, asks player whether to replace it or not
                                        else:
                                            potential_equip = Equipment(
                                                new_item[0].replace('_', ' '),
                                                new_item[1], int(new_item[2]),
                                                int(new_item[3]),
                                                int(new_item[4]),
                                                int(new_item[5]))
                                            print(
                                                "{} found {} but already has a(n) {}."
                                                .format(
                                                    player.get_name(),
                                                    potential_equip.get_name(),
                                                    potential_equip.get_type()
                                                ))
                                            sleep(delay)
                                            print("Old:")
                                            sleep(delay)
                                            player.get_equipment()[
                                                player.check_equipment_type(
                                                    potential_equip.get_type(
                                                    ))].display()
                                            sleep(delay)
                                            print("New:")
                                            sleep(delay)
                                            potential_equip.display()
                                            sleep(delay)

                                            while True:
                                                p_input = input(
                                                    "'T' to take new equipment, 'K' to keep old equipment."
                                                )
                                                if p_input.lower() == 't':
                                                    print(
                                                        "{} discarded {} and took {}."
                                                        .format(
                                                            player.get_name(),
                                                            player.
                                                            get_equipment()
                                                            [player.
                                                             check_equipment_type(
                                                                 potential_equip
                                                                 .get_type()
                                                             )].get_name(),
                                                            potential_equip.
                                                            get_name()))
                                                    player.add_equipment(
                                                        potential_equip)
                                                    sleep(delay)
                                                    break
                                                elif p_input.lower() == 'k':
                                                    print(
                                                        "{} discarded {} and kept {}."
                                                        .format(
                                                            player.get_name(),
                                                            potential_equip.
                                                            get_name(),
                                                            player.
                                                            get_equipment()
                                                            [player.
                                                             check_equipment_type(
                                                                 potential_equip
                                                                 .get_type()
                                                             )].get_name()))
                                                    sleep(delay)
                                                    break
                                                else:
                                                    print(
                                                        "Invalid response: Expected 'T' or 'K'."
                                                    )
                                                    sleep(delay)

                                    # For consumable items
                                    elif item_type == "consumable":
                                        new_item = f_in2.readline().split()

                                        potential_item = Consumable(
                                            new_item[0].replace('_', ' '),
                                            int(new_item[1]), int(new_item[2]))
                                        print("{} found {}.".format(
                                            player.get_name(),
                                            potential_item.get_name()))
                                        sleep(delay)
                                        potential_item.display()
                                        sleep(delay)

                                        while True:
                                            p_input = input(
                                                "'T' to take item, 'D' to discard item."
                                            )
                                            if p_input.lower() == 't':
                                                player.add_item(potential_item)
                                                print("{} took {}.".format(
                                                    player.get_name(),
                                                    potential_item.get_name()))
                                                sleep(delay)
                                                break
                                            elif p_input.lower() == 'd':
                                                print(
                                                    "{} discarded {}.".format(
                                                        player.get_name(),
                                                        potential_item.
                                                        get_name()))
                                                sleep(delay)
                                                break
                                            else:
                                                print(
                                                    "Invalid response: Expected 'T' or 'D'."
                                                )
                                                sleep(delay)

            del enemies[e]