DEVELOPMENT ENVIRONMENT

~liljamo/deck-builder

ref: 89bbb3e7d988f5064e775a6a398c5b53096fa186 deck-builder/client/src/plugins/game/mod.rs -rw-r--r-- 1.1 KiB
89bbb3e7 — skye feat(client): change parser to just take &Game 1 year, 7 months ago
                                                                                
443c9b0c skye
c5909cd0 skye
443c9b0c skye
c5909cd0 skye
443c9b0c skye
c5909cd0 skye
443c9b0c skye
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
/*
 * This file is part of laurelin_client
 * Copyright (C) 2023 Jonni Liljamo <jonni@liljamo.com>
 *
 * Licensed under GPL-3.0-only.
 * See LICENSE for licensing information.
 */

use bevy::prelude::*;

use crate::{api::game::Game, Global, AppState, game_status::GameStatus};

use super::GameDetailsCallEvent;

mod ui;

pub struct GamePlugin;

impl Plugin for GamePlugin {
    fn build(&self, app: &mut App) {
        app.insert_resource(GameData::default())
            .add_system(game_setup.in_schedule(OnEnter(AppState::InGame)))
            .add_system(ui::ui.run_if(in_state(AppState::InGame)));
    }
}

#[derive(Resource)]
pub struct GameData {
    pub game: Option<Game>,
    pub game_status: Option<GameStatus>,

    pub parsing_data: bool,
}

impl Default for GameData {
    fn default() -> Self {
        Self {
            game: None,
            game_status: None,

            parsing_data: false,
        }
    }
}

fn game_setup(
    mut details_ev_w: EventWriter<GameDetailsCallEvent>,
    global: Res<Global>,
) {
    details_ev_w.send(GameDetailsCallEvent {
        game_id: global.cur_game_id.clone(),
    });
}