piece: VisiblePieceId,
gen: Generation,
cseq: ClientSequence,
+ #[serde(default)] loose: bool,
op: O,
}
+#[derive(Debug)]
+pub struct ContinueDespiteConflict;
+
mod op {
use super::*;
throw!(Ia::PieceHeld)
}
}
+
+ fn conflict_loose_check(&self, _gpc: &GPiece)
+ -> Result<ContinueDespiteConflict, ApiPieceOpError> {
+ throw!(Fatal::BadLoose)
+ }
}
pub trait Simple: Debug {
ServerFailure(_) => Status::InternalServerError,
NoClient | NoPlayer(_) | GameBeingDestroyed(_)
=> Status::NotFound,
- BadJSON(_)
+ BadJSON(_) | BadLoose
=> Status::BadRequest,
}
}
debug!("client={:?} pc.lastclient={:?} pc.gen_before={:?} pc.gen={:?} q_gen={:?} u_gen={:?}", &client, &gpc.lastclient, &gpc.gen_before_lastclient, &gpc.gen, &q_gen, &u_gen);
- if u_gen > q_gen { throw!(Inapplicable::Conflict) }
+ if u_gen > q_gen {
+ if ! form.loose { throw!(Inapplicable::Conflict); }
+ let ContinueDespiteConflict = form.op.conflict_loose_check(&gpc)?;
+ }
trace_dbg!("form.op", player, piece, &form.op, &gpc);
form.op.check_held(gpc,player)?;
let update =
ServerFailure(#[from] InternalError),
#[error("JSON deserialisation error: {0}")]
BadJSON(serde_json::Error),
+ #[error("Malformed command - loose not allowed for this op")]
+ BadLoose,
}
#[derive(Error,Debug)]