Item Sources

The sole purpose of this code is to generate the item-sources.json file. This documentation will describe that file and the program that generates it. All of this code is found in the ItemData/ItemDataGenerator C# console program.


This file contains a list of item sources that are imported directly into the item database. It is stored in JSON format as a dictionary of arrays: the key is the item ID as seen on (e.g. in the URL for an item in the database), and the value is an array of ItemSource objects for that item (a single item can have multiple sources).

Does this contain every known source?

No. There are some sources that are auto-generated on, and thus never need to be included in item-sources.json:
  • Crafted Items -- Any item with a Recipe is handled automatically.
  • "Ripped" Data -- Many mods can be ripped from gear that drops with those mods. This is handled automatically.
  • Mission Rewards -- Feel free to add sources for items that are mission rewards, and where you know the name of the mission. Otherwise, any item whose moniker starts with "" is automatically given a generic Mission Reward source.

How to use the Code

All of the item generation code is currently in the ItemSourceWriter class. It has 2 public methods:
  • Write() -- Generate all of the item sources and overwrite item-sources.json
  • Test() -- Test a single part of the item source generation. This will write a report to a text file (or the console), and is handy for testing any new code that you write.

The goal of the design of this program is to allow anybody to contribute source information, even if you are not familiar with C# programming. To that end, there are two general ways to add item sources: manually and with code.

Adding Sources Manually

The project contains a csv file called manual-sources.csv. This can be opened in whatever program you like (e.g. Excel) and edited to manually add whatever sources you want. The next time Write() is called, it will read anything from this file and generate sources. The columns correspond exactly to the properties of the ItemSource object. See the ItemSource documentation for more details.

That's it! A handy way to do one-off item sources, or stuff that is too much of a pain to code.

Adding Sources with Code

There are already several methods to generate some of the other more "formulaic" item sources -- mainly set items and operation drops at the moment. This code can be used as an example for writing your own methods to add more item sources.

Included in the project is an items.json file, which contains all known items (that we at Team Robot have data-mined from the game client). This data is provided to facilitate programmatic generation of item sources. It is a simplified format that strips out a ton of extra junk -- see the Item object for more details. The provided Write() method reads it into memory as a List<Item> for your use.

Here are a few notes on the available helper methods:
  • AddSource(item, sources, newSource) -- a handy helper to add a source to the final list, takes as arguments the newSource, the item for which it is a source, and the current list of all sources into which it should be added.
  • GetBetterSlot(item) -- another handy helper, the Slot property on the Item object is a bit more specific than is generally needed for determining item sources. For many cases, stuff used in the main hand all drops from one place, and stuff used in the off hand drops from another. This resolves the more specific slots to just "MainHand" and "OffHand". See AddRakataSource for an example of how it is used.

That's really all there is to it -- feel free to add whatever code is required to generate new item sources, fix the existing methods if there are issues with them, etc. The site only uses the final item-sources.json file, so the item source generation code itself is not critical (but please make it readable/maintainable/testable for your coder buddies).

Writing the Final File

There is already code to do this. It uses and verbose settings to make the file human-readable. There is really no reason to change this part of the code.

Last edited Apr 26, 2013 at 2:02 AM by Yellowfive, version 1


No comments yet.