Plan data structures for the game
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed

This commit is contained in:
Isaac Mills 2024-03-10 20:27:00 -04:00
parent 2cf16d34f3
commit a8efeda463
Signed by: fnmain
GPG key ID: B67D7410F33A0F61
98 changed files with 163 additions and 15 deletions

5
.gitattributes vendored
View file

@ -1,4 +1 @@
*.ktx filter=lfs diff=lfs merge=lfs -text
*.blend filter=lfs diff=lfs merge=lfs -text
*.ktx2 filter=lfs diff=lfs merge=lfs -text
*.wav filter=lfs diff=lfs merge=lfs -text
assets/ filter=lfs diff=lfs merge=lfs -text

1
.gitignore vendored
View file

@ -1 +1,2 @@
/target
*.protobuf

View file

@ -4,12 +4,7 @@ steps:
commands:
- apt-get -y update
- apt-get -y install wayland-protocols wayland-utils libwayland-client0 libwayland-dev libasound2 libasound2-dev libudev-dev libudev1
- wget https://github.com/mozilla/sccache/releases/download/v0.7.7/sccache-v0.7.7-x86_64-unknown-linux-musl.tar.gz
- tar xzf sccache-v0.7.7-x86_64-unknown-linux-musl.tar.gz
- mv sccache-v0.7.7-x86_64-unknown-linux-musl/sccache /usr/bin/sccache
- chmod +x /usr/bin/sccache
- sccache --start-server
- sccache --show-stats
- cargo test --target-dir /var/woodpecker --features bevy/dynamic_linking
- cargo doc --target-dir /var/woodpecker --features bevy/dynamic_linking
volumes:
- /var/woodpecker:/var/woodpecker

24
Cargo.lock generated
View file

@ -3071,6 +3071,15 @@ dependencies = [
"byteorder",
]
[[package]]
name = "hash32"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "47d60b12902ba28e2730cd37e95b8c9223af2808df9e902d4df49588d1470606"
dependencies = [
"byteorder",
]
[[package]]
name = "hashbrown"
version = "0.14.3"
@ -3104,13 +3113,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cdc6457c0eb62c71aac4bc17216026d8410337c4126773b9c5daba343f17964f"
dependencies = [
"atomic-polyfill",
"hash32",
"hash32 0.2.1",
"rustc_version",
"serde",
"spin 0.9.8",
"stable_deref_trait",
]
[[package]]
name = "heapless"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0bfb9eb618601c89945a70e254898da93b13be0388091d42117462b265bb3fad"
dependencies = [
"hash32 0.3.1",
"stable_deref_trait",
]
[[package]]
name = "heck"
version = "0.4.1"
@ -4943,6 +4962,7 @@ dependencies = [
"flume",
"futures",
"futures-timer",
"heapless 0.8.0",
"keyframe",
"libp2p",
"postcard",
@ -5014,7 +5034,7 @@ checksum = "a55c51ee6c0db07e68448e336cf8ea4131a620edefebf9893e759b2d793420f8"
dependencies = [
"cobs",
"embedded-io",
"heapless",
"heapless 0.7.17",
"serde",
]

View file

@ -14,6 +14,7 @@ bevy_egui = { version = "0.25.0", features = ["manage_clipboard"] }
flume = "0.11.0"
futures = "0.3.30"
futures-timer = "3.0.2"
heapless = "0.8.0"
keyframe = { version = "1.1.1", default-features = false }
libp2p = { version = "0.53.2", features = ["async-std", "dns", "dcutr", "identify", "macros", "noise", "ping", "relay", "rendezvous", "tcp", "yamux", "gossipsub"] }
postcard = { version = "1.0.8", features = ["use-std"] }

Binary file not shown.

Binary file not shown.

BIN
assets/plane_map.ktx2 Normal file

Binary file not shown.

BIN
assets/scene.glb Normal file

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

47
src/cards.rs Normal file
View 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 {}

View file

@ -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>();
}

View file

@ -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)]

View file

@ -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
View 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>,
}

View file

@ -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>,