From b551179ba760c9d90808551b3b46d77fad3947ae Mon Sep 17 00:00:00 2001 From: Isaac Mills Date: Wed, 13 Mar 2024 08:30:41 -0400 Subject: [PATCH] Finish effect data type --- src/cards.rs | 12 ++++++++---- src/networking.rs | 2 +- src/player.rs | 2 ++ 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/cards.rs b/src/cards.rs index 892be66..615a09b 100644 --- a/src/cards.rs +++ b/src/cards.rs @@ -1,12 +1,13 @@ use std::borrow::Cow; +use serde::Deserialize; use yoke::Yokeable; use super::player::Position; /// A card in a players deck which can apply an effect /// to the game or advance a solution -#[derive(Yokeable)] +#[derive(Yokeable, Deserialize)] pub struct ActionCard<'a> { /// How much influence the card will cost to play influence: i32, @@ -21,7 +22,7 @@ pub struct ActionCard<'a> { } /// A card which must be solved by someone on the politburo -#[derive(Yokeable)] +#[derive(Yokeable, Deserialize)] pub struct SituationCard<'a> { /// Points associated with the card points: i32, @@ -43,5 +44,8 @@ pub enum CardType { Position(Position), } -/// ?? -pub enum Effect {} +#[derive(Deserialize)] +pub struct Effect { + effect: char, + magnitude: f32, +} diff --git a/src/networking.rs b/src/networking.rs index 3bd2f5b..02c781e 100644 --- a/src/networking.rs +++ b/src/networking.rs @@ -11,8 +11,8 @@ use libp2p::{ use rand::Rng; use serde::{Deserialize, Serialize}; use std::{borrow::Cow, hash::Hash}; -use std::{cell::OnceCell, sync::OnceLock, time::Duration}; use std::{collections::hash_map::DefaultHasher, hash::Hasher}; +use std::{sync::OnceLock, time::Duration}; use yoke::{Yoke, Yokeable}; #[derive(NetworkBehaviour)] diff --git a/src/player.rs b/src/player.rs index b72fbff..7fce689 100644 --- a/src/player.rs +++ b/src/player.rs @@ -1,8 +1,10 @@ +use serde::Deserialize; use yoke::Yoke; use crate::cards::ActionCard; /// The players position on the Politburo +#[derive(Deserialize)] pub enum Position { /// Very direct, aggressive. Focuses on generating influence. /// Public opinion suffers as a result.