def save_export(self):
     helper.save_json_data(
         self.settings_dir + '/export.json', {
             'name': self.ui.lineEditCampaignName.text(),
             'creator': self.ui.lineEditCreator.text(),
             'about': self.ui.plainTextEditAbout.toPlainText()
         })
 def save_standard(self):
     self.save_player_data(
         self.settings_dir + '/std/player.json', self.ui.standardStarting,
         self.ui.standardInventoryList, self.ui.standardCurrency,
         self.ui.standardOtherList, self.ui.standardResourceList,
         self.ui.standardHealthMax, self.ui.standardHealthStart)
     # Globals
     standard_globals = {}
     for index in range(self.ui.standardGlobalsList.count()):
         item = self.ui.standardGlobalsList.itemWidget(
             self.ui.standardGlobalsList.item(index))
         standard_globals[item.get_name()] = item.get_value()
     helper.save_json_data(self.settings_dir + '/std/globals.json',
                           standard_globals)
    def save_data(self):
        name = self.ui.lineEditName.text()
        desc = self.ui.textEditDescription.toPlainText()
        options = []
        option_list = self.ui.optionList
        for index in range(option_list.count()):
            option = option_list.itemWidget(option_list.item(index))
            options.append(option.get_data())

        helper.save_json_data(self.file_location, {
            'name': name,
            'desc': desc,
            'options': options
        })
 def save_debug(self):
     self.save_player_data(self.settings_dir + '/debug/player.json',
                           self.ui.debugStarting,
                           self.ui.debugInventoryList,
                           self.ui.debugCurrency, self.ui.debugOtherList,
                           self.ui.debugResourceList,
                           self.ui.debugHealthMax, self.ui.debugHealthStart)
     # Globals
     debug_globals = {}
     for index in range(self.ui.debugGlobalsList.count()):
         item = self.ui.debugGlobalsList.itemWidget(
             self.ui.debugGlobalsList.item(index))
         debug_globals[item.get_name()] = item.get_value()
     helper.save_json_data(self.settings_dir + '/debug/globals.json',
                           debug_globals)
    def save_player_data(file_location, starting, inventory_list, currency,
                         other_list, resource_list, health_max, health_start):
        start = starting.text()
        # Inventory
        items = {}
        for index in range(inventory_list.count()):
            item = inventory_list.itemWidget(inventory_list.item(index))
            items[item.get_name()] = item.get_count()
        # Stats
        health_info = {
            'min': 0,
            'max': health_max.value(),
            'current': health_start.value()
        }

        other_stats = {}
        for index in range(other_list.count()):
            stat = other_list.itemWidget(other_list.item(index))
            other_stats[stat.stat_id] = stat.get_data()

        resource_stats = {}
        for index in range(resource_list.count()):
            stat = resource_list.itemWidget(resource_list.item(index))
            resource_stats[stat.stat_id] = stat.get_data()

        # Final player save
        helper.save_json_data(
            file_location, {
                'scenario': start,
                'inventory': {
                    'currency': currency.value(),
                    'items': items
                },
                'stats': {
                    'health': health_info,
                    'other': other_stats,
                    'resource': resource_stats
                }
            })
示例#6
0
 def save_data(self):
     helper.save_json_data(self.file_location, self.get_data())
示例#7
0
 def save_data(self):
     helper.save_json_data(self.file_location,
                           self.ui.plainTextEditFunc.toPlainText())