Add: show animal icon in typing app button
This commit is contained in:
@@ -84,6 +84,7 @@ class MenuTypingPractice {
|
||||
let dbConnectManager = new DBConnectManager();
|
||||
dbConnectManager.requestTypingPracticeAppList(
|
||||
sessionStorageManager.maestroID,
|
||||
sessionStorageManager.playerID,
|
||||
self.downloadListSucceeded,
|
||||
self.downloadListFailed
|
||||
);
|
||||
@@ -99,6 +100,27 @@ class MenuTypingPractice {
|
||||
return false;
|
||||
}
|
||||
|
||||
getBestRecord(jsonList, appID) {
|
||||
let count = Object.keys(jsonList).length;
|
||||
|
||||
for(let i = 0; i < count; i++) {
|
||||
if(jsonList[i].AppID === appID)
|
||||
return jsonList[i].BestRecord;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
getIconImage(jsonList, appID) {
|
||||
let bestRecord = this.getBestRecord(jsonList, appID);
|
||||
|
||||
if(bestRecord === 0)
|
||||
return "snail_shadow";
|
||||
|
||||
let animalLevel = Animal.animalLevelIDByRecord(bestRecord, Animal.TYPE_PRACTICE);
|
||||
return Animal.SPECIES_DATA[animalLevel].species + Animal.SPRITE_NAMES.icon;
|
||||
}
|
||||
|
||||
downloadListSucceeded(replyJSON) {
|
||||
// console.log(replyJSON);
|
||||
|
||||
@@ -115,11 +137,10 @@ class MenuTypingPractice {
|
||||
TypingAppButton.BUTTON_UPPER_POS_Y
|
||||
);
|
||||
|
||||
let iconImage = "snail_shadow";
|
||||
let typingPracticeButton = new TypingAppButton(
|
||||
TypingAppButton.TYPE_PRACTICE_KOREAN,
|
||||
posX, posY,
|
||||
iconImage,
|
||||
self.getIconImage(replyJSON.KoreanHighScoreList, activeApp.AppID),
|
||||
activeApp.KoreanName,
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
@@ -141,11 +162,10 @@ class MenuTypingPractice {
|
||||
TypingAppButton.BUTTON_LOWER_POS_Y
|
||||
);
|
||||
|
||||
let iconImage = "snail_shadow";
|
||||
let typingPracticeButton = new TypingAppButton(
|
||||
TypingAppButton.TYPE_PRACTICE_ENGLISH,
|
||||
posX, posY,
|
||||
iconImage,
|
||||
self.getIconImage(activeApp.AppID),
|
||||
activeApp.KoreanName,
|
||||
() => {
|
||||
sessionStorageManager.playingAppID = activeApp.AppID;
|
||||
|
||||
Reference in New Issue
Block a user