0

I'm trying to do a small combat system(turn based), where the user can move or atk with a unit, but I was wondering, how do it to 2 users access the same "combat"(one fight against another).

I'm thinking in before start the combat, save in session, all the data of the units(order, atk, etc), so after the user execute a command(move or atk) i need end the turn, and let the other user play...

There is a way to do it with session?? or if someone know i better way...

note: I want use less as possible of the database.

Thales_rb
  • 1
  • 1
  • 5

2 Answers2

2

When you create a new game, assign a unique ID to it.

Then set this ID to the players session.

$_SESSION['GAME_ID'] = $game_id;

This way all users who has this session game ID, would see the same game.


Further thinking would suggest to store only the PLAYER_ID in the session, and use some database to query what games the player is playing, side, color, point, and so on.

aorcsik
  • 15,271
  • 5
  • 39
  • 49
0

as I know, you can pass session id with url. so, when first player log in your system, you get his session id and save to db or a file, then when second player log in system, you should add this session id to all link in your web site.

you can look how to pass session id via url in passing session id via url

for knowing which get parameter using for sessin id passing, you can use a header listener plugin in firefox

Community
  • 1
  • 1
Adem
  • 9,402
  • 9
  • 43
  • 58