aboutsummaryrefslogtreecommitdiff
path: root/src/data.rs
diff options
context:
space:
mode:
authorKatharina Fey <kookie@spacekookie.de>2020-03-22 19:44:26 +0100
committerKatharina Fey <kookie@spacekookie.de>2020-03-22 19:44:26 +0100
commit22c18205bcb3702ddf60f41f77f6f06554202f35 (patch)
tree5f402722bbd767354e040179f0b4cd5ccb6b3899 /src/data.rs
parenta55c5bded047e1e2c54f6e3f25c9b8e36e605110 (diff)
Updating gameplay starting mechanics, adding quadtree to map
Diffstat (limited to 'src/data.rs')
-rw-r--r--src/data.rs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/data.rs b/src/data.rs
index 4cfe0c09e463..940bda10e7e8 100644
--- a/src/data.rs
+++ b/src/data.rs
@@ -78,13 +78,13 @@ pub type PlayerId = usize;
#[derive(Serialize, Deserialize)]
pub struct Player {
/// A unique player ID (per match)
- id: PlayerId,
+ pub id: PlayerId,
/// The player name
- name: String,
+ pub name: String,
/// Player color
- color: Color,
+ pub color: Color,
/// The player's money
- money: AtomicU16,
+ pub money: AtomicU16,
}
/// Optionally, players can create teams
@@ -144,7 +144,7 @@ pub trait ColorPalette {
/// Create a new color palette
fn palette() -> Self;
/// Get a palette without a certain colour
- fn without(b: &Color) -> Self;
+ fn without(&mut self, b: &Color);
/// Mix a color back into the available palette
fn remix(&mut self, new: Color);
}
@@ -167,8 +167,11 @@ impl ColorPalette for Vec<Color> {
pal
}
- fn without(b: &Color) -> Self {
- Self::palette().into_iter().filter(|a| a == b).collect()
+ /// Drop a colour from the palette
+ fn without(&mut self, b: &Color) {
+ if let Some(pos) = self.into_iter().rposition(|a| a == b) {
+ self.remove(pos);
+ }
}
fn remix(&mut self, new: Color) {