From: Ian Jackson Date: Sat, 11 Jul 2020 22:45:16 +0000 (+0100) Subject: rename PieceState and PlayerState X-Git-Tag: otter-0.2.0~1382 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=b8b97f4e46c9aa7eb798102ad218edbd25aff101;p=otter.git rename PieceState and PlayerState --- diff --git a/src/api.rs b/src/api.rs index 17a80db0..641ac026 100644 --- a/src/api.rs +++ b/src/api.rs @@ -18,9 +18,9 @@ trait ApiPieceOp : Debug { } trait Lens { - fn log_pri(&self, piece: PieceId, pc: &PieceRecord) + fn log_pri(&self, piece: PieceId, pc: &PieceState) -> PieceRenderInstructions; - fn svg_pri(&self, piece: PieceId, pc: &PieceRecord, player: PlayerId) + fn svg_pri(&self, piece: PieceId, pc: &PieceState, player: PlayerId) -> PieceRenderInstructions; fn massage_prep_piecestate(&self, ns : &mut PreparedPieceState); fn decode_visible_pieceid(&self, vpiece: VisiblePieceId, player: PlayerId) @@ -28,13 +28,13 @@ trait Lens { } struct TransparentLens { } impl Lens for TransparentLens { - fn log_pri(&self, piece: PieceId, pc: &PieceRecord) + fn log_pri(&self, piece: PieceId, pc: &PieceState) -> PieceRenderInstructions { let kd : slotmap::KeyData = piece.into(); let id = VisiblePieceId(kd); PieceRenderInstructions { id, face : pc.face } } - fn svg_pri(&self, piece: PieceId, pc: &PieceRecord, _player: PlayerId) + fn svg_pri(&self, piece: PieceId, pc: &PieceState, _player: PlayerId) -> PieceRenderInstructions { self.log_pri(piece, pc) } diff --git a/src/gamestate.rs b/src/gamestate.rs index 9b5c26eb..52d23a8a 100644 --- a/src/gamestate.rs +++ b/src/gamestate.rs @@ -32,14 +32,14 @@ pub struct ZLevel { #[derive(Debug)] pub struct GameState { - pub pieces : DenseSlotMap, - pub players : DenseSlotMap, + pub pieces : DenseSlotMap, + pub players : DenseSlotMap, pub gen : Generation, pub log : Vec<(Generation, Arc)>, } #[derive(Debug)] -pub struct PieceRecord { +pub struct PieceState { pub pos : Pos, pub p : Box, pub face : FaceId, @@ -51,7 +51,7 @@ pub struct PieceRecord { } #[derive(Debug)] -pub struct Player { +pub struct PlayerState { pub nick : String, } @@ -125,7 +125,7 @@ impl Display for ZCoord { // ---------- game state ---------- -impl PieceRecord { +impl PieceState { pub fn make_defs(&self, pri : &PieceRenderInstructions) -> String { let pr = self; let mut defs = String::new(); @@ -173,7 +173,7 @@ pub fn xxx_gamestate_init() -> GameState { let mut pieces = DenseSlotMap::with_key(); let mut gen = Generation(0); for (pos, p) in xxx_make_pieces() { - let pr = PieceRecord { + let pr = PieceState { pos, p, face : 0.into(), held : None, diff --git a/src/global.rs b/src/global.rs index 123d313c..483bc3f1 100644 --- a/src/global.rs +++ b/src/global.rs @@ -109,7 +109,7 @@ pub fn xxx_global_setup() { let amu = Arc::new(Mutex::new(gi)); let mut ig = amu.lock().unwrap(); for (token, nick) in XXX_PLAYERS_TOKENS { - let np = Player { + let np = PlayerState { nick : nick.to_string(), }; let player = ig.gs.players.insert(np);