Coverage Summary for Class: LocateQuest (com.mygdx.game.Quests)
| Class | Class, % | Method, % | Line, % |
|---|---|---|---|
| LocateQuest | 100% (1/1) | 100% (4/4) | 92.9% (26/28) |
1 package com.mygdx.game.Quests; 2 3 import com.badlogic.gdx.math.Vector2; 4 import com.mygdx.game.Entitys.Player; 5 6 import static com.mygdx.utils.Constants.TILE_SIZE; 7 8 /** 9 * Competed once the player has gone to a specific position 10 */ 11 public class LocateQuest extends Quest { 12 private final Vector2 loc; 13 private float radius; 14 15 /** 16 * Creates a Location Quest, with all the base attributes filled in with templates 17 */ 18 public LocateQuest() { 19 super(); 20 name = "Find a chest"; 21 description = "North east"; 22 plunderReward = 100; 23 pointReward = 150; 24 loc = new Vector2(); 25 radius = -1; 26 } 27 28 /** 29 * The loc to go to and radius that the play has to be in to complete it 30 * @param pos location to find 31 * @param r leeway in completion 32 */ 33 public LocateQuest(Vector2 pos, float r) { 34 this(); 35 loc.set(pos); 36 radius = r * r; 37 pos.scl(1 / TILE_SIZE).sub(50, 50); // centres on 0, 0 38 description = ""; 39 if (pos.y > 0) { 40 description += "North "; 41 } else if (pos.y < 0) { 42 description += "South "; 43 } 44 if (pos.x > 0) { 45 description += "East"; 46 } else if (pos.x < 0) { 47 description += "West"; 48 } 49 50 } 51 52 /** 53 * @return The completion status of the quest 54 */ 55 @Override 56 public boolean checkCompleted(Player p) { 57 if (radius == -1) { 58 return false; 59 } 60 Vector2 delta = p.getPosition().cpy(); 61 delta.sub(loc); 62 float l = delta.len2(); 63 isCompleted = l < radius; 64 return isCompleted; 65 } 66 67 /** 68 * @return The end location of the quest 69 */ 70 public Vector2 getLocation() { 71 return loc; 72 } 73 }