}
}
-#[typetag::serde(name="ChessClock")]
-impl PieceTrait for Clock {
+impl PieceBaseTrait for Clock {
fn nfaces(&self) -> RawFaceId { 1 }
+}
+#[typetag::serde(name="ChessClock")]
+impl PieceTrait for Clock {
#[throws(IE)]
fn svg_piece(&self, f: &mut Html, gpc: &GPiece, gs: &GameState,
vpid: VisiblePieceId) {
}
}
+impl PieceBaseTrait for Deck {
+ fn nfaces(&self) -> RawFaceId { 1 }
+}
+
#[typetag::serde]
impl PieceTrait for Deck {
- fn nfaces(&self) -> RawFaceId { 1 }
#[throws(IE)]
fn svg_piece(&self, f: &mut Html, gpc: &GPiece,
gs: &GameState, _vpid: VisiblePieceId) {
pub wrc: WhatResponseToClientOp,
}
-#[typetag::serde] // usual variable: p
-pub trait PieceTrait: OutlineTrait + Send + Debug + 'static {
- /// by convention, occult face is nfaces-1
+pub trait PieceBaseTrait: OutlineTrait + Send + Debug + 'static {
+ /// By convention, occult face is nfaces-1
fn nfaces(&self) -> RawFaceId;
+}
+#[typetag::serde] // usual variable: p
+pub trait PieceTrait: PieceBaseTrait + Send + Debug + 'static {
#[throws(InternalError)]
fn add_ui_operations(&self, _: ShowUnocculted,
_upd: &mut Vec<UoDescription>,
}
#[typetag::serde]
-pub trait InertPieceTrait: OutlineTrait {
- fn nfaces(&self) -> RawFaceId;
-
+pub trait InertPieceTrait: PieceBaseTrait {
/// When used for occultated version of another object,
/// face used is always default, regardless of nfaces.
fn svg(&self, f: &mut Html, id: VisiblePieceId, face: FaceId)
}
}
+impl PieceBaseTrait for Hand {
+ fn nfaces(&self) -> RawFaceId { 1 }
+}
+
#[typetag::serde]
impl PieceTrait for Hand {
- fn nfaces(&self) -> RawFaceId { 1 }
#[throws(IE)]
fn svg_piece(&self, f: &mut Html, gpc: &GPiece,
gs: &GameState, _vpid: VisiblePieceId) {
}
// let edge_attrs = format!(r##"stroke-width="" stroke"##
+impl PieceBaseTrait for SimpleShape {
+ fn nfaces(&self) -> RawFaceId { self.count_faces() }
+}
+
#[typetag::serde]
impl PieceTrait for SimpleShape {
#[throws(IE)]
};
r
}
- fn nfaces(&self) -> RawFaceId {
- self.count_faces()
- }
fn itemname(&self) -> &str { self.itemname() }
}
#[typetag::serde]
impl InertPieceTrait for SimpleShape {
- fn nfaces(&self) -> RawFaceId { PieceTrait::nfaces(self) }
-
#[throws(IE)]
fn svg(&self, f: &mut Html, _vpid: VisiblePieceId, face: FaceId) {
self.svg_piece_raw(f, face, &mut |_|Ok(()))?;
fn thresh_dragraise(&self) -> Result<Option<Coord>, IE>;
fn bbox_approx(&self) -> Result<Rect, IE>;
}}}
+impl PieceBaseTrait for ItemInertForOcculted {
+ fn nfaces(&self) -> RawFaceId { 1 }
+}
#[typetag::serde(name="Lib")]
impl InertPieceTrait for ItemInertForOcculted {
- fn nfaces(&self) -> RawFaceId { 1 }
-
#[throws(IE)]
fn svg(&self, f: &mut Html, _: VisiblePieceId, face: FaceId) {
if face != FaceId::default() {
}
}
-#[typetag::serde(name="Lib")]
-impl PieceTrait for Item {
+impl PieceBaseTrait for Item {
fn nfaces(&self) -> RawFaceId {
(self.faces.len()
+ self.back.iter().count())
.try_into().unwrap()
}
+}
+#[typetag::serde(name="Lib")]
+impl PieceTrait for Item {
#[throws(IE)]
fn svg_piece(&self, f: &mut Html, gpc: &GPiece,
_gs: &GameState, vpid: VisiblePieceId) {
#[typetag::serde(name="LibItem")]
impl InertPieceTrait for Item {
- fn nfaces(&self) -> RawFaceId { <Item as PieceTrait>::nfaces(self) }
-
#[throws(IE)]
fn svg(&self, f: &mut Html, id: VisiblePieceId, face: FaceId) {
self.svg_face(f, face, id)?;