diff --git a/client/cryps.css b/client/cryps.css index 3fa56ad2..e95eb617 100644 --- a/client/cryps.css +++ b/client/cryps.css @@ -377,47 +377,22 @@ header { box-shadow: inset -0.5em 0 0 0 forestgreen; } -progress { - /* Dimensions */ - width: 100%; - height: .25em; +.timer-container { + display: flex; + flex: 1 1 100%; + height: 0.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; + border: none; + margin: 0.5em 0; } -progress::-webkit-progress-bar { - background-color: forestgreen; -} +.timer { + background: whitesmoke; + transition-property: all; + transition-duration: 0.5s; + transition-delay: 0; + transition-timing-function: ease; -.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 { diff --git a/client/src/components/game.component.jsx b/client/src/components/game.component.jsx index 87c28153..5b84db3e 100644 --- a/client/src/components/game.component.jsx +++ b/client/src/components/game.component.jsx @@ -78,18 +78,6 @@ 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); @@ -97,9 +85,23 @@ function GamePanel(props) { } const otherTeams = game.players.filter(t => t.id !== account.id); - const playerTeam = game.players.find(t => t.id === account.id); + const zero = Date.parse(game.phase_end) - (1000 * 60); + const now = Date.now(); + const end = Date.parse(game.phase_end); + const timerPct = ((now - zero) / (end - zero) * 100); + const timerStyles = { + width: `${timerPct < 100 && !resolution ? timerPct : 0}%`, + background: playerTeam.ready ? 'forestgreen' : 'whitesmoke', + }; + + const timer = ( +
+
 
+
+ ); + function stackElement(c, i) { let skills = game.stack.filter(s => s.source_cryp_id === c.id).map((s, j) => { const target = findCryp(s.target_cryp_id); diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index c1b84273..ebc57b18 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -73,6 +73,22 @@ function InstanceComponent(args) { ? readyBtn : null; + // TIMER + const zero = Date.parse(instance.phase_end) - (1000 * 120); + const now = Date.now(); + const end = Date.parse(instance.phase_end); + const timerPct = ((now - zero) / (end - zero) * 100); + const timerStyles = { + width: `${timerPct < 100 ? timerPct : 0}%`, + background: player.ready ? 'forestgreen' : 'whitesmoke', + }; + + const timer = ( +
+
 
+
+ ); + return (
@@ -83,6 +99,7 @@ function InstanceComponent(args) {
{actionBtn} + {timer} diff --git a/client/src/components/vbox.component.jsx b/client/src/components/vbox.component.jsx index b354ca4a..aa169a27 100644 --- a/client/src/components/vbox.component.jsx +++ b/client/src/components/vbox.component.jsx @@ -210,7 +210,6 @@ function Vbox(args) { return setReclaiming(!reclaiming); } -console.log('reclaiminig', reclaiming) const classes = `vbox ${activeVar !== null || activeCryp ? 'hidden' : ''}`; const reclaimClass = `instance-btn instance-ui-btn vbox-btn ${reclaiming ? 'reclaiming' : ''}`; diff --git a/server/src/game.rs b/server/src/game.rs index 21e55e2c..14b0588a 100644 --- a/server/src/game.rs +++ b/server/src/game.rs @@ -564,7 +564,7 @@ impl Game { } fn phase_timed_out(&self) -> bool { - !Utc::now().signed_duration_since(self.phase_end).is_zero() + Utc::now().signed_duration_since(self.phase_end).num_milliseconds() > 0 } pub fn upkeep(mut self) -> Game { diff --git a/server/src/instance.rs b/server/src/instance.rs index 5975cff7..deabe9df 100644 --- a/server/src/instance.rs +++ b/server/src/instance.rs @@ -83,7 +83,7 @@ impl Instance { } fn phase_timed_out(&self) -> bool { - !Utc::now().signed_duration_since(self.phase_end).is_zero() + Utc::now().signed_duration_since(self.phase_end).num_milliseconds() > 0 } fn timed_out_players(&self) -> Vec {