auto ready for learn mode and remove upkeep warnings
This commit is contained in:
parent
8aee7dc084
commit
44f008740e
@ -49,6 +49,11 @@ function InstanceCtrlBtns(args) {
|
|||||||
|
|
||||||
const finished = instance && instance.phase === 'Finished';
|
const finished = instance && instance.phase === 'Finished';
|
||||||
|
|
||||||
|
const skip = instance.time_control === 'Practice' && instance.phase === 'Lobby';
|
||||||
|
if (skip) {
|
||||||
|
sendReady();
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div class="instance-ctrl-btns">
|
<div class="instance-ctrl-btns">
|
||||||
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>
|
<button disabled={!account.subscribed} onClick={() => setChatShow(!chatShow)}>Chat</button>
|
||||||
|
|||||||
@ -209,7 +209,6 @@ function registerEvents(store) {
|
|||||||
return store.dispatch(actions.setInvite(code));
|
return store.dispatch(actions.setInvite(code));
|
||||||
}
|
}
|
||||||
|
|
||||||
let autoReady = null;
|
|
||||||
function setInstance(v) {
|
function setInstance(v) {
|
||||||
const { account, instance, ws, tutorial } = store.getState();
|
const { account, instance, ws, tutorial } = store.getState();
|
||||||
if (v) {
|
if (v) {
|
||||||
@ -218,25 +217,10 @@ function registerEvents(store) {
|
|||||||
const player = v.players.find(p => p.id === account.id);
|
const player = v.players.find(p => p.id === account.id);
|
||||||
store.dispatch(actions.setPlayer(player));
|
store.dispatch(actions.setPlayer(player));
|
||||||
|
|
||||||
if (!instance || v.id !== instance.id) {
|
|
||||||
clearTimeout(autoReady);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v.phase === 'Finished') {
|
if (v.phase === 'Finished') {
|
||||||
ws.sendAccountInstances();
|
ws.sendAccountInstances();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (v.phase_end && v.phase === 'Lobby' && !autoReady) {
|
|
||||||
const skip = v.time_control === 'Practice' ? 10000 : 2000;
|
|
||||||
const autoReadyDelay = Date.parse(v.phase_end) - Date.now() - skip;
|
|
||||||
autoReady = setTimeout(() => {
|
|
||||||
ws.sendInstanceReady(v.id);
|
|
||||||
autoReady = null;
|
|
||||||
}, autoReadyDelay);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (v.phase !== 'Lobby') clearTimeout(autoReady);
|
|
||||||
|
|
||||||
// instance.mobile.less hides info at @media 1000
|
// instance.mobile.less hides info at @media 1000
|
||||||
if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) {
|
if (localStorage.getItem('tutorial-complete') || window.innerWidth <= 1100) {
|
||||||
store.dispatch(actions.setTutorial(null));
|
store.dispatch(actions.setTutorial(null));
|
||||||
|
|||||||
@ -469,14 +469,14 @@ impl Game {
|
|||||||
|
|
||||||
let mut resolutions = resolution_steps(&cast, &mut self);
|
let mut resolutions = resolution_steps(&cast, &mut self);
|
||||||
r_animation_ms = resolutions.iter().fold(r_animation_ms, |acc, r| acc + r.clone().get_delay());
|
r_animation_ms = resolutions.iter().fold(r_animation_ms, |acc, r| acc + r.clone().get_delay());
|
||||||
|
|
||||||
|
|
||||||
// the cast itself goes into this temp vec to handle cooldowns
|
// the cast itself goes into this temp vec to handle cooldowns
|
||||||
// if theres no resolution events, the skill didn't trigger (disable etc)
|
// if theres no resolution events, the skill didn't trigger (disable etc)
|
||||||
if resolutions.len() > 0 {
|
if resolutions.len() > 0 {
|
||||||
casts.push(cast);
|
casts.push(cast);
|
||||||
}
|
}
|
||||||
|
|
||||||
self.resolved.append(&mut resolutions);
|
self.resolved.append(&mut resolutions);
|
||||||
|
|
||||||
// while let Some(resolution) = resolutions.pop() {
|
// while let Some(resolution) = resolutions.pop() {
|
||||||
@ -635,15 +635,15 @@ impl Game {
|
|||||||
for player in self.players.iter_mut() {
|
for player in self.players.iter_mut() {
|
||||||
if !player.ready {
|
if !player.ready {
|
||||||
player.set_ready(true);
|
player.set_ready(true);
|
||||||
player.add_warning();
|
// player.add_warning();
|
||||||
info!("upkeep: {:} warned", player.name);
|
// info!("upkeep: {:} warned", player.name);
|
||||||
if player.warnings >= 3 {
|
// if player.warnings >= 3 {
|
||||||
player.forfeit();
|
// player.forfeit();
|
||||||
info!("upkeep: {:} forfeited", player.name);
|
// info!("upkeep: {:} forfeited", player.name);
|
||||||
//todo
|
// //todo
|
||||||
// self.resolved.push(forfeit)
|
// // self.resolved.push(forfeit)
|
||||||
// self.log.push(format!("{:} forfeited.", player.name));
|
// // self.log.push(format!("{:} forfeited.", player.name));
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1622,6 +1622,6 @@ mod tests {
|
|||||||
game.players[0].set_ready(true);
|
game.players[0].set_ready(true);
|
||||||
game.phase_end = Some(Utc::now().checked_sub_signed(Duration::seconds(500)).unwrap());
|
game.phase_end = Some(Utc::now().checked_sub_signed(Duration::seconds(500)).unwrap());
|
||||||
game = game.upkeep();
|
game = game.upkeep();
|
||||||
assert!(game.players[1].warnings == 1);
|
// assert!(game.players[1].warnings == 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,7 +63,6 @@ pub struct Player {
|
|||||||
pub constructs: Vec<Construct>,
|
pub constructs: Vec<Construct>,
|
||||||
pub bot: bool,
|
pub bot: bool,
|
||||||
pub ready: bool,
|
pub ready: bool,
|
||||||
pub warnings: u8,
|
|
||||||
pub draw_offered: bool,
|
pub draw_offered: bool,
|
||||||
pub score: Score,
|
pub score: Score,
|
||||||
}
|
}
|
||||||
@ -85,7 +84,6 @@ impl Player {
|
|||||||
constructs,
|
constructs,
|
||||||
bot: false,
|
bot: false,
|
||||||
ready: false,
|
ready: false,
|
||||||
warnings: 0,
|
|
||||||
draw_offered: false,
|
draw_offered: false,
|
||||||
score: Score::Zero,
|
score: Score::Zero,
|
||||||
})
|
})
|
||||||
@ -100,7 +98,6 @@ impl Player {
|
|||||||
constructs,
|
constructs,
|
||||||
bot: false,
|
bot: false,
|
||||||
ready: false,
|
ready: false,
|
||||||
warnings: 0,
|
|
||||||
draw_offered: false,
|
draw_offered: false,
|
||||||
score: Score::Zero,
|
score: Score::Zero,
|
||||||
}
|
}
|
||||||
@ -134,11 +131,6 @@ impl Player {
|
|||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn add_warning(&mut self) -> &mut Player {
|
|
||||||
self.warnings += 1;
|
|
||||||
self
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn forfeit(&mut self) -> &mut Player {
|
pub fn forfeit(&mut self) -> &mut Player {
|
||||||
for construct in self.constructs.iter_mut() {
|
for construct in self.constructs.iter_mut() {
|
||||||
construct.force_ko();
|
construct.force_ko();
|
||||||
@ -358,7 +350,7 @@ impl Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
self.vbox.bound.push(target);
|
self.vbox.bound.push(target);
|
||||||
|
|
||||||
if target_construct_id.is_some() {
|
if target_construct_id.is_some() {
|
||||||
let equip_index = self.vbox.bound.len() - 1;
|
let equip_index = self.vbox.bound.len() - 1;
|
||||||
self.vbox_apply(equip_index, target_construct_id.expect("no construct"))?;
|
self.vbox_apply(equip_index, target_construct_id.expect("no construct"))?;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user