Thread:Sylvandyr/@comment-1536121-20130318135547/@comment-4830404-20130318155737

The Monster Story code won't help you, it's very old and terrible. Most of the stuff is hard coded in a bizarre way, poorly designed and just all-in-all not well written. I never found the time to refactor it to make it better. Instead, you should only look at the Dragon Story code. However, there is a caveat. You *cannot* take the code word for word, and doing so will result in massive design flaws. Some things are done for very specific reasons, either having to do with how MediaWiki breaks code that works fine elsewhere, or tailoring towards needs that don't apply to other games.

Although you say that Dragon Story has a similar function of breeding, that is completely untrue. I have played Tiny Castle, and its breeding rules are actually much more like Dragonvale (although still different). Allow me to elaborate, and hopefully you will see that the breeding rules (and consequently the code as well as the design that reflects it) must be completely different.

Tiny Castle follows a system that involves elements and opposites. Some creatures can't breed with each other depending on whether all their elements are opposite or not. In this respect, it very much matters which parent contributes which elements. A Treant can never breed with a Phoenix even though it is a hybrid, because Volcano is an opposite of both Forest and Garden. This rule makes certain pairings impossible. However, if a pairing is possible, then it does not matter which element came from which parent, as they go into an element pool to decide on the offspring. As far as I know, Tiny Castle is parent-restrictive, but not offspring-restrictive (prevents certain pairings, but as long as the elements are there, any offspring with those elements are possible?)  I haven't played enough to see if there are certain subtleties in rules or if certain offspring require special rules such as specific parents.

Dragon Story allows any dragon to breed together regardless of color as long as the dragon is allowed to be a parent. Getting at particular offspring can be tricky though. Some offspring can only be gotten if there are enough distinct colors in the pool. Some can only be gotten with specific parents. Some can surface within particular combinations of color pools. In addition, some colors don't behave normally - some can emerge when a pool contains their color components, some can split into their respective components to add to a pool, etc. Dragon Story has a lot of very complicated breeding rules that you won't see even in its sister game, Monster Story. As such, there is a LOT of code that won't be applicable to you when you read the file, and there is an incredible amount of structure built specifically around the way Dragon Story works that I would not use for a different game.

My advice to you is DO NOT try to simply take some functions and convert them 1-for-1 into Tiny Castle code by substituting some lines of code. It won't do you much good, it would introduce incorrect structure, and it will make your code unnecessarily hard to navigate because my code structure was designed specifically to work well with Dragon Story. I can visualize a Tiny Castle code structure right now, and I can tell you from experience that it is extremely different and requires a lot fewer functions.

What you should FIRST do is create all the code in a text file, name it (file name).html, and then make sure it works in your browser. All you need to do is open the file and it should show up in your browser. Refreshing your browser after you have saved changes to the file will refresh your code also, so you don't have to keep closing and re-opening it. Javascript makes that part easy.

The reason I say to make sure it works in your browser first (and not wikia yet) is two-fold:

1) MediaWiki does a lot of annoying javascript caching.  You preferably want to change your MediaWiki javascript files *as little as possible* because even though you can manually update your cache, every other wiki user may not do it, and changes can take up to a day to show up if the cache is not manually purged.

2) As mentioned before, MediaWiki and wikia force you to do some weird things to coax code to work that you wouldn't have to do normally.  This is annoying and sometimes makes no sense, and you don't want these weird things to distract you from getting your program right.  There are many things that could go wrong and trick you into thinking that your code is broken if you immediately try to get it onto wikia.  Get the program working first - ignore wikia until you have your program working perfectly in your browser.

If you have any questions, don't hesitate to ask.