def find_item_by_attribute(self, attribute):
     items_with_attr = {}
     for item_name in self._inventory:
         item = self._inventory[item_name]
         if (utils.has_attribute(item, attribute)):
             items_with_attr[item_name] = item
     return items_with_attr
 def damage(self):
     config = self.get_config()
     if (utils.has_attribute(config, "damageable")):
         utils.add_attribute(config, "damaged")
         if ("damaged" in config):
             damaged = config.pop("damaged")
             for key in damaged:
                 config[key] = damaged[key]
示例#3
0
    def GET(self, key):
        uid = check_headers()
        if uid is None:
            return result_nok()

        if (utils.has_attribute(uid, key) is True):
            return result_ok()
        else:
            return result_nok()
    def open(self, context):
        if (utils.has_attribute(self._config, "openable")):
            if (utils.has_attribute(self._config, "locked")):
                utils.print_message("Item '{}' is locked.".format(
                    colour.red(self.name)))
                return
            if ("inside" in self._config):
                items = self._config.pop("inside", None)
                self._config["revealed"] = items
                item_name = sorted(items)[
                    0]  # only allow 1 item - inside stuff
                self.add_inventory_items(items)
                if (len(items) > 0):
                    #if(utils.has_attribute(self._config, "door")):
                    if ("opened" in self._config):
                        utils.print_messages(self._config["opened"])
                    ## remove doors after open
                    if (utils.has_attribute(self._config, "door")):
                        context.remove_inventory_item(self.name)

                    if (utils.has_attribute(self._config, "door")):
                        utils.print_message(
                            "You see the '{}' through the '{}'".format(
                                colour.green(item_name),
                                colour.green(self.name)))
                    else:
                        utils.print_message(
                            "You see the '{}' in the '{}'".format(
                                colour.green(item_name),
                                colour.green(self.name)))
                if (self.has_inventory()):
                    context.add_inventory_items(self.get_inventory_items())
        else:
            if ("taken" in self._config and "inside" in self._config["taken"]):
                utils.print_message("{}".format(
                    colour.red(
                        "You cannot open this item until it has been taken.")))
                utils.print_message("Hint: {}".format(
                    colour.green(
                        "Taking items show more details - You may see more detail when examined, and be able to open it!"
                    )))
            return
            utils.print_message("{}".format(
                colour.red("You cannot open this item.")))
示例#5
0
def install_all(self):
    sleep(1)
    ticks = 0
    for entry in db:
        if not utils.has_attribute('exclude_%s' % entry.name):
            if entry.needs_update and entry.create_delta is True or entry.not_installed or entry.create_delta is False:
                ticks += 1
    dia_set_ticks(ticks)
    dia_tick()

    for entry in db:
        if not was_dia_cancelled():
            if not utils.has_attribute('exclude_%s' % entry.name):
                if entry.needs_update and entry.create_delta is True:
                    update_item(self,entry,False)
                    update_tree_view(self)
                elif entry.not_installed or entry.create_delta is False:
                    install_item(self,entry,False)
                    update_tree_view(self)

    wx.CallAfter(dispose_dialog)
示例#6
0
 def unlock(self, context, tool, method):
     if (utils.has_attribute(self._config, "locked")):
         if (self._config["unlock"] == tool.name):
             if (method == "pick"):
                 if (self._config["unlock-method"] == "key"):
                     utils.print_message(
                         "You cannot pick '{}' with a key '{}'.".format(
                             colour.red(self.name),
                             colour.red(tool.name),
                         ))
                     return
                 if (utils.has_attribute(tool.get_config(), "damaged")):
                     utils.print_message(
                         "You cannot pick '{}' with a '{}'.".format(
                             colour.red(self.name),
                             colour.red(tool.name),
                         ))
                     return
                 tool.damage()
             else:
                 if (self._config["unlock-method"] == "pick"):
                     utils.print_message(
                         "You cannot unlock '{}' with a '{}'.".format(
                             colour.red(self.name),
                             colour.red(tool.name),
                         ))
                     return
             utils.remove_attribute(self._config, "locked")
             self.open(context)
         else:
             utils.print_message("You cannot {} '{}' with a '{}'.".format(
                 method,
                 colour.red(self.name),
                 colour.red(tool.name),
             ))
     else:
         utils.print_message("You cannot unlock this item.")
