package AdventureModel; import java.io.Serializable; import java.util.ArrayList; /** * This class keeps track of the progress * of the player in the game. */ public class Player implements Serializable { /** * The current room that the player is located in. */ private Room currentRoom; /** * The list of items that the player is carrying at the moment. */ public ArrayList inventory; public Attack attack; //attack used by player public String name; //name of player public double hitPoints; //strength of player public double attackBonus; // attacks are strengthened by this public String weakness; /** * Adventure Game Player Constructor */ public Player(String name, Attack attack, int hitpoints) { this.inventory = new ArrayList(); this.name = name; this.attack = attack; this.hitPoints = hitpoints; this.attackBonus = 0.0; } /** * This method adds an object into players inventory if the object is present in * the room and returns true. If the object is not present in the room, the method * returns false. * * @param object name of the object to pick up * @return true if picked up, false otherwise */ public boolean takeObject(String object){ if(this.currentRoom.checkIfObjectInRoom(object)){ AdventureObject object1 = this.currentRoom.getObject(object); this.currentRoom.removeGameObject(object1); this.addToInventory(object1); return true; } else { return false; } } /** * checkIfObjectInInventory * __________________________ * This method checks to see if an object is in a player's inventory. * * @param s the name of the object * @return true if object is in inventory, false otherwise */ public boolean checkIfObjectInInventory(String s) { for(int i = 0; i getInventory() { ArrayList objects = new ArrayList<>(); for(int i=0;i