Saturday, August 14, 2010

Migrating to Maven

This week, I've finally done what I wanted to do for a very long time: I migrated my project to Maven. Warning: Non-programmers will probably be hopelessly bored.

Maven is a build system with many capabilities that are probably beyond my current recognition. For me, it means essentially these things:
  • Managing dependencies to external libraries, such as Dom4J, an XML API, and also to the different projects that belong to LaternaMagica, like TreeProperties.
    • For an Open Source project, this also means that I don't have to care that others have all the required libraries, because they can find and download them on-demand. Having the right configurations in the development environment is not that important this way. As a downside, it makes Maven pretty much a requirement for working with my code, but that's just like English is required to read my blog: it's good to know English, no matter what.
  • Automatic testing and generation of source, binary and documentation archives, or "snapshots"
I said I wanted to do this for a long time. If you're asking why I haven't done it earlier... well, I was dumb. I couldn't get my Eclipse installation working with the Maven plugin. The problem was... that my eclipse installation was owned by root (the administrator, for all the poor Windows users out there^^) and installing the plugin simply didn't do anything as I didn't have the rights.

So finally, everything is alright. I have totally rewritten TreeProperties and Utils, and also greatly reworked LaternaDoc, which finally does what it should. More on those another time ;)

3 comments:

nantuko84 said...

I've got one guestion regarding phase structure and priority player.
If you take look at PhaseStructureImpl, you first set hasPrior to false, then make some actions that may fire next phase event, and only then set hasPrior back to true.
As hasPrior is false, PhaseStructure returns null in getPriorPlayer. so I couldn't find a way to get priority Player in PhaseChangeListener. Could you please help with this.
Should I wait for phase change completion, when someone gets his\her priority? Or do I miss anything?

Silly Freak said...

You made me think a lot today with this comment, and I'm glad that I can answer you and that the behavior is correct. It came to my mind while I was working on combat. You can still find the would-be prior player, because the active player always gets priority first.

The point in setting hasPrior to false is to prevent players from playing spells and abilities; an example would be combat: While the active player chooses attacking creatures, he is executing a turn based action. You could check for this in the GUI and prevent playing spells/abilities this way, but it's cleaner to do so rules-wise.

I should probably consider adding another event for "a step having finished beginning" if that makes sense

by the way, how do you find these details? are you just interested in the code, or even using it for MagicWars where applicable? I'd be honored by both...

nantuko84 said...

I see now, I just need to use TurnStructure.getActivePlayer() in phase change listener.

To be honest, time to time I looked into your code, and I remember first time it was very difficult to understand the workflow and how everything is connected. now it's much easier. Need to say I like the way you code, and the ideas that are in laterna. You probably know that MagicWars is based on MTGForge architecture. I've changed there a lot, but still there are some limits (e.g. there is no way to implement Totem armor correctly) (I also know that mtg forge also is being developed and has new features that version, on which mw was based, doesn't have).

I've spent few days trying to understand whether it is really possible to combine current versions of mw and laterna. The most trickiest part is to find the line between those two projects. I want to have new features and rules enforcement from laterna, and keep as much as possible code from mw. At the moment, if you interested, I have passing priority working in mw that uses your code: it is great step forward for mw, at least spells like Reverberate(M11) would be possible now.
Casting spell\abilities and special actions will be next step, but it won't be so easy as changing phase and passing priority were.

Keep up the brilliant work!)