let was = was.map(|was| htmlescape::encode_minimal(&was.nick));
let gpl = players.byid_mut(player)?;
- let pri = piece_pri(&gs.occults, player, gpl, piece, gpc)
+ let pri = piece_pri(&gs.occults, player, gpl, piece, gpc, &p)
.ok_or(OE::PieceGone)?;
let pcs = pri.describe(gpc, &p).0;
let p = if let Some(pto) = ig.ipieces.get(piece) { pto }
else { continue /* was deleted */ };
- let pri = piece_pri(&ig.gs.occults, player, gpl, piece, gpc);
+ let pri = piece_pri(&ig.gs.occults, player, gpl, piece, gpc, p);
let pri = if let Some(pri) = pri { pri } else { continue /*invisible*/};
let defs = pri.make_defs(gpc, p)?;
// ========== public entrypoints ==========
/// None => do not render at all
-pub fn piece_pri(
+pub fn piece_pri<'p, P:Borrow<dyn PieceTrait + 'p>>(
+ occults: &GameOccults,
+ player: PlayerId, gpl: &mut GPlayer,
+ piece: PieceId, gpc: &GPiece, p: &P,
+) -> Option<PieceRenderInstructions>
+{
+fn inner(
_occults: &GameOccults, // xxx
- player: PlayerId,
- gpl: &mut GPlayer,
- piece: PieceId,
- gpc: &GPiece,
-) -> Option<PieceRenderInstructions> {
+ player: PlayerId, gpl: &mut GPlayer,
+ piece: PieceId, gpc: &GPiece, _p: &dyn PieceTrait,
+) -> Option<PieceRenderInstructions>
+{
let vpid = gpl.idmap.fwd_or_insert(piece);
let angle = gpc.angle;
let occluded = PriOccluded::Visible; // xxx
player, piece, vpid, angle);
Some(PieceRenderInstructions { vpid, occluded })
}
+ inner(occults, player, gpl, piece, gpc, p.borrow())
+}
pub fn piece_at_all_occluded(
_occults: &GameOccults, // xxx
did: &str,
) -> (Vec<LogEntry>, Option<Html>) {
let who_by = Html(htmlescape::encode_minimal(&gpl.nick));
- let pri = piece_pri(occults, player, gpl, piece, gpc)
+ let pri = piece_pri(occults, player, gpl, piece, gpc, &p)
.ok_or(OE::PieceGone)?;
let log = vec![ LogEntry { html: Html(format!(
};
let op = match (&mut gpc, p) {
(Some(gpc), Some(p)) => {
- let pri = piece_pri(&gs.occults, player, gpl, piece, *gpc);
+ let pri = piece_pri(&gs.occults, player, gpl, piece, *gpc, p);
Self::piece_update_player(
&mut gs.max_z, gpc, p, ops, &pri
)?