Skip to content

Commit

Permalink
Lots of improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
BakerNet committed Oct 14, 2024
1 parent 3198f5e commit 31f730a
Show file tree
Hide file tree
Showing 8 changed files with 352 additions and 141 deletions.
2 changes: 2 additions & 0 deletions web/migrations/0009_games_timed_out_seconds.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
alter table games add column timed_out integer null;
alter table games add column seconds integer null;
15 changes: 9 additions & 6 deletions web/src/app/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,15 @@ pub fn Header(user: Resource<Option<FrontendUser>, JsonSerdeCodec>) -> impl Into
<A href="/" attr:class="flex items-center space-x-2">
<h1>{logo()}</h1>
</A>
<A href="/active" attr:class=format!("{} flex items-center space-x-2 text-lg", aclass)>
"Active Games"
</A>
<A href="/recent" attr:class=format!("{} flex items-center space-x-2 text-lg", aclass)>
"Recent Games"
</A>
<div class="flex items-center space-x-2">
<A href="/active" attr:class=format!("{} text-lg", aclass)>
"Active Games"
</A>
<span>"|"</span>
<A href="/recent" attr:class=format!("{} text-lg", aclass)>
"Recent Games"
</A>
</div>
<div class="flex grow justify-end items-center space-x-2">
<Transition fallback=move || ()>
{move || Suspend::new(async move {
Expand Down
48 changes: 24 additions & 24 deletions web/src/app/minesweeper/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,23 +29,23 @@ pub enum GameMode {
impl GameMode {
pub fn short_name(self) -> &'static str {
match self {
GameMode::ClassicBeginner => "Beginner",
GameMode::ClassicIntermediate => "Intermediate",
GameMode::ClassicExpert => "Expert",
GameMode::SmallMultiplayer => "Small",
GameMode::LargeMultiplayer => "Large",
GameMode::Custom => "Custom",
Self::ClassicBeginner => "Beginner",
Self::ClassicIntermediate => "Intermediate",
Self::ClassicExpert => "Expert",
Self::SmallMultiplayer => "Small",
Self::LargeMultiplayer => "Large",
Self::Custom => "Custom",
}
}

pub fn long_name(self) -> &'static str {
match self {
GameMode::ClassicBeginner => "Classic Beginner",
GameMode::ClassicIntermediate => "Classic Intermediate",
GameMode::ClassicExpert => "Classic Expert",
GameMode::SmallMultiplayer => "Multiplayer Small",
GameMode::LargeMultiplayer => "Multiplayer Large",
GameMode::Custom => "Custom",
Self::ClassicBeginner => "Classic Beginner",
Self::ClassicIntermediate => "Classic Intermediate",
Self::ClassicExpert => "Classic Expert",
Self::SmallMultiplayer => "Multiplayer Small",
Self::LargeMultiplayer => "Multiplayer Large",
Self::Custom => "Custom",
}
}
}
Expand All @@ -59,32 +59,32 @@ impl Default for GameMode {
impl From<&GameMode> for GameSettings {
fn from(value: &GameMode) -> Self {
match value {
GameMode::ClassicBeginner => GameSettings {
GameMode::ClassicBeginner => Self {
rows: 9,
cols: 9,
num_mines: 10,
max_players: 1,
},
GameMode::ClassicIntermediate => GameSettings {
GameMode::ClassicIntermediate => Self {
rows: 16,
cols: 16,
num_mines: 40,
max_players: 1,
},
GameMode::ClassicExpert => GameSettings {
GameMode::ClassicExpert => Self {
rows: 16,
cols: 30,
num_mines: 99,
max_players: 1,
},
GameMode::SmallMultiplayer => GameSettings {
GameMode::SmallMultiplayer => Self {
rows: 16,
cols: 30,
num_mines: 80,
max_players: 2,
},
GameMode::LargeMultiplayer => GameSettings::default(),
GameMode::Custom => GameSettings::default(),
GameMode::LargeMultiplayer => Self::default(),
GameMode::Custom => Self::default(),
}
}
}
Expand All @@ -103,32 +103,32 @@ impl From<&GameSettings> for GameMode {
cols: 9,
num_mines: 10,
max_players: 1,
} => GameMode::ClassicBeginner,
} => Self::ClassicBeginner,
GameSettings {
rows: 16,
cols: 16,
num_mines: 40,
max_players: 1,
} => GameMode::ClassicIntermediate,
} => Self::ClassicIntermediate,
GameSettings {
rows: 16,
cols: 30,
num_mines: 99,
max_players: 1,
} => GameMode::ClassicExpert,
} => Self::ClassicExpert,
GameSettings {
rows: 16,
cols: 30,
num_mines: 80,
max_players: 2,
} => GameMode::SmallMultiplayer,
} => Self::SmallMultiplayer,
GameSettings {
rows: 50,
cols: 50,
num_mines: 500,
max_players: 8,
} => GameMode::LargeMultiplayer,
_ => GameMode::Custom,
} => Self::LargeMultiplayer,
_ => Self::Custom,
}
}
}
Expand Down
Loading

0 comments on commit 31f730a

Please sign in to comment.