fixed play field

This commit is contained in:
Seoxi Ryouko
2025-02-09 02:56:16 -05:00
committed by Seoxi Ryouko
parent 2936440103
commit 9571d38030
2 changed files with 5 additions and 21 deletions

5
build
View File

@ -1,4 +1,5 @@
#!/usr/bin/env bash
lsc -bc --no-header -o static/ web-src/script.ls
npx sass web-src/style.scss static/style.css
lsc -bc --no-header -o static/ web-src/script.ls && \
npx sass web-src/style.scss static/style.css && \
rustfmt src/*.rs && \
cargo $(basename $0) "${@:1}"

View File

@ -7,7 +7,6 @@ use url::Url;
use uuid::Uuid;
#[derive(Deserialize, Serialize, Clone, Debug)]
//#[serde(crate = "rocket::serde")]
struct CardInfo {
#[serde(with = "uuid::serde::braced")]
id: Uuid,
@ -19,7 +18,6 @@ struct CardInfo {
}
#[derive(Deserialize, Serialize, Clone, Copy, Debug)]
//#[serde(crate = "rocket::serde")]
pub enum Player {
A,
B,
@ -27,7 +25,6 @@ pub enum Player {
#[derive(Deserialize, Serialize, Clone, Debug)]
#[serde(deny_unknown_fields)]
//#[serde(crate = "rocket::serde")]
struct InPlay {
#[serde(with = "uuid::serde::braced")]
id: Uuid,
@ -41,14 +38,12 @@ struct InPlay {
}
#[derive(Serialize, Clone, Debug)]
//#[serde(crate = "rocket::serde")]
struct Hand {
cards: Vec<Uuid>,
owner: Player,
}
#[derive(Serialize, Clone, Debug)]
//#[serde(crate = "rocket::serde")]
enum Event {
Shuffle(Player),
Draw(Player, usize),
@ -61,7 +56,6 @@ enum Event {
}
#[derive(Serialize, Clone, Debug)]
//#[serde(crate = "rocket::serde")]
struct CountedEvent {
id: usize,
event: Event,
@ -81,16 +75,10 @@ pub struct GameState {
#[serde_as]
#[derive(Serialize)]
#[serde(deny_unknown_fields)]
//#[serde(crate = "rocket::serde")]
pub struct OnePlayerGameState {
discard_pile: Vec<Uuid>,
shadow_realm: Vec<Uuid>,
// I hate my life. Uuid seems to be causing issues and for some
// reason serde just keeps giving an empty object instead of
// serializing properly.
#[serde_as(as = "Vec<(_, _)>")]
play: HashMap<String, InPlay>,
play: Vec<InPlay>,
hand: Vec<Uuid>,
life_totals: Vec<i32>,
turn_player: Player,
@ -103,12 +91,7 @@ impl GameState {
OnePlayerGameState {
discard_pile: self.discard_pile.clone(),
shadow_realm: self.shadow_realm.clone(),
play: self
.play
.clone()
.into_iter()
.map(|(key, value)| (format!("{}", key.hyphenated()), value))
.collect(),
play: self.play.values().map(|val| val.clone()).collect(),
hand: match player {
Player::A => self.hands[0].cards.clone(),
_ => self.hands[1].cards.clone(),