Page 1 of 1
How to lock the room when play more than 2 people
Posted: 07 Apr 2005, 12:40
by Kawa
I under development card game with SmartFoxBasic (slave game).It 90% almost finish but I can't solve one problem and need your advice.
OK I will explain my game first.My game can play 4-6 players.The first round every player be people and next round the first winner will be king and receive 2 best card from slave who lose in last round.OK no problem about game rule. My problem is about how to lock the game room at game lobby.Because if some player in game left the game I want the game can play until end of the game and don't allow other people enter the room.But I found that at the game lobby the room list automatic list by server and if some one left the game other people in main lobby can click and enter to the game and make the game fail.I try to make new XML value and send to SFS to tell all people that room is lock but i think SFS not allow to do that.Hope you have good solution Lapo ,Thank you.
Posted: 07 Apr 2005, 13:48
by Lapo
Hello Kawa,
one solution could be to keep the status of each game and allow or disallow players to enter in a game room depending on the status of the game.
In other words:
1) keep track of each game by using a simple array
2) when the game is not started people will be able to enter the game room
3) when the game is started you set a flag in the game object, this will tell you the status of the game
4) If someone wants to enter in a game room you check that flag and see if they can enter or not
5) finally when a games is finished, you set the game flag back to false to allow people create a new match
makes sense?

Posted: 08 Apr 2005, 03:37
by Kawa
Thank Lapo!
But my exact problem is the room list update at the main lobby.I don't have problem when start game but during the game if anyone leave the game.Your function "RoomListUpdate" and "UpdateRoomStatus" will update status of the room automaticly.
Let me give an example.If I create the room for 4 players and 4 player enter the game room.The status of this room at main lobby show "[4/4]roomname" and other people can't enter game room because game room is full.But when one of the player leave the room(close browser).Your server will know and auto update this room to "[3/4]roomname" and other people can enter this room because room status isn't full.But I don't want it because 1) if new one enter the game after the game already start.The game will fail because the new one don't have any parameter when other players have. 2) the game can play even one or two player leave the game.This is because it not good if one player left and give the game end.
So my exact question is how to tell the server that this room is lock even the room isn't full.
Posted: 08 Apr 2005, 07:22
by Lapo
You don't have to tell the server to do that. You have to implement a little bit of game logic on your side to add this feature.
You can control when a user clicks a room to go inside. That's the point where you have to make controls. If the room is a game and the game is not finished yet, you simply discard the user request or show a message saying "Game is busy" or so
Now the problem is how to keep track of the statuses of the other rooms. A nice solution is to keep the status in room variables in main Lobby.
In other words you should have one variable for each game room that tells you if the game is busy or not. If it's busy you will not allow users to join that room
Makes more sense?

Posted: 08 Apr 2005, 08:08
by Kawa
Now the problem is how to keep track of the statuses of the other rooms. A nice solution is to keep the status in room variables in main Lobby.
In other words you should have one variable for each game room that tells you if the game is busy or not. If it's busy you will not allow users to join that room
Yes,Lapo and my problem is this point.Yes,I can keep status of all room in main Lobby and all users in main Lobby 'at that time' know all room status.But problem happen with user who just arrive.New arrival users don't have any room status.They receive all room status from server and how can they know the room is busy or not.That why I ask you how can the server know and tell new arrival user to know the room status.
Sorry Lapo my English is not so good and may not clear in some points.
Posted: 08 Apr 2005, 08:30
by Lapo
When a new user logs in the "Main Lobby" (which I suppose is the default room) he receives also all the variables for that room, therefore he knows the status of all the current games.
Let me know if you have any other questions
