{
ig.fastsplit_split(player, tpiece, show, new_z,
move |_: &IOccults, _: &GameOccults, gpl: &GPlayer,
- tgpc: &mut GPiece, _tipc: &IPiece, tipc_p: &dyn PieceTrait,
+ tgpc: &mut GPiece, tipc: &IPiece,
ngpc: &mut GPiece|
{
- let self_: &Banknote = tipc_p.downcast_piece()?;
+ let self_: &Banknote = tipc.p.show(show).downcast_piece_fastsplit()?;
let tgpc_value: &mut Value = tgpc.xdata.get_mut_exp()?;
let remaining = tgpc_value.qty.checked_sub(take)
#[throws(ApiPieceOpError)]
pub fn fastsplit_split<I>(
&mut self, player: PlayerId,
- tpiece: PieceId, show: ShowUnocculted, tpc_new_z: ShouldSetZLevel,
+ tpiece: PieceId, _: ShowUnocculted, tpc_new_z: ShouldSetZLevel,
implementation: I
) -> UpdateFromOpComplex
where I: FnOnce(&IOccults, &GameOccults, &GPlayer,
- &mut GPiece, &IPiece, &dyn PieceTrait,
+ &mut GPiece, &IPiece,
&mut GPiece)
-> Result<UpdateFromOpComplex, ApiPieceOpError>
{
fastsplit: tgpc.fastsplit,
};
- let tipc_p = tipc.p
- .show(show).downcast_piece::<Piece>()?
- .ipc.as_ref().ok_or_else(|| internal_error_bydebug(tipc))?
- .p.show(show);
-
let (t_pu, t_unprepared) = implementation(
&ig.ioccults, &ig.gs.occults, gpl,
- tgpc, tipc, tipc_p,
+ tgpc, tipc,
&mut ngpc
)?;
})
}
}
+
+#[ext(pub)]
+impl<'r> &'r dyn PieceTrait {
+ #[throws(IE)]
+ fn downcast_piece_fastsplit<P: PieceTrait>(self) -> &'r P {
+ self.downcast_piece::<Piece>()?
+ .ipc.as_ref().ok_or_else(|| internal_logic_error(
+ format!("downcast_piece_fastsplit not fastsplit {:?}", self)))?
+ .p.direct_trait_access() // we're just digging down, this is fine
+ .downcast_piece::<P>()?
+ }
+}
pub use crate::utils::*;
pub use crate::ui::*;
+pub use crate::gamestate::RefTraitObjectPieceTraitExt as _;
+pub use crate::fastsplit::RefTraitObjectPieceTraitExt as _;
+
pub type SecondarySlotMap<K,V> = slotmap::secondary::SecondaryMap<K,V>;
pub type SvgData = Vec<u8>;
pub type Colour = Html;