You would probably only get the pun if you were a programmer. To non-programmers, let's explain:

Most of our databases have what's called "Keys" which are unique values identifying individual records. We Search these records for the Keys, and then we are VICTORIOUS!

Well, okay, maybe I am being far too enthusiastic, but hopefully you now understand.

So, what has been happening recently?

Searching the Database

We can now search the database. And this is not just manually created on a per object type basis, because that would take too long. Instead, like most programmers should, we use what's called "Generics". In procedural programming, it's called polymorphism. It's basically a way of saying: "We do not know the Type of a structure or object we want to use, but we have a general idea of what we will be using that Type for and how it should be handled."

In C#, we can use what's called Reflection to take the fields, methods, properties and all other pieces of data from any of our DBObject's, and perform all the necessary calculations to them to find out how we should display it in our search results.

For example, after creating a DBObject class, which, by the way, is empty, each of our data holding structures or classes now "inherit" this empty DBObject. Why inherit nothing from a class called DBObject? Well, because without it, we wouldn't strictly know what data holding structure is actually a data holding structure. If we were clumsy, we could assume anything as holding data we use for our project, pass it into our search and, well, it probably wouldn't work.

Well, it might, but it may look a little odd.

Our Search needs a DBObject derived type, so we make sure we check that. We also have three different attributes defining meta data for all of our fields in our data holding structures. Take CharacterTrait, for example:

class CharacterTrait : DBObject

    public int ID;

    [SearchRelationship(typeof(Character), "ID", "FirstName", "Characters")]
    public int CharacterID;
    public string Name;

    [SearchOptions(Hidden = true)]
    public string Description;
    public int InitialValue;
    public int MaxValue;

    public int CharacterPriority;

    public CharacterTrait()
        ID = ++Globals.GlobalIdentifiers.CharacterTraitID;

        Name = "";
        Description = "";
        InitialValue = 0;
        MaxValue = 10;
        CharacterPriority = 0;


If we were to look at the results of our search again, you will find our results match the structure above, somewhat. Description is "Hidden" from search, which can be identified accordingly.

We also have two different types of data sources. One is a relationship between one field and another, which is why we get the names of characters in our search results instead of a number. Here, SearchRelationship means to look for the type Character, which is another class or structure, and inside Character we should have an ID field which we want this CharacterID to look up, we want to display the result from the FirstName value found in each record, and use the "Characters" source data found inside our Globals class.

For example, we have two characters that currently exist in the game as below:

Our ID field is hidden here, but this is what we reference when looking at each record in the above results.

And so, we get the First Name of each character and display that correctly.

The same applies for the meta data source SearchCustomDataSource which was easier to implement.


Naturally, we should be able to filter our search results to get something more refined.

Above, we can see all the filters relevant to our search and define them accordingly. These are the results following this filter:

We could refine this even further using CharacterPriority:

And the results:

Now you know why this feature was needed.

When this database grows large, we will need to search hundreds, or even thousands, of records to speed up retrieving all the relevant data when we need it.

Now we should move onto something even more interesting. We will start playing with GDI+ and start drawing some 2D graphics to create maps.

Developer at home, customer services at work. In my free-time, I enjoy writing and coding.