Browse files

Merge branch 'master' of github.com:byang223/TurnBAPI

  • Loading branch information...
2 parents d0520a1 + b9c549a commit 192be1edd554abf4e6e4da1c0a927aecafafa347 @prithvi923 prithvi923 committed Apr 26, 2012
Showing with 419 additions and 91 deletions.
  1. BIN resources/upgrades/upgrade.jpg
  2. +1 −0 src/achievement/Achievement.java
  3. +1 −0 src/achievement/AchievementKill.java
  4. +1 −0 src/achievement/AchievementLevelUp.java
  5. +1 −0 src/achievement/AchievementNewEnvironment.java
  6. +1 −0 src/achievement/AchievementTime.java
  7. +3 −3 src/achievement/AchievementUnlockUnit.java
  8. +11 −0 src/achiever/Achiever.java
  9. +21 −0 src/achiever/upgrades/AchieverAddUnitModification.java
  10. +34 −0 src/achiever/upgrades/AchieverAttributeModification.java
  11. +39 −0 src/achiever/upgrades/AchieverDecorator.java
  12. +12 −0 src/achiever/upgrades/AchieverExperienceModification.java
  13. +12 −0 src/achiever/upgrades/AchieverLevelModification.java
  14. +21 −0 src/achiever/upgrades/AchieverUnlockUnitModification.java
  15. +11 −0 src/achiever/upgrades/AchieverUpgradable.java
  16. +1 −1 src/attribute/AchievementList.java
  17. +1 −1 src/attribute/Attribute.java
  18. +1 −1 src/attribute/AttributeExperience.java
  19. +1 −1 src/attribute/AttributeKills.java
  20. +1 −1 src/attribute/AttributeLevel.java
  21. +28 −11 src/attribute/AttributeReactable.java
  22. +21 −8 src/environment/Environment.java
  23. +5 −0 src/environment/Mountain.java
  24. +7 −2 src/environment/Permanent.java
  25. +5 −0 src/environment/PoisonGas.java
  26. +7 −2 src/environment/Portal.java
  27. +10 −1 src/environment/Snow.java
  28. +12 −2 src/environment/Transient.java
  29. +1 −1 src/modes/EditMode.java
  30. +6 −6 src/modes/GameMode.java
  31. +1 −1 src/observers/GameObserver.java
  32. +1 −1 src/observers/ObserverEnvironment.java
  33. +2 −2 src/observers/ObserverKills.java
  34. +2 −2 src/observers/ObserverLevelUp.java
  35. +2 −2 src/observers/ObserverUnlockUnits.java
  36. +2 −2 src/player/Player.java
  37. +0 −1 src/units/ElectrodeUnit.java
  38. +1 −2 src/units/Unit.java
  39. +62 −0 src/units/WeezingUnit.java
  40. +2 −2 src/units/interactions/PassivePoisonGas.java
  41. +6 −1 src/units/reactions/HealthBasedMoveReaction.java
  42. +7 −3 src/units/reactions/ParalyzingAttackReaction.java
  43. +4 −2 src/units/reactions/Reaction.java
  44. +6 −1 src/units/upgrades/HealthModification.java
  45. +6 −2 src/units/upgrades/ImageModification.java
  46. +7 −0 src/units/upgrades/MoveModification.java
  47. +7 −2 src/units/upgrades/TeleportModification.java
  48. +1 −0 src/units/upgrades/UnitAttributeModification.java
  49. +8 −4 src/units/upgrades/UnitDecorator.java
  50. +1 −1 src/units/upgrades/UnitUpgradable.java
  51. +15 −19 src/units/upgrades/UpgradeTest.java
