Skip to content

Commit

Permalink
assign models to players upon DM assignment
Browse files Browse the repository at this point in the history
  • Loading branch information
Tyler-Lentz committed Jun 6, 2024
1 parent 26bbe3c commit cf34fb7
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,29 @@ std::chrono::milliseconds Server::doTick() {
sendUpdateToAllClients(Event(this->world_eid, EventType::LoadGameState, LoadGameStateEvent(partial_update)));
}


int player_idx = 0; // only increment when assigning a model

auto players = this->state.objects.getPlayers();
for (int i = 0; i < players.size(); i++) {
auto player = players.get(i);
if (player == nullptr) continue;

if (player_idx == 0) {
player->modelType = ModelType::PlayerFire;
} else if (player_idx == 1) {
player->modelType = ModelType::PlayerLightning;
} else if (player_idx == 2) {
player->modelType = ModelType::PlayerWater;
}

player_idx++;

if (player_idx > 2) {
player_idx = 0;
}
}

std::cout << "Assigned player " + std::to_string(index) + " to be the DM" << std::endl;
std::cout << "Starting game!" << std::endl;
}
Expand Down

0 comments on commit cf34fb7

Please sign in to comment.