douboshan1466 2012-01-27 18:36
浏览 58
已采纳

使用PHP / MySQL创建基于回合制的系统的可能方法[关闭]

Right, I'm trying to create a system where by the user can do something, but then must wait until all the other users in the mysql table have made their move, i.e

User1 makes move, user2 and 3 must wait user2 makes move, user 1 and 3 must wait user3 makes move, user 1 and 2 must wait user1 makes move...

One way I thought of was to give each of the users an number (ranging from 1 to the total number of players, say 6) and then when a player makes a move, set their number to the max number (6) and decrease everyone else's number by one, so the one with the minimum number is the only one who can play.

That's my only idea, is there an easier or alternative way?

  • 写回答

6条回答 默认 最新

  • dtch60248 2012-01-27 18:46
    关注

    My suggestion would be just store the last move date as a datetime. When you need to check if a user can move, simply just select out of the table all of the other players where the last move date is less than or equal to the current player's last move date. If the number of rows is not 0, then the player cannot move yet.

    The benefits of this approach is the simplicity- every time you allow a player to make a move, just update the column with the current date and time.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(5条)

报告相同问题?