Aiming to multiplayer (and better structure)

I think it would be handy to move PlayerZones inside the player structure to allow matches between more than 2 opponents. Don't know when it's going to happen, buy formats like archenemy and commander... I think they would be welcome by players - that's a lot of work on AI and UI, I don't even imagine how much. But I believe, the one of the first steps might be attempted already now.
I think this code needs some refactoring. So I would love to pull these lines to player classes with all the dependencies... well, if noone minds. And if anyone does, this is a good place to express your opinion.
I think this code needs some refactoring. So I would love to pull these lines to player classes with all the dependencies... well, if noone minds. And if anyone does, this is a good place to express your opinion.
- Code: Select all
public FGameState() {
getZoneNamesToPlayerZones().put(Constant.Zone.Graveyard + getHumanPlayer(), getHumanGraveyard());
getZoneNamesToPlayerZones().put(Constant.Zone.Hand + getHumanPlayer(), getHumanHand());
getZoneNamesToPlayerZones().put(Constant.Zone.Library + getHumanPlayer(), getHumanLibrary());
getZoneNamesToPlayerZones().put(Constant.Zone.Battlefield + getHumanPlayer(), getHumanBattlefield());
getZoneNamesToPlayerZones().put(Constant.Zone.Exile + getHumanPlayer(), getHumanExile());
getZoneNamesToPlayerZones().put(Constant.Zone.Command + getHumanPlayer(), getHumanCommand());
getZoneNamesToPlayerZones().put(Constant.Zone.Graveyard + getComputerPlayer(), getComputerGraveyard());
getZoneNamesToPlayerZones().put(Constant.Zone.Hand + getComputerPlayer(), getComputerHand());
getZoneNamesToPlayerZones().put(Constant.Zone.Library + getComputerPlayer(), getComputerLibrary());
getZoneNamesToPlayerZones().put(Constant.Zone.Battlefield + getComputerPlayer(), getComputerBattlefield());
getZoneNamesToPlayerZones().put(Constant.Zone.Exile + getComputerPlayer(), getComputerExile());
getZoneNamesToPlayerZones().put(Constant.Zone.Command + getComputerPlayer(), getComputerCommand());
getZoneNamesToPlayerZones().put(Constant.Zone.Stack + null, getStackZone());
- Code: Select all
// These fields should be moved to the player class(es) and implementation(s), and the getters
// should be moved there. PMD complains of too many fields, and it is right.
// The battlefields are different because Card.comesIntoPlay() is called when a card is added by
// PlayerZone.add(Card).
private PlayerZone humanBattlefield = new PlayerZone_ComesIntoPlay(Constant.Zone.Battlefield, getHumanPlayer());
private PlayerZone humanHand = new DefaultPlayerZone(Constant.Zone.Hand, getHumanPlayer());
private PlayerZone humanGraveyard = new DefaultPlayerZone(Constant.Zone.Graveyard, getHumanPlayer());
private PlayerZone humanLibrary = new DefaultPlayerZone(Constant.Zone.Library, getHumanPlayer());
private PlayerZone humanExile = new DefaultPlayerZone(Constant.Zone.Exile, getHumanPlayer());
private PlayerZone humanCommand = new DefaultPlayerZone(Constant.Zone.Command, getHumanPlayer());