def __init__(self, *, usernames: list[str]) -> None: super().__init__() with self.doc, e.Table(style=self._get_css("table")), e.Tr(): for username in usernames: with e.Td(): with ce.Username(name=username): e.Div(style=self._get_css("background1")) e.Div(username, style=self._get_css("username")) with ce.Username(name=username): e.Div(style=self._get_css("background2"))
def _add_table(self, version: LocationsVersion) -> None: with e.Table(style=self._get_css("table")): with e.Tr(): e.Th("Location") e.Th("Method") e.Th("Level") e.Th("Rarity", colspan=2) for slot in sorted(version.slots.values()): with e.Tr(): e.Td(slot.location) e.Td(slot.method.prose) with e.Td(f"L{slot.min_level}"): if slot.min_level < slot.max_level: e.TextNode(f"-{slot.max_level}") e.Td(f"{slot.rarity}%", colspan=None if slot.conditions else 2) if slot.conditions: e.Td(", ".join([x.prose for x in slot.conditions]))
def load_page(self, page: int) -> None: db = Database.open() with db.get_session() as session: stmt_last_page = self._stmt.with_only_columns(func.count()) last_page = math.ceil(session.scalar(stmt_last_page) / 100) page = min(page, last_page) stmt_rs = self._stmt.limit(100).offset(100 * (page - 1)) rs = session.execute(stmt_rs).all() with self.doc, e.Div(class_="pad"): e.H2(self._title) if not rs: e.TextNode("No results found") return with e.Div(class_="ladder"), e.Table(): with e.Tr(): for field_header, _ in self._fields: e.Th(field_header) e.Th(self._actions_header) for row in rs: with e.Tr(): for _, field in self._fields: e.Td( str(getattr(row[0], field) or "") if isinstance(field, str) else field(row)) with e.Td(style=self._get_css("one_pixel_width")): self._add_action_buttons(row) page_cmd = (f"/pm {self._botname}, {self._cmd_char}changepage " f"{self._command}, {self._room.roomid}, ") for p in range(last_page): with e.Button(p + 1, class_="option") as btn: if page == p + 1: btn.add_class("sel") btn["disabled"] = True else: btn["name"] = "send" btn["value"] = f"{page_cmd}{p + 1}"
def _add_table(self, method: LearnsetMethod) -> None: with e.Table(style=self._get_css("table")): with e.Tr(): e.Th("Move") if method.method.id == 1: e.Th("Level") elif method.method.id == 4: e.Th("Machine") if method.form_column: e.Th("Form") for move in sorted(method.moves.values()): with e.Tr(): e.Td(move.move.name) if method.method.id == 1: e.Td(move.level, style=self._get_css("align_right")) elif method.method.id == 4: e.Td( getattr(getattr(move.machine, "item", None), "name", "")) if method.form_column: e.Td(", ".join([x.name for x in sorted(move.forms)]))