Author: loic
Date: Thu Aug 6 16:37:17 2009
New Revision: 6138
URL: http://svn.gna.org/viewcvs/pokersource?rev=6138&view=rev
Log:
Allow more than one avatar per serial. The PokerTable and PokerServices had a
serial2client map associating exactly one PokerAvatar instance (named client
for historical reasons) to a serial. This map has been replaced with an
instance of the PokerAvatarCollection that associates a serial to a list of
PokerAvatar.
The PokerAvatarCollection behaves like a map that removes the entries for which
there is an empty list of avatars ( remove method ) and creates a list of
avatars if the entry for a given serial does not exist ( add method ). Creating
a class with these two methods reduces the usage complexity.
The implementation of poker-network relying on serial2client allows for
overriding an existing entry serial2client. Ideally an entry is never overriden
if it exists and any attempt should result in an error. Instead, the
PokerAvatarCollection silently ignores an attempt to add a duplicate avatar to
the list of a given serial.
The PokerService.auth method failed if an avatar attempts to authenticate using
a name that was the same as an avatar found in the serial2client map ("Already
logged in from somewhere else"). This safegard is no longer necessary as the
PokerAvatarCollection that replaces serial2client can now associate a list of
avatars to a serial. Two avatar authenticated with the same id will show in the
list associated to the serial. In addition the safegard was bugous when two
users have a different serial but use the same name.
The PokerTable.movePlayer method was provided with a single avatar. The
prototype has changed to allow a list of avatars, so that all authenticated
avatars impersonating the player are notified that the player was moved from
one table to another during a tournament.
The verbose level of the PokerAvatar is set from the container verbose level.
The verbose messages of the PokerService instance are prefixed with "service"
and those of PokerTable are prefixed with "TableX" where X is the id of the
table.
When a PokerTable is destroyed, the deletion code that removes the table from
the list of tables known by each avatar that is joined to it is slightly more
complex but remains essentially the same. The test and the comment associated
with this method has been removed because the structure change made this test
obsolete. The same logic was applied to the destroyPlayer method.
When a PokerTable such as getName needs to call an avatar function for caching
purposes, it uses the first avatar in the list. It works as long as all avatars
contain the exact same information.
All tests have been modified, run and the coverage percentage was preserved.
tests/test-pokeravatar.py.in::test67_getPlayerInfoBug(self) was removed
because it does not refer to a bug description and fails under the new
implementation, because there are many avatars for a single serial.
tests/test-pokeravatar.py.in::test04_relogin_avatarExists(self) was modified
because relogin when an avatar already exists does not have the same semantic (
new avatar is appened instead of replacing the previous one )
task #6690
Modified:
branches/multi-session/pokernetwork/pokeravatar.py
branches/multi-session/pokernetwork/pokerservice.py
branches/multi-session/pokernetwork/pokertable.py
branches/multi-session/pokernetwork/server.py
branches/multi-session/tests/test-pokeravatar.py.in
branches/multi-session/tests/test-pokerclient.py.in
branches/multi-session/tests/test-pokerservice.py.in
branches/multi-session/tests/test-pokersite.py.in
branches/multi-session/tests/test-pokertable.py.in
branches/multi-session/tests/test-tourneytablebalance.py.in
branches/multi-session/tests/testmessages.py
_______________________________________________
Pokersource-commits mailing list
[email protected]
https://mail.gna.org/listinfo/pokersource-commits