Basically, there are 4 parts:
Framework which represents conditions. These come in the form of methods like HasAura, HasItem, etc
An expression tree representation that we can store in the database. In our case, we probably want SQL insert statements
Conversion from the former to the latter
Mangos Core implementation to rebuild and execute the expression tree
[h]Database Structure[/h]
Conditions will go in a table, similar to Schmoo's design but with a small difference (my approach sacrifices space for simplicity):
(id, Type, Val1, Val2)
eg:
(0, 1, 1234, 1)
(1, 6, 67, 0)
(2, -2, 0, 1)
(3, 1, 1235, 1)
(4, 6, 469, 0)
(5, -2, 3, 4)
(6, -1, 2, 5)
Where
Type = -2 := AND
Type = -1 := OR
From the rows above, we can build condition 6 by repeated expansion of each expression:
6
2 OR 5
(0 AND 1) OR (3 AND 5)
((Aura 1234 idx 1) AND (Team Horde)) OR ((Aura 1235 idx 1) AND (Team Alliance))
[h]Code Format[/h]
A very expressive, extendible way to represent the above condition expression in C#:
(c.HasAura(1234, 1) && c.IsHorde()) || (c.HasAura(1235, 1) && c.IsAlliance())
[h]Conversion[/h]
Basically, the database developer will just need to write some C# code, and the framework will convert it into a suitable format.
I have pushed the code to http://github.com/faramir118/MangosUtil/ - it works with MonoDevelop and Visual Studio 2010. It demonstrates that complex logic is easily parsed and formatted (currently not the format we need)
For an example, just look at https://github.com/faramir118/MangosUtil/blob/master/MangosUtil/Runner.cs. You can step through with the debugger if you wish to learn how it works.