示例#7
0
 def switch(self):               
     if(utils.has_attribute(self._config, "switchable")):                        
         if("event" not in self._config):
              utils.print_message("Config Error: switch '{}' has no event in config.".format(
                 colour.red(location_name)
             ))
         event = self._config["event"]
         if(self.game.locations.is_valid_location_name(event[0])):
             location = self.game.locations.get_location(event[0])
             location.handle_event(event)
         if("switched" in self._config):
             utils.print_messages(self._config["switched"])
         else:
             utils.print_message("Config Error: switch '{}' has bad event location in config.".format(
                 colour.red(location_name)
             ))                
     else:
         utils.print_message("You cannot switch this item.")
 def move(self, context):
     if (utils.has_attribute(self._config, "moveable")):
         if ("inside" in self._config):
             items = self._config.pop("inside", None)
             self._config["revealed"] = items
             item_name = sorted(items)[
                 0]  # only allow 1 item - inside stuff
             self.add_inventory_items(items)
             if (len(items) > 0):
                 if ("moved" in self._config):
                     utils.print_messages(self._config["moved"])
                 utils.print_message(
                     "You see a '{}' after moving the '{}'".format(
                         colour.green(item_name), colour.green(self.name)))
             if (self.has_inventory()):
                 context.add_inventory_items(self.get_inventory_items())
         else:
             utils.print_message("You moved the '{}'".format(
                 colour.green(self.name)))
     else:
         utils.print_message("{}".format(
             colour.red("You cannot move this item.")))
示例#9
0
def refresh_tree(self):
    self.tree.DeleteAllItems()
    self.root = self.tree.AddRoot("Location [%s]" % dir_name)
    image_list = wx.ImageList(16, 16)
    root = image_list.Add(wx.Image("images/root2.png", wx.BITMAP_TYPE_PNG).Scale(16, 16).ConvertToBitmap())
    updated = image_list.Add(wx.Image("images/updated.png", wx.BITMAP_TYPE_PNG).Scale(16, 16).ConvertToBitmap())
    not_installed = image_list.Add(wx.Image("images/notinstalled.png", wx.BITMAP_TYPE_PNG).Scale(16, 16).ConvertToBitmap())
    needs_update = image_list.Add(wx.Image("images/needsupdate.png", wx.BITMAP_TYPE_PNG).Scale(16, 16).ConvertToBitmap())

    self.tree.AssignImageList(image_list)
    self.tree.SetItemImage(self.root, root, wx.TreeItemIcon_Normal)
    for entry in db:
        if not utils.has_attribute('exclude_%s' % entry.name):
            menu_item = self.tree.AppendItem(self.root,entry.name)
            if entry.needs_manual_update:
                self.tree.SetItemImage(menu_item, needs_update, wx.TreeItemIcon_Normal)
            elif entry.not_installed:
                self.tree.SetItemImage(menu_item, not_installed, wx.TreeItemIcon_Normal)
            elif entry.needs_update:
                self.tree.SetItemImage(menu_item, needs_update, wx.TreeItemIcon_Normal)
            else:
                self.tree.SetItemImage(menu_item, updated, wx.TreeItemIcon_Normal)

    self.tree.ExpandAll()
示例#10
0
    def OnInit(self):
        global client_id

        utils.assert_folders()
        utils.migrate_from_tmp()
        try:
            setup_log()
        except:
            wx.MessageBox('Another instance of Assembly is running', 'Unable to start',wx.OK | wx.ICON_ERROR)
            sys.exit(0)

        platform = utils.get_platform()
        auto_upgrade = utils.string2bool(platform['autoupgrade'])

        if len(sys.argv) > 1:
            utils.add_user_attribute('show_info_popup','True')
            utils.delete_folder_async('%s/upgrade' %os.getcwd())
            wx.MessageBox('Congratulations! Assembly64 was upgraded from version %s to %s.' %(sys.argv[1], version), 'Assembly64 upgraded!',wx.OK | wx.ICON_INFORMATION)

        try:
            utils.update_server_db()
            newer_available,force,available_version = utils.check_version(version)
            if newer_available and force:
                update_dia = UpdateDialog(None,"New version available", "New version available. Upgrade is vital!",auto_upgrade, True)
                update_dia.ShowModal()
                if update_dia.is_app_upgrade():
                    upgrade = UpgradeSplash()
                    upgrade.Show()
                    utils.do_upgrade(upgrade,version,platform)
                    os._exit(1)
            elif newer_available and not force:
                update_dia = UpdateDialog(None,"New version available", "New version available, but you can stay with this one.. For now!", auto_upgrade, False)
                update_dia.ShowModal()
                if update_dia.is_app_upgrade():
                    upgrade = UpgradeSplash()
                    upgrade.Show()
                    utils.do_upgrade(upgrade,version,platform)
                    os._exit(1)
        except FtpOverloadedException:
            wx.MessageBox('Too many users right now, please try later', 'Assembly Error',wx.OK | wx.ICON_WARNING)
            sys.exit(0)
        except ftplib.all_errors as a:
            wx.MessageBox('Unable to communicate with Assembly64 server.', 'Assembly Error',wx.OK | wx.ICON_WARNING)
            sys.exit(0)
        except:
            wx.MessageBox('Unable to communicate with assembly64 server.', 'Assembly Error',wx.OK | wx.ICON_WARNING)
            sys.exit(0)

        if not utils.has_attribute('uid'):
            client_id = str(uuid.uuid1())
            utils.add_user_attribute('uid',client_id)
            post_ga_event('application','startup_new_user')

        else:
            client_id = utils.get_user_attribute('uid')
            post_ga_event('application','startup_existing_user')

        if not utils.has_attribute('show_info_popup'):
            utils.add_user_attribute('show_info_popup','true')

        if utils.has_attribute(delete_files_after_install) is False:
            utils.add_user_attribute(delete_files_after_install,'true')

        thread = Thread(target = update_db,args = (10, ))
        thread.start()

        AssemblySplash().Show()
        return 1
