Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: magicGuessCard Arguments: Description: Page type: webl Render function: Module: global Page source: var suits = ["Spades", "Hearts", "Clubs", "Diamonds"]; var numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13"]; var rndSuit = Wub_RandomInt(Size(suits)); var rndNumber = Wub_RandomInt(Size(numbers)); var f = WubCall("checkFixedCard", []) ? nil; var cvt = fun(num) if (num == "13") then num = "K" elsif num == "12" then num = "Q" elsif num == "11" then num = "J" elsif num == "1" then num = "A" end; return num end; if (f != nil and f != []) then rndSuit = f.suit; rndNumber = f.number //else // rndSuit = 0; // rndNumber = 6; end; var suit = suits[rndSuit]; var number = numbers[rndNumber]; var suitC = Select(Str_ToLowerCase(suits[rndSuit]),0,1); var numberC = Str_ToLowerCase(numbers[rndNumber]); if Size(numberC) > 2 then numberC = Select(numberC, 0, 1) end; if numberC == "a" then numberC = "1" end; var res = `{ "suit": "` + suit + `", ` + ` "value": "` + number + `", ` + ` "imageUrl": "http://adam.cheyer.com/images/cards2/PNG/` + cvt(numberC) + Str_ToUpperCase(suitC) + `.png"}`; res; NewPage(res, "text/plain");