|
|
@ -2,9 +2,13 @@ package de.hsfulda.onses.models; |
|
|
|
|
|
|
|
import de.hsfulda.onses.services.PlayerService; |
|
|
|
|
|
|
|
import java.beans.PropertyChangeSupport; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
public class Player { |
|
|
|
public final static String PROPERTY_PLAYER_DECK = "playerDeck"; |
|
|
|
|
|
|
|
protected PropertyChangeSupport listeners; |
|
|
|
|
|
|
|
private PlayerService playerService; |
|
|
|
private Game game; |
|
|
@ -15,11 +19,11 @@ public class Player { |
|
|
|
} |
|
|
|
|
|
|
|
public void addCardToPlayerDeck(Card card) { |
|
|
|
final ArrayList<Card> oldplayerDeck = new ArrayList<>(this.playerDeck); |
|
|
|
playerDeck.add(card); |
|
|
|
this.firePropertyChange(PROPERTY_PLAYER_DECK, oldplayerDeck, playerDeck); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public PlayerService getPlayerService() { |
|
|
|
return playerService; |
|
|
|
} |
|
|
@ -37,4 +41,19 @@ public class Player { |
|
|
|
this.game = game; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
public PropertyChangeSupport listeners() { |
|
|
|
if(this.listeners == null) { |
|
|
|
this.listeners = new PropertyChangeSupport(this); |
|
|
|
} |
|
|
|
return this.listeners; |
|
|
|
} |
|
|
|
|
|
|
|
public boolean firePropertyChange(String propertyName, Object oldValue, Object newValue) { |
|
|
|
if (this.listeners != null) { |
|
|
|
this.listeners.firePropertyChange(propertyName, oldValue, newValue); |
|
|
|
return true; |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
} |