Class PlayerProfileDisplay
java.lang.Object
com.deco2800.game.components.Component
com.deco2800.game.rendering.RenderComponent
com.deco2800.game.ui.UIComponent
com.deco2800.game.components.player.PlayerProfileDisplay
- All Implemented Interfaces:
com.badlogic.gdx.utils.Disposable,Renderable,Comparable<Renderable>
This class creates the player profile window.
Description of the feature:
This feature displays the player's profile for the current player of the game.
The profile includes useful and perhaps interesting statistics about the player's performance in the game,
including the average time they have taken to win the game,
the average number of attempts taken to guess the traitor until they win,
how many times they have lost the game, and how many times they have won the game.
-
Field Summary
Fields inherited from class com.deco2800.game.ui.UIComponent
skin, stage -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionfloatcalculateAveTi(int timeLeft, int timeWins) floatcalculateAvg(int sum, int numElements) Calculates the average value.floatcalculateAvgAtm(int numberOfAttempt, int timeItWin) voidcreate()Called when the entity is created and registered.voiddraw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Draw the renderable.Gets the list of performance stats of the player (player profile) in the json file.Methods inherited from class com.deco2800.game.ui.UIComponent
getLayer, getZIndexMethods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, dispose, renderMethods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, updateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.deco2800.game.rendering.Renderable
render
-
Constructor Details
-
PlayerProfileDisplay
public PlayerProfileDisplay()
-
-
Method Details
-
create
public void create()Description copied from class:ComponentCalled when the entity is created and registered. Initial logic such as calls to GetComponent should be made here, not in the constructor which is called before an entity is finished.- Overrides:
createin classUIComponent
-
getPlayerProfile
Gets the list of performance stats of the player (player profile) in the json file.- Returns:
- list of performance stats
-
calculateAvg
public float calculateAvg(int sum, int numElements) Calculates the average value.- Parameters:
sum- the sum of all elements.numElements- the number of elements.- Returns:
- the average of the elements.
-
calculateAveTi
public float calculateAveTi(int timeLeft, int timeWins) -
calculateAvgAtm
public float calculateAvgAtm(int numberOfAttempt, int timeItWin) -
draw
public void draw(com.badlogic.gdx.graphics.g2d.SpriteBatch batch) Description copied from class:RenderComponentDraw the renderable. Should be called only by the renderer, not manually.- Specified by:
drawin classRenderComponent- Parameters:
batch- Batch to render to.
-