Perfect PlayerDictionary and Player
Posted: Tue Dec 31, 2019 11:39 am
Perfect PlayerDictionary must have the following properties:
1. It should be one for the whole plugin.
2. It should add and remove player instances when client connect to the server and disconnects from the server respectively.
3. It should if necessary contains functions related to many players.
Also PlayerDictionary must store instances of perfect Player class which have the following properties:
1. It should be inherited from PlayerMixin or another good implementation which also inherited from PlayerMixin.
2. It should store only functions related to the player itself.
3. It shoudn't store functions related to many players.
In this way I do not recommend using standard Player and PlayerDictionary from Source.Python because they don't meet these requirements.
I created a sample prototype of perfect realization of PlayerDictionary and Player.
PlayerDictionary:
Player:
Edit:
Probably better though separate functions related to many players in another class so it doesn't bend the meaning of PlayerDictionary only for associating indexes with some instances.
So we can have a list with player instances for fast iterating over it and PlayerDictionary itself only for retrieving instance by index from it.
I'll redo it later.
1. It should be one for the whole plugin.
2. It should add and remove player instances when client connect to the server and disconnects from the server respectively.
3. It should if necessary contains functions related to many players.
Also PlayerDictionary must store instances of perfect Player class which have the following properties:
1. It should be inherited from PlayerMixin or another good implementation which also inherited from PlayerMixin.
2. It should store only functions related to the player itself.
3. It shoudn't store functions related to many players.
In this way I do not recommend using standard Player and PlayerDictionary from Source.Python because they don't meet these requirements.
I created a sample prototype of perfect realization of PlayerDictionary and Player.
PlayerDictionary:
Player:
Edit:
Probably better though separate functions related to many players in another class so it doesn't bend the meaning of PlayerDictionary only for associating indexes with some instances.
So we can have a list with player instances for fast iterating over it and PlayerDictionary itself only for retrieving instance by index from it.
I'll redo it later.