#include "pico/stdlib.h"
#include "i2c_annexe.h"
#include "Score.h"

#define SCORE_INITIAL 5

uint32_t Score_nb_cerises=0;
uint32_t Score_nb_points=0;
uint32_t Score_funny_action=0;
uint32_t Score_pieds_dans_plat=0;

void Score_recalcule(){
    Score_nb_points = SCORE_INITIAL;
    if(Score_nb_cerises > 0){
        Score_nb_points += Score_nb_cerises + 5;
    }
    Score_nb_points += Score_funny_action;
    Score_nb_points += Score_pieds_dans_plat;

}

void Score_actualise(){
    Score_recalcule();
    i2c_annexe_envoie_score(Score_nb_points);
}

void Score_set_funny_action(){
    Score_funny_action = 5;
    Score_actualise();
}

void Score_set_pieds_dans_plat(){
    Score_pieds_dans_plat = 15;
    Score_actualise();
}

void Score_ajout_cerise(uint32_t nb_cerises){
    Score_nb_cerises += nb_cerises;
    Score_actualise();
}