Source: site.view [edit]
Function name: wordGame
Arguments: name
Description: plays a language learning game. name = player's name.
Page type: webl
Render function:   wordGameRender
Module: noahGames

Page source:

var funcs = Wub_GetFunctionsByTag("flag.langdata2");

var html = "<H1>Flashcards Game</H1>\nHave fun, " + Str_ToUpperCase(name) + "!\n<p><p>";
var lastChap = "";
var list = [];

var peopleScores = WubCall("wordGameScores", []);
var scores = peopleScores[name] ? [. .];
var info = WubCall("wordGameInfo", []);


var funcinfo = Wub_GetFunctionInfo("noahGames.lastRnd");
funcinfo.exec := "[];";
Wub_SaveFunctionInfo(funcinfo);

var vocabLines = [];
every f in funcs do
   var fi = Wub_GetFunctionInfo(f);
   var flags = Str_Split(fi.oldflags, ",");
   if (Size(flags) == 3) then

      var hs = ToString(scores[flags[1] + flags[2]].high ? 0);
      var hsChap = ToString(scores[flags[1] + "*"].high ? 0);
      var hsMax = ToString(scores[flags[1] + flags[2]].max ? "?");
      var hsChapMax = ToString(scores[flags[1] + "*"].max ? "?");

      list = list + [ [. chapter = flags[1], section = flags[2], 
           func = f,
           high = ToString(scores[flags[1] + flags[2]].high ? 0), 
           max =ToString(scores[flags[1] + flags[2]].max ? "?"),
           chapHigh = ToString(scores[flags[1] + "*"].high ? 0),
           chapMax = ToString(scores[flags[1] + "*"].max ? "?") .] ]
   end
end;

list = Sort(list, fun(a, b)
   if a.chapter > b.chapter then 1
   elsif a.chapter == b.chapter then 0
   else -1
   end
end);

every line in list do

      if (lastChap != line.chapter) then
           var guide = info[line.chapter] + "<P>"  ? "";

           html = html +"</UL>" + guide + line.chapter + "  : " +
            `<a href="/webl/WubHub_DoIt?cmdline=` + "wordGameChapSec: " + line.chapter + ",*," + name +`">`+ "[PLAY]" + "</a>   High Score: " + line.chapHigh + 
      " / " + line.chapMax +
     "<UL><LI>\n"  + line.section + `:  <a href="/webl/WubHub_DoIt?cmdline=` + line.func + `">` + "[REVIEW]" + `</a>,  <a href="/webl/WubHub_DoIt?cmdline=` + "wordGameChapSec: " + line.chapter + "," + line.section + "," + name + `">` + "[PLAY]" + "</a>   High Score: " + line.high + " / " + line.max + "</LI>\n";
           lastChap = line.chapter;
      else
           html = html + "<LI>" + line.section + `:  <a href="/webl/WubHub_DoIt?cmdline=` + line.func + `">` + "[REVIEW]" + 
`</a>,  <a href="/webl/WubHub_DoIt?cmdline=` + "wordGameChapSec: " + line.chapter + "," + line.section + "," + name + `">` + "[PLAY]" + 
"</a>   High Score: " + line.high + " / " + line.max + "</LI>\n";
      end
end;


NewPiece(html, "text/html");