Skip to content

Commit

Permalink
Added createMonster method, also minor adjustments to item files
Browse files Browse the repository at this point in the history
  • Loading branch information
artem-j committed Nov 18, 2016
1 parent c8c2148 commit 419046b
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 68 deletions.
13 changes: 0 additions & 13 deletions src/edu/ucsb/cs56/projects/games/roguelike/Beef.java
Original file line number Diff line number Diff line change
Expand Up @@ -38,19 +38,6 @@ public Beef(boolean use){
this.setIcon('+');
}

/**
*This is the getter to figure out what piece icon it is.
*/
@Override public char getIcon(){
return this.icon;
}
/**
*This is the setter for the Icon it will be
*@param NewIcon is the icon of piece that will be in the game
*/
@Override public void setIcon(char NewIcon){
this.icon=NewIcon;
}
/**
this method uses the effect value in someway.
in this method it just adds attack points to the player
Expand Down
16 changes: 0 additions & 16 deletions src/edu/ucsb/cs56/projects/games/roguelike/Elixir.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,6 @@ public Elixir(boolean use){
this.setIcon('S');
}

/**
This is the getter to figure out what piece icon it is.
*/
@Override
public char getIcon(){
return this.icon;
}

/**
*This is the setter for the Icon it will be
*@param NewIcon is the icon of piece that will be in the game
*/
@Override public void setIcon(char NewIcon){
this.icon=NewIcon;
}

/**
this method uses the effect value in someway.
in this method it adds the speed value to the player.
Expand Down
18 changes: 1 addition & 17 deletions src/edu/ucsb/cs56/projects/games/roguelike/HealthPotion.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,23 +39,7 @@ public HealthPotion(boolean use){
this.setIcon('H');
}

/**
*This is the getter to figure out what piece icon it is.
*/
@Override public char getIcon(){
return this.icon;
}
/**
*This is the setter for the Icon it will be
*@param NewIcon is the icon of piece that will be in the game
*/
@Override public void setIcon(char NewIcon){
this.icon=NewIcon;
}
/**
this method uses the effect value in someway.
in this method it just adds health to the player.
*/

@Override public void UseEffect(Player p){
p.setHitPoints(this.getEffect()+p.getHitPoints());
}
Expand Down
68 changes: 59 additions & 9 deletions src/edu/ucsb/cs56/projects/games/roguelike/Monster.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public class Monster implements GamePiece{
private int pointValue=5;
private char icon;

// Default attributes for monsters
// Default attributes for monsters. To add a new monster, add a new array with the values for hitPoints, attack, pointValue, and icon
public static final int[] BAT = {5,1,10,66};
public static final int[] GOLEM = {25,5,30,71};
public static final int[] MONSTER = {20,10,5,77};
Expand All @@ -40,18 +40,68 @@ public Monster(){
this.typeOfMovement=0;
}
/**
* creates a player with 20 hitPoints and 10 attack
* creates a monster with 20 hitPoints and 10 attack
* @param typeOfMovement whether or not the monster will move randomly or not
* @param typeOfMonster integer array containing monster's stats
*/
public Monster(int typeOfMovement, int[] typeOfMonster){
this.setHitPoints(typeOfMonster[0]);
this.setAttack(typeOfMonster[1]);
this.setPointValue(typeOfMonster[2]);
char[] iconArray = Character.toChars(typeOfMonster[3]);
char iconChar = iconArray[0];
this.setIcon(iconChar);
this.typeOfMovement=typeOfMovement;
this(typeOfMovement, typeOfMonster[0], typeOfMonster[1],
typeOfMonster[2], Character.toChars(typeOfMonster[3])[0]);
}
/**
* Creates a monster with the stats passed in
* @param typeOfMovement determines the monster's movement behavior
* @param hitPoints the monster's hitPoints
* @param attack the monster's attack
* @param pointValue how many points the monster is worth
* @param icon the icon which will represent the monster on screen
*/

public Monster(int typeOfMovement, int hitPoints, int attack, int pointValue, char icon) {
this.setHitPoints(hitPoints);
this.setAttack(attack);
this.setPointValue(pointValue);
this.setIcon(icon);
this.typeOfMovement = typeOfMovement;
}

/**
* Static factory method for generating a monster based on an input string
* @param typeOfMovement determines the monster's movement behavior
* @param monsterName a string containing the name of the monster you want to create
*/

public static Monster createMonster(int typeOfMovement, String monsterName) {
monsterName = monsterName.toUpperCase();
Monster retMonster;
switch (monsterName) {
case "BAT" :
retMonster = new Monster(typeOfMovement, BAT);
break;
case "GOLEM" :
retMonster = new Monster(typeOfMovement, GOLEM);
break;
case "MONSTER" :
retMonster = new Monster(typeOfMovement, MONSTER);
break;
case "PIRATE" :
retMonster = new Monster(typeOfMovement, PIRATE);
break;
case "SNAKE" :
retMonster = new Monster(typeOfMovement, SNAKE);
break;
case "TROLL" :
retMonster = new Monster(typeOfMovement, TROLL);
break;
case "ZOMBIE" :
retMonster = new Monster(typeOfMovement, ZOMBIE);
break;
default :
retMonster = new Monster(typeOfMovement, MONSTER);
}

return retMonster;
}

/**
* @return the monster's hitPoints
Expand Down
13 changes: 0 additions & 13 deletions src/edu/ucsb/cs56/projects/games/roguelike/Poison.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,6 @@ public Poison(boolean use){
this.setIcon('!');
}

/**
This is the getter to figure out what piece icon it is.
*/
@Override public char getIcon(){
return this.icon;
}
/**
*This is the setter for the Icon it will be
*@param NewIcon is the icon of piece that will be in the game
*/
@Override public void setIcon(char NewIcon){
this.icon=NewIcon;
}
/**
this method uses the effect value in someway.
in this method it just subtracts health from the player.
Expand Down

0 comments on commit 419046b

Please sign in to comment.