This commit is contained in:
parent
2cf16d34f3
commit
a8efeda463
98 changed files with 163 additions and 15 deletions
47
src/cards.rs
Normal file
47
src/cards.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use std::borrow::Cow;
|
||||
|
||||
use yoke::Yokeable;
|
||||
|
||||
use super::player::Position;
|
||||
|
||||
/// A card in a players deck which can be played to solve
|
||||
/// a situation card
|
||||
#[derive(Yokeable)]
|
||||
pub struct ActionCard<'a> {
|
||||
/// How much influence the card will cost to play
|
||||
influence: i32,
|
||||
/// The effect the card will have on the game once it's played
|
||||
effect: Effect,
|
||||
/// The image on the card
|
||||
image: Cow<'a, str>,
|
||||
/// The name of the card
|
||||
name: Cow<'a, str>,
|
||||
/// A description of what the card does
|
||||
description: Cow<'a, str>,
|
||||
}
|
||||
|
||||
/// A card which must be solved by someone on the politburo
|
||||
#[derive(Yokeable)]
|
||||
pub struct SituationCard<'a> {
|
||||
/// Points associated with the card
|
||||
points: i32,
|
||||
/// Solving this card benefits the player in this position
|
||||
benefactor: Position,
|
||||
/// The image on the card
|
||||
image: Cow<'a, str>,
|
||||
/// The name of the card
|
||||
name: Cow<'a, str>,
|
||||
/// A description of the situation the card entails
|
||||
description: Cow<'a, str>,
|
||||
}
|
||||
|
||||
pub enum CardType {
|
||||
/// A card which can be used by anyone
|
||||
General,
|
||||
/// A card which can only be used by the given
|
||||
/// poisition
|
||||
Position(Position),
|
||||
}
|
||||
|
||||
/// ??
|
||||
pub enum Effect {}
|
|
@ -24,6 +24,7 @@ pub struct LogoAssets {
|
|||
#[derive(Resource)]
|
||||
struct LogoData {
|
||||
logo_entity: Entity,
|
||||
camera_entity: Entity,
|
||||
}
|
||||
|
||||
impl Plugin for LogoPlugin {
|
||||
|
@ -67,9 +68,10 @@ fn load_logo(mut commands: Commands, assets: Res<LogoAssets>) {
|
|||
),
|
||||
))
|
||||
.id();
|
||||
commands.spawn(Camera2dBundle::default());
|
||||
let camera_entity = commands.spawn(Camera2dBundle::default()).id();
|
||||
commands.insert_resource(LogoData {
|
||||
logo_entity: sprite_entity,
|
||||
camera_entity,
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -111,6 +113,7 @@ fn fade_in_logo(
|
|||
|
||||
fn cleanup_logo(mut commands: Commands, logo_data: Res<LogoData>) {
|
||||
commands.entity(logo_data.logo_entity).despawn_recursive();
|
||||
commands.entity(logo_data.camera_entity).despawn_recursive();
|
||||
commands.remove_resource::<LogoData>();
|
||||
commands.remove_resource::<LogoAssets>();
|
||||
}
|
||||
|
|
|
@ -1,12 +1,17 @@
|
|||
//! A social deduction, historically based card game
|
||||
|
||||
use bevy::prelude::*;
|
||||
use bevy_asset_loader::loading_state::{
|
||||
config::ConfigureLoadingState, LoadingState, LoadingStateAppExt,
|
||||
};
|
||||
// use bevy_editor_pls::prelude::*;
|
||||
use tracing_subscriber::EnvFilter;
|
||||
|
||||
mod cards;
|
||||
mod logo;
|
||||
mod menu;
|
||||
mod networking;
|
||||
mod player;
|
||||
mod rooms;
|
||||
|
||||
#[derive(Debug, Clone, Copy, Default, Eq, PartialEq, Hash, States)]
|
||||
|
|
35
src/menu.rs
35
src/menu.rs
|
@ -1,4 +1,4 @@
|
|||
use bevy::{app::AppExit, prelude::*};
|
||||
use bevy::{app::AppExit, pbr::Lightmap, prelude::*};
|
||||
use bevy_asset_loader::asset_collection::AssetCollection;
|
||||
|
||||
use crate::AppState;
|
||||
|
@ -9,6 +9,10 @@ pub struct MenuPlugin;
|
|||
pub struct MenuAssets {
|
||||
#[asset(path = "logo_bw.ktx2")]
|
||||
pub logo: Handle<Image>,
|
||||
#[asset(path = "plane_map.ktx2")]
|
||||
pub plane_lightmap: Handle<Image>,
|
||||
#[asset(path = "scene.glb#Scene0")]
|
||||
pub scene: Handle<Scene>,
|
||||
}
|
||||
|
||||
const NORMAL_BUTTON: Color = Color::BLACK;
|
||||
|
@ -59,8 +63,29 @@ fn setup_menu(
|
|||
mut commands: Commands,
|
||||
assets: Res<MenuAssets>,
|
||||
mut clear_color: ResMut<ClearColor>,
|
||||
mut materials: ResMut<Assets<StandardMaterial>>,
|
||||
meshes: Query<
|
||||
(Entity, &Name, &Handle<StandardMaterial>),
|
||||
(With<Handle<Mesh>>, Without<Lightmap>),
|
||||
>,
|
||||
) {
|
||||
clear_color.0 = Color::GRAY;
|
||||
let exposure = 250.0;
|
||||
clear_color.0 = Color::BLACK;
|
||||
for (entity, name, material) in meshes.iter() {
|
||||
if &**name == "Light" {
|
||||
materials.get_mut(material).unwrap().emissive = Color::WHITE * exposure;
|
||||
continue;
|
||||
}
|
||||
|
||||
if &**name == "Plane" {
|
||||
materials.get_mut(material).unwrap().lightmap_exposure = exposure;
|
||||
commands.entity(entity).insert(Lightmap {
|
||||
image: assets.plane_lightmap.clone(),
|
||||
..default()
|
||||
});
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let logo_bw_entity = commands
|
||||
.spawn(NodeBundle {
|
||||
style: Style {
|
||||
|
@ -168,6 +193,12 @@ fn setup_menu(
|
|||
});
|
||||
})
|
||||
.id();
|
||||
commands.spawn(Camera3dBundle {
|
||||
transform: Transform::from_xyz(0.0, -585.9, 193.0),
|
||||
// .with_rotation(Quat::from_rotation_x(71.0)),
|
||||
..Default::default()
|
||||
});
|
||||
commands.insert_resource(AmbientLight::NONE);
|
||||
commands.insert_resource(MenuData {
|
||||
button_entity,
|
||||
logo_bw_entity,
|
||||
|
|
36
src/player.rs
Normal file
36
src/player.rs
Normal file
|
@ -0,0 +1,36 @@
|
|||
use yoke::Yoke;
|
||||
|
||||
use crate::cards::ActionCard;
|
||||
|
||||
/// The players position on the Politburo
|
||||
pub enum Position {
|
||||
/// Very direct, aggressive. Focuses on generating influence.
|
||||
/// Public opinion suffers as a result.
|
||||
MilitaryChief,
|
||||
/// Opposite of Military. Mostly high public opinion, low influence.
|
||||
/// Generates influence from public opinion
|
||||
PropogandaCheif,
|
||||
/// Backroom backstabber. Half of your influence is refunded if you
|
||||
/// fail to shut down or support a bill.
|
||||
InternalSecurityCheif,
|
||||
/// ??
|
||||
EconomicPlanningCheif,
|
||||
/// ??
|
||||
PositionFive,
|
||||
/// ??
|
||||
PositionSix,
|
||||
/// ??
|
||||
PositionSeven,
|
||||
/// ??
|
||||
PositionEight,
|
||||
}
|
||||
|
||||
/// A player participating in the Politburo
|
||||
pub struct Player {
|
||||
/// The player's position on the Politburo
|
||||
position: Position,
|
||||
/// The display name of the player
|
||||
name: String,
|
||||
/// The action cards in a player's hand
|
||||
cards: heapless::Vec<Yoke<ActionCard<'static>, Vec<u8>>, 7>,
|
||||
}
|
12
src/rooms.rs
12
src/rooms.rs
|
@ -5,7 +5,10 @@ use bevy_egui::egui::Align2;
|
|||
use bevy_egui::EguiContexts;
|
||||
use bevy_egui::{egui, EguiClipboard};
|
||||
use libp2p::{relay, swarm::SwarmEvent, PeerId};
|
||||
use yoke::Yoke;
|
||||
|
||||
use crate::cards::SituationCard;
|
||||
use crate::player::Player;
|
||||
use crate::{
|
||||
menu::{MenuAssets, MenuData},
|
||||
networking::{BehaviourEvent, NetworkEvent, NetworkManager},
|
||||
|
@ -35,6 +38,15 @@ struct ChatBuffer {
|
|||
history: String,
|
||||
}
|
||||
|
||||
/// A virtual table all the players sit around
|
||||
pub struct SituationTable {
|
||||
/// The situation currently on the table
|
||||
situation: Yoke<SituationCard<'static>, Vec<u8>>,
|
||||
/// The players sitting around the table and participating
|
||||
/// in the Politburo
|
||||
players: heapless::Vec<Player, 8>,
|
||||
}
|
||||
|
||||
fn rooms(
|
||||
mut next_state: ResMut<NextState<AppState>>,
|
||||
mut text_buffer: ResMut<ChatBuffer>,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue