1.8
This commit is contained in:
parent
63e10af865
commit
fc7c94bd69
26 changed files with 1167 additions and 271 deletions
|
|
@ -57,6 +57,9 @@ const ACHIEVEMENT_IDS = [
|
|||
'chaos_seeker_666_fights',
|
||||
'clean_freak_robot_only',
|
||||
'true_tarinai_observer',
|
||||
'sniper_333_shots',
|
||||
'megalopolis',
|
||||
'fertility_seeker_721_love_births',
|
||||
];
|
||||
const DATA_DIR_NAME = '.achievement_data';
|
||||
const DATA_FILE_NAME = 'state.json';
|
||||
|
|
@ -199,6 +202,7 @@ if (!valid_player_id($playerId)) {
|
|||
respond(['ok' => false, 'error' => 'invalid_player'], 400);
|
||||
}
|
||||
$syncUnlocks = [];
|
||||
$completionistEligible = null;
|
||||
if ($action === 'unlock') {
|
||||
$achievementId = (string)($payload['achievementId'] ?? '');
|
||||
if (!in_array($achievementId, ACHIEVEMENT_IDS, true)) {
|
||||
|
|
@ -209,6 +213,12 @@ if ($action === 'unlock') {
|
|||
if (!is_array($submittedUnlocks) || count($submittedUnlocks) > count(ACHIEVEMENT_IDS)) {
|
||||
respond(['ok' => false, 'error' => 'invalid_unlocks'], 400);
|
||||
}
|
||||
if (array_key_exists('completionistEligible', $payload)) {
|
||||
if (!is_bool($payload['completionistEligible'])) {
|
||||
respond(['ok' => false, 'error' => 'invalid_completionist_state'], 400);
|
||||
}
|
||||
$completionistEligible = $payload['completionistEligible'];
|
||||
}
|
||||
foreach ($submittedUnlocks as $achievementId => $timestamp) {
|
||||
if (!is_string($achievementId) || !in_array($achievementId, ACHIEVEMENT_IDS, true)) {
|
||||
respond(['ok' => false, 'error' => 'invalid_achievement'], 400);
|
||||
|
|
@ -256,6 +266,9 @@ try {
|
|||
$state['unlocks'][$achievementId][$playerId] = $now;
|
||||
}
|
||||
} elseif ($action === 'sync') {
|
||||
if ($completionistEligible === false && isset($state['unlocks']['true_tarinai_observer'][$playerId])) {
|
||||
unset($state['unlocks']['true_tarinai_observer'][$playerId]);
|
||||
}
|
||||
foreach ($syncUnlocks as $achievementId => $submittedTimestamp) {
|
||||
if (!isset($state['unlocks'][$achievementId]) || !is_array($state['unlocks'][$achievementId])) {
|
||||
$state['unlocks'][$achievementId] = [];
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue