-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
55 additions
and
30 deletions.
There are no files selected for viewing
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import './index.css'; | ||
|
||
export default function AchievementsList({ achievements, t }) { | ||
console.log(achievements); | ||
return ( | ||
<div class="achievement-list"> | ||
{achievements.map((currentAchievement) => { | ||
return ( | ||
<div class="achievement-list-item"> | ||
<img src={`/img/alchemistry/achievements/${currentAchievement.name}_ok.png`} /> | ||
<div class="achievement-list-item-body"> | ||
<div class="achievement-list-item-title"> | ||
{t(`alchemistry:achievements:NEW_ACHIEVEMENT_1_${currentAchievement.index}_NAME`)} | ||
</div> | ||
<span class={'achievement-list-rarity' + ((currentAchievement.percent < 10) ? ' achievement-list-rarity-rare' : '')}> | ||
{Math.floor(currentAchievement.percent)}% | ||
</span> | ||
<div class="achievement-list-item-description"> | ||
{currentAchievement.description} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
); | ||
} |
13 changes: 13 additions & 0 deletions
13
src/components/AlchemistryAchievementDescription/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { neededItems, neededIngredients } from '/src/business/alchemistry_neededItems.js'; | ||
|
||
export default function AlchemistryAchievementDescription({ achievement, t }) { | ||
return ( | ||
<div> | ||
{t(`alchemistry:achievements:NEW_ACHIEVEMENT_1_${achievement.index}_DESC`).replace('N/A', '')} | ||
{neededItems[achievement.name] && <details> | ||
<summary>Item needed</summary>{/* TODO: i18n */} | ||
You should create <b>{neededItems[achievement.name]}</b>{neededIngredients[achievement.name] && ` using ${neededIngredients[achievement.name]}`}. | ||
</details>} | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,34 @@ | ||
--- | ||
import AchievementsList from '/src/components/AchievementsList'; | ||
import AlchemistryAchievementDescription from '/src/components/AlchemistryAchievementDescription'; | ||
import Layout from '/src/layout/layout.astro'; | ||
import { achievements } from '/src/business/alchemistry_achievementManager.js'; | ||
import { APP_ID } from '/src/business/alchemistry_constants.js'; | ||
import { neededItems, neededIngredients } from '/src/business/alchemistry_neededItems.js'; | ||
import getAchievementsPercentagesForGame from '/src/business/getAchievementsPercentagesForGame.js'; | ||
import { getLangFromUrl, useTranslations } from '/src/i18n/utils'; | ||
import '/src/css/achievements.css'; | ||
const lang = getLangFromUrl(Astro.url); | ||
const t = useTranslations(lang); | ||
const achievementsPercentages = await getAchievementsPercentagesForGame(APP_ID); | ||
if(achievementsPercentages.length !== Object.keys(achievements).length) { | ||
throw new Error('There are some missing achievements to generate the wiki'); | ||
} | ||
const achievementsToDisplay = achievementsPercentages.map((achievementData) => { | ||
const achievement = { | ||
name: achievementData.name, | ||
index: Object.keys(achievements).indexOf(achievementData.name), | ||
percent: achievementData.percent | ||
}; | ||
achievement.description = AlchemistryAchievementDescription({ t, achievement }); | ||
return achievement; | ||
}); | ||
--- | ||
<Layout title="Alchemistry - Achievements"> | ||
<div class="achievement-list"> | ||
{achievementsPercentages.map((achievementData) => { | ||
const achievement = achievementData.name; | ||
const index = Object.keys(achievements).indexOf(achievement); | ||
|
||
return ( | ||
<div class="achievement-list-item"> | ||
<img src={`/img/alchemistry/achievements/${achievement}_ok.png`} /> | ||
<div class="achievement-list-item-body"> | ||
<div class="achievement-list-item-title"> | ||
{t(`alchemistry:achievements:NEW_ACHIEVEMENT_1_${index}_NAME`)} | ||
</div> | ||
<span class={'achievement-list-rarity' + ((achievementData.percent < 10) ? ' achievement-list-rarity-rare' : '')}> | ||
{Math.floor(achievementData.percent)}% | ||
</span> | ||
<div class="achievement-list-item-description"> | ||
{t(`alchemistry:achievements:NEW_ACHIEVEMENT_1_${index}_DESC`).replace('N/A', '')} | ||
{neededItems[achievement] && <details> | ||
<summary>Item needed</summary>{/* TODO: i18n */} | ||
You should create <b>{neededItems[achievement]}</b>{neededIngredients[achievement] && ` using ${neededIngredients[achievement]}`}. | ||
</details>} | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
<AchievementsList t={t} achievements={achievementsToDisplay} /> | ||
</Layout> |