Skip to content

Commit

Permalink
Adjust naming
Browse files Browse the repository at this point in the history
  • Loading branch information
Shatur committed Mar 2, 2025
1 parent c63ede3 commit d54ba50
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions bevy_replicon_example_backend/examples/tic_tac_toe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,15 +96,15 @@ fn read_cli(mut commands: Commands, cli: Res<Cli>) -> io::Result<()> {
Cli::Hotseat => {
info!("starting hotseat");
// Set all players to server to play from a single machine and start the game right away.
commands.spawn((LocalPlayer, Symbol::Cross, PlayerClient(SERVER)));
commands.spawn((LocalPlayer, Symbol::Nought, PlayerClient(SERVER)));
commands.spawn((LocalPlayer, PlayerOwner(SERVER), Symbol::Cross));
commands.spawn((LocalPlayer, PlayerOwner(SERVER), Symbol::Nought));
commands.set_state(GameState::InGame);
}
Cli::Server { port, symbol } => {
info!("starting server as {symbol} at port {port}");
let server = ExampleServer::new(port)?;
commands.insert_resource(server);
commands.spawn((LocalPlayer, symbol, PlayerClient(SERVER)));
commands.spawn((LocalPlayer, PlayerOwner(SERVER), symbol));
}
Cli::Client { port } => {
info!("connecting to port {port}");
Expand Down Expand Up @@ -244,7 +244,7 @@ fn apply_pick(
mut commands: Commands,
cells: Query<(Entity, &Cell)>,
turn_symbol: Res<TurnSymbol>,
players: Query<(&PlayerClient, &Symbol)>,
players: Query<(&PlayerOwner, &Symbol)>,
) {
// It's good to check the received data because client could be cheating.
if trigger.index > GRID_SIZE * GRID_SIZE {
Expand All @@ -254,7 +254,7 @@ fn apply_pick(

if !players
.iter()
.any(|(&client, &symbol)| *client == trigger.client_entity && symbol == **turn_symbol)
.any(|(&owner, &symbol)| *owner == trigger.client_entity && symbol == **turn_symbol)
{
error!(
"`{}` chose cell {} at wrong turn",
Expand Down Expand Up @@ -349,8 +349,8 @@ fn init_client(
let player_entity = commands
.spawn((
Player,
PlayerOwner(trigger.client_entity),
server_symbol.next(),
PlayerClient(trigger.client_entity),
))
.id();
entity_map.insert(player_entity, trigger.player_entity);
Expand Down Expand Up @@ -625,7 +625,7 @@ struct LocalPlayer;
///
/// It's not replicated and present only on server or singleplayer.
#[derive(Clone, Copy, Component, Deref)]
struct PlayerClient(Entity);
struct PlayerOwner(Entity);

/// A trigger that indicates a symbol pick.
///
Expand Down

0 comments on commit d54ba50

Please sign in to comment.