dorbmd1177 2012-01-30 18:22 采纳率: 100%
浏览 36

基于PHP文本的游戏时间段[关闭]

Many web based text games have tasks which take real world time to complete. A basic example would be a game where you need to process some resource. You could "upgrade" your processing plant, but doing so would take, say 6 hours. If you chose to do this upgrade, you would be unable to do anything else in game until your 6 hours had elapsed, other than see a remaining time screen. Does anybody have any suggestions as to how this could be achieved in a game written in PHP?

  • 写回答

3条回答 默认 最新

  • dongweihuai5601 2012-01-30 18:37
    关注

    It's pretty straightforward actually:

    • each task is associated with a time it takes to finish it
    • while the task is active, no other tasks may be started

    Now when a user starts a new task you record the time the task was started and which task it is and add the time when it will be finished. You store that in the database. The next time the user logs into the game, you check whether there is any active tasks for that user and if so, display the remaining time.

    So you could have a table Tasks with

    • ID
    • name
    • description
    • time_to_complete

    and another table for the User and one for Active_Tasks with

    • user_id
    • task_id
    • started_at
    • ends_at

    And in your PHP script you have corresponding code to query and update those tables.

    Try to get something working from that description and when you hit any roadblocks, ask a new question about the specific parts.

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)