def populate_list(self): try: try: if not splash.isHidden(): splash.showMessage(f"Connecting to server..", color=splash_color) except NameError: pass # Get apps json loaded_json = metadata.get_apps(host_name=HOST_NAME) i = 0 for package in loaded_json: try: self.ui.listAppsWidget.addItem(f"{package['display_name']}\n" f"{metadata.file_size(package['extracted'])} | " f"{package['version']} | " f"{package['coder']} | " f"{package['short_description']}") list_item = self.ui.listAppsWidget.item(i) list_item.setData(Qt.UserRole, package) # Set category icon category = package["category"] # real icons test: if realicons is specified, set icon if utils.is_test("realicons"): list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/testicon.png"))) else: if category == "utilities": list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/utility.png"))) elif category == "games": list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/game.png"))) elif category == "emulators": list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/emulator.png"))) elif category == "media": list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/media.png"))) elif category == "demos": list_item.setIcon(QIcon(resource_path("assets/gui/icons/category/demo.png"))) try: if not splash.isHidden(): splash.showMessage(f"Loaded {i} apps..", color=splash_color) except NameError: pass i += 1 except IndexError: pass self.sort_list_alphabetically() self.ui.listAppsWidget.setCurrentRow(0) self.ui.AppsAmountLabel.setText(str(self.ui.listAppsWidget.count()) + " Apps") except Exception as e: QMessageBox.critical(self, 'OSCDL: Critical Network Error', 'Could not connect to the Open Shop Channel server.\n' 'Cannot continue. :(\n' 'Please check your internet connection, or report this incident.\n\n' f'{e}') sys.exit(1)
def build_for_target(self, target, max_turns=8): corpus_size = len(self.corpus[0]) p = np.zeros(corpus_size) for i in range(len(self.corpus[0])): if target in self.keywords[i]: p[i] = 1 mask = 1 - p p = [self.transition_mat.dot(p) * mask] for i in range(max_turns): p.append( self.transition_mat.dot( self.transition_mat.multiply( p[-1]).max(axis=-1).todense().getA().reshape(-1)) * mask) if is_test('build_for_target'): from IPython import embed embed() self.p = sum(p)
import secret_setting alrim_api_base_url = 'https://api-alimtalk.cloud.toast.com' alrim_api_app_key = secret_setting.alrim_api_app_key secret = secret_setting.secret sms_api_base_url = 'https://api-sms.cloud.toast.com' sms_api_app_key = secret_setting.sms_api_app_key alrim_header = { 'X-Secret-Key': secret, 'Content-Type': 'application/json;charset=UTF-8' } sms_header = {'Content-Type': 'application/json;charset=UTF-8'} if utils.is_test(): plus_friend_id = 'ah_cha' else: plus_friend_id = 'acha' def send_interval_alrim(phone_number, store_name, person_name, person_num, date, until_date, road_address, detail_address, token): date = utils.datetime2str(date) until_date = int(until_date) if until_date >= 1440: template_code = 'RRM0004' until_date = '%d일' % (until_date // 1440) else: template_code = 'RRM0003' if until_date >= 60:
def __init__(self, test_mode=False): super(MainWindow, self).__init__() self.ui = gui.ui_united.Ui_MainWindow() self.ui.setupUi(self) self.test_mode = test_mode # Set title and icon of window self.setWindowTitle(f"Open Shop Channel Downloader v{DISPLAY_VERSION} - Library") app_icon = QIcon(resource_path("assets/gui/windowicon.png")) self.setWindowIcon(app_icon) self.current_category = "all" self.current_developer = "" self.repo_data = None # Set GUI Icons # ABOUT self.ui.actionAbout_OSC_DL.setIcon(QIcon(resource_path("assets/gui/icons/about-open-version.png"))) # CLIENTS self.ui.menuHomebrew_Browser.setIcon(QIcon(resource_path("assets/gui/icons/hbb-icon.png"))) self.ui.actionDownload_HBB_Client_Latest.setIcon(QIcon(resource_path("assets/gui/icons/download.png"))) self.ui.actionCheck_for_Updates.setIcon(QIcon(resource_path("assets/gui/icons/check-for-updates.png"))) self.ui.actionRefresh.setIcon(QIcon(resource_path("assets/gui/icons/refresh.png"))) # DEBUG self.ui.actionEnable_Log_File.setIcon(QIcon(resource_path("assets/gui/icons/enable-log.png"))) self.ui.actionClear_Log.setIcon(QIcon(resource_path("assets/gui/icons/clear-log.png"))) self.ui.actionClose_the_shop.setIcon(QIcon(resource_path("assets/gui/icons/close-shop.png"))) self.ui.menuExperimental.setIcon(QIcon(resource_path("assets/gui/icons/experimental.png"))) self.ui.actionSelect_Theme.setIcon(QIcon(resource_path("assets/gui/icons/theme.png"))) # DEBUG -> EXPERIMENTAL self.ui.menuAnnouncement_Banner.setIcon(QIcon(resource_path("assets/gui/icons/announcement-banner.png"))) # DEBUG -> EXPERIMENTAL -> ANNOUNCEMENT BANNER self.ui.actionDisplay_Banner.setIcon(QIcon(resource_path("assets/gui/icons/announcement-banner-reload.png"))) # CATEGORIES COMBOBOX self.ui.CategoriesComboBox.setItemIcon(1, QIcon(resource_path("assets/gui/icons/category/utility.png"))) self.ui.CategoriesComboBox.setItemIcon(2, QIcon(resource_path("assets/gui/icons/category/emulator.png"))) self.ui.CategoriesComboBox.setItemIcon(3, QIcon(resource_path("assets/gui/icons/category/game.png"))) self.ui.CategoriesComboBox.setItemIcon(4, QIcon(resource_path("assets/gui/icons/category/media.png"))) self.ui.CategoriesComboBox.setItemIcon(5, QIcon(resource_path("assets/gui/icons/category/demo.png"))) # real icons test: if realicons is specified, set size of icon to 171x64 if utils.is_test("realicons"): self.ui.listAppsWidget.setIconSize(QSize(171, 32)) # create spinner movie self.spinner = QMovie(resource_path("assets/gui/icons/spinner.gif")) self.spinner.setScaledSize(QSize(32, 32)) self.spinner.start() self.ui.longDescriptionLoadingSpinner.setMovie(self.spinner) self.populate() self.selection_changed() self.status_message("Ready to download") self.ui.progressBar.setHidden(False) self.ui.statusBar.addPermanentWidget(self.ui.progressBar) # Load announcement banner t = threading.Thread(target=self.load_announcement_banner) t.start()
async def on_ready(): print("Ready!") if utils.is_test(): from commands import console await console.execute(db)
def __init__(self, db: PostgreSQL, user_id: int): super().__init__(db, 'users', dict(id=user_id)) self.id = user_id self.member = None self._tutorial_stage: DictRef[int] = DictRef(self._data, 'tutorial') if utils.is_test(): self._tutorial_stage.set(-1) self.upgrades_row = Row(db, 'user_upgrades', dict(user_id=user_id)) self.upgrades = { 'bank': upgrades.UpgradeLink(upgrades.BANK_LIMIT, DictRef(self.upgrades_row._data, 'bank'), before=self._update_bank_limit), 'money': upgrades.UpgradeLink(upgrades.MONEY_LIMIT, DictRef(self.upgrades_row._data, 'money')), 'garden': upgrades.UpgradeLink(upgrades.GARDEN_PROD, DictRef(self.upgrades_row._data, 'garden'), after=self._update_bank_increment), 'inventory': upgrades.UpgradeLink(upgrades.INVENTORY_LIMIT, DictRef(self.upgrades_row._data, 'inventory'), after=self._update_inventory_limit), } self._bank = Incremental( DictRef(self._data, 'bank'), DictRef(self._data, 'bank_time'), TimeSlot(TimeMetric.HOUR, self.upgrades['garden'].get_value())) self._tokens = Incremental(DictRef(self._data, 'tokens'), DictRef(self._data, 'tokens_time'), TimeSlot(TimeMetric.HOUR, 2)) self._adventure: Optional[Adventure] = None self._lang: DictRef[str] = DictRef(self._data, 'lang') # User entity self.user_entity: UserEntity = UserEntity( DictRef(self._data, 'last_name')) self._user_class: DictRef[int] = DictRef(self._data, 'class') if utils.is_test(): self._user_class.set(UserClass.WARRIOR.get_id()) self._persistent_stats: dict[StatInstance, int] = {} if self._user_class.get() != -1: uc: UserClass = UserClass.get_from_id(self._user_class.get()) self.user_entity.set_class(uc) self._persistent_stats: dict[StatInstance, int] = { stat: value for stat, value in uc.get_stats().items() if stat.is_persistent() } # Fill inventory items_data = self._db.start_join('users', dict(id=self.id), columns=['slot', 'item_id'], limit=30) \ .join('user_items', field_matches=[('user_id', 'id')]) \ .execute() self.inventory: Inventory = Inventory( self._db, items_data, self.upgrades['inventory'].get_value(), 1, self.id, self.user_entity) # for is_info in item_slots: # slot: str = is_info['slot'] # item_dict: dict[str, Any] = self._db.get_row_data('items', dict(id=is_info['item_id'])) # # slots = self.upgrades['inventory'].get_value() # inv_items: list[Optional[Item]] = [None] * slots # item_slots = self._db.start_join('users', dict(id=self.id), columns=['slot', 'item_id'], # limit=self.upgrades['inventory'].get_value()) \ # .join('user_items', field_matches=[('user_id', 'id')]) \ # .execute() # for is_info in item_slots: # item_dict: dict[str, Any] = self._db.get_row_data('items', dict(id=is_info['item_id'])) # item: Item = item_utils.from_dict(item_dict['data']) # item.id = item_dict['id'] # inv_items[is_info['slot']] = item # if len(item_slots) > slots: # # Too many item_data... log # print(f"{user_id} exceeded {slots} items: {len(item_slots)}!") # self.inventory: Inventory = Inventory(self._db, DictRef(self._data, 'equipment'), slots, inv_items, # self.user_entity, self.id) # Observables self.on_money_changed: Observable[int] = Observable()
async def init(self) -> None: self._group_a.load(self.get_adventure()) self._group_b.load(self.get_adventure()) self._turn_a = (self._group_a.get_speed() >= self._group_b.get_speed()) # Pretext if self._pre_text: self.start_log() ta: list[str] = [f"_{x}_" for x in self._pre_text] for i in range(len(self._pre_text)): await self.send_log('\n'.join([ta[i]])) await asyncio.sleep(2) # Add reactions await self.update() abilities: int = 0 for battle_entity in self._group_a.get_battle_entities( ) + self._group_b.get_battle_entities(): if battle_entity.is_user(): abilities = max(abilities, len(battle_entity.get_abilities())) await self.get_adventure().add_reaction(BattleEmoji.ATTACK.value, self.execute_action) for battle_emoji in BattleEmoji.get_spells(abilities): await self.get_adventure().add_reaction(battle_emoji.value, self.execute_action) for user in self.get_adventure().get_users(): if (self._group_a.find_user(user) is not None) or (self._group_b.find_user(user) is not None): if user.inventory.get_potion() is not None: await self.get_adventure().add_reaction( BattleEmoji.POTION.value, self.execute_action) break if utils.is_test(): await self.get_adventure().add_reaction(BattleEmoji.WAIT.value, self.execute_action) await self._recalculate_max_targets() # Loop self._round = 1 while True: if (not self._round_offbeat) and self._battle_log and \ (self._group_a.get_alive_user_count() + self._group_b.get_alive_user_count() == 0): await self.update() await asyncio.sleep(3) self._battle_log.clear() await self.execute_turn() if self._is_finished(): break speed_diff: float = (self._group_a.get_speed() - self._group_b.get_speed()) if self._dont_add_speed: self._dont_add_speed = False else: self._speed_balance += speed_diff * 0.5 if self._turn_a and self._speed_balance >= 1: self._speed_balance -= 1 self._dont_add_speed = True elif not self._turn_a and self._speed_balance <= -1: self._speed_balance += 1 self._dont_add_speed = True else: if self._round_offbeat: self._round_offbeat = False self._round += 1 else: self._round_offbeat = True self._turn_a = not self._turn_a # End if self._group_a.get_alive_count() == 0: winner = self._group_b loser = self._group_a else: winner = self._group_a loser = self._group_b if winner.has_users(): money_won: int = 0 for battle_entity in loser.get_battle_entities(): money_won += battle_entity.get_money_value() self._battle_log.append( f"**{Emoji.TROPHY} " f"{tr(self.get_lang(), 'BATTLE.WIN', name=self._get_current_team().get_name())}** " f"(+{utils.print_money(self.get_lang(), money_won)})") distribute: int = round( float(money_won) / len(self.get_adventure().get_users())) for user in self.get_adventure().get_users(): user.add_money(distribute) await self.update(final=True) await self.end() else: self._battle_log.append( f"**{Emoji.TROPHY} " f"{tr(self.get_lang(), 'BATTLE.WIN', name=self._get_current_team().get_name())}**" ) await self.update(final=True) await self.end(lost=True)