View
BIN resources/upgrades/upgrade.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
1 src/achievement/Achievement.java
@@ -3,6 +3,7 @@
import java.util.ArrayList;
import observers.GameObserver;
+import achiever.Achiever;
import attribute.Attribute;
/**
View
1 src/achievement/AchievementKill.java
@@ -1,5 +1,6 @@
package achievement;
+import achiever.Achiever;
import attribute.AttributeKills;
import observers.GameObserver;
import observers.ObserverKills;
View
1 src/achievement/AchievementLevelUp.java
@@ -2,6 +2,7 @@
import observers.GameObserver;
import observers.ObserverLevelUp;
+import achiever.Achiever;
import attribute.AttributeExperience;
public class AchievementLevelUp extends Achievement<AttributeExperience> {
View
1 src/achievement/AchievementNewEnvironment.java
@@ -1,6 +1,7 @@
package achievement;
import observers.GameObserver;
+import achiever.Achiever;
import attribute.AttributeUnitGroup;
public class AchievementNewEnvironment extends Achievement<AttributeUnitGroup> {
View
1 src/achievement/AchievementTime.java
@@ -1,5 +1,6 @@
package achievement;
+import achiever.Achiever;
import attribute.Attribute;
import observers.GameObserver;
View
6 src/achievement/AchievementUnlockUnit.java
@@ -12,6 +12,7 @@
import units.PikachuUnit;
import units.SnorlaxUnit;
import units.Unit;
+import achiever.Achiever;
import attribute.AttributeLevel;
public class AchievementUnlockUnit<A extends Achiever> extends Achievement<AttributeLevel> {
@@ -45,7 +46,6 @@ private AchievementUnlockUnit() {
myObserver = new ObserverUnlockUnits(this.unlockablesMap);
super.attachObserver(myObserver);
- setNextUnlockable();
}
public void addUnlockableUnit(int unlockLevel, Unit unlockable) {
@@ -55,9 +55,9 @@ public void addUnlockableUnit(int unlockLevel, Unit unlockable) {
@Override
public void notifyObserver(GameObserver o, Achiever achiever) {
- if (unlockablesMap.size() > 0) {
- o.notifyObserver(achiever);
+ if (unlockLevels.size() > 0) {
setNextUnlockable();
+ o.notifyObserver(achiever);
} else {
System.out.println(this.NO_MORE_UNLOCKABLES_MESSAGE);
}
View
11 src/achiever/Achiever.java
@@ -0,0 +1,11 @@
+package achiever;
+
+import achiever.upgrades.AchieverUpgradable;
+import attribute.Attribute;
+
+
+public interface Achiever<T extends Attribute> extends AchieverUpgradable {
+
+ public void addAchievementMessage(String message);
+ public T getAttribute(String name);
+}
View
21 src/achiever/upgrades/AchieverAddUnitModification.java
@@ -0,0 +1,21 @@
+package achiever.upgrades;
+
+import units.Unit;
+import achiever.Achiever;
+import attribute.Attribute;
+import attribute.AttributeUnitGroup;
+
+public class AchieverAddUnitModification extends
+ AchieverAttributeModification<AttributeUnitGroup,Unit> {
+
+ public AchieverAddUnitModification(AchieverUpgradable achiever, Unit value) {
+ super(achiever, value, Attribute.UNIT_GROUP);
+ value.setOwner((Achiever) achiever);
+ }
+
+ public void changeUnit(Unit value) {
+ value.setOwner((Achiever) super.getDecoratedAchiever());
+ setData(value);
+
+ }
+}
View
34 src/achiever/upgrades/AchieverAttributeModification.java
@@ -0,0 +1,34 @@
+package achiever.upgrades;
+
+import attribute.Attribute;
+
+
+public abstract class AchieverAttributeModification<T extends Attribute,E> extends AchieverDecorator<E> {
+
+ private T attribute;
+
+ public AchieverAttributeModification(AchieverUpgradable achiever, E value, String attr) {
+ super(achiever, value);
+ attribute = (T) this.getDecoratedAchiever().getAttribute(attr);
+ }
+
+ public T getAttribute() {
+ return attribute;
+ }
+
+ public void setAttribute(T attr) {
+ this.attribute = attr;
+ }
+
+ @Override
+ public void modify() {
+ if (getAttribute() == null) {
+ System.out.println("1");
+ }
+ if (getData() == null) {
+ System.out.println("2");
+ }
+ getAttribute().augmentData(getData());
+ }
+
+}
View
39 src/achiever/upgrades/AchieverDecorator.java
@@ -0,0 +1,39 @@
+package achiever.upgrades;
+
+import attribute.Attribute;
+
+
+public abstract class AchieverDecorator<T> implements AchieverUpgradable {
+
+ private AchieverUpgradable decoratedAchiever;
+ private T data;
+
+
+ public AchieverDecorator(AchieverUpgradable achiever, T value) {
+ this.setDecoratedPlayer(achiever);
+ data = value;
+ }
+
+ abstract public void modify();
+
+
+ public AchieverUpgradable getDecoratedAchiever() {
+ return decoratedAchiever;
+ }
+
+ public void setDecoratedPlayer(AchieverUpgradable decoratedAchiever) {
+ this.decoratedAchiever = decoratedAchiever;
+ }
+
+ public Attribute getAttribute(String attr) {
+ return getDecoratedAchiever().getAttribute(attr);
+ }
+
+ public T getData() {
+ return data;
+ }
+
+ public void setData(T newValue) {
+ this.data = newValue;
+ }
+}
View
12 src/achiever/upgrades/AchieverExperienceModification.java
@@ -0,0 +1,12 @@
+package achiever.upgrades;
+
+import attribute.Attribute;
+import attribute.AttributeExperience;
+
+public class AchieverExperienceModification extends AchieverAttributeModification<AttributeExperience,Integer> {
+
+ public AchieverExperienceModification(AchieverUpgradable achiever, Integer value) {
+ super(achiever, value, Attribute.EXPERIENCE);
+ }
+
+}
View
12 src/achiever/upgrades/AchieverLevelModification.java
@@ -0,0 +1,12 @@
+package achiever.upgrades;
+
+import attribute.Attribute;
+import attribute.AttributeLevel;
+
+public class AchieverLevelModification extends AchieverAttributeModification<AttributeLevel,Integer> {
+
+ public AchieverLevelModification(AchieverUpgradable achiever, Integer value) {
+ super(achiever, value, Attribute.LEVEL);
+ }
+
+}
View
21 src/achiever/upgrades/AchieverUnlockUnitModification.java
@@ -0,0 +1,21 @@
+package achiever.upgrades;
+
+import units.Unit;
+import attribute.Attribute;
+import attribute.AttributeUnitTypes;
+
+public class AchieverUnlockUnitModification extends AchieverAttributeModification<AttributeUnitTypes,Unit> {
+
+ public AchieverUnlockUnitModification(AchieverUpgradable achiever, Unit unit) {
+ super(achiever, unit, Attribute.UNITS);
+ }
+
+ @Override
+ public void modify() {
+ System.out.println(getAttribute() + "in Achieverunlockunitmodification");
+ System.out.println(getData() + "in Achieverunlockunitmodification");
+ System.out.println(getDecoratedAchiever() + "in Achievemerunklockunitmodificant");
+ getAttribute().augmentData(getData());
+ }
+
+}
View
11 src/achiever/upgrades/AchieverUpgradable.java
@@ -0,0 +1,11 @@
+package achiever.upgrades;
+
+import units.upgrades.Upgradable;
+import attribute.Attribute;
+
+
+public interface AchieverUpgradable extends Upgradable {
+
+ public Attribute getAttribute(String attr);
+
+}
View
2 src/attribute/AchievementList.java
@@ -2,7 +2,7 @@
import java.util.ArrayList;
-import achievement.Achiever;
+import achiever.Achiever;
public class AchievementList extends Attribute<ArrayList<String>,String> {
View
2 src/attribute/Attribute.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import achievement.Achievement;
-import achievement.Achiever;
+import achiever.Achiever;
public abstract class Attribute<T,E> implements java.io.Serializable {
View
2 src/attribute/AttributeExperience.java
@@ -1,7 +1,7 @@
package attribute;
import achievement.AchievementLevelUp;
-import achievement.Achiever;
+import achiever.Achiever;
public class AttributeExperience extends Attribute<Integer,Integer> {
View
2 src/attribute/AttributeKills.java
@@ -6,7 +6,7 @@
import player.Player;
import units.Unit;
import achievement.AchievementKill;
-import achievement.Achiever;
+import achiever.Achiever;
public class AttributeKills extends Attribute<ArrayList<Unit>,Unit> {
View
2 src/attribute/AttributeLevel.java
@@ -1,7 +1,7 @@
package attribute;
import achievement.AchievementUnlockUnit;
-import achievement.Achiever;
+import achiever.Achiever;
public class AttributeLevel extends Attribute<Integer,Integer> {
View
39 src/attribute/AttributeReactable.java
@@ -3,14 +3,20 @@
import java.util.HashMap;
import java.util.Map;
-import environment.Environment;
import units.Unit;
import units.reactions.Reaction;
+import environment.Environment;
+/**
+ * Makes the unit reactable to environmental factors
+ * Contains a map of reactions that the unit reacts to the environment
+ * and a map of booleans that that tell the unit if they can/cannot move onto the environment
+ * @author lenajia
+ *
+ */
public class AttributeReactable extends Attribute {
-
- protected Map <Environment, Reaction> myReactions;
- protected Map <Environment, Boolean> myValidMoves;
+ private Map <Environment, Reaction> myReactions;
+ private Map <Environment, Boolean> myValidMoves;
public AttributeReactable(Unit unit,Map <Environment, Reaction> reactions, Map<Environment, Boolean> moves){
super(unit);
@@ -21,16 +27,27 @@ public AttributeReactable(Unit unit,Map <Environment, Reaction> reactions, Map<E
public AttributeReactable(Unit unit){
this (unit, new HashMap <Environment, Reaction>(), new HashMap<Environment, Boolean>());
}
+
+ /**
+ * Checks to see if the unit can move onto the environment,
+ * based on the specific type of unit and environment
+ * @param u
+ * @param environ
+ * @return boolean
+ */
public boolean isValidMove(Unit u, Environment environ) {
- //if (myValidMoves!=null){
- Boolean r = myValidMoves.get(environ);
- if (r!= null)
- return r.booleanValue();
- return true;
- // }
- // return true;
+ Boolean r = myValidMoves.get(environ);
+ if (r!= null)
+ return r.booleanValue();
+ return true;
}
+ /**
+ * Gets the appropriate reaction based on the passed in environment and applies
+ * the reaction on the unit
+ * @param u
+ * @param environ
+ */
public void reactToEnvironment(Unit u, Environment environ) {
Reaction r = myReactions.get(environ);
if (u != null && r!=null) r.apply(u);
View
29 src/environment/Environment.java
@@ -11,6 +11,12 @@
import com.golden.gamedev.object.Sprite;
import com.golden.gamedev.util.ImageUtil;
+/**
+ * Abstract class of environmental effects placed on the map
+ * @author lenajia
+ *
+ */
+
public abstract class Environment extends Sprite implements java.io.Serializable {
protected int myDimX;
@@ -19,6 +25,7 @@
/**
* Constructor for environment
+ * Sets the image-to-tile ratio.
* @param ratio
*/
public Environment(double ratio) {
@@ -41,6 +48,11 @@ public Environment(){
this (1);
}
+ public abstract String Name();
+
+ public abstract String getImageURL();
+
+
public int getDimX() {
return myDimX;
}
@@ -49,16 +61,17 @@ public int getDimY() {
return myDimY;
}
- public abstract String Name();
-
- public abstract String getImageURL();
-
- //resizes environment image based on height, width parameter
- public void resize(int dx, int dy){
+ /**Resizes environment image based on given tile x, y dimensions
+ * and the ratio
+ *
+ * @param dx
+ * @param dy
+ */
+ public void resize(int tilex, int tiley){
if(this.getImage()!=null){
- myDimX = (int) (myRatio * dx);
- myDimY = (int) (myRatio * dy);
+ myDimX = (int) (myRatio * tilex);
+ myDimY = (int) (myRatio * tiley);
setImage(ImageUtil.resize(this.getImage(), myDimX, myDimY));
}
}
View
5 src/environment/Mountain.java
@@ -1,5 +1,10 @@
package environment;
+/**
+ * Concrete example of a permanent environment
+ * @author lenajia
+ *
+ */
public class Mountain extends Permanent{
/**
View
9 src/environment/Permanent.java
@@ -1,17 +1,22 @@
package environment;
+/**
+ * Type of environment that is permanently on the map
+ * @author lenajia
+ *
+ */
public abstract class Permanent extends Environment{
/**
- * Constructor for permanent environments. Set image ratio size.
+ * Constructor for permanent environments. Set image-to-tile ratio size.
* @param ratio
*/
public Permanent(double ratio) {
super(ratio);
}
- /* Always returns true (environment is always active)
+ /** Always returns true (environment is always active)
*/
public boolean isActive(int turn){
return true;
View
5 src/environment/PoisonGas.java
@@ -1,5 +1,10 @@
package environment;
+/**
+ * Concrete example of a non-weather transient environment
+ * @author lenajia
+ *
+ */
public class PoisonGas extends Transient {
/**
View
9 src/environment/Portal.java
@@ -1,9 +1,14 @@
package environment;
-public class Portal extends Permanent{
+/**
+ * Concrete example of a transient environment
+ * @author Lena Jia
+ *
+ */
+public class Portal extends Transient{
/**
- * Constructor for permanent environments. Set image ratio size.
+ * Constructor that sets the image-to-tile ratio size.
* @param ratio
*/
public Portal(double ratio) {
View
11 src/environment/Snow.java
@@ -8,8 +8,18 @@
import map.LevelMap;
+
+/**
+ * Concrete example of a transient weather environment
+ * @author lenajia
+ *
+ */
public class Snow extends Transient{
+ /**
+ * Sets the image-to-tile ratio.
+ * @param ratio
+ */
public Snow(double ratio){
super(ratio);
}
@@ -20,7 +30,6 @@ public String Name() {
}
@Override
-
public String getImageURL() {
return "resources/environment/snowflake.jpg";
}
View
14 src/environment/Transient.java
@@ -1,19 +1,29 @@
package environment;
+/**
+ * Type of environment that is not permanently on the map
+ * @author lenajia
+ *
+ */
public abstract class Transient extends Environment{
protected int myStartTurn;
protected int myEndTurn;
/**
- * Constructor for transient environments. Set image ratio size.
+ * Constructor for transient environments.
+ * Sets the image-to-tile ratio.
* @param ratio
*/
public Transient(double ratio) {
super(ratio);
}
- //Sets active if the current turn is within the active turn bounds
+ /**Sets active if the current turn is within the active turn bounds
+ *
+ * @param turn
+ * @return boolean
+ */
public boolean isActive(int turn){
if (turn>=myStartTurn && turn <= myEndTurn)
return true;
View
2 src/modes/EditMode.java
@@ -14,14 +14,14 @@
import player.Player;
import player.PlayerState;
import player.PlayerStateActive;
-import player.upgrades.AchieverAddUnitModification;
import serialization.EnvironmentElement;
import serialization.GameElement;
import serialization.MapElement;
import serialization.UnitElement;
import units.Unit;
import util.Wait;
import GUI.EditModeGUI;
+import achiever.upgrades.AchieverAddUnitModification;
import ai.HumanPlayer;
import com.golden.gamedev.GameEngine;
View
12 src/modes/GameMode.java
@@ -23,14 +23,14 @@
import modes.models.StandbyModel;
import modes.models.WaitingModel;
import player.Player;
-import player.upgrades.AchieverAddUnitModification;
-import units.ElectrodeUnit;
import units.PikachuFactoryUnit;
import units.PikachuUnit;
import units.Unit;
+import units.WeezingUnit;
import units.reactions.HealthBasedMoveReaction;
import units.reactions.ParalyzingAttackReaction;
import units.reactions.Reaction;
+import achiever.upgrades.AchieverAddUnitModification;
import ai.Bot;
import ai.HumanPlayer;
import ai.SlightlySmarterAI;
@@ -157,12 +157,12 @@ public void defaultInitialization() {
getMap().getTileByCoords(4, 4).setEnvironment(s4);
getMap().getTileByCoords(4, 5).setEnvironment(m);
- Unit pika4 = new ElectrodeUnit();
+ Unit weezing = new WeezingUnit();
- getMap().getTileByCoords(4, 3).setUnit(pika4);
- AchieverAddUnitModification addUnit = new AchieverAddUnitModification(getPlayerList().get(0), pika4);
+ getMap().getTileByCoords(4, 3).setUnit(weezing);
+ AchieverAddUnitModification addUnit = new AchieverAddUnitModification(getPlayerList().get(0), weezing);
addUnit.modify();
- AttributeReactable react = (AttributeReactable) pika4.getAttribute("Reactable");
+ AttributeReactable react = (AttributeReactable) weezing.getAttribute("Reactable");
HashMap<Environment, Reaction> Electrodereactions = new HashMap<Environment, Reaction>();
HashMap<Environment, Boolean> Electrodemoves = new HashMap<Environment, Boolean>();
View
2 src/observers/GameObserver.java
@@ -1,6 +1,6 @@
package observers;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.Attribute;
View
2 src/observers/ObserverEnvironment.java
@@ -1,6 +1,6 @@
package observers;
-import achievement.Achiever;
+import achiever.Achiever;
import environment.Portal;
public class ObserverEnvironment extends GameObserver {
View
4 src/observers/ObserverKills.java
@@ -2,10 +2,10 @@
import java.util.Stack;
-import player.upgrades.AchieverExperienceModification;
import units.Unit;
import achievement.Achievement;
-import achievement.Achiever;
+import achiever.Achiever;
+import achiever.upgrades.AchieverExperienceModification;
import attribute.Attribute;
import attribute.AttributeExperience;
import attribute.AttributeKills;
View
4 src/observers/ObserverLevelUp.java
@@ -1,8 +1,8 @@
package observers;
-import player.upgrades.AchieverLevelModification;
import achievement.Achievement;
-import achievement.Achiever;
+import achiever.Achiever;
+import achiever.upgrades.AchieverLevelModification;
import attribute.Attribute;
import attribute.AttributeLevel;
View
4 src/observers/ObserverUnlockUnits.java
@@ -2,10 +2,10 @@
import java.util.TreeMap;
-import player.upgrades.AchieverUnlockUnitModification;
import units.Unit;
import achievement.Achievement;
-import achievement.Achiever;
+import achiever.Achiever;
+import achiever.upgrades.AchieverUnlockUnitModification;
import attribute.Attribute;
public class ObserverUnlockUnits extends GameObserver {
View
4 src/player/Player.java
@@ -2,10 +2,10 @@
import java.util.ArrayList;
-import player.upgrades.AchieverUpgradable;
import units.Unit;
import achievement.AchievementUnlockUnit;
-import achievement.Achiever;
+import achiever.Achiever;
+import achiever.upgrades.AchieverUpgradable;
import attribute.AchievementList;
import attribute.Attribute;
import attribute.AttributeExperience;
View
1 src/units/ElectrodeUnit.java
@@ -43,7 +43,6 @@ public ElectrodeUnit(){
interactionList.add(new UnitButtonMove());
interactionList.add(new UnitButtonAttack());
interactionList.add(new UnitButtonNova());
- interactionList.add(new PassivePoisonGas());
}
@Override
View
3 src/units/Unit.java
@@ -3,10 +3,9 @@
import java.awt.Graphics2D;
import java.util.ArrayList;
-import player.Player;
import units.interactions.Interaction;
import units.upgrades.UnitUpgradable;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.AchievementList;
import attribute.Attribute;
import attribute.AttributeList;
View
62 src/units/WeezingUnit.java
@@ -0,0 +1,62 @@
+package units;
+
+import units.interactions.PassivePoisonGas;
+import units.interactions.UnitButtonAttack;
+import units.interactions.UnitButtonMove;
+import attribute.AchievementList;
+import attribute.AttributeAttack;
+import attribute.AttributeExperience;
+import attribute.AttributeHealth;
+import attribute.AttributeImage;
+import attribute.AttributeKills;
+import attribute.AttributeLevel;
+import attribute.AttributeMove;
+import attribute.AttributeReactable;
+import attribute.AttributeTurn;
+import attribute.AttributeUpgrades;
+
+public class WeezingUnit extends Unit {
+
+ public static final String PIKACHU_ADD_BUTTON = "resources/buttons/addPikachuButton.png";
+
+ public WeezingUnit(){
+ attributeList.add(new AttributeMove(this,5));
+ attributeList.add(new AttributeAttack(this,10, 2,1));
+ attributeList.add(new AttributeHealth(this,5));
+ attributeList.add(new AttributeReactable(this));
+ attributeList.add(new AttributeLevel(this));
+ attributeList.add(new AttributeExperience(this));
+
+ attributeList.add(new AttributeImage(this,imageFilepath()));
+ attributeList.add(new AttributeUpgrades(this));
+ // turn attribute, determines only one attribute interaction per turn
+ // maybe connect this more to interactions class
+ AttributeTurn turn = new AttributeTurn(this);
+ turn.addAttributeBoolean("Move");
+ turn.addAttributeBoolean("Attack");
+ attributeList.add(turn);
+ attributeList.add(new AchievementList(this));
+ attributeList.add(new AttributeKills(this));
+
+ interactionList.add(new UnitButtonMove());
+ interactionList.add(new UnitButtonAttack());
+ interactionList.add(new PassivePoisonGas());
+
+ }
+ @Override
+ public String unitName() {
+ return "Pikachu";
+ }
+
+ @Override
+ public String imageFilepath() {
+ return "resources/unit images/Weezing.png";
+ }
+
+ @Override
+ public String addButton() {
+ return PIKACHU_ADD_BUTTON;
+ }
+
+
+}
View
4 src/units/interactions/PassivePoisonGas.java
@@ -26,8 +26,8 @@ public void performInteraction(GameModel g, Unit myUnit) {
health.decrementHP(att.getAttackDamage()/5); //passive does 1/5 the normal attack damage
if (health.getHP() <= 0) {
System.out.println(target);
- target.beDestroyed(g.getSelectedUnit());
-
+ target.beDestroyed(myUnit);
+
}
System.out.println("USED POISON GAS, target has " + health.getHP()
+ "health left");
View
7 src/units/reactions/HealthBasedMoveReaction.java
@@ -5,9 +5,14 @@
import units.Unit;
import units.upgrades.MoveModification;
+/**
+ * Concrete example of a reaction.
+ * Move count left is decremented even more if the health HP of unit is lower
+ * @author lenajia
+ *
+ */
public class HealthBasedMoveReaction extends Reaction{
- // Move count left is decremented even more if the health HP of unit is lower
@Override
public void apply(Unit u) {
System.out.println("original "+((AttributeMove) u.getAttribute("Move")).getMovesLeft());
View
10 src/units/reactions/ParalyzingAttackReaction.java
@@ -5,13 +5,17 @@
import units.Unit;
import units.upgrades.MoveModification;
+/**
+ * Concrete example of a reaction.
+ * Paralyzes the unit so that the unit cannot attack
+ * @author lenajia
+ *
+ */
public class ParalyzingAttackReaction extends Reaction{
- // Paralyzes unit so that it cannot use any attacks
@Override
public void apply(Unit u) {
- // TODO Auto-generated method stub
-
+
((AttributeAttack) u.getAttribute("Attack")).setAttacksLeft(0);
}
View
6 src/units/reactions/Reaction.java
@@ -2,8 +2,10 @@
import units.Unit;
-/* Class used by units to react to environmental effects
- *
+/**
+ * Used by the AttributeReactable class so that units can react to environments
+ * @author lenajia
+ *
*/
public abstract class Reaction {
View
7 src/units/upgrades/HealthModification.java
@@ -1,6 +1,6 @@
package units.upgrades;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.AttributeExperience;
import attribute.AttributeHealth;
@@ -41,4 +41,9 @@ public void applyCost() {
exp.setData(((Integer) exp.getData()-getUpgradeCost()));
}
+ @Override
+ public String getButtonImage() {
+ return "resources/upgrades/upgrade.png";
+ }
+
}
View
8 src/units/upgrades/ImageModification.java
@@ -1,14 +1,13 @@
package units.upgrades;
-
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import serialization.SBufferedImage;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.AttributeExperience;
import attribute.AttributeImage;
@@ -62,5 +61,10 @@ public void applyCost() {
Achiever owner = getOwner();
AttributeExperience exp = (AttributeExperience) owner.getAttribute("Experience");
}
+
+ @Override
+ public String getButtonImage() {
+ return "resources/upgrades/upgrade.png";
+ }
}
View
7 src/units/upgrades/MoveModification.java
@@ -3,6 +3,7 @@
import attribute.AttributeMove;
+
public class MoveModification extends UnitAttributeModification {
private int incrementValue;
@@ -28,5 +29,11 @@ public boolean checkCost() {
public void applyCost() {
// TODO Auto-generated method stub
+ }
+
+ @Override
+ public String getButtonImage() {
+ return "resources/upgrades/upgrade.png";
}
+
}
View
9 src/units/upgrades/TeleportModification.java
@@ -1,8 +1,8 @@
package units.upgrades;
import map.LevelMap;
-import achievement.Achiever;
-import attribute.AttributeExperience;
+import achiever.Achiever;
+import attribute.AttributeExperience;
/**
* Concrete example of MapModification that changes reproduces the
@@ -42,4 +42,9 @@ public void applyCost() {
AttributeExperience exp = (AttributeExperience) owner.getAttribute("Experience");
exp.setData(((Integer) exp.getData()-getUpgradeCost()));
}
+
+ @Override
+ public String getButtonImage() {
+ return "resources/upgrades/upgrade.png";
+ }
}
View
1 src/units/upgrades/UnitAttributeModification.java
@@ -2,6 +2,7 @@
import attribute.Attribute;
+
/**
* A modification that changes a unit's attribute
* @author Alex Mariakakis
View
12 src/units/upgrades/UnitDecorator.java
@@ -1,9 +1,11 @@
package units.upgrades;
+
import java.util.ArrayList;
+import player.Player;
import units.interactions.Interaction;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.Attribute;
/**
@@ -16,7 +18,7 @@
private UnitUpgradable decoratedUnit;
private int upgradeCost;
private Achiever owner;
-
+
public UnitDecorator(UnitUpgradable unit, int cost) {
this.setDecoratedUnit(unit);
// If a cost is not entered, make it 0 to avoid exceptions
@@ -48,12 +50,14 @@ public int getUpgradeCost() {
public void setUpgradeCost(int cost) {
this.upgradeCost = cost;
}
-
+
+ public abstract String getButtonImage();
+
/**
* Decorator methods below
*/
public Attribute getAttribute(String attr) {
- return getDecoratedUnit().getAttribute(attr);
+ return getDecoratedUnit().getAttribute(attr);
}
public ArrayList<Interaction> getInteractionList() {
View
2 src/units/upgrades/UnitUpgradable.java
@@ -3,7 +3,7 @@
import java.util.ArrayList;
import units.interactions.Interaction;
-import achievement.Achiever;
+import achiever.Achiever;
import attribute.Attribute;
/**
View
34 src/units/upgrades/UpgradeTest.java
@@ -1,14 +1,10 @@
package units.upgrades;
import map.LevelMap;
-import player.upgrades.AchieverAddUnitModification;
-import player.upgrades.AchieverUpgradable;
+import player.Player;
import units.PikachuUnit;
import units.Unit;
-import achievement.Achiever;
import ai.HumanPlayer;
-import attribute.AttributeHealth;
-import attribute.AttributeUpgrades;
/**
* Place to test my design
@@ -19,28 +15,28 @@
public static void main(String[] args) {
// Create a player
- Achiever player1 = new HumanPlayer("Player 1");
+ Player player1 = new HumanPlayer("Player 1");
player1.getAttribute("Experience").setData(60);
// Create a unit
Unit oldUnit = new PikachuUnit();
// PlayerUpgradable addUnit = new PlayerAddUnitModification(player1, oldUnit);
// addUnit.modify();
- System.out.println("HP before: " + ((AttributeHealth) oldUnit.getAttribute("Health")).getHP());
- System.out.println("Experience before: " + player1.getAttribute("Experience").getData());
+// System.out.println("HP before: " + ((AttributeHealth) oldUnit.getAttribute("Health")).getHP());
+ System.out.println("Experience before: " + player1.getAttribute("Experience").getData());
// Create an upgrade tree and give it to the unit
- AttributeUpgrades tree = (AttributeUpgrades) oldUnit.getAttribute("Upgrades");
- UpgradeTree myTree = tree.getMyTree();
- myTree.addLeaf(myTree.getRoot(), new UpgradeNode(new HealthModification(oldUnit, 20, 5)));
-
- // Decorate the unit with better health
- UpgradeNode node1 = new UpgradeNode(new HealthModification(oldUnit, 20, 5));
- node1.setAvailable(true);
- node1.modify();
- System.out.println("HP after upgrade: " + ((AttributeHealth) oldUnit.getAttribute("Health")).getHP());
- System.out.println("Experience after upgrade: " + player1.getAttribute("Experience").getData());
- System.out.println("");
+// AttributeUpgrades tree = (AttributeUpgrades) oldUnit.getAttribute("Upgrades");
+// UpgradeTree myTree = tree.getMyTree();
+// myTree.addLeaf(myTree.getRoot(), new UpgradeNode(new HealthModification(oldUnit, 20, 5)));
+//
+// // Decorate the unit with better health
+// UpgradeNode node1 = new UpgradeNode(new HealthModification(oldUnit, 20, 5));
+// node1.setAvailable(true);
+// node1.modify();
+// System.out.println("HP after upgrade: " + ((AttributeHealth) oldUnit.getAttribute("Health")).getHP());
+// System.out.println("Experience after upgrade: " + player1.getAttribute("Experience").getData());
+// System.out.println("");
// Decorate the map
LevelMap myMap = new LevelMap(10);

0 comments on commit 192be1e

Please sign in to comment.