示例#11
0
    def __init__(self, parent, title):
        reload(sys)
        sys.setdefaultencoding('utf8')

        log_info('Assembly v.%s started' % version)
        Thread(target=login_user, args=(self,client_id)).start()

        if not initial_db_refresh_done:
            wx.MessageBox('Unable to communicate with server.', 'Assembly Error',wx.OK | wx.ICON_ERROR)
            sys.exit(0)

        width = 300
        height = 600

        wx.Frame.__init__(self, parent, pos=get_pos(width,height), title=title, size=(width,height))
        favicon = wx.Icon('images/bigicon2.ico',wx.BITMAP_TYPE_ICO)
        wx.Frame.SetIcon(self,favicon)
        menu_bar = wx.MenuBar()
        menu = wx.Menu()
        m_open = menu.Append(wx.ID_FILE1, "S&elect SDCard location", "Select the location where your SD card or such is located")
        self.Bind(wx.EVT_MENU, self.on_open, m_open)

        m_refresh_local_db = menu.Append(wx.ID_FILE3, "R&efresh db from server", "")
        self.Bind(wx.EVT_MENU, self.on_refresh_db, m_refresh_local_db)
        self.Bind(wx.EVT_MENU, self.on_exit,menu.Append(wx.ID_FILE8, "Exit", ""))

        menu_bar.Append(menu, "&File")

        artifactsMenu = wx.Menu()

        m_restorehidden = artifactsMenu.Append(wx.ID_FILE6, "Restore view")
        self.Bind(wx.EVT_MENU, self.restore_hidden, m_restorehidden)
        menu_bar.Append(artifactsMenu, "Artifacts")

        m_delta_artifacts = artifactsMenu.Append(wx.ID_FILE2, "Delete artifacts cache", "")
        self.Bind(wx.EVT_MENU, self.on_delete_artifacts, m_delta_artifacts)

        settingsMenu = wx.Menu()

        m_settings = settingsMenu.Append(wx.ID_FILE7, "Settings")
        self.Bind(wx.EVT_MENU, self.view_settings, m_settings)
        menu_bar.Append(settingsMenu, "Misc")

        m_log = settingsMenu.Append(wx.ID_FILE5, "View log", "")
        self.Bind(wx.EVT_MENU, self.on_show_log, m_log)

        m_about = settingsMenu.Append(wx.ID_FILE4, "About", "")
        self.Bind(wx.EVT_MENU, self.on_about, m_about)

        self.SetMenuBar(menu_bar)
        self.tree = wx.TreeCtrl(self, style=wx.TR_DEFAULT_STYLE | wx.TR_FULL_ROW_HIGHLIGHT | wx.TR_EDIT_LABELS)
        self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.on_drag, self.tree)

        if utils.has_attribute(work_dir_key):
            work_dir = utils.get_user_attribute(work_dir_key)
            if os.path.exists(work_dir):
                global dir_name
                dir_name = work_dir
                update_tree_view(self)

        self.Show()

        if utils.get_bool_attribute('show_info_popup') :
            Thread(target=show_info, args=(self,)).start()