fixed play field
This commit is contained in:
committed by
Seoxi Ryouko
parent
2936440103
commit
9571d38030
5
build
5
build
@ -1,4 +1,5 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
lsc -bc --no-header -o static/ web-src/script.ls
|
lsc -bc --no-header -o static/ web-src/script.ls && \
|
||||||
npx sass web-src/style.scss static/style.css
|
npx sass web-src/style.scss static/style.css && \
|
||||||
|
rustfmt src/*.rs && \
|
||||||
cargo $(basename $0) "${@:1}"
|
cargo $(basename $0) "${@:1}"
|
||||||
|
|||||||
21
src/game.rs
21
src/game.rs
@ -7,7 +7,6 @@ use url::Url;
|
|||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
struct CardInfo {
|
struct CardInfo {
|
||||||
#[serde(with = "uuid::serde::braced")]
|
#[serde(with = "uuid::serde::braced")]
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
@ -19,7 +18,6 @@ struct CardInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Copy, Debug)]
|
#[derive(Deserialize, Serialize, Clone, Copy, Debug)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
pub enum Player {
|
pub enum Player {
|
||||||
A,
|
A,
|
||||||
B,
|
B,
|
||||||
@ -27,7 +25,6 @@ pub enum Player {
|
|||||||
|
|
||||||
#[derive(Deserialize, Serialize, Clone, Debug)]
|
#[derive(Deserialize, Serialize, Clone, Debug)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
struct InPlay {
|
struct InPlay {
|
||||||
#[serde(with = "uuid::serde::braced")]
|
#[serde(with = "uuid::serde::braced")]
|
||||||
id: Uuid,
|
id: Uuid,
|
||||||
@ -41,14 +38,12 @@ struct InPlay {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
struct Hand {
|
struct Hand {
|
||||||
cards: Vec<Uuid>,
|
cards: Vec<Uuid>,
|
||||||
owner: Player,
|
owner: Player,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
enum Event {
|
enum Event {
|
||||||
Shuffle(Player),
|
Shuffle(Player),
|
||||||
Draw(Player, usize),
|
Draw(Player, usize),
|
||||||
@ -61,7 +56,6 @@ enum Event {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Clone, Debug)]
|
#[derive(Serialize, Clone, Debug)]
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
struct CountedEvent {
|
struct CountedEvent {
|
||||||
id: usize,
|
id: usize,
|
||||||
event: Event,
|
event: Event,
|
||||||
@ -81,16 +75,10 @@ pub struct GameState {
|
|||||||
|
|
||||||
#[serde_as]
|
#[serde_as]
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
|
||||||
//#[serde(crate = "rocket::serde")]
|
|
||||||
pub struct OnePlayerGameState {
|
pub struct OnePlayerGameState {
|
||||||
discard_pile: Vec<Uuid>,
|
discard_pile: Vec<Uuid>,
|
||||||
shadow_realm: Vec<Uuid>,
|
shadow_realm: Vec<Uuid>,
|
||||||
// I hate my life. Uuid seems to be causing issues and for some
|
play: Vec<InPlay>,
|
||||||
// reason serde just keeps giving an empty object instead of
|
|
||||||
// serializing properly.
|
|
||||||
#[serde_as(as = "Vec<(_, _)>")]
|
|
||||||
play: HashMap<String, InPlay>,
|
|
||||||
hand: Vec<Uuid>,
|
hand: Vec<Uuid>,
|
||||||
life_totals: Vec<i32>,
|
life_totals: Vec<i32>,
|
||||||
turn_player: Player,
|
turn_player: Player,
|
||||||
@ -103,12 +91,7 @@ impl GameState {
|
|||||||
OnePlayerGameState {
|
OnePlayerGameState {
|
||||||
discard_pile: self.discard_pile.clone(),
|
discard_pile: self.discard_pile.clone(),
|
||||||
shadow_realm: self.shadow_realm.clone(),
|
shadow_realm: self.shadow_realm.clone(),
|
||||||
play: self
|
play: self.play.values().map(|val| val.clone()).collect(),
|
||||||
.play
|
|
||||||
.clone()
|
|
||||||
.into_iter()
|
|
||||||
.map(|(key, value)| (format!("{}", key.hyphenated()), value))
|
|
||||||
.collect(),
|
|
||||||
hand: match player {
|
hand: match player {
|
||||||
Player::A => self.hands[0].cards.clone(),
|
Player::A => self.hands[0].cards.clone(),
|
||||||
_ => self.hands[1].cards.clone(),
|
_ => self.hands[1].cards.clone(),
|
||||||
|
|||||||
Reference in New Issue
Block a user