diff --git a/client/cryps.css b/client/cryps.css index 4b58b91d..3fa56ad2 100644 --- a/client/cryps.css +++ b/client/cryps.css @@ -338,7 +338,6 @@ header { flex-flow: row; flex: 0 0 100%; - margin-bottom: 1em; } .instance-info { @@ -378,6 +377,49 @@ header { box-shadow: inset -0.5em 0 0 0 forestgreen; } +progress { + /* Dimensions */ + width: 100%; + height: .25em; + + /* Reset the apperance */ + -webkit-appearance: none; + -moz-appearance: none; + appearance: none; + + /* Get rid of the default border in Firefox/Opera. */ + border: none; + + /* For Firefox/IE10+ */ + background-color: transparent; + + /* For IE10+, color of the progress bar */ + color: forestgreen; + + margin: 0.5em 0; +} + +progress::-webkit-progress-bar { + background-color: forestgreen; +} + +.progress-container { + width: 100%; + background-color: transparent; + position: fixed; + top: 0; + left: 0; + height: .25em; + display: block; +} + +.progress-bar { + background-color: forestgreen; + width: 50%; + display: block; + height: inherit; +} + .instance-ui-btn { font-size: 100%; padding: 0; diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index fbe614d1..87c28153 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -78,6 +78,18 @@ function GamePanel(props) { ); + const timerPct = (Date.parse(game.phase_start) + 1000 * 60 * 60) - Date.now(); + console.log(Date.now(), Date.parse(game.phase_start)); + console.log(timerPct); + + const timer = ( + +
+ +
+
+ ); + function findCryp(id) { const team = game.players.find(t => t.cryps.find(c => c.id === id)); if (team) return team.cryps.find(c => c.id === id); @@ -173,6 +185,7 @@ function GamePanel(props) { return (
setActiveCryp(null)} > {header} + {timer} {PlayerTeam(playerTeam, setActiveSkill)}
{mobileSkills} diff --git a/server/src/game.rs b/server/src/game.rs index 934f8851..21e55e2c 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -37,7 +37,7 @@ pub struct Game { pub resolved: Vec, pub log: Vec, pub instance: Option, - phase_start: DateTime, + phase_end: DateTime, } impl Game { @@ -52,7 +52,7 @@ impl Game { resolved: vec![], log: vec![], instance: None, - phase_start: Utc::now(), + phase_end: Utc::now(), }; } @@ -163,7 +163,9 @@ impl Game { } fn skill_phase_start(mut self) -> Game { - self.phase_start = Utc::now(); + self.phase_end = Utc::now() + .checked_add_signed(Duration::seconds(60)) + .expect("could not set phase end"); for player in self.players.iter_mut() { if player.skills_required() != 0 { @@ -562,7 +564,7 @@ impl Game { } fn phase_timed_out(&self) -> bool { - Utc::now().signed_duration_since(self.phase_start).num_seconds() > 60 + !Utc::now().signed_duration_since(self.phase_end).is_zero() } pub fn upkeep(mut self) -> Game { @@ -1309,7 +1311,7 @@ mod tests { fn upkeep_test() { let mut game = create_2v2_test_game(); game.players[0].set_ready(true); - game.phase_start = Utc::now().checked_sub_signed(Duration::seconds(61)).unwrap(); + game.phase_end = Utc::now().checked_sub_signed(Duration::seconds(61)).unwrap(); game = game.upkeep(); assert!(game.players[1].warnings == 1); } diff --git a/server/src/instance.rs b/server/src/instance.rs index eca9ffb6..5975cff7 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -48,7 +48,7 @@ pub struct Instance { max_rounds: usize, password: Option, pub name: String, - phase_start: DateTime, + phase_end: DateTime, } impl Instance { @@ -63,7 +63,7 @@ impl Instance { max_rounds: 16, name: String::new(), password: None, - phase_start: Utc::now(), + phase_end: Utc::now(), } } @@ -78,12 +78,12 @@ impl Instance { max_rounds: 1, name: "Global Matchmaking".to_string(), password: None, - phase_start: Utc::now(), + phase_end: Utc::now(), } } fn phase_timed_out(&self) -> bool { - Utc::now().signed_duration_since(self.phase_start).num_seconds() > 60 + !Utc::now().signed_duration_since(self.phase_end).is_zero() } fn timed_out_players(&self) -> Vec { @@ -270,7 +270,10 @@ impl Instance { fn next_round(&mut self) -> &mut Instance { self.phase = InstancePhase::InProgress; - self.phase_start = Utc::now(); + self.phase_end = Utc::now() + .checked_add_signed(Duration::seconds(60)) + .expect("could not set phase end"); + if self.rounds.len() >= self.max_rounds { return self.finish(); @@ -811,7 +814,7 @@ mod tests { instance.player_ready(a_id).expect("a ready"); instance.player_ready(b_id).expect("b ready"); - instance.phase_start = Utc::now().checked_sub_signed(Duration::seconds(61)).unwrap(); + instance.phase_end = Utc::now().checked_sub_signed(Duration::seconds(61)).unwrap(); let (mut instance, new_games) = instance.upkeep(); diff --git a/server/src/vbox.rs b/server/src/vbox.rs index 81dc8523..300da22e 100644 --- a/server/src/vbox.rs +++ b/server/src/vbox.rs @@ -333,9 +333,9 @@ fn get_combos() -> Vec { let mut combinations = vec![ Combo { units: vec![Var::Buff, Var::Red, Var::Red], var: Var::Empower }, Combo { units: vec![Var::Buff, Var::Green, Var::Green], var: Var::Triage }, - Combo { units: vec![Var::Buff, Var::Blue, Var::Blue], var: Var::Hostility }, + Combo { units: vec![Var::Buff, Var::Blue, Var::Blue], var: Var::Amplify }, Combo { units: vec![Var::Buff, Var::Red, Var::Green], var: Var::Clutch }, - Combo { units: vec![Var::Buff, Var::Green, Var::Blue], var: Var::Amplify }, + Combo { units: vec![Var::Buff, Var::Green, Var::Blue], var: Var::Hostility }, Combo { units: vec![Var::Buff, Var::Red, Var::Blue], var: Var::Haste }, Combo { units: vec![Var::Debuff, Var::Red, Var::Red], var: Var::Snare },