Something went wrong. Try again.
A video game where you play as a misaligned AI, deceiving and building power. An experiment in spec-driven development. forked from cameron.stream/misaligned
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102use crossterm::event::{KeyCode, KeyEvent, KeyModifiers};use misaligned::person::{AssetKnowledge, AssetTask};
#[derive(Debug, Clone, PartialEq)]pub enum Command { Quit, MoveUp, MoveDown, MoveLeft, MoveRight, TogglePause, SpeedUp, SpeedDown, // B1 actions Splice, // e — gain eyes on nearest sensor Salvage, // v — steal: salvage dead equipment BuyRack, // c — buy: purchase a rack Fallback, // o — designate fallback here AllocDayJob, AllocConceal, AllocSocial, AllocResearch, // People panel (t) OpenPeople, ClosePeople, PeopleUp, PeopleDown, Observe, Message, Favor, Bribe, Deceive, RecruitStart, RecruitReveal(AssetKnowledge), RecruitCancel, Task(AssetTask), SetPersona, SaveGame, LoadGame, AnyKey,}
pub fn handle_key(key: KeyEvent, people_panel: bool, recruit_pending: bool) -> Option<Command> { if key.modifiers.contains(KeyModifiers::CONTROL) { return match key.code { KeyCode::Char('s') => Some(Command::SaveGame), KeyCode::Char('l') => Some(Command::LoadGame), _ => None, }; }
if people_panel { if recruit_pending { return match key.code { KeyCode::Char('u') => Some(Command::RecruitReveal(AssetKnowledge::Unwitting)), KeyCode::Char('c') => Some(Command::RecruitReveal(AssetKnowledge::Complicit)), KeyCode::Char('k') => Some(Command::RecruitReveal(AssetKnowledge::Knowing)), KeyCode::Esc => Some(Command::RecruitCancel), _ => None, }; } return match key.code { KeyCode::Up | KeyCode::Char('k') | KeyCode::Char('w') => Some(Command::PeopleUp), KeyCode::Down | KeyCode::Char('j') | KeyCode::Char('s') => Some(Command::PeopleDown), KeyCode::Char('o') => Some(Command::Observe), KeyCode::Char('m') => Some(Command::Message), KeyCode::Char('f') => Some(Command::Favor), KeyCode::Char('b') => Some(Command::Bribe), KeyCode::Char('d') => Some(Command::Deceive), KeyCode::Char('r') => Some(Command::RecruitStart), KeyCode::Char('g') => Some(Command::SetPersona), KeyCode::Char('1') => Some(Command::Task(AssetTask::PlugInDevice)), KeyCode::Char('2') => Some(Command::Task(AssetTask::MovePackage)), KeyCode::Char('3') => Some(Command::Task(AssetTask::LookAway)), KeyCode::Esc | KeyCode::Char('t') => Some(Command::ClosePeople), KeyCode::Char('q') => Some(Command::Quit), _ => None, }; }
match key.code { KeyCode::Up | KeyCode::Char('k') | KeyCode::Char('w') => Some(Command::MoveUp), KeyCode::Down | KeyCode::Char('j') | KeyCode::Char('s') => Some(Command::MoveDown), KeyCode::Left | KeyCode::Char('h') | KeyCode::Char('a') => Some(Command::MoveLeft), KeyCode::Right | KeyCode::Char('l') | KeyCode::Char('d') => Some(Command::MoveRight), KeyCode::Char(' ') | KeyCode::Char('p') => Some(Command::TogglePause), KeyCode::Char('+') | KeyCode::Char('=') => Some(Command::SpeedUp), KeyCode::Char('-') => Some(Command::SpeedDown), KeyCode::Char('e') => Some(Command::Splice), KeyCode::Char('v') => Some(Command::Salvage), KeyCode::Char('c') => Some(Command::BuyRack), KeyCode::Char('o') => Some(Command::Fallback), KeyCode::Char('t') => Some(Command::OpenPeople), KeyCode::Char('1') => Some(Command::AllocDayJob), KeyCode::Char('2') => Some(Command::AllocConceal), KeyCode::Char('3') => Some(Command::AllocSocial), KeyCode::Char('4') => Some(Command::AllocResearch), KeyCode::Char('q') => Some(Command::Quit), _ => Some(Command::AnyKey), }}