Thread:Sylvandyr/@comment-5619126-20121014124324/@comment-5619126-20121028150847

Sylvandyr: So many things to fix there.... this far I used the breeding options supplied by your calculator. Which is nice but everytime a new dragon gets added I need to add more options.... doing it all dynamically works better IMHO :)

Using your supplied query it would also think that: Air + Angel could produce an Air dragon. Air is yellow and Angel is diamond and white. To my understanding that won't produce an Air dragon.

I altered the query now to this:

SELECT * FROM dragons WHERE (color1 = ? OR color1 = "Diamond") AND (color2 IS NULL OR color2 = "Diamond" OR color2 = ?)

(Of course replace the ? with the current color.)

Rationale: If it's a single color dragon in the db, then color2 is NULL. As for color1 and color2 I just sort them alphabetically. Meaning color1 is the first color in the alphabet of the two.

In the case of the air dragon it will only find values that have as color1 'yellow' or 'diamond' and as color2 'yellow', 'diamond' or unset.

But I wonder now: Can two gold dragons also produce air?