예제 #1
0
def main():
    gameStateObj = GameStateObj.GameStateObj()
    metaDataObj = {}
    gameStateObj.build_new()
    wait_for = 1
    for num in range(0, GC.cf.CONSTANTS['num_levels']):
        time1 = time.clock()
        print('Level: %s' % num)
        SaveLoad.load_level('Data/Level' + str(num), gameStateObj, metaDataObj)
        print('Time to Load: %s' % (time.clock() - time1))
        print('Num Units: %s  Map Size: %s' %
              (len(gameStateObj.allunits),
               gameStateObj.map.width * gameStateObj.map.height))
        for unit in gameStateObj.allunits:
            CustomObjects.handle_info_key(gameStateObj, metaDataObj, unit)
            info_menu = InfoMenu.InfoMenu()
            info_menu.begin(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            # Move right
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)

        gameStateObj.clean_up()
        print('Num Units Remaining: %s' % (len(gameStateObj.allunits)))
예제 #2
0
 def parse_tile_line(self, coord, property_list):
     if coord not in self.tile_info_dict:
         self.tile_info_dict[coord] = {}
     for tile_property in property_list:
         property_name, property_value = tile_property.split('=')
         if property_name in ("Escape", "Arrive"):
             self.escape_highlights[coord] = CustomObjects.Highlight(GC.IMAGESDICT["YellowHighlight"])
         elif property_name == "Formation":
             self.formation_highlights[coord] = CustomObjects.Highlight(GC.IMAGESDICT["BlueHighlight"])
         self.tile_info_dict[coord][property_name] = property_value
예제 #3
0
def main():
    gameStateObj = GameStateObj.GameStateObj()
    metaDataObj = {}
    gameStateObj.build_new()
    gameStateObj.set_generic_mode()
    wait_for = 1
    num = 0
    while True:
        levelfolder = 'Assets/Lex-Talionis/Data/Level' + str(num)
        if not os.path.exists(levelfolder):
            break
        print('Level: %s' % num)
        time1 = time.clock()
        SaveLoad.load_level('Assets/Lex-Talionis/Data/Level' + str(num),
                            gameStateObj, metaDataObj)
        print('Time to Load: %s' % (time.clock() - time1))
        print('Num Units: %s  Map Size: %s' %
              (len(gameStateObj.allunits),
               gameStateObj.map.width * gameStateObj.map.height))
        for unit in gameStateObj.allunits:
            CustomObjects.handle_info_key(gameStateObj, metaDataObj, unit)
            info_menu = InfoMenu.InfoMenu()
            info_menu.begin(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            # Move right
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)
            info_menu.move_right(gameStateObj, metaDataObj)
            for _ in range(wait_for):
                run(gameStateObj, metaDataObj, info_menu)

        gameStateObj.clean_up()
        print('Num Units Remaining: %s' % (len(gameStateObj.allunits)))

        num += 1
