dongqiuxu2270 2011-10-19 11:25
浏览 82
已采纳

基于PHP文本的MMO游戏任务组织

I am developing a php text based game. I am organizing tasks in games. Basically tasks increase the understanding of the game.

A task is a group of small actions in the game.

For example:

TASK Description: You are required to steal a bike, repair it and ship to another city.

It includes 3 actions.

  1. Steal a bike
  2. Repair the bike
  3. Ship it to another city (let say London)

These 3 actions are possible at single of different pages.

I created a table for TASK(task_id, title, description (TASK Description Above),STATUS), but I'm not sure how to store and execute actions of task.

I have one idea, to use a related table TASK_ACTIONS (task_id, action_id,action(?),done)

But I'm not sure in which form to store actions action(?):

An sql statement to check for actions Like following three points.

  1. Bike has been stolen or not. If yes, Mark action to DONE
  2. Bike has been repaired or still damaged. If repaired, Mark Action DONE
  3. Bike has been shipped to London or not. If shipped, Mark Action DONE

If all above marked DONE then mark TASK STATUS as COMPLETED, show next task.

  • 写回答

1条回答 默认 最新

  • doujiaci7976 2011-10-19 13:57
    关注

    A cheap way to do this would look like this:

    tasks
    {
        user_id
        has_theft_bike
        has_repaired_bike
        ... 
    }
    

    However, this is not easy to expand. A more correct way would be to define all actions in an actions table

     actions // defines all possible actions (also actions not part of a task)
     {
          action_id
          description
     }
    
     user_actions // has one record for every action a user commits
     {
          user_id
          action_id
          date // possible extra
     }
    
     tasks // all possible tasks
     {
         task_id
         name
     }
    
     task_actions // all actions linked to a task
     {
         task_id
         action_id
     }
    

    This way you log every action a user does. You could make a steal bike action and a repair bike action.

    Now you can for instance retrieve all actions you need to complete task 5 (steal a bike and repair it). Then if all those action id's are in the user_actions table for your current user. it means the user has completed the task.

    Just not that your user_actions table will grow really really really fast if you have a couple of users.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 smptlib使用465端口发送邮件失败
  • ¥200 总是报错,能帮助用python实现程序实现高斯正反算吗?有偿
  • ¥15 对于squad数据集的基于bert模型的微调
  • ¥15 为什么我运行这个网络会出现以下报错?CRNN神经网络
  • ¥20 steam下载游戏占用内存
  • ¥15 CST保存项目时失败
  • ¥15 树莓派5怎么用camera module 3啊
  • ¥20 java在应用程序里获取不到扬声器设备
  • ¥15 echarts动画效果的问题,请帮我添加一个动画。不要机器人回答。
  • ¥15 Attention is all you need 的代码运行