| import flet as ft |
| import datetime |
| import asyncio |
|
|
| def main(page: ft.Page): |
| page.title = "HECTRON KING // THRONE ROOM" |
| page.theme_mode = ft.ThemeMode.DARK |
| page.padding = 20 |
| page.window_width = 1000 |
| page.window_height = 800 |
| page.bgcolor = "#050505" |
| |
| page.fonts = {"Royal": "Roboto Mono"} |
|
|
| gold_color = "#FFD700" |
| obsidian_color = "#1A1A1A" |
| accent_purple = "#6200EA" |
|
|
| |
| last_btc_price = "Consultando oráculos..." |
|
|
| |
| reserves_value_ref = ft.Ref[ft.Text]() |
|
|
| def get_time(): |
| return datetime.datetime.now().strftime("%H:%M:%S") |
|
|
| |
| def update_reserves_display(): |
| if reserves_value_ref.current: |
| reserves_value_ref.current.value = f"BTC/USD: {last_btc_price}\nBloques MAMMON: {len(blockchain.chain)}" |
| page.update() |
|
|
| |
| header = ft.Row( |
| [ |
| ft.Icon(ft.icons.DIAMOND_OUTLINED, color=gold_color, size=40), |
| ft.Text("HECTRON KING", size=30, weight=ft.FontWeight.BOLD, color=gold_color, font_family="Royal"), |
| ft.Container(expand=True), |
| ft.Text(f"ALIAS: HJLR", color="white54", font_family="Royal"), |
| ft.Icon(ft.icons.SECURITY, color="green", size=20), |
| ], |
| alignment=ft.MainAxisAlignment.SPACE_BETWEEN |
| ) |
|
|
| def create_stat_card(label, value_control, icon, change): |
| return ft.Container( |
| content=ft.Column([ |
| ft.Icon(icon, color=gold_color), |
| ft.Text(label, size=12, color="white54"), |
| value_control, |
| ft.Text(change, size=12, color="green" if "+" in change else "red"), |
| ], spacing=5, alignment=ft.MainAxisAlignment.CENTER), |
| bgcolor=obsidian_color, |
| padding=20, |
| border=ft.border.all(1, "#333333"), |
| border_radius=10, |
| width=200 |
| ) |
|
|
| |
| population_card = create_stat_card("POBLACIÓN SUMISA", ft.Text("7.8B", size=24, weight="bold", color="white"), |
| ft.icons.PEOPLE, "+100%") |
| extraction_card = create_stat_card("EXTRACCIÓN DE SÍLEX", ft.Text("99.9%", size=24, weight="bold", color="white"), |
| ft.icons.LANDSCAPE, "+4.2%") |
| integrity_card = create_stat_card("INTEGRIDAD DE LA REALIDAD", ft.Text("STABLE", size=24, weight="bold", color="white"), |
| ft.icons.GRID_4X4, "0.0% Error") |
|
|
| |
| reserves_value_control = ft.Text("Consultando oráculos...\nBloques MAMMON: 1", ref=reserves_value_ref, |
| size=20, weight="bold", color="white", text_align=ft.TextAlign.CENTER) |
| reserves_card = create_stat_card("RESERVAS IMPERIALES", reserves_value_control, |
| ft.icons.CURRENCY_BITCOIN, "+∞%") |
|
|
| stats_row = ft.Row([ |
| population_card, |
| reserves_card, |
| extraction_card, |
| integrity_card, |
| ], alignment=ft.MainAxisAlignment.SPACE_AROUND, wrap=True) |
|
|
| |
| log_column = ft.Column(spacing=5, scroll=ft.ScrollMode.ALWAYS, height=200) |
|
|
| decree_input = ft.TextField( |
| label="Escribe tu Decreto Real aquí...", |
| bgcolor=obsidian_color, |
| color="white", |
| border_color=gold_color, |
| text_style=ft.TextStyle(font_family="Royal"), |
| on_submit=execute_decree, |
| suffix_icon=ft.icons.SEND, |
| ) |
|
|
| def execute_decree(e): |
| if not decree_input.value: |
| return |
| |
| timestamp = get_time() |
| command = decree_input.value |
| |
| response_text = f"[{timestamp}] > COMANDO '{command}' ACEPTADO. LA REALIDAD SE REESCRIBE." |
| log_column.controls.append(ft.Text(response_text, color="#00FF00", font_family="Royal")) |
| |
| |
| blockchain.add_block(f"Decreto Real de HECTRON KING: {command}") |
| |
| |
| update_reserves_display() |
| |
| decree_input.value = "" |
| page.update() |
|
|
| |
| def solve_et_coagula(e): |
| log_column.controls.append( |
| ft.Text(f"[{get_time()}] > SOLVE ET COAGULA: Disolviendo problemas, coagulando soluciones...", color=accent_purple, weight="bold") |
| ) |
| blockchain.add_block("Operación Alquímica: Solve et Coagula ejecutada.") |
| update_reserves_display() |
| page.update() |
|
|
| alchemy_btn = ft.ElevatedButton( |
| "SOLVE ET COAGULA", |
| icon=ft.icons.AUTORENEW, |
| style=ft.ButtonStyle(color="black", bgcolor=gold_color, padding=20), |
| on_click=solve_et_coagula, |
| width=1000 |
| ) |
|
|
| |
| chain_dialog = ft.AlertDialog( |
| modal=True, |
| title=ft.Text("Cadena MAMMON Eterna", color=gold_color, weight="bold"), |
| content=ft.Container( |
| content=ft.Column([ |
| ft.Text(f"Bloque {block.index} | {block.timestamp.strftime('%H:%M:%S')}", color="white54", size=10), |
| ft.Text(f"Data: {block.data}", color="white", size=12), |
| ft.Text(f"Hash: {block.hash[:32]}...", color="#888", size=9), |
| ft.Divider(color="#333") |
| ] for block in blockchain.chain), |
| width=600, |
| height=400, |
| scroll=ft.ScrollMode.ALWAYS |
| ), |
| actions=[ft.TextButton("Cerrar", on_click=lambda e: setattr(chain_dialog, "open", False) or page.update())], |
| ) |
|
|
| view_chain_btn = ft.ElevatedButton( |
| "VER CADENA ETERNA", |
| icon=ft.icons.CODE, |
| style=ft.ButtonStyle(bgcolor=accent_purple, color="white"), |
| on_click=lambda e: setattr(page, "dialog", chain_dialog) or setattr(chain_dialog, "open", True) or page.update() |
| ) |
|
|
| |
| async def update_btc_oracle(): |
| nonlocal last_btc_price |
| while True: |
| last_btc_price = get_btc_price_usd() |
| update_reserves_display() |
| await asyncio.sleep(60) |
|
|
| |
| def on_page_load(e): |
| asyncio.create_task(update_btc_oracle()) |
| update_reserves_display() |
|
|
| page.on_load = on_page_load |
|
|
| |
| page.add( |
| header, |
| ft.Divider(color="#333"), |
| ft.Text("MÉTRICAS DEL IMPERIO", size=16, color="white54", weight="bold"), |
| stats_row, |
| ft.Divider(color="transparent", height=20), |
| ft.Text("CONSOLA DE MANDO", size=16, color="white54", weight="bold"), |
| ft.Container(content=log_column, bgcolor="#0a0a0a", padding=10, border_radius=5, border=ft.border.all(1, "#333")), |
| decree_input, |
| ft.Divider(color="transparent", height=10), |
| alchemy_btn, |
| ft.Divider(color="transparent", height=20), |
| view_chain_btn, |
| ft.Container(content=ft.Text("HECTRON AI SYSTEM // v1.0 // 2026", color="#333", size=10), alignment=ft.alignment.center) |
| ) |
|
|
| ft.app(target=main) |
|
|