]> git.cworth.org Git - empires-server/commit
game: Store players in both an array _and_ a session-indexed object
authorCarl Worth <cworth@cworth.org>
Fri, 5 Jun 2020 23:15:47 +0000 (16:15 -0700)
committerCarl Worth <cworth@cworth.org>
Fri, 5 Jun 2020 23:15:47 +0000 (16:15 -0700)
commit756dc24a56a1da12d01025d7ebdef88ac7ea3471
treec2034c863a76eb01c4f3adda87dd154eeeac3664
parentcf23efebe1600d10396b674e20e7cdf7f88bb58f
game: Store players in both an array _and_ a session-indexed object

We originally wrote the code storing palyers in an array, and then we
changed to using an object (indexed by session ID) for convenience in
looking up players by the session ID value.

Here, we add the array back so that we can access players either way:

1. Indexing into players_by_session to lookup a player by session ID

2. Iterating over players when we want to access players in order

The second usage, (in order), will be convenient for a subsequent
commit where we assign teams out to players in the order that they
joined the game.
game.js
lmno.js