如何在SQL中存储目标(认为是RPG Quest) [英] How to store Goals (think RPG Quest) in SQL

查看:61
本文介绍了如何在SQL中存储目标(认为是RPG Quest)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

今天有人问我他们应该如何在SQL数据库中存储任务目标。在这种情况下,请考虑一个RPG。目标可以包括以下内容:




  • 发现[位置]

  • 杀死n [MOB类型]

  • 获取[对象]的n

  • 在[技能组]中获得[技能]

  • 全部在RPG中获得的其他东西



我能想到的最好的方法是:

  Quest 1- * QuestStep 
QuestStep 1- * MobsToKill
QuestStep 1- * PlacesToFind
QuestStep 1- * ThingsToAcquire
QuestStep 1- *等。

这似乎有些笨拙-如果他们存储的是某个描述的查询, (或公式或???)



任何建议得到赞赏

解决方案

我会创建类似这样的东西。



对于Quest表:

  | ID |标题| FirstStep(GuestStep表的外键)等。

QuestStep表

  | ID |标题|目标(目标表的外键)| NextStep(下一个QuestStep的ID)|等。

当然,这是最困难的部分,我们如何描述目标?我想说的是在目标表中为目标创建一条记录,并将目标的每个字段(例如,要杀死多少类型的小怪,要访问的位置等等)保存在目标表中,因此: / p>

目标表:

  | ID |类型(类型是目标类型的Enum中的一种)| 

GoalFields Table

  | ID |目标(目标的外键)|领域价值| 

我知道这可能有点含糊,所以下面是数据库中数据的示例



Quest table

  | 0 | 开始任务 | 0 | ... 
| 1 | 时间为剑 | 2 | ...

QuestStep表

  | 0 | 去城堡 | 0 | 1 | ... 
| 1 | 杀死两只萤火虫 | 1 | NULL | ...
| 2 | 一把剑 | 2 | NULL | ...

球桌

  | 0 |寻找地方| 
| 1 | MobsToKill |
| 2 |要获取的东西|

GoalFields表

  | 0 | 0 |地点| 城堡 | 
| 1 | 1 |类型萤火虫 |
| 2 | 1 |金额| 2 |
| 3 | 2 |类型剑 |
| 4 | 2 |金额| 1 |


Someone asked me today how they should store quest goals in a SQL database. In this context, think of an RPG. Goals could include some of the following:

  • Discover [Location]
  • Kill n [MOB Type]
  • Acquire n of [Object]
  • Achieve a [Skill] in [Skillset]
  • All the other things you get in RPGs

The best I could come up with is:

Quest 1-* QuestStep
QuestStep 1-* MobsToKill
QuestStep 1-* PlacesToFind
QuestStep 1-* ThingsToAcquire
QuestStep 1-* etc.

This seems a little clunky - Should they be storing a query of some description instead (or a formula or ???)

Any suggestions appreciated

解决方案

I would create something like this.

For the Quest table:

| ID | Title | FirstStep (Foreign key to GuestStep table) | etc.

The QuestStep table

| ID | Title | Goal (Foreign key to Goal table) | NextStep (ID of next QuestStep) | etc.

Ofcourse this is where the hard part start, how do we describe the goals? I'd say create one record for the goal in the Goal table and save each of the fields of the goal (I.E. how many mobs of what type to kill, what location to visit, etc.) in a GoalFields table, thus:

Goal table:

| ID | Type (type is one from an Enum of goal types) |

The GoalFields Table

| ID | Goal (Foreign key to goal) | Field | Value |

I understand that this can be a bit vague, so here is an example of what dat in the database could look like.

Quest table

| 0 | "Opening quest" | 0 | ...
| 1 | "Time for a Sword" | 2 | ...

QuestStep table

| 0 | "Go to the castle" | 0 | 1 | ...
| 1 | "Kill two fireflies" | 1 | NULL | ...
| 2 | "Get a sword" | 2 | NULL | ...

Goal table

| 0 | PlacesToFind |
| 1 | MobsToKill |
| 2 | ThingsToAcquire |

GoalFields table

| 0 | 0 | Place | "Castle" |
| 1 | 1 | Type | "firefly" |
| 2 | 1 | Amount | 2 |
| 3 | 2 | Type | "sword" |
| 4 | 2 | Amount | 1 | 

这篇关于如何在SQL中存储目标(认为是RPG Quest)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