chiark / gitweb /
table_colour in game state
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 27 Nov 2020 20:56:13 +0000 (20:56 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 27 Nov 2020 20:56:13 +0000 (20:56 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/cmdlistener.rs
src/gamestate.rs
src/global.rs
src/session.rs
templates/macros.tera

index 691e238fad755900d81df397a039841c9ea961f5..465812c4273740613e85c92a9c424daa4973042f 100644 (file)
@@ -157,6 +157,7 @@ fn execute(cs: &mut CommandStream, cmd: MgmtCommand) -> MgmtResponse {
       let auth = authorise_by_account(cs, &ag, &game)?;
 
       let gs = crate::gamestate::GameState {
+        table_colour: Html::lit("green"),
         table_size : DEFAULT_TABLE_SIZE,
         pieces : Default::default(),
         players : Default::default(),
index b4edba3ae20451718636d80b8e3c936b773fb056..dcab02986e23ff73fb7880ad3268cba151f23453 100644 (file)
@@ -41,6 +41,7 @@ pub struct ZLevel {
 
 #[derive(Debug,Serialize,Deserialize)]
 pub struct GameState {
+  pub table_colour: Colour,
   pub table_size : Pos,
   pub pieces : Pieces,
   pub gen : Generation,
index f88ca22ec7e4cff7fdb357991b3cb0676cbaaa71..76f452bd58b829254fb121b191c92863d08ed417 100644 (file)
@@ -545,6 +545,7 @@ impl<'ig> InstanceGuard<'ig> {
     // New state
     let mut gs = GameState {
       // These parts are straightforward and correct
+      table_colour: self.c.g.gs.table_colour.clone(),
       table_size: self.c.g.gs.table_size,
       gen: self.c.g.gs.gen,
       max_z: self.gs.max_z.clone(),
index 73e6dbecc8e67c7cc20fc1cb33007db55901614e..f3abea29bba40edd6471ecb92aae02ac7e2c1822 100644 (file)
@@ -6,6 +6,7 @@ use crate::imports::*;
 
 #[derive(Serialize,Debug)]
 struct SessionRenderContext {
+  table_colour: Colour,
   ptoken : RawToken,
   ctoken : RawToken,
   player : PlayerId,
@@ -185,6 +186,7 @@ fn session(form : Json<SessionForm>, layout: Option<PresentationLayout>)
     };
 
     let src = SessionRenderContext {
+      table_colour: ig.gs.table_colour.clone(),
       ctoken,
       gen : ig.gs.gen,
       log,
index 4264a1d767d8da37d10a7ce2231e6e9d20b85500..bff0051f7ccb8de82cbe7d22c8a9b2c3c37a61fc 100644 (file)
@@ -42,7 +42,7 @@ Hi {{nick | escape}}
         viewBox="0 0 {{ table_size[0] }} {{ table_size[1] }}"
         width="{{ table_size[0]*6 }}" height="{{ table_size[1]*6 }}"
         >
-      <rect fill="green" x="0" y="0"
+      <rect fill="{{ table_colour }}" x="0" y="0"
            width="{{ table_size[0] }}" height="{{ table_size[1] }}"/>
       <g id="pieces_marker"></g>
 {%- for piece in uses %}