let _ipc = ig.ipieces.as_mut(modperm)
.get(piece).ok_or(ME::PieceNotFound)?;
- let (desc_html, xupdates) =
+ let (desc_html, puo, xupdates) =
ig.delete_piece(modperm, to_permute, piece,
|ioccults, goccults, ipc, gpc| {
if let (Some(ipc), Some(gpc)) = (ipc, gpc) {
}
})?;
- (U{ pcs: vec![(piece, PieceUpdateOp::Delete())],
+ (U{ pcs: vec![(piece, puo)],
log: vec![ LogEntry {
html: hformat!("A piece {} was removed from the game",
desc_html),
}
impl<'ig> InstanceGuard<'ig> {
- /// Idempotent.
+ /// Core of piece deletion
+ ///
+ /// Caller is completely responsible for the necessary log entries.
+ ///
+ /// Idempotent (so does not detect if the piece didn't exist,
+ /// other than by passing `None`s to the callback.
#[throws(IE)]
pub fn delete_piece<H,T>(&mut self, modperm: ModifyingPieces,
to_permute: &mut ToRecalculate,
piece: PieceId, hook: H)
- -> (T, UnpreparedUpdates)
+ -> (T, PieceUpdateOp<(),()>, UnpreparedUpdates)
where H: FnOnce(&IOccults, &GOccults,
Option<&IPiece>, Option<&GPiece>) -> T
{
}
}
- (hook_r, xupdates.into_unprepared(None))
+ (hook_r, PieceUpdateOp::Delete(), xupdates.into_unprepared(None))
}
/// caller is responsible for logging; threading it through