Coverage Summary for Class: Player (com.mygdx.game.Entitys)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| Player | 100% (1/1) | 75% (6/8) | 71% (22/31) |
1 package com.mygdx.game.Entitys; 2 3 import com.badlogic.gdx.utils.JsonValue; 4 import com.mygdx.game.Components.Pirate; 5 import com.mygdx.game.Components.PlayerController; 6 import com.mygdx.game.Managers.DifficultyManager; 7 import com.mygdx.game.Managers.GameManager; 8 9 /** 10 * Player's ship entity. 11 */ 12 public class Player extends Ship { 13 boolean reward_powerUp; 14 /** 15 * Adds ship with PlayerController component and sets its speed. 16 * 17 * @param speed of movement across map 18 */ 19 private Player(float speed) { 20 super(); 21 22 PlayerController pc = new PlayerController(this, speed); 23 addComponent(pc); 24 reward_powerUp = false; 25 setName("Player"); 26 } 27 28 /** 29 * Adds ship with PlayerController component, loading its speed from GameManager settings. 30 */ 31 public Player() { 32 this(GameManager.getSettings().get("starting").getFloat("playerSpeed")); 33 } 34 35 /**NEW 36 * update the players health based upon the difficulty 37 */ 38 public void updateHealth() { 39 String mode = DifficultyManager.getDifficulty(); 40 JsonValue starting = GameManager.getSettings().get("starting"); 41 int health; 42 if (mode == "e") { 43 health = starting.getInt("health-easy"); 44 } else if (mode == "h") { 45 health = starting.getInt("health-hard"); 46 } else { 47 health = starting.getInt("health"); 48 } 49 setHealth(health); 50 } 51 52 @Override 53 public void cleanUp() { 54 super.cleanUp(); 55 } 56 57 public int getAmmo() { 58 return getComponent(Pirate.class).getAmmo(); 59 } 60 61 //NEW 62 public void setAmmo(Integer ammo){ 63 getComponent(Pirate.class).setAmmo(ammo); 64 } 65 66 public void setReward_powerUp(boolean reward_powerUp){ 67 this.reward_powerUp = reward_powerUp; 68 } 69 70 public boolean getReward_powerUp(){ 71 return reward_powerUp; 72 } 73 }