chiark / gitweb /
PlayerLabel: wip provide
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Mar 2021 20:10:17 +0000 (21:10 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Tue, 30 Mar 2021 22:31:54 +0000 (23:31 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hand.rs
src/spec.rs

index 01f4f657397d4694521125c34f4bb804239bb390..48681ca1d62206aaea80867a59c249de51aaeb45 100644 (file)
@@ -28,6 +28,7 @@ struct HandState {
 #[derive(Debug,Copy,Clone,Serialize,Deserialize)]
 enum Sort {
   Hand,
+  PlayerLabel,
 }
 
 type MkOccCA = fn(&OccDisplacement, &ZCoord) -> OccKA;
@@ -36,22 +37,28 @@ impl Sort {
   fn backcompat_upgrade() -> Self { Sort::Hand }
   fn itemname(self) -> &'static str { use Sort::*; match self {
     Hand => "magic-hand",
+    PlayerLabel => "player-label",
   } }
   fn unclaimed_desc(self) -> HtmlLit { use Sort::*; Html::lit(match self {
     Hand => UNCLAIMED_HAND_DESC,
+    PlayerLabel => "unclaimed player label",
   }) }
   fn deact_desc(self) -> HtmlLit { use Sort::*; Html::lit(match self {
     Hand => "Deactivate hand",
+    PlayerLabel => "Relinquish player label",
   }) }
   fn claim_desc(self) -> HtmlLit { use Sort::*; Html::lit(match self {
     Hand => "Claim this as your hand",
+    PlayerLabel => "Claim player label",
   }) }
   fn owned_desc(self, nick: &HtmlStr) -> Html { use Sort::*; match self {
     Hand => hformat!("{}'s hand", nick),
+    PlayerLabel => hformat!("{}'s player label", nick),
   } }
   fn views(self) -> Option<(MkOccCA, MkOccCA)> { use Sort::*; match self {
     Hand => Some((|_,_| OccKA::Visible,
                   |d,z| OccKA::Displaced((d.clone(), z.clone())))),
+    PlayerLabel => None,
   } }
 }
 
@@ -113,6 +120,16 @@ impl PieceSpec for piece_specs::Hand {
   }
 }
 
+#[typetag::serde]
+impl PieceSpec for piece_specs::PlayerLabel {
+  #[throws(SpecError)]
+  fn load(&self, _: usize, _: &mut GPiece,
+          _pcaliases: &PieceAliases, _ir: &InstanceRef)
+          -> PieceSpecLoaded {
+    self.c.load(Sort::Hand)?
+  }
+}
+
 impl Sort {
   fn describe_html_inner(self, xdata: Option<&HandState>) -> Html {
     if_chain! {
index c93b2f2cb4ed27ad28cbda8237884f6d2a14ba04..ebdecf8aeb8dbef8f0ae2bb39edd41148b6fe4c0 100644 (file)
@@ -244,6 +244,11 @@ pub mod piece_specs {
     #[serde(flatten)] pub c: OwnedCommon,
   }
 
+  #[derive(Debug,Serialize,Deserialize)]
+  pub struct PlayerLabel {
+    #[serde(flatten)] pub c: OwnedCommon,
+  }
+
   #[derive(Debug,Serialize,Deserialize)]
   pub struct OwnedCommon {
     pub colour: ColourSpec,