예제 #4
0
    def __init__(self, window):
        super(UnitView, self).__init__(window)
        self.grid = QtGui.QGridLayout()
        self.window = window
        # window.setLayout(self.grid)
        self.current_unit = None

        # === Unit Face Display ===
        face_grid = QtGui.QGridLayout()

        self.portrait = QtGui.QLabel()
        face_grid.addWidget(self.portrait, 0, 0, 4, 4, QtCore.Qt.AlignCenter)

        self.smile_button = QtGui.QPushButton('Smile')
        self.smile_button.setCheckable(True)
        self.smile_button.clicked.connect(self.smile)
        self.talk_button = QtGui.QPushButton('Talk')
        self.talk_button.setCheckable(True)
        self.talk_button.clicked.connect(self.talk)
        face_grid.addWidget(self.smile_button, 4, 0, 1, 2)
        face_grid.addWidget(self.talk_button, 4, 2, 1, 2)

        blink_label = QtGui.QLabel('Blink Pos. (x, y)')
        mouth_label = QtGui.QLabel('Mouth Pos. (x, y)')
        face_grid.addWidget(blink_label, 5, 0, 1, 2)
        face_grid.addWidget(mouth_label, 5, 2, 1, 2)
        self.portrait_pos_boxes = []
        for num in xrange(4):
            box = QtGui.QSpinBox()
            box.setMinimum(0)
            box.setMaximum(96)
            face_grid.addWidget(box, 6, num)
            self.portrait_pos_boxes.append(box)

        # === Character Data ===
        char_grid = QtGui.QGridLayout()

        # Name
        name_label = QtGui.QLabel('Name:')
        char_grid.addWidget(name_label, 0, 0, 1, 2)
        self.name = QtGui.QLineEdit()
        self.name.setMaxLength(12)
        self.name.setStatusTip("Change name")
        char_grid.addWidget(self.name, 0, 1, 1, 2)
        # Level
        level_label = QtGui.QLabel('Level:')
        char_grid.addWidget(level_label, 1, 0)
        self.level = QtGui.QSpinBox()
        self.level.setMinimum(1)
        char_grid.addWidget(self.level, 1, 1)
        # Gender
        gender_label = QtGui.QLabel('Gender:')
        char_grid.addWidget(gender_label, 1, 2)
        self.gender = QtGui.QSpinBox()
        self.gender.setMinimum(0)
        self.gender.setMaximum(9)
        char_grid.addWidget(self.gender, 1, 3)
        # Class
        klass_label = QtGui.QLabel('Class:')
        char_grid.addWidget(klass_label, 2, 0)
        self.klass = QtGui.QComboBox()
        self.klass.uniformItemSizes = True
        self.klass.setIconSize(QtCore.QSize(48, 32))
        for klass in class_data:
            if 'icon' in klass and klass['icon']:
                self.klass.addItem(klass['icon'], klass['name'])
            else:
                self.klass.addItem(klass['name'])
        char_grid.addWidget(self.klass, 2, 1, 1, 3)

        # Faction
        faction_label = QtGui.QLabel('Faction:')
        char_grid.addWidget(faction_label, 3, 0)
        self.faction = QtGui.QLineEdit()
        char_grid.addWidget(self.faction, 3, 1, 1, 3)
        # Lordbox
        self.lord = QtGui.QCheckBox('Lord?')
        char_grid.addWidget(self.lord, 4, 0, 1, 2)
        # Boss box
        self.boss = QtGui.QCheckBox('Boss?')
        char_grid.addWidget(self.boss, 4, 2, 1, 2)

        # Description
        desc_label = QtGui.QLabel('Desc:')
        char_grid.addWidget(desc_label, 5, 0)
        self.desc = QtGui.QTextEdit()
        char_grid.addWidget(self.desc, 5, 1, 2, 3)

        # === Stats ===
        stat_grid = QtGui.QGridLayout()
        # Names
        stats_label = QtGui.QLabel('Stats:')
        stat_grid.addWidget(stats_label, 0, 0)
        for index, stat_name in enumerate(cf.CONSTANTS['stat_names']):
            stat_label = QtGui.QLabel(stat_name)
            stat_grid.addWidget(stat_label, 0, index + 1)

        bases_label = QtGui.QLabel('Bases:')
        stat_grid.addWidget(bases_label, 1, 0)
        growths_label = QtGui.QLabel('Growths:')
        stat_grid.addWidget(growths_label, 2, 0)

        self.stat_bases = [
            QtGui.QSpinBox() for stat in cf.CONSTANTS['stat_names']
        ]
        self.stat_growths = [
            QtGui.QSpinBox() for stat in cf.CONSTANTS['stat_names']
        ]
        for index, s in enumerate(self.stat_bases):
            s.setMinimum(0)
            s.setMaximum(cf.CONSTANTS['max_stat'])
            stat_grid.addWidget(s, 1, index + 1)
        for index, s in enumerate(self.stat_growths):
            s.setSingleStep(5)
            s.setMaximum(500)
            stat_grid.addWidget(s, 2, index + 1)

        # === Weapon Exp ===
        wexp_grid = QtGui.QGridLayout()
        wexp_label = QtGui.QLabel('Wexp:')
        wexp_grid.addWidget(wexp_label, 0, 0, 2, 1)
        weapon_types = CustomObjects.WEAPON_TRIANGLE.types
        for index, wexp_name in enumerate(weapon_types):
            name_label = QtGui.QLabel(wexp_name)
            icon_label = QtGui.QLabel()
            wexp_icon = CustomObjects.WeaponIcon(idx=index)
            icon_label.setPixmap(
                create_pixmap(wexp_icon.image.convert_alpha(), self.window))
            wexp_grid.addWidget(name_label, 0, (index + 1) * 2 + 1)
            wexp_grid.addWidget(icon_label, 0, (index + 1) * 2)
        self.wexp = [QtGui.QSpinBox() for wexp in weapon_types]
        for index, s in enumerate(self.wexp):
            s.setMinimum(0)
            s.setMaximum(CustomObjects.WEAPON_EXP.sorted_list[-1][1])
            wexp_grid.addWidget(s, 1, (index + 1) * 2, 1, 2)
        # Horizontal line
        line = QtGui.QFrame()
        line.setFrameStyle(QtGui.QFrame.HLine)
        line.setLineWidth(0)
        wexp_grid.addWidget(line, 2, 0, 1, len(self.wexp) * 2 + 2)

        # === Items ===
        item_grid = QtGui.QGridLayout()
        item_label = QtGui.QLabel('Item:')
        drop_label = QtGui.QLabel('Drop?')
        event_label = QtGui.QLabel('Event?')
        self.add_item_button = QtGui.QPushButton('Add Item')
        self.add_item_button.clicked.connect(self.add_item)
        self.remove_item_button = QtGui.QPushButton('Remove Item')
        self.remove_item_button.clicked.connect(self.remove_item)
        self.remove_item_button.setEnabled(False)

        self.items = []
        for num in xrange(cf.CONSTANTS['max_items']):
            self.items.append((self.create_item_combo_box(), QtGui.QCheckBox(),
                               QtGui.QCheckBox()))
        for index, item in enumerate(self.items):
            item_box, drop, event = item
            item_grid.addWidget(item_box, index + 1, 0, 1, 2,
                                QtCore.Qt.AlignTop)
            item_grid.addWidget(drop, index + 1, 2, QtCore.Qt.AlignTop)
            item_grid.addWidget(event, index + 1, 3, QtCore.Qt.AlignTop)

        item_grid.addWidget(item_label, 0, 0, 1, 2, QtCore.Qt.AlignTop)
        item_grid.addWidget(drop_label, 0, 2, QtCore.Qt.AlignTop)
        item_grid.addWidget(event_label, 0, 3, QtCore.Qt.AlignTop)
        item_grid.addWidget(self.add_item_button,
                            cf.CONSTANTS['max_items'] + 2, 0, 1, 2,
                            QtCore.Qt.AlignBottom)
        item_grid.addWidget(self.remove_item_button,
                            cf.CONSTANTS['max_items'] + 2, 2, 1, 2,
                            QtCore.Qt.AlignBottom)
        self.clear_items()

        # === Personal Skills ===
        skill_grid = QtGui.QGridLayout()
        skill_label = QtGui.QLabel('Personal Skill:')
        self.add_skill_button = QtGui.QPushButton('Add Skill')
        self.add_skill_button.clicked.connect(self.add_skill)
        self.remove_skill_button = QtGui.QPushButton('Remove Skill')
        self.remove_skill_button.clicked.connect(self.remove_skill)
        self.remove_skill_button.setEnabled(False)

        self.skills = []
        for num in xrange(cf.CONSTANTS['num_skills']):
            self.skills.append(self.create_skill_combo_box())
        for index, skill_box in enumerate(self.skills):
            skill_grid.addWidget(
                skill_box,
                index + 1,
                0,
                1,
                2,
            )

        skill_grid.addWidget(skill_label, 0, 0, 1, 2, QtCore.Qt.AlignTop)
        skill_grid.addWidget(self.add_skill_button,
                             cf.CONSTANTS['num_skills'] + 2, 0)
        skill_grid.addWidget(self.remove_skill_button,
                             cf.CONSTANTS['num_skills'] + 2, 1)
        self.clear_skills()

        # === Final gridding ===
        self.grid.addLayout(self.stretch(face_grid), 0, 0)
        self.grid.addLayout(self.stretch(char_grid), 0, 1)
        self.grid.addLayout(self.stretch(stat_grid), 1, 0, 1, 2)
        self.grid.addLayout(self.stretch(wexp_grid), 2, 0, 1, 2)
        # item_frame = QtGui.QFrame()
        # item_frame.setFrameStyle(QtGui.QFrame.StyledPanel)
        # item_frame.setLineWidth(0)
        # item_frame.setLayout(self.stretch(item_grid))
        self.grid.addLayout(self.stretch(item_grid), 3, 0)
        self.grid.addLayout(self.stretch(skill_grid), 3, 1)

        # === Timing ===
        self.main_timer = QtCore.QTimer()
        self.main_timer.timeout.connect(self.tick)
        self.main_timer.start(33)  # 30 FPS
        self.elapsed_timer = QtCore.QElapsedTimer()
        self.elapsed_timer.start()