Trait otter_api_tests::PieceTrait
source · [−]pub trait PieceTrait: 'static + OutlineTrait + Send + Debug + Serialize + Deserialize {
fn nfaces(&self) -> u8;
fn svg_piece(
&self,
f: &mut Html,
gpc: &GPiece,
gs: &GameState,
id: VisiblePieceId
) -> Result<(), InternalError>;
fn describe_html(
&self,
gpc: &GPiece,
_goccults: &GameOccults
) -> Result<Html, InternalError>;
fn itemname(&self) -> &str;
fn add_ui_operations(
&self,
ShowUnocculted,
_upd: &mut Vec<UoDescription, Global>,
_gs: &GameState,
_gpc: &GPiece
) -> Result<(), InternalError> { ... }
fn ui_operation(
&self,
ShowUnocculted,
_a: ApiPieceOpArgs<'_>,
_opname: &str,
_wrc: WhatResponseToClientOp
) -> Result<(PieceUpdate, Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>), ApiPieceOpError> { ... }
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gpieces: &mut GPieces,
_piece: PieceId,
_was_held: Option<PlayerId>
) -> Result<Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>, InternalError> { ... }
fn loaded_hook(
&self,
_piece: PieceId,
_gs: &mut GameState,
_ig: &InstanceRef
) -> Result<(), InternalError> { ... }
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates { ... }
fn sortkey(&self) -> Option<&str> { ... }
fn occultation_notify_hook(
&self,
_piece: PieceId
) -> Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>> { ... }
fn abs_bbox(&self, p: &GPiece) -> Result<RectC<i32>, InternalError> { ... }
}
Required methods
fn svg_piece(
&self,
f: &mut Html,
gpc: &GPiece,
gs: &GameState,
id: VisiblePieceId
) -> Result<(), InternalError>
fn describe_html(
&self,
gpc: &GPiece,
_goccults: &GameOccults
) -> Result<Html, InternalError>
Provided methods
fn add_ui_operations(
&self,
ShowUnocculted,
_upd: &mut Vec<UoDescription, Global>,
_gs: &GameState,
_gpc: &GPiece
) -> Result<(), InternalError>
fn ui_operation(
&self,
ShowUnocculted,
_a: ApiPieceOpArgs<'_>,
_opname: &str,
_wrc: WhatResponseToClientOp
) -> Result<(PieceUpdate, Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>), ApiPieceOpError>
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gpieces: &mut GPieces,
_piece: PieceId,
_was_held: Option<PlayerId>
) -> Result<Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>, InternalError>
fn held_change_hook(
&self,
_ig: &InstanceRef,
_gpieces: &mut GPieces,
_piece: PieceId,
_was_held: Option<PlayerId>
) -> Result<Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>, InternalError>
Piece is responsible for dealing with the possibility that they may be occulted!
fn loaded_hook(
&self,
_piece: PieceId,
_gs: &mut GameState,
_ig: &InstanceRef
) -> Result<(), InternalError>
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates
fn delete_hook(
&self,
_p: &GPiece,
_gs: &mut GameState
) -> ExecuteGameChangeUpdates
Not called if the whole game is destroyed. You can use Drop of course but it’s not usually much use since you don’t have a reference to the game or anything.
fn occultation_notify_hook(
&self,
_piece: PieceId
) -> Option<Box<dyn FnOnce(&'r mut PrepareUpdatesBuffer<'_>) + 'static, Global>>
Trait Implementations
sourceimpl<'typetag> Serialize for dyn PieceTrait + Sync + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Sync + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + Send + Sync + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Send + Sync + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
sourceimpl<'typetag> Serialize for dyn PieceTrait + Send + 'typetag
impl<'typetag> Serialize for dyn PieceTrait + Send + 'typetag
sourcefn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
Serialize this value into the given Serde serializer. Read more