-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pokemon trainer battling and exploring maps
- Loading branch information
1 parent
769ab68
commit ce0b04f
Showing
20 changed files
with
2,182 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
n w n p n | ||
i p w n c | ||
s n p i n | ||
w c n w w | ||
n w n p f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
n w p f w | ||
c n n p i | ||
n w i n c | ||
p n p w n | ||
w n w n s |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
w n n s p | ||
n w n i c | ||
f p w w n | ||
p n w n n | ||
w c i n p |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
</component> | ||
</module> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
/** | ||
* Bulbasaur is a representation of a Bulbasaur, subclass of Pokemon, implementation of the Grass interface | ||
* | ||
* @author Daniel Jo 2021 | ||
*/ | ||
public class Bulbasaur extends Pokemon implements Grass { | ||
/** | ||
* Creates a Bulbasaur object as a Pokemon with the name Bulbasaur | ||
*/ | ||
public Bulbasaur() { | ||
super("Bulbasaur"); | ||
} | ||
|
||
/** | ||
* Returns the menu of the Bulbasaur's special attacks | ||
* | ||
* @return the menu of the Bulbasaur's special attacks | ||
*/ | ||
@Override | ||
public String getSpecialMenu() { | ||
return specialMenu; | ||
} | ||
|
||
/** | ||
* Returns the number of the Bulbasaur's special attacks in the menu | ||
* | ||
* @return the number of the Bulbasaur's special attacks in the menu | ||
*/ | ||
@Override | ||
public int getNumSpecialMenuItems() { | ||
return numSpecialMenuItems; | ||
} | ||
|
||
/** | ||
* Bulbasaur attacks the Pokemon p based on the corresponding special attack move selected as an int | ||
* | ||
* @param p Pokemon that is being attacked | ||
* @param move the number of the corresponding special attack | ||
* @return the description of the special attack the Pokemon was attacked with by the Bulbasaur | ||
* based on the corresponding move and how much damage was taken | ||
*/ | ||
@Override | ||
public String specialAttack(Pokemon p, int move) { | ||
switch (move) { | ||
case 1: | ||
return this.vineWhip(p); | ||
case 2: | ||
return this.razorLeaf(p); | ||
case 3: | ||
return this.solarBeam(p); | ||
default: | ||
return "Invalid move"; | ||
} | ||
} | ||
|
||
/** | ||
* Bulbasaur attacks the Pokemon p with vine whip. | ||
* The damage is multiplied by the multiplier which is based on the other Pokemon's type. | ||
* | ||
* @param p Pokemon that is being attacked with vine whip | ||
* @return the description of the Pokemon being attacked with vine whip by the Bulbasaur and how much damage was taken. | ||
*/ | ||
@Override | ||
public String vineWhip(Pokemon p) { | ||
int bulbasaurType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[bulbasaurType][pType]; | ||
int damage = (int) ((Math.floor(Math.random() * 3) + 1) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is slapped with VINE WHIP and takes " + damage + " damage."; | ||
} | ||
|
||
/** | ||
* Bulbasaur attacks the Pokemon p with razor leaf. | ||
* The damage is multiplied by the multiplier which is based on the other Pokemon's type. | ||
* | ||
* @param p Pokemon that is being attacked with razor leaf | ||
* @return the description of the Pokemon being attacked with razor leaf by the Bulbasaur and how much damage was taken. | ||
*/ | ||
@Override | ||
public String razorLeaf(Pokemon p) { | ||
int bulbasaurType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[bulbasaurType][pType]; | ||
int damage = (int) ((Math.floor(Math.random() * 3) + 2) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is slashed with RAZOR LEAF and takes " + damage + " damage."; | ||
} | ||
|
||
/** | ||
* Bulbasaur attacks the Pokemon p with solar beam. | ||
* The damage is multiplied by the multiplier which is based on the other Pokemon's type. | ||
* | ||
* @param p Pokemon that is being attacked with solar beam | ||
* @return the description of the Pokemon being attacked with solar beam by the Bulbasaur and how much damage was taken. | ||
*/ | ||
@Override | ||
public String solarBeam(Pokemon p) { | ||
int bulbasaurType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[bulbasaurType][pType]; | ||
int damage = (int) (Math.floor(Math.random() * 6) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is dazzled by SOLAR BEAM and takes " + damage + " damage."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/** | ||
* Charmander is a representation of a Charmander, subclass of Pokemon, implementation of the Fire interface | ||
* | ||
* @author Chloee Gong 2021 | ||
*/ | ||
public class Charmander extends Pokemon implements Fire { | ||
/** | ||
* Creates a Charmander object of a Pokemon with the name Charmander | ||
*/ | ||
public Charmander() { | ||
super("Charmander"); | ||
} | ||
|
||
/** | ||
* Returns the menu of the Charmander's special attacks | ||
* | ||
* @return the menu of the Charmander's special attacks | ||
*/ | ||
@Override | ||
public String getSpecialMenu() { | ||
return specialMenu; | ||
} | ||
|
||
/** | ||
* Returns the number of the Charmander's special attacks in the menu | ||
* | ||
* @return the number of the Charmander's special attacks in the menu | ||
*/ | ||
|
||
@Override | ||
public int getNumSpecialMenuItems() { | ||
return numSpecialMenuItems; | ||
} | ||
|
||
/** | ||
* Returns string description of the special attack used by Charmander and its effect on the target Pokemon p. | ||
* | ||
* @param p Pokemon that is being attacked | ||
* @param move the number of the corresponding special attack | ||
* @return the string of the corresponding special attack, and it's effect on the target pokemon. | ||
*/ | ||
@Override | ||
public String specialAttack(Pokemon p, int move) { | ||
switch (move) { | ||
case 1: | ||
return this.ember(p); | ||
case 2: | ||
return this.fireBlast(p); | ||
case 3: | ||
return this.firePunch(p); | ||
default: | ||
return "Invalid move"; | ||
} | ||
} | ||
|
||
/** | ||
* Returns the description of the Pokemon being attacked by ember by Charmander and how much damage was taken. | ||
* | ||
* @param p the Pokemon object to be affected by ember's attack. | ||
* @return The description of ember and it's random damage on the Pokemon object being targeted. | ||
*/ | ||
@Override | ||
public String ember(Pokemon p) { | ||
int charmanderType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[charmanderType][pType]; | ||
int damage = (int) (Math.floor(Math.random() * 4) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is toasted with EMBER and takes " + damage + " damage."; | ||
} | ||
|
||
/** | ||
* Returns the description of the Pokemon being attacked by fire blast by Charmander and how much damage was taken. | ||
* | ||
* @param p the Pokemon object to be affected by fire blasts' attack. | ||
* @return the description of fire blast and it's random damage on the Pokemon object being targeted. | ||
*/ | ||
@Override | ||
public String fireBlast(Pokemon p) { | ||
int charmanderType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[charmanderType][pType]; | ||
int damage = (int) ((Math.floor(Math.random() * 4) + 1) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is almost dead with FIRE BLAST and takes " + damage + " damage."; | ||
} | ||
|
||
/** | ||
* Returns the description of the Pokemon being attacked by fire punch by Charmander and how much damage was taken. | ||
* | ||
* @param p the Pokemon object to be affected by fire blasts' attack. | ||
* @return The description of fire punch and its random damage on the Pokemon object being targeted. | ||
*/ | ||
|
||
@Override | ||
public String firePunch(Pokemon p) { | ||
int charmanderType = this.getType(); | ||
int pType = p.getType(); | ||
double multiplier = battleTable[charmanderType][pType]; | ||
int damage = (int) ((Math.floor(Math.random() * 3) + 1) * multiplier); | ||
|
||
p.takeDamage(damage); | ||
|
||
return p.getName() + " is burned with FIRE PUNCH and takes " + damage + " damage."; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,140 @@ | ||
import java.util.Scanner; | ||
|
||
/** | ||
* Static functions used to check console input for validity. | ||
* <p> | ||
* Use: Place CheckInput class in the same project folder as your code. | ||
* Call CheckInput functions from your code using "CheckInput." | ||
* <p> | ||
* Example: int num = CheckInput.getInt(); | ||
* | ||
* @author Shannon Cleary 2021 | ||
*/ | ||
public class CheckInput { | ||
|
||
/** | ||
* Checks if the inputted value is an integer. | ||
* | ||
* @return the valid input. | ||
*/ | ||
public static int getInt() { | ||
Scanner in = new Scanner(System.in); | ||
int input = 0; | ||
boolean valid = false; | ||
while (!valid) { | ||
if (in.hasNextInt()) { | ||
input = in.nextInt(); | ||
valid = true; | ||
} else { | ||
in.next(); //clear invalid string | ||
System.out.println("Invalid Input."); | ||
} | ||
} | ||
return input; | ||
} | ||
|
||
/** | ||
* Checks if the inputted value is an integer and | ||
* within the specified range (ex: 1-10) | ||
* | ||
* @param low lower bound of the range. | ||
* @param high upper bound of the range. | ||
* @return the valid input. | ||
*/ | ||
public static int getIntRange(int low, int high) { | ||
Scanner in = new Scanner(System.in); | ||
int input = 0; | ||
boolean valid = false; | ||
while (!valid) { | ||
if (in.hasNextInt()) { | ||
input = in.nextInt(); | ||
if (input <= high && input >= low) { | ||
valid = true; | ||
} else { | ||
System.out.println("Invalid Range."); | ||
} | ||
} else { | ||
in.next(); //clear invalid string | ||
System.out.println("Invalid Input."); | ||
} | ||
} | ||
return input; | ||
} | ||
|
||
/** | ||
* Checks if the inputted value is a non-negative integer. | ||
* | ||
* @return the valid input. | ||
*/ | ||
public static int getPositiveInt() { | ||
Scanner in = new Scanner(System.in); | ||
int input = 0; | ||
boolean valid = false; | ||
while (!valid) { | ||
if (in.hasNextInt()) { | ||
input = in.nextInt(); | ||
if (input >= 0) { | ||
valid = true; | ||
} else { | ||
System.out.println("Invalid Range."); | ||
} | ||
} else { | ||
in.next(); //clear invalid string | ||
System.out.println("Invalid Input."); | ||
} | ||
} | ||
return input; | ||
} | ||
|
||
/** | ||
* Checks if the inputted value is a double. | ||
* | ||
* @return the valid input. | ||
*/ | ||
public static double getDouble() { | ||
Scanner in = new Scanner(System.in); | ||
double input = 0; | ||
boolean valid = false; | ||
while (!valid) { | ||
if (in.hasNextDouble()) { | ||
input = in.nextDouble(); | ||
valid = true; | ||
} else { | ||
in.next(); //clear invalid string | ||
System.out.println("Invalid Input."); | ||
} | ||
} | ||
return input; | ||
} | ||
|
||
/** | ||
* Takes in a string from the user. | ||
* | ||
* @return the inputted String. | ||
*/ | ||
public static String getString() { | ||
Scanner in = new Scanner(System.in); | ||
String input = in.nextLine(); | ||
return input; | ||
} | ||
|
||
/** | ||
* Takes in a yes/no from the user. | ||
* | ||
* @return true if yes, false if no. | ||
*/ | ||
public static boolean getYesNo() { | ||
boolean valid = false; | ||
while (!valid) { | ||
String s = getString(); | ||
if (s.equalsIgnoreCase("yes") || s.equalsIgnoreCase("y")) { | ||
return true; | ||
} else if (s.equalsIgnoreCase("no") || s.equalsIgnoreCase("n")) { | ||
return false; | ||
} else { | ||
System.out.println("Invalid Input."); | ||
} | ||
} | ||
return false; | ||
} | ||
} |
Oops, something went wrong.