Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualKhoaVN

Posted 13 October 2012 - 10:24 PM

My Java exercise is creating a card game like Microsoft Hearts plus multiplayer via internet.
I decided to let player create game room.
When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist.
The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server.
If I send an object, I can use arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time)
I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example:
We have
Game : a b c d e f
Index : 1 2 3 4 5 6
We remove c
Game : a b d e f
Index : 1 2 3 4 5
In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not existing, but its index is 3. It is still there.
Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.

#3KhoaVN

Posted 13 October 2012 - 09:12 PM

My Java exercise is creating a card game like Microsoft Hearts plus multiplayer via internet.
I decided to let player create game room.
When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist.
The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server.
If I send an object, I can us arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time)
I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example:
We have
Game : a b c d e f
Index : 1 2 3 4 5 6
We remove c
Game : a b d e f
Index : 1 2 3 4 5
In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not existing, but its index is 3. It is still there.
Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.

#2KhoaVN

Posted 13 October 2012 - 09:10 PM

My Java exercise is creating a card game like Microsoft Hearts plus multiplayer via internet.
I decided to let player create game room.
When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist.
The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server.
If I send an object, I can us arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time)
I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example:
We have
Game : a b c d e f
Index : 1 2 3 4 5 6
We remove c
Game : a b d e f
Index : 1 2 3 4 5
In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not existing, but its index is 3. It is still there.
Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.

#1KhoaVN

Posted 13 October 2012 - 09:06 PM

My Java exercise is creating a card game like Microsoft Hearts plus multiplayer via internet.
I decided to let player create game room.
When player clicks button create game, a signal is send to server, and server creates a game object. This game object is managed by using an arraylist.
The problem is if this game is destroyed, others player don’t know it was removed. They choose game from their lists and send it back to server.
If I send an object, I can us arraylist.contains(…) to determine if this game still exist or not. However, I think this way is not good because we must loop all array for each client request. This is not efficient (I assume we have a lot of players at the same time)
I move to other way. I send index of the game I choose. At server, I get the game with this index. If the comparison returns true, this game is still there and vice versa. It sounds good but new problem appears. Let see this example:
We have
Game : a b c d e f
Index : 1 2 3 4 5 6
We remove c
Game : a b d e f
Index : 1 2 3 4 5
In this case, player chooses game “c”, we can definitely say “c” is out. If player chooses game “d”, he sends to server index 4. Now, 4 is game “e” and the comparison return false. We say game not exist, but its index is 3. It is still there.
Hic. I don’t know how to do. I hope receiving advice from you. Thx a lot.

PARTNERS