Package model
Class Engine
java.lang.Object
model.Engine
- All Implemented Interfaces:
IEngine
The type Engine.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ArrayList<MemoryObject>private final IGameControllerprivate int(package private) intThe number of incorrect tries.private longprivate ArrayList<MemoryObject>private final longThe time when the game started / engine created (in milliseconds).The Storage.(package private) final Timer(package private) final TimerTaskprivate longprivate intThe points received for each correct guess, decreased by 100 by each wrong guess.private final ModeTypeprivate final Userlogged in userprivate int -
Constructor Summary
ConstructorsConstructorDescriptionEngine(ModeType type, IGameController controller) Instantiates a new Engine. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMemoryObjectsToList(Integer amount) voidaddToComparing(int i) voidclearPair(ArrayList<MemoryObject> memoryList) voidvoidcompareObjects(ArrayList<MemoryObject> objectList) voidendGame()intgetHint()Gets memory objects list.longintGetter for the total score.getType()voidrunTimer()voidsetChosenObjectReady(MemoryObject object) voidvoidCalled by a method that ends the game.voidsetReturnStatus(boolean returnStatus) voidvoidvoidtoString()voidupdateDynamicScore(int score) voidupdateScore(CompareResultType type)
-
Field Details
-
storage
The Storage. -
correctIds
-
correctIdsIds
-
controller
-
type
-
comparingList
-
rightPairList
-
memoryObjectsList
-
hint
private int hint -
user
logged in user -
startTime
private final long startTimeThe time when the game started / engine created (in milliseconds). -
totalScore
private int totalScoreThe points received for each correct guess, decreased by 100 by each wrong guess. -
incorrectTries
int incorrectTriesThe number of incorrect tries. Resets when a correct guess is made. -
timerTime
private long timerTime -
lastCorrectGuess
private long lastCorrectGuess -
t
-
task
-
wrong_guesses
private int wrong_guesses
-
-
Constructor Details
-
Engine
Instantiates a new Engine.- Parameters:
type- the typecontroller- the controller
-
-
Method Details
-
setReturnStatus
public void setReturnStatus(boolean returnStatus) -
getMemoryObjectsList
Gets memory objects list.- Returns:
- the memory objects list
-
getTimerTime
public long getTimerTime() -
setMemoryObjects
public void setMemoryObjects()- Specified by:
setMemoryObjectsin interfaceIEngine
-
startTime
public void startTime() -
addMemoryObjectsToList
- Specified by:
addMemoryObjectsToListin interfaceIEngine
-
suffleObjects
public void suffleObjects()- Specified by:
suffleObjectsin interfaceIEngine
-
setChosenObjectReady
- Specified by:
setChosenObjectReadyin interfaceIEngine
-
addToComparing
public void addToComparing(int i) - Specified by:
addToComparingin interfaceIEngine
-
endGame
public void endGame() -
stopTimer
public void stopTimer() -
getHint
public int getHint() -
setPersonalScore
public void setPersonalScore()Called by a method that ends the game. Saves the score to the leaderboard. Only if logged in.- Specified by:
setPersonalScorein interfaceIEngine
-
updateScore
-
getTotalScore
public int getTotalScore()Getter for the total score.- Specified by:
getTotalScorein interfaceIEngine- Returns:
- see
totalScore
-
clearStorage
public void clearStorage()- Specified by:
clearStoragein interfaceIEngine
-
clearPair
-
compareObjects
- Specified by:
compareObjectsin interfaceIEngine
-
runTimer
public void runTimer() -
getType
-
updateDynamicScore
public void updateDynamicScore(int score) - Specified by:
updateDynamicScorein interfaceIEngine
-
toString
-