Hello,
I would like to implement a 2 player game in php in an object oriented manner. The game logic should be controlled by an object that would be instantiated by player A, yet it should also be possible for player B to access and manipulate this object. I'm not too familiar with php but after a long day of googling for answers I've learned that objects in php seem to only persist in a SESSION context (that is on a per user basis). Workarounds seem to include object serialisation/deserialisation either in a database or to/from a file. Another proposed solution could be something called "shared memory" access, yet I don't like to fiddle with such low level issues.
So I'd like to ask you: is this really all there is? And if this IS really all there is, and if I would have to go for the serialisation/deserialisation solution, isn't there a library or framework that would abstract out the implementation details of it, since I don't like re-inventing the wheel and writing up such a solution myself is likely to be auite errorprone and subject to various security issues. Yes, you can call me lazy
Many thanks.Is there any reason why each player needs to share the same object? Seems like a bit of a design issue to me.Yes, each player needs to be aware of the other one's last actions. And I don't like my gamecontrolling object to rebuild all its logic from scratch each time a user makes a request.The Memcache extension might be worth a look. To be honest though the cost of grabbing state from the db is likely to be pretty insignificant compared to processing the state changes.is the game flash or html based if so you could
A) code the flash to send its map/game data to php
B) code the php html to send the map/game data to php
the reason im referring to this as map/game data is bacause the only type of games that require this are map based games because they are the only ones working slow enough for them to be server side scripted unless you want massive overheads.
Just to satisfy my curiosity what type of game is it------------------------------------------------------
can't you do that by using one database?
each action is stored in it then other users get access to it
------------------------------------------------------yes you can store it with inline php code and using eval($db_result);
so what kind of game is this?
Top Trumps / Pokemon / Yu Gi Oh type thing / Other?I think for this case, you will be better using var_export, this will dump the object instance completely with data. and store it in your database and share it between the two players.
I would like to implement a 2 player game in php in an object oriented manner. The game logic should be controlled by an object that would be instantiated by player A, yet it should also be possible for player B to access and manipulate this object. I'm not too familiar with php but after a long day of googling for answers I've learned that objects in php seem to only persist in a SESSION context (that is on a per user basis). Workarounds seem to include object serialisation/deserialisation either in a database or to/from a file. Another proposed solution could be something called "shared memory" access, yet I don't like to fiddle with such low level issues.
So I'd like to ask you: is this really all there is? And if this IS really all there is, and if I would have to go for the serialisation/deserialisation solution, isn't there a library or framework that would abstract out the implementation details of it, since I don't like re-inventing the wheel and writing up such a solution myself is likely to be auite errorprone and subject to various security issues. Yes, you can call me lazy
Many thanks.Is there any reason why each player needs to share the same object? Seems like a bit of a design issue to me.Yes, each player needs to be aware of the other one's last actions. And I don't like my gamecontrolling object to rebuild all its logic from scratch each time a user makes a request.The Memcache extension might be worth a look. To be honest though the cost of grabbing state from the db is likely to be pretty insignificant compared to processing the state changes.is the game flash or html based if so you could
A) code the flash to send its map/game data to php
B) code the php html to send the map/game data to php
the reason im referring to this as map/game data is bacause the only type of games that require this are map based games because they are the only ones working slow enough for them to be server side scripted unless you want massive overheads.
Just to satisfy my curiosity what type of game is it------------------------------------------------------
can't you do that by using one database?
each action is stored in it then other users get access to it
------------------------------------------------------yes you can store it with inline php code and using eval($db_result);
so what kind of game is this?
Top Trumps / Pokemon / Yu Gi Oh type thing / Other?I think for this case, you will be better using var_export, this will dump the object instance completely with data. and store it in your database and share it between the two players.