From de99c5f7636a952025ea13de02bafd25bcb6bdec Mon Sep 17 00:00:00 2001 From: LLLL Colonq Date: Mon, 17 Aug 2026 20:14:16 -0400 Subject: Fix broken --- 2026/games/rpc2dot0/src/computer/os.rs | 117 --------------------------------- 1 file changed, 117 deletions(-) delete mode 100644 2026/games/rpc2dot0/src/computer/os.rs (limited to '2026/games/rpc2dot0/src/computer/os.rs') diff --git a/2026/games/rpc2dot0/src/computer/os.rs b/2026/games/rpc2dot0/src/computer/os.rs deleted file mode 100644 index 797e07e..0000000 --- a/2026/games/rpc2dot0/src/computer/os.rs +++ /dev/null @@ -1,117 +0,0 @@ -use std::fmt::Debug; - -use crate::computer::ComputerPhase; -use crate::message::Message; -use crate::{assets::VIDEO_ASSETS, random::RandomState}; -use crate::{constants::*, game}; -use teleia::context; -use web_sys::{Blob, BlobPropertyBag, Url}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub struct Os { - state: OsState, -} - -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub enum OsState { - Booting, - On, - ShutDown, - Off, -} - -// TODO ??? -impl From for ComputerPhase { - fn from(value: OsState) -> Self { - match value { - OsState::Booting => ComputerPhase::Booting, - OsState::On => ComputerPhase::On, - OsState::ShutDown => ComputerPhase::ShutDown, - OsState::Off => ComputerPhase::Off, - } - } -} - -impl From for OsState { - fn from(value: ComputerPhase) -> Self { - match value { - ComputerPhase::Off => OsState::Off, - ComputerPhase::Booting => OsState::Booting, - ComputerPhase::On => OsState::On, - ComputerPhase::ShutDown => OsState::ShutDown, - } - } -} - -impl Os { - pub fn new() -> Self { - Self { - state: OsState::Off, - } - } - pub fn from(phase: ComputerPhase) -> Self { - Self { - state: OsState::from(phase), - } - } - - pub fn set(&mut self, phase: ComputerPhase) { - self.state = OsState::from(phase); - } -} - -impl Default for Os { - fn default() -> Self { - Self { - state: OsState::Off, - } - } -} - -impl Os { - pub fn boot(rng: &mut RandomState) { - let idx = rng.next_range(0.0, VIDEO_ASSETS.len() as f32) as usize; - let bytes = VIDEO_ASSETS[idx].1; - - // huh ? `of1` nice api name - let parts = js_sys::Array::of1(&js_sys::Uint8Array::from(bytes)); - let blob_props = BlobPropertyBag::new(); - blob_props.set_type("video/mp4"); - - let blob = match Blob::new_with_u8_array_sequence_and_options(&parts, &blob_props) { - Ok(b) => b, - Err(_) => { - log::error!("eatyourgreens:: failed to create blob"); - return; - } - }; - - let url = match Url::create_object_url_with_blob(&blob) { - Ok(s) => s, - Err(_) => { - log::error!("eatyourgreens:: failed to create object URL"); - return; - } - }; - if let Some(window) = web_sys::window() { - let msg = Message { - op: "play_video", - verb: None, - win: None, - score: None, - video_url: Some(url), - }; - Message::post(&window, &msg); - } else { - log::error!("eatyourgreens:: failed to get window and send os msg"); - } - } - - pub fn os_play(&self, ctx: &context::Context) { - log::debug!("eatyourgreens:: os play game:"); - } - - pub fn os_quit() { - log::debug!("eatyourgreens:: os quit"); - } -} -- cgit v1.3.1