Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Player {
- Location loc;
- private String name;
- private int HP;
- private int AP;
- private int DP;
- private Inventory inventory;
- public Player(Location l, String name, int HP, int AP, int DP, Inventory inventory) {
- loc=l;
- this.name=name;
- this.HP=HP;
- this.AP=AP;
- this.DP=DP;
- this.inventory=inventory;
- }
- public void movePlayer(int rowShift, int colShift) {
- loc.setRow(loc.getRow()+rowShift);
- loc.setCol(loc.getCol()+colShift);
- }
- public void promptMove(Map m){
- Scanner scan=new Scanner (System.in);
- System.out.println("Please Move");
- String move=scan.next();
- if (move.equalsIgnoreCase("d")){
- if(m.validMove(loc,0,1)){
- movePlayer(0,1);
- m.inputPlayerLoc(getLoc());
- }
- else{
- System.out.println("Please enter a valid move");
- }
- }
- else if (move.equalsIgnoreCase("a")){
- if(m.validMove(loc,0,-1)){
- movePlayer(0,-1);
- m.inputPlayerLoc(getLoc());
- }
- else{
- System.out.println("Please enter a valid move");
- }
- }
- else if (move.equalsIgnoreCase("w")){
- if(m.validMove(loc,-1,0)){
- movePlayer(-1,0);
- m.inputPlayerLoc(getLoc());
- }
- else{
- System.out.println("Please enter a valid move");
- }
- }
- else if (move.equalsIgnoreCase("s")){
- if(m.validMove(loc,1,0)){
- movePlayer(1,0);
- m.inputPlayerLoc(getLoc());
- }
- else{
- System.out.println("Please enter a valid move");
- }
- }
- else{
- System.out.println("That is an invalid move");
- }
- m.printMap();
- }
- public Location getLoc() {
- return loc;
- }
- public void setLoc(Location loc) {
- this.loc = loc;
- }
- public String getName(){
- return name;
- }
- public void setName(String name){
- this.name=name;
- }
- public int getHP(){
- return HP;
- }
- public void setHP(int HP){
- this.HP=HP;
- }
- public int getAP(){
- return AP;
- }
- public void setAP(int AP){
- this.AP=AP;
- }
- public int getDP(){
- return DP;
- }
- public void setDP(int DP){
- this.DP=DP;
- }
- public Inventory getInventory(){
- return inventory;
- }
- public void setInventory(Inventory inventory){
- this.inventory=inventory;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement