package com.stefanhoth.ropasclisp.achievements;

import com.stefanhoth.ropasclisp.games_sdk.PlayGamesClient;

public class AchievementObserver {

    private final PlayGamesClient playGamesClient;
    private final boolean firstSessionToday;

    public AchievementObserver(PlayGamesClient playGamesClient, boolean firstSessionToday) {
        this.playGamesClient = playGamesClient;
        this.firstSessionToday = firstSessionToday;
    }

    public void onGameStart() {
        // first game start ever
        playGamesClient.unlockAchievement(ACHIEVEMENT.HELLO_THERE);

        // on X game starts per day
        if(! firstSessionToday){
            playGamesClient.unlockAchievement(ACHIEVEMENT.CONNOISSEUR);
            playGamesClient.unlockAchievement(ACHIEVEMENT.ADDICT);
        }
    }

    public void onGameWin() {
        playGamesClient.unlockAchievement(ACHIEVEMENT.GOTCHA);
        playGamesClient.unlockAchievement(ACHIEVEMENT.ON_A_ROLL);
        playGamesClient.unlockAchievement(ACHIEVEMENT.POKER_FACE);
    }
}

@@ -42,16 +42,49 @@
 ments;%0A%0A
+import android.content.Context;%0A%0A
 import c
@@ -245,33 +245,23 @@
 nal 
-boolean firstSessionToday
+Context context
 ;%0A%0A 
@@ -327,33 +327,29 @@
 nt, 
-boolean firstSessionToday
+final Context context
 ) %7B%0A
@@ -413,45 +413,25 @@
 his.
-firstSessionToday = firstSessionToday
+context = context
 ;%0A  
@@ -569,16 +569,77 @@
 HERE);%0A%0A
+        DAILY_STATE dailyState = DAILY_STATE.with(context);%0A%0A
         
@@ -680,103 +680,340 @@
   if
+ 
 (!
- firstSessionToday)%7B%0A            playGamesClient.unlockAchievement(ACHIEVEMENT.CONNOISSEUR);%0A
+dailyState.isTodaysFirstStart()) %7B%0A%0A            final int todaysStarts = dailyState.getTodaysStarts();%0A            if (ACHIEVEMENT.ADDICT.isGoalReached(todaysStarts)) %7B%0A                playGamesClient.unlockAchievement(ACHIEVEMENT.ADDICT);%0A            %7D%0A            if (ACHIEVEMENT.CONNOISSEUR.isGoalReached(todaysStarts)) %7B%0A    
     
@@ -1062,32 +1062,52 @@
 ACHIEVEMENT.
-ADDICT);
+CONNOISSEUR);%0A            %7D%0A
 %0A        %7D%0A 

Correct behavior for daily start awards