CardFactory Refactor?

Guys, have you considered refactoring the CardFactory* files ?
A quick look at the svn showed me that they represent around 50'000 lines of code.
I know Java is verbose, but I'm sure it could be reduced to 10'000 lines of codes with good inheritance mechanisms and more Object Oriented code...
As an example, the function makeToken appears countless times in the following file:
http://code.google.com/p/cardforge/sour ... tures.java
it could probably be made a static function of the class Ability, that takes arguments and spits a resulting token.
So, in Ability, you would have (pseudocode, haven't done any java in ages):
makeToken(1, 1, card,"W 1 1 Soldier", "Soldier", "W", ["soldier"]);
I think the image name can also be removed, as it seems to be computed based on cost/p/t/Name
and there you go, around 500 lines of code can be removed, and token generation becomes easy. It also makes debugging way easier...
A quick look at the svn showed me that they represent around 50'000 lines of code.
I know Java is verbose, but I'm sure it could be reduced to 10'000 lines of codes with good inheritance mechanisms and more Object Oriented code...
As an example, the function makeToken appears countless times in the following file:
http://code.google.com/p/cardforge/sour ... tures.java
it could probably be made a static function of the class Ability, that takes arguments and spits a resulting token.
So, in Ability, you would have (pseudocode, haven't done any java in ages):
- Code: Select all
static makeToken(Integer p, Integer t, Card card, String imageName, String name, String cost, String[] types) {
Card c = new Card();
c.setOwner(card.getController());
c.setController(card.getController());
c.setImageName(imageName);
c.setName(name);
c.setManaCost(cost);
c.setToken(true);
c.addType("Creature");
for (int i < types.length) {
c.addType(types[i]);
}
c.setBaseAttack(p);
c.setBaseDefense(t);
PlayerZone play = AllZone.getZone(Constant.Zone.Play, c.getController());
play.add(c);
}//makeToken()
makeToken(1, 1, card,"W 1 1 Soldier", "Soldier", "W", ["soldier"]);
I think the image name can also be removed, as it seems to be computed based on cost/p/t/Name
and there you go, around 500 lines of code can be removed, and token generation becomes easy. It also makes debugging way easier...