%%%
% Jeton
%%%
\setKVdefault[Jeton]{Diametre=5mm,Impression=false}%

\NewDocumentCommand\Jeton{om}{%
  \useKVdefault[Jeton]%
  \setKV[Jeton]{#1}%
  \ifluatex%
    \setsepchar{,}\ignoreemptyitems%
    \readlist*\PfCListeJeton{#2}%
    \foreachitem\compteur\in\PfCListeJeton{\BuildJeton{\PfCListeJeton[\compteurcnt]}}%
    \reademptyitems%
  \fi%
}%

\NewDocumentCommand\BuildJeton{m}{%
  \ifluatex%
    \mplibforcehmode%
    \begin{mplibcode}
      input fiziko;
      
      boolean Impression;
      Impression=\useKV[Jeton]{Impression};
      numeric Diametre;
      Diametre=\useKV[Jeton]{Diametre};
      color Fond;
      Fond= if Impression:white else:BurlyWood fi;
      
      path p;
      p:=fullcircle scaled Diametre;
      fill p withcolor Fond;
      JetonAngle:=45+uniformdeviate(30);
      Intensite:=0.3+uniformdeviate(2)/10;
      draw woodenThing(p,JetonAngle) withcolor Intensite*Fond;
      draw p;
      label(TEX("\bfseries "&decimal(#1)),(0,0));
    \end{mplibcode}
  \fi%
}%