Skip to content

Commit facc569

Browse files
committed
v1.0.16hf
1 parent 5166d87 commit facc569

File tree

7 files changed

+49
-32
lines changed

7 files changed

+49
-32
lines changed

assets/head/octopulp1.png

3 Bytes
Loading

assets/planets/.DS_Store

0 Bytes
Binary file not shown.

src/engine/game.rs

+5-2
Original file line numberDiff line numberDiff line change
@@ -396,11 +396,14 @@ impl<'game> Game {
396396
fn apply_tiredness_update(&mut self) {
397397
for team in [&mut self.home_team_in_game, &mut self.away_team_in_game] {
398398
for (id, player) in team.players.iter_mut() {
399-
let stats = team.stats.get_mut(&id).unwrap();
399+
let stats = team.stats.get_mut(&id).expect("Player should have stats");
400400
if stats.is_playing() && !self.timer.is_break() {
401401
stats.seconds_played += 1;
402402
if !player.is_knocked_out() {
403-
stats.experience_at_position[stats.position.unwrap() as usize] += 1;
403+
stats.experience_at_position[stats
404+
.position
405+
.expect("Playing player should have a position")
406+
as usize] += 1;
404407
player.add_tiredness(TirednessCost::LOW);
405408
}
406409
} else if player.tiredness > RECOVERING_TIREDNESS_PER_SHORT_TICK

src/ui/swarm_panel.rs

+10-3
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,12 @@ impl SwarmPanel {
217217
format!(
218218
"{} ({})",
219219
team.name.clone(),
220-
peer_id.to_base58().chars().take(6).collect::<String>()
220+
peer_id
221+
.to_base58()
222+
.chars()
223+
.skip(8)
224+
.take(8)
225+
.collect::<String>()
221226
),
222227
style,
223228
)));
@@ -271,6 +276,8 @@ impl SwarmPanel {
271276
continue;
272277
}
273278

279+
let peer_id = peer_id.unwrap();
280+
274281
let line_split = Layout::horizontal([
275282
Constraint::Length(32),
276283
Constraint::Length(6),
@@ -293,10 +300,10 @@ impl SwarmPanel {
293300
team.name,
294301
world.team_rating(team.team_id).unwrap_or_default().stars(),
295302
peer_id
296-
.unwrap()
297303
.to_base58()
298304
.chars()
299-
.take(6)
305+
.skip(8)
306+
.take(8)
300307
.collect::<String>()
301308
),
302309
UiCallbackPreset::GoToTeam {

src/ui/ui.rs

+15-12
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use super::popup_message::PopupMessage;
66
use super::splash_screen::{AudioPlayerState, SplashScreen};
77
use super::traits::SplitPanel;
88
use super::ui_callback::{CallbackRegistry, UiCallbackPreset};
9+
use super::utils::SwarmPanelEvent;
910
use super::widgets::default_block;
1011
use super::{
1112
game_panel::GamePanel, my_team_panel::MyTeamPanel, new_team_screen::NewTeamScreen,
@@ -353,20 +354,22 @@ impl Ui {
353354
active_render
354355
}
355356
};
356-
if render_result.is_err() {
357-
self.push_popup(PopupMessage::Error(
358-
format!("Render error\n{}", render_result.err().unwrap().to_string()),
359-
true,
360-
Tick::now(),
361-
));
357+
if let Err(err) = render_result {
358+
let event = SwarmPanelEvent {
359+
timestamp: Tick::now(),
360+
peer_id: None,
361+
text: format!("Render error\n{}", err.to_string()),
362+
};
363+
self.swarm_panel.push_log_event(event);
362364
}
363365

364-
if self.render_popup_messages(frame, area).is_err() {
365-
self.push_popup(PopupMessage::Error(
366-
"Popup render error".into(),
367-
true,
368-
Tick::now(),
369-
));
366+
if let Err(err) = self.render_popup_messages(frame, area) {
367+
let event = SwarmPanelEvent {
368+
timestamp: Tick::now(),
369+
peer_id: None,
370+
text: format!("Popup render error\n{}", err.to_string()),
371+
};
372+
self.swarm_panel.push_log_event(event);
370373
}
371374
self.last_update = Instant::now();
372375
}

src/ui/widgets.rs

+17-13
Original file line numberDiff line numberDiff line change
@@ -241,20 +241,24 @@ pub fn render_challenge_button<'a>(
241241
frame.render_widget(decline_button, c_split[2]);
242242
} else {
243243
let challenge_button = if let Some(game_id) = team.current_game {
244-
let game = world.get_game_or_err(game_id)?;
245-
let game_text = if let Some(action) = game.action_results.last() {
246-
format!(
247-
"{} {:>3}-{:<3} {}",
248-
game.home_team_in_game.name,
249-
action.home_score,
250-
action.away_score,
251-
game.away_team_in_game.name,
252-
)
244+
// The game is not necessarily part of the world if it's a network game.
245+
let game_text = if let Ok(game) = world.get_game_or_err(game_id) {
246+
if let Some(action) = game.action_results.last() {
247+
format!(
248+
"{} {:>3}-{:<3} {}",
249+
game.home_team_in_game.name,
250+
action.home_score,
251+
action.away_score,
252+
game.away_team_in_game.name,
253+
)
254+
} else {
255+
format!(
256+
"{} 0-0 {}",
257+
game.home_team_in_game.name, game.away_team_in_game.name,
258+
)
259+
}
253260
} else {
254-
format!(
255-
"{} 0-0 {}",
256-
game.home_team_in_game.name, game.away_team_in_game.name,
257-
)
261+
"Unknown game".to_string()
258262
};
259263
Button::new(
260264
format!("Playing - {}", game_text),

src/world/constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ pub const SOL_ID: Lazy<PlanetId> = Lazy::new(|| PlanetId::try_parse(SOL_STR).unw
9393
pub struct TirednessCost;
9494
impl TirednessCost {
9595
pub const NONE: f32 = 0.0;
96-
pub const LOW: f32 = 0.0075;
97-
pub const MEDIUM: f32 = 0.175;
96+
pub const LOW: f32 = 0.005;
97+
pub const MEDIUM: f32 = 0.15;
9898
pub const HIGH: f32 = 0.5;
9999
pub const SEVERE: f32 = 2.5;
100100
pub const CRITICAL: f32 = 5.0;

0 commit comments

Comments
 (0)