Progres
Quest & Objective
Mencatat progres target collect item atau kunjungan destinasi.
quest.js
function recordObjective(progress, questUuid, objectiveKey, amount = 1) {
const current = progress[questUuid]?.[objectiveKey] ?? 0;
return {
...progress,
[questUuid]: {
...progress[questUuid],
[objectiveKey]: current + amount,
},
};
}
Potongan kode disederhanakan untuk pembelajaran. Implementasi production dapat memiliki validasi, penyimpanan progres, dan penanganan error tambahan.