Page 1 of 1

MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 12 Nov 2009, 21:57
by mtgrares
I just wanted to thank Dennis, Rob, Zerker and everybody else that has submitted code for MTG Forge. Some of the code is very beastly and hard to understand. I should know because I wrote horrible code just to get everything running.

MTG Forge has many features that are "broken by design". Code that I wrote just to get things working but then haunts you later when you try to do something more complicated, like the phase code which will not let me code Time Walk. I haven't programmed new cards for MTG Forge in awhile because it is really hard, and by "really hard" I mean that you work an hour or two on something but you can never get it working 100%. Which is exactly what happened when I did Fieldmist Borderpost. I could never get the code to exactly match the card text.

Correct me if I'm wrong, but Dennis had to update all of the cards that let the player choose targets in order to implement protection. I didn't think MTG Forge would ever support protection because it was so frigging complicated. Dennis has added a load of cards by expanding the keywords that cards.txt understand. And Zerker bravely added a mana pool despite the lack of documentation.

Guys like Dennis, Rob, and Zerker wrestle with the code that I wrote during my marathon coding sessions from 11-2am and sometimes later. Everytime I download a new version of MTG Forge I'm amazed by the number of new cards and features. Features that I didn't have to code and debug for hours on end. New versions appear almost "magically" and I envision little elves furiously coding at night.

I thank Dennis, Rob, and Zerker not because working on MTG Forge is easy, but because it is hard.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 12 Nov 2009, 22:16
by DennisBergkamp
Thanks for the kind words :)
I believe Silly Freak deserves praise also, he has made some awesome improvements to MTGForge (GUI, packaging, new deck format, properties files, error handler/reporter..., etc. etc.), very big updates.
And of course Chris and Cyclope who have submitted numerous code updates =D>

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 12 Nov 2009, 22:21
by mtgrares
Well all of your guys deserve it. I updated my set editor so it works with the new subdirectory and it took me around 45 minutes and maybe longer. :shock: I can't even guess how much time I spent on MTG Forge and probably neither can you.

I knew I would probably leave a few people out because I'm not actively involved. A big "thank you" goes out to Silly Freak, Chris and Cyclope. =D>

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 12 Nov 2009, 22:34
by mtgrares
Online it is hard to show appreciation, in real life I could by you a steak or something. (If you liked steak.) And just because thousands of people enjoy MTG Forge, doesn't mean that you'll get thousands of "thank yous". (Which is ok.) It is just hard to work on something and not really know how people are reacting to it.

On a side note I really would like to have a real life meeting of MTG Forge people (MTG Forgers). This doesn't seem possible because we seem to be spread across the globe. I'm in Jacksonville, Florida.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 12 Nov 2009, 23:56
by zerker2000
You are very welcome.
mtgrares wrote:I'm in Jacksonville, Florida.
South Pasadena, California :)
Zerker bravely added a mana pool despite the lack of documentation.
I do not think documentation would have helped any: ManaCost interface is pretty self-explanatory, and the ManaPool and Ability_Mana classes weren't much harder to make than an average complicated card/ability.
mtgrares wrote:marathon coding sessions from 11-2am and sometimes later
Maybe I am wrong about others, but that sounds a lot like us "little elves furiously coding at night".
the phase code which will not let me code Time Walk.
Wouldn't that be possible by putting "skip a turn" in an EOT effect (i.e. you skip from the end of one turn to the end of the next, which, in most cases, is equivalent to taking another turn)?

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 13 Nov 2009, 03:31
by Rob Cashwalker
I think you're on the right track Zerker. The current phase is controlled by a counter. Time Walk would have to set up a triggered command when the phase counter hit the player's EOT and reset it to 0 or 1 (as the case may be).

Thank you Rares.

Forget about getting an eyeball together - Gando and I live in the same city (NY) and even we couldn't hookup over the summer, though that's mostly on me and my schedule.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 16 Nov 2009, 09:56
by silly freak
i'm another one hard to reach, in vienna, Austria^^
i don't really consider my changes that dramatic, but i happily take any praise i can get :roll:
well, thanks to all others too, it feels good to work with an enthusiastic team to bring something forward (and if you ask me for my latest coding, i guess it was 4 or 5am CET, not sure...)

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 17 Nov 2009, 19:52
by mtgrares
Wouldn't that be possible by putting "skip a turn" in an EOT effect (i.e. you skip from the end of one turn to the end of the next, which, in most cases, is equivalent to taking another turn)?
It is like trying to make the computer go first, it just isn't going to work. You get weird exceptions and you don't know what is going on. I probably have too many observers that are observing the phase object. The reason that MTG Forge used to slow down (and still does a little) is because the code that observes phase is never "reset" so the stack trace of all of the methods calls keeps getting bigger and bigger and longer and longer. That took me FOREVER to figure out. In a pinch you can call the static method Thread.printStateTrace() to see what is going on.

If I could reset all of the global variables in AllZone at the beginning of every game that would solve most of the phase errors. The reason why you cannot do this is because the code presumes the variables in AllZone will never change, so objects just say "add this listener" and never update it.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 23 Nov 2009, 22:10
by DennisBergkamp
Rares,

Do you remember what issues came up exactly when trying to implement Time Walk?
I was bored, so I decided to give it a shot... this is the code:

Code: Select all
//*************** START *********** START **************************
    else if (cardName.equals("Time Walk"))
   {
       final SpellAbility spell = new Spell(card)
       {
         private static final long serialVersionUID = 8634822208146060381L;

         public void resolve() {
            final Command atEOT = new Command()
                {

               private static final long serialVersionUID = -8380743460207665203L;

               public void execute()
                  {
                    AllZone.Phase.setPhase(Constant.Phase.Untap, card.getController());
                              int turn = AllZone.Phase.getTurn();      
               AllZone.Phase.setTurn(++turn);
                  }
                };
                String opponent = AllZone.GameAction.getOpponent(AllZone.Phase.getActivePlayer());
                AllZone.GameAction.setLastPlayerToDraw(opponent);
                AllZone.EndOfTurn.addAt(atEOT);
         }
       };
       
       card.clearSpellAbility();
       card.addSpellAbility(spell);
    }//*************** END ************ END **************************
(I also added the public methods setLastPlayerToDraw(String s) and getLastPlayerToDraw() in GameAction).

Anyway, very simple.... I've been testing it for a bit, and quite surprisingly, stuff seems to work just fine: I'm able to use it, the AI can use it, the phase counter just gets reset and cards untap + the draw step occurs. Anyway, I'm probably missing something here, but so far it actually works great :shock:

So I will test this a bunch more...
Hmm, I seem to remember adding some really nasty hacks which allow a Raging Goblin to attack on turn one. Maybe that hack has something to with the fact that this is working now.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 23 Nov 2009, 22:38
by silly freak
what about two time walks during one turn? *challenge*

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 23 Nov 2009, 22:39
by DennisBergkamp
Yeah, that doesn't work yet :)

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 24 Nov 2009, 00:31
by DennisBergkamp
Now it does, I think... I've just added an "int extraTurns" variable to Phase. If I cast two Time Walks during one turn, I seem to get two extra turns :)
This also changes the code for Time Walk, its resolve method merely increments the extraTurns variable in Phase by one.

Re: MTG Forge - broken by design - thanks Dennis, Rob, Zerker

PostPosted: 24 Nov 2009, 02:53
by Rob Cashwalker
See Rares, nothing is impossible with your framework, just highly improbable.