rotateable: true,
};
let SpecLoaded { p, occultable, special } =
- info.load(piece_i as usize, &mut gpc, ig, SpecDepth::zero())?;
+ info.load(PLA {
+ i: piece_i as usize,
+ gpc: &mut gpc,
+ ig,
+ depth: SpecDepth::zero(),
+ })?;
if p.nfaces() <= face.into() {
throw!(SpecError::FaceNotFound);
}
#[typetag::serde(name="ChessClock")]
impl PieceSpec for Spec {
#[throws(SpecError)]
- fn load(&self, _: usize, gpc: &mut GPiece, _ig: &Instance, _:SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { gpc,.. }: PLA) -> SpecLoaded {
if self.time <= 0 { throw!(SpecError::NegativeTimeout) }
let clock = Clock {
#[typetag::serde(name="Currency")]
impl PieceSpec for Spec {
#[throws(SpecError)]
- fn load(&self, _: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { gpc,ig,depth,.. }: PLA) -> SpecLoaded {
gpc.rotateable = false;
let Spec { ref image, ref currency, qty } = *self;
#[typetag::serde(name="PickupDeck")]
impl PieceSpec for piece_specs::Deck {
#[throws(SpecError)]
- fn load(&self, _: usize, gpc: &mut GPiece, _ig: &Instance, _:SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { gpc,.. }: PLA) -> SpecLoaded {
let common = SimpleCommon {
itemname: None,
faces: self.faces.clone(),
#[typetag::serde(name="Die")]
impl PieceSpec for Spec {
#[throws(SpecError)]
- fn load(&self, _: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { gpc,ig,depth,.. }: PLA) -> SpecLoaded {
gpc.rotateable = false;
let SpecLoadedInert { p: image, occultable: img_occultable } =
pub multigrab: bool,
}
+pub struct PieceLoadArgs<'a> {
+ pub i: usize,
+ pub gpc: &'a mut GPiece,
+ pub ig: &'a Instance,
+ pub depth: SpecDepth,
+}
+
#[typetag::serde(tag="type")]
pub trait PieceSpec: Debug + Sync + Send + 'static {
#[throws(SpecError)]
fn count(&self, _pcaliases: &PieceAliases) -> usize { 1 }
- fn load(&self, i: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
- -> Result<SpecLoaded, SpecError>;
+ fn load(&self, pla: PieceLoadArgs<'_>) -> Result<SpecLoaded, SpecError>;
/// Used when a piece wants to use another for its occulted form
fn load_inert(&self, _ig: &Instance, _:SpecDepth)
-> Result<SpecLoadedInert, SpecError> {
#[typetag::serde]
impl PieceSpec for piece_specs::Hand {
#[throws(SpecError)]
- fn load(&self, _: usize, gpc: &mut GPiece, _ig: &Instance, _:SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { gpc,..}: PLA) -> SpecLoaded {
gpc.moveable = PieceMoveable::IfWresting;
gpc.rotateable = false;
self.c.load(Behaviour::Hand)?
#[typetag::serde]
impl PieceSpec for piece_specs::PlayerLabel {
#[throws(SpecError)]
- fn load(&self, _: usize, _: &mut GPiece, _ig: &Instance, _:SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { .. }: PLA) -> SpecLoaded {
self.c.load(Behaviour::PlayerLabel)?
}
}
self.resolve(pcaliases)?.count(&default())?
}
#[throws(SpecError)]
- fn load(&self, i: usize, gpc: &mut GPiece, ig: &Instance, depth: SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { i,gpc,ig,depth,.. }: PLA) -> SpecLoaded {
let r = self.resolve(&ig.pcaliases)?
- .load(i, gpc, ig, self.new_depth(depth)?)?;
+ .load(PLA { i, gpc, ig, depth: self.new_depth(depth)? })?;
r
}
#[throws(SpecError)]
#[typetag::serde]
impl PieceSpec for $ty {
#[throws(SpecError)]
- fn load(&self, _: usize, _: &mut GPiece, _ig: &Instance, _:SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { .. }: PLA) -> SpecLoaded {
SpecLoaded {
p: Box::new(self.load_raw()?.0),
occultable: None,
pub type SvgE = SVGProcessingError;
pub type SpE = SpecError;
+// gamestate.rs
+pub use PieceLoadArgs as PLA;
+
// hidden.rs
pub type OccK = OccultationKind;
pub use OccultationKindGeneral as OccKG;
#[typetag::serde(name="Lib")]
impl PieceSpec for ItemSpec {
#[throws(SpecError)]
- fn load(&self, _: usize, _: &mut GPiece, ig: &Instance, depth: SpecDepth)
- -> SpecLoaded {
+ fn load(&self, PLA { ig,depth,.. }: PLA) -> SpecLoaded {
self.find_load(ig,depth)?.into()
}
#[throws(SpecError)]
fn count(&self, _pcaliases: &PieceAliases) -> usize { self.items.len() }
#[throws(SpecError)]
- fn load(&self, i: usize, _: &mut GPiece, ig: &Instance, depth:SpecDepth)
- -> SpecLoaded
+ fn load(&self, PLA { i,ig,depth,.. }: PLA) -> SpecLoaded
{
let item = self.items.get(i).ok_or_else(
|| SpE::InternalError(format!("item {:?} from {:?}", i, &self))