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条)

报告相同问题?

悬赏问题

  • ¥15 请问如何在openpcdet上对KITTI数据集的测试集进行结果评估?
  • ¥15 powerbuilder中的datawindow数据整合到新的DataWindow
  • ¥20 有人知道这种图怎么画吗?
  • ¥15 pyqt6如何引用qrc文件加载里面的的资源
  • ¥15 安卓JNI项目使用lua上的问题
  • ¥20 RL+GNN解决人员排班问题时梯度消失
  • ¥60 要数控稳压电源测试数据
  • ¥15 能帮我写下这个编程吗
  • ¥15 ikuai客户端l2tp协议链接报终止15信号和无法将p.p.p6转换为我的l2tp线路
  • ¥15 phython读取excel表格报错 ^7个 SyntaxError: invalid syntax 语句报错