diff options
author | Karl Berry <karl@freefriends.org> | 2021-08-24 23:54:38 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2021-08-24 23:54:38 +0000 |
commit | 0052fcfc5c7b6a85b5f9cb128c299effd52c6ebb (patch) | |
tree | a999657da9d9b9026f7a75a0a681e8d1fa5562f6 /Master/texmf-dist/tex/latex/gamebooklib | |
parent | 1e0cf33a2c4ee1f510b36e7fc5eb408c349ba1bb (diff) |
gamebooklib (25aug21)
git-svn-id: svn://tug.org/texlive/trunk@60318 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex/latex/gamebooklib')
-rw-r--r-- | Master/texmf-dist/tex/latex/gamebooklib/gamebooklib.sty | 74 |
1 files changed, 41 insertions, 33 deletions
diff --git a/Master/texmf-dist/tex/latex/gamebooklib/gamebooklib.sty b/Master/texmf-dist/tex/latex/gamebooklib/gamebooklib.sty index 7822d932cdc..b85504a71a0 100644 --- a/Master/texmf-dist/tex/latex/gamebooklib/gamebooklib.sty +++ b/Master/texmf-dist/tex/latex/gamebooklib/gamebooklib.sty @@ -20,7 +20,7 @@ %% and version 1.3 or later is part of all distributions of %% LaTeX version 2005/12/01 or later. %% -\ProvidesPackage{gamebooklib}[2021/08/10 Gamebook by R Lee latex@rjlee.homelinux.org] +\ProvidesPackage{gamebooklib}[2021/08/24 Gamebook by R Lee latex@rjlee.homelinux.org] \NeedsTeXFormat{LaTeX2e}[1994/06/01] \newcommand{\gamebook@info}[1]{}% \DeclareOption{verbose}{% @@ -41,7 +41,6 @@ \gamebook@info{Gamebook Library entries output in order}% }% \DeclareOption*{% - \typeout{Current option: \CurrentOption}% \PassOptionsToClass{\CurrentOption}{lcg}% }% \ProcessOptions\relax% @@ -54,10 +53,14 @@ \setcounter{gentryctr}{0}% \newcommand{\gentry}[1][]{\@gentry{#1}}% \newenvironment{@gentry}[2]{% - \def\gentryidx{#1}% - \def\gentrycode{#2}% + \xdef\gentryidx{#1}% + \xdef\gentrycode{#2}% \@@gentry% }{\ignorespacesandallpars% + \global\let\gentryidx\@undefined% + \global\let\gentrycode\@undefined% + \global\let\gentryidxu\@undefined% + \global\let\gentryidxs\@undefined% }% \newcommand{\@@gentry}[1][]{% \def\gentrytitle{#1}% @@ -102,50 +105,55 @@ \setcounter{gentryctr}{0}% \ifthenelse{\gentrycount<3}{}{%SHUFFLE START \whiledo{\not{\value{gentryctr}>\gentrycount}}{% - \edef\myidx{\arabic{gentryctr}}% - \expandafter\xdef\csname paraIdx\myidx\endcsname{\myidx}% + \edef\gentryidxu{\arabic{gentryctr}}% + \expandafter\xdef\csname paraIdx\gentryidxu\endcsname{\gentryidxu}% \stepcounter{gentryctr}% }% \if@gamebook@shuffle - \setcounter{gentryctr}{2}% \setcounter{rand}{\gentrycount}% \addtocounter{rand}{-1}\edef% \stoppoint{\arabic{rand}}% + \setcounter{gentryctr}{2}% \chgrand[last=\stoppoint]% \whiledo{\value{gentryctr}<\stoppoint}{% - \edef\myidx{\arabic{gentryctr}}% - \expandafter\ifcsname fixedat\myidx\endcsname% - \gamebook@info{Not shuffling \myidx; fixed pos}% + \edef\gentryidxu{\arabic{gentryctr}}% + \expandafter\ifcsname fixedat\gentryidxu\endcsname% + \gamebook@info{Not shuffling \gentryidxu; fixed pos}% \stepcounter{gentryctr}% \else% - \gamebook@info{Shuffling \myidx}% + \gamebook@info{Shuffling \gentryidxu}% \stepcounter{gentryctr}% \edef\nextidx{\arabic{gentryctr}}% - \expandafter\ifcsname fixedto\arabic{rand}\endcsname\else% \chgrand[first=\nextidx]% \rand% - \gamebook@info{Shuffling \myidx to \arabic{rand}}% - \macroswap{paraIdx\myidx}{paraIdx\arabic{rand}}% + \expandafter\ifcsname fixedat\arabic{rand}\endcsname\else% + \gamebook@info{Shuffling \gentryidxu to \arabic{rand}}% + \macroswap{paraIdx\gentryidxu}{paraIdx\arabic{rand}}% \fi% \fi% }% \setcounter{gentryctr}{2}% - \whiledo{\value{gentryctr}<\stoppoint}{% - \edef\myidx{\arabic{gentryctr}}% - \expandafter\ifcsname fixedat\myidx\endcsname% - \expandafter\edef\expandafter\mydest\expandafter% - {\expandafter\csname fixedat\myidx\endcsname}% - \gamebook@info{MOVING FIXED GAMEBOOK ENTRY INTO PLACE: \myidx -> \mydest}% - \macroswap{paraIdx\myidx}% - {paraIdx\expandafter\csname fixedat\myidx\endcsname}% + \whiledo{\not{\value{gentryctr}>\stoppoint}}{% + \edef\gentryidxu{\arabic{gentryctr}}% + \expandafter\ifcsname fixedat\gentryidxu\endcsname% + \expandafter\edef\expandafter\mydest\expandafter% + {\expandafter\csname fixedat\gentryidxu\endcsname}% + \gamebook@info{MOVING FIXED GAMEBOOK ENTRY INTO PLACE: \gentryidxu -> \mydest}% + \macroswap{paraIdx\gentryidxu}% + {paraIdx\expandafter\csname fixedat\gentryidxu\endcsname}% + \expandafter\ifcsname fixedat\mydest\endcsname% + \macroswap{fixedat\gentryidxu}{fixedat\mydest}% + \expandafter\global\expandafter\let\csname fixedat\mydest\endcsname\@undefined% + \addtocounter{gentryctr}{-1}% + \fi% \fi% \stepcounter{gentryctr}% }}\fi%SHUFFLE END \gamebook@info{Shuffled! Gentry order:}% \setcounter{gentryctr}{1}% \whiledo{\not{\value{gentryctr}>\gentrycount}}{% - \edef\myidx{\arabic{gentryctr}}% - \gamebook@info{\myidx -> \csname paraIdx\myidx\endcsname}% + \edef\gentryidxu{\arabic{gentryctr}}% + \gamebook@info{\gentryidxu -> \csname paraIdx\gentryidxu\endcsname}% \stepcounter{gentryctr}% }% \setcounter{gentryctr}{0}% @@ -155,21 +163,21 @@ \ifthenelse{\value{gentryctr}=\gentrycount}{% \gamebook@beforelast% }{}% - \edef\myidx{\arabic{gentryctr}}% - \xdef\youridx{\csname paraIdx\myidx\endcsname}% - \gamebook@info{Output gentry \myidx\ of \gentrycount,% - original idx \youridx}% - \the\csname paratok\youridx\endcsname% + \edef\gentryidxu{\arabic{gentryctr}}% + \xdef\gentryidxs{\csname paraIdx\gentryidxu\endcsname}% + \gamebook@info{Output gentry \gentryidxu\ of \gentrycount,% + original idx \gentryidxs}% + \the\csname paratok\gentryidxs\endcsname% }% \gamebook@info{All gamebook entries added to main vertical list}% \setcounter{gentryctr}{1}% \whiledo{\not{\value{gentryctr}>\gentrycount}}{% - \edef\myidx{\arabic{gentryctr}}% + \edef\gentryidxu{\arabic{gentryctr}}% \expandafter\global\expandafter\let% - \csname paratok\myidx\endcsname\@undefined% - \expandafter\ifcsname fixedat\myidx\endcsname% + \csname paratok\gentryidxu\endcsname\@undefined% + \expandafter\ifcsname fixedat\gentryidxu\endcsname% \expandafter\global\expandafter\let% - \csname fixedat\myidx\endcsname\@undefined% + \csname fixedat\gentryidxu\endcsname\@undefined% \fi% \stepcounter{gentryctr}% }% |