~phate/tes-rpc

bc78837e0abb29011e60d771293f73f37a7cd7a3 — ValleyKnight 6 months ago 7635ac6 master
update
1 files changed, 74 insertions(+), 21 deletions(-)

M src/main.rs
M src/main.rs => src/main.rs +74 -21
@@ 23,18 23,35 @@ fn presence(drpc: &mut Client, top: &String, bottom: &String, icon: &str) {
    }
}

fn run(
    drpc: &mut Client,
    system: &String,
    game: &String,
    character: &String,
    race: &String,
    weapons: &String,
    armor: &String,
    icon: &str
) {
    presence(drpc, &system, &game, icon);
    thread::sleep(time::Duration::from_secs(15));
    presence(drpc, &character, &race, icon);
    thread::sleep(time::Duration::from_secs(15));
    presence(drpc, &weapons, &armor, icon);
    thread::sleep(time::Duration::from_secs(15));
}

fn main() {
    let config: Config = toml::from_str(
        r#"
        system = 'Xbox 360'
        game = 'TESV: Skyrim'
        race = 'Bosmer'
        character = 'Ashley'
        weapons = 'Greatsword and Bow'
        armor = 'Clothing Only'
        game = 'TESIV: Oblivion'
        race = 'Argonian'
        character = 'Thing'
        weapons = 'Fists'
        armor = 'Clothing Only (except in Arena)'
    "#,
    )
    .unwrap();
    ).unwrap();

    let system = config.system;
    let game = config.game;


@@ 49,28 66,64 @@ fn main() {

    match game.as_str() {
        "TESV: Skyrim" => loop {
            presence(&mut drpc, &system, &game, "skyrim");
            thread::sleep(time::Duration::from_secs(15));
            presence(&mut drpc, &character, &race, "skyrim");
            thread::sleep(time::Duration::from_secs(15));
            presence(&mut drpc, &weapons, &armor, "skyrim");
            thread::sleep(time::Duration::from_secs(15));
            run(
                &mut drpc,
                &system,
                &game,
                &character,
                &race,
                &weapons,
                &armor,
                "skyrim"
            );
        },
        "TESIV: Oblivion" => loop {
            presence(&mut drpc, &system, &game, "oblivion");
            thread::sleep(time::Duration::from_secs(15));
            run(
                &mut drpc,
                &system,
                &game,
                &character,
                &race,
                &weapons,
                &armor,
                "oblivion"
            );
        },
        "TESIII: Morrowind" => loop {
            presence(&mut drpc, &system, &game, "morrowind");
            thread::sleep(time::Duration::from_secs(15));
            run(
                &mut drpc,
                &system,
                &game,
                &character,
                &race,
                &weapons,
                &armor,
                "morrowind"
            );
        },
        "TESII: Daggerfall" => loop {
            presence(&mut drpc, &system, &game, "daggerfall");
            thread::sleep(time::Duration::from_secs(15));
            run(
                &mut drpc,
                &system,
                &game,
                &character,
                &race,
                &weapons,
                &armor,
                "daggerfall",
            );
        },
        "TES: Arena" => loop {
            presence(&mut drpc, &system, &game, "daggerfall");
            thread::sleep(time::Duration::from_secs(15));
            run(
                &mut drpc,
                &system,
                &game,
                &character,
                &race,
                &weapons,
                &armor,
                "arena"
            );
        },
        _ => println!("Invalid game! :("),
    }