Minor tweaks (and cargo fmt
got aggressive)
This commit is contained in:
parent
89b9bf860b
commit
567cec9500
2 changed files with 236 additions and 195 deletions
|
@ -84,6 +84,19 @@ impl GameState {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn get_network_current_side(&self) -> Option<Turn> {
|
||||
if let GameState::NetworkedMultiplayer {
|
||||
paired: _,
|
||||
current_side,
|
||||
current_turn: _,
|
||||
} = *self
|
||||
{
|
||||
current_side
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_networked_current_turn(&mut self, turn: Turn) {
|
||||
if let GameState::NetworkedMultiplayer {
|
||||
paired: _,
|
||||
|
|
|
@ -702,12 +702,6 @@ impl Component for Wrapper {
|
|||
current_side,
|
||||
current_turn,
|
||||
} => {
|
||||
log::warn!(
|
||||
"paired is {}, current_side is {:?}, current_turn is {:?}",
|
||||
paired,
|
||||
current_side,
|
||||
current_turn
|
||||
);
|
||||
if paired {
|
||||
if let Some(current_side) = current_side {
|
||||
if current_side == current_turn {
|
||||
|
@ -715,7 +709,6 @@ impl Component for Wrapper {
|
|||
}
|
||||
}
|
||||
}
|
||||
log::warn!("Set place request to {:?}", self.place_request);
|
||||
return true;
|
||||
}
|
||||
GameState::PostGameResults(_) => (),
|
||||
|
@ -1212,7 +1205,8 @@ impl Component for Wrapper {
|
|||
WrapperMsg::BackendRequest { place } => {
|
||||
self.place_request = Some(place);
|
||||
}
|
||||
WrapperMsg::BackendResponse(br_enum) => match br_enum {
|
||||
WrapperMsg::BackendResponse(br_enum) => {
|
||||
match br_enum {
|
||||
BREnum::Error(string) => {
|
||||
// TODO maybe suppress this for release builds
|
||||
log::warn!("{}", string);
|
||||
|
@ -1238,7 +1232,14 @@ impl Component for Wrapper {
|
|||
append_to_info_text(
|
||||
&document,
|
||||
"info_text1",
|
||||
"<b class=\"cyan\">It is CyanPlayer's Turn</b>",
|
||||
&format!(
|
||||
"<b class=\"cyan\">It is CyanPlayer's ({}) Turn</b>",
|
||||
if turn_type == Turn::CyanPlayer {
|
||||
"your"
|
||||
} else {
|
||||
"opponent's"
|
||||
}
|
||||
),
|
||||
1,
|
||||
)
|
||||
.ok();
|
||||
|
@ -1263,7 +1264,14 @@ impl Component for Wrapper {
|
|||
append_to_info_text(
|
||||
&document,
|
||||
"info_text1",
|
||||
"<b class=\"cyan\">It is CyanPlayer's Turn</b>",
|
||||
&format!(
|
||||
"<b class=\"cyan\">It is CyanPlayer's ({}) Turn</b>",
|
||||
if turn_type == Turn::CyanPlayer {
|
||||
"your"
|
||||
} else {
|
||||
"opponent's"
|
||||
}
|
||||
),
|
||||
1,
|
||||
)
|
||||
.ok();
|
||||
|
@ -1283,7 +1291,18 @@ impl Component for Wrapper {
|
|||
append_to_info_text(
|
||||
&document,
|
||||
"info_text1",
|
||||
"<b class=\"cyan\">It is CyanPlayer's Turn</b>",
|
||||
&format!(
|
||||
"<b class=\"cyan\">It is CyanPlayer's ({}) Turn</b>",
|
||||
if current_game_state
|
||||
.get_network_current_side()
|
||||
.unwrap_or(Turn::CyanPlayer)
|
||||
== Turn::CyanPlayer
|
||||
{
|
||||
"your"
|
||||
} else {
|
||||
"opponent's"
|
||||
}
|
||||
),
|
||||
1,
|
||||
)
|
||||
.ok();
|
||||
|
@ -1291,12 +1310,20 @@ impl Component for Wrapper {
|
|||
}
|
||||
NetworkedGameState::MagentaTurn => {
|
||||
if current_game_state.get_current_turn() != Turn::MagentaPlayer {
|
||||
current_game_state.set_networked_current_turn(Turn::MagentaPlayer);
|
||||
current_game_state
|
||||
.set_networked_current_turn(Turn::MagentaPlayer);
|
||||
shared.game_state.set(current_game_state);
|
||||
append_to_info_text(
|
||||
&document,
|
||||
"info_text1",
|
||||
"<b class=\"magenta\">It is MagentaPlayer's Turn</b>",
|
||||
&format!(
|
||||
"<b class=\"magenta\">It is MagentaPlayer's ({}) Turn</b>",
|
||||
if current_game_state.get_network_current_side().unwrap_or(Turn::CyanPlayer) == Turn::MagentaPlayer
|
||||
{
|
||||
"your"
|
||||
} else {
|
||||
"opponent's"
|
||||
}),
|
||||
1,
|
||||
)
|
||||
.ok();
|
||||
|
@ -1493,7 +1520,8 @@ impl Component for Wrapper {
|
|||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
} // match (msg)
|
||||
|
||||
true
|
||||
|
|
Loading…
Reference in a new issue