简体   繁体   English

具有大量属性的存储大量单位的方法

[英]Method for storing a large amount of units, with a large array of attributes

Me and a friend are currently looking at developing a game, with similarities to a certain trademarked francise. 我和一个朋友目前正在开发一款与某商标特许经营类似的游戏。 To define the units in the game, we've created an abstract class which denotes the 44 variables, and two methods that need to be instantiated with each instance of a unit. 为了定义游戏中的单位,我们创建了一个抽象类,该类表示44个变量,以及需要在每个单位实例中实例化的两个方法。 The next step in this game would be to of course, define all the units in the game. 当然,该游戏的下一步就是定义游戏中的所有单位。 Unfortunately, I have 648 units that need to be defined, with 22 final values for each which must be examined at each individual instantiation in the game. 不幸的是,我有648个单位需要定义,每个单位有22个最终值,必须在游戏中的每个单独实例中进行检查。 For example, if I encounter this unit in the game, I would pass a method it's value, and it would look at some sort of defining table which give all these base, final values. 例如,如果我在游戏中遇到此单元,则将其值传递给方法,它将查看某种定义表,这些表给出所有这些基本最终值。 The problem we've encountered with this of course, is finding a method of doing this effectively, and securely. 当然,我们在此过程中遇到的问题是找到一种有效且安全地执行此操作的方法。 Currently, for testing of other methods, I have a few units defined through enumeration, and have their values stored in an array. 目前,为了测试其他方法,我通过枚举定义了一些单位,并将它们的值存储在数组中。 My partner has suggest we create a defining class, which will look at a plaintext lookup table. 我的伙伴建议我们创建一个定义类,该类将查看纯文本查找表。 However, I see the problem with such a solution would either be the length, or quantity of lookup tables would be massive. 但是,我看到这种解决方案的问题可能是查询表的长度或数量庞大。 I have searched around, but most solutions entail the use of a server. 我四处搜寻,但是大多数解决方案都需要使用服务器。 Our current goal, however is to just release an offline client with everything already defined. 但是,我们当前的目标是仅发布具有所有已定义内容的脱机客户端。

Anyways, I know this was a lot of possible rambling, but... does anyone have any suggestions on how to store 648 units with 22 different final attributes effectively, so that such an entity could be called later and examined? 无论如何,我知道这有很多可能的麻烦,但是...关于如何有效地存储具有22种不同最终属性的648个单位,有没有人有任何建议,以便以后可以调用这种实体并对其进行检查? I don't need a thorough code example, but ideas would be helpful. 我不需要完整的代码示例,但是想法会有所帮助。

You probably want to create a database which contains a table of units and a set of columns (or fields) for the respective attributes. 您可能想创建一个数据库 ,其中包含一个单位和一组用于各个属性的 (或字段)。 This is most abstract example I can provide. 这是我可以提供的最抽象的示例。

An implementation without a server would instead entail a flat file database such as SQLite . 没有服务器的实现将需要一个平面文件数据库,例如SQLite Of course, if you want to build your own custom database as your friend suggests, it would be the same. 当然,如果您要按照朋友的建议构建自己的自定义数据库,那将是相同的。

Just use Excel or Spreadsheet in Google Documents. 只需在Google Documents中使用Excel或Spreadsheet。 Write your table and then export as CSV (comma separated values). 编写表格,然后导出为CSV(逗号分隔值)。 Will be very simple to create, modify and parse. 创建,修改和解析将非常简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM