phase end
This commit is contained in:
parent
2dfdd0d09c
commit
7319b4b2ba
@ -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;
|
||||
|
||||
@ -78,6 +78,18 @@ function GamePanel(props) {
|
||||
</div>
|
||||
);
|
||||
|
||||
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 = (
|
||||
<progress value="100">
|
||||
<div className="progress-container">
|
||||
<span className="progress-bar"></span>
|
||||
</div>
|
||||
</progress>
|
||||
);
|
||||
|
||||
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 (
|
||||
<main className="game" onClick={() => setActiveCryp(null)} >
|
||||
{header}
|
||||
{timer}
|
||||
{PlayerTeam(playerTeam, setActiveSkill)}
|
||||
<div className="mobile-skills">
|
||||
{mobileSkills}
|
||||
|
||||
@ -37,7 +37,7 @@ pub struct Game {
|
||||
pub resolved: Vec<Resolution>,
|
||||
pub log: Vec<String>,
|
||||
pub instance: Option<Uuid>,
|
||||
phase_start: DateTime<Utc>,
|
||||
phase_end: DateTime<Utc>,
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -48,7 +48,7 @@ pub struct Instance {
|
||||
max_rounds: usize,
|
||||
password: Option<String>,
|
||||
pub name: String,
|
||||
phase_start: DateTime<Utc>,
|
||||
phase_end: DateTime<Utc>,
|
||||
}
|
||||
|
||||
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<Uuid> {
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -333,9 +333,9 @@ fn get_combos() -> Vec<Combo> {
|
||||
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 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user