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
-
Method Summary
Modifier and TypeMethodDescriptionfloat
calculateAveTi
(int timeLeft, int timeWins) float
calculateAvg
(int sum, int numElements) Calculates the average value.float
calculateAvgAtm
(int numberOfAttempt, int timeItWin) void
create()
Called when the entity is created and registered.void
draw
(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, getZIndex
Methods inherited from class com.deco2800.game.rendering.RenderComponent
compareTo, dispose, render
Methods inherited from class com.deco2800.game.components.Component
earlyUpdate, getEntity, setEnabled, setEntity, toString, triggerEarlyUpdate, triggerUpdate, update
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Comparable
compareTo
Methods inherited from interface com.deco2800.game.rendering.Renderable
render
-
Constructor Details
-
PlayerProfileDisplay
public PlayerProfileDisplay()
-
-
Method Details
-
create
public void create()Description copied from class:Component
Called 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:
create
in 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:RenderComponent
Draw the renderable. Should be called only by the renderer, not manually.- Specified by:
draw
in classRenderComponent
- Parameters:
batch
- Batch to render to.
-