Collaborama About Help Contact Anonymous [login] Source: site.view [edit] Function name: cmdRankSkill Arguments: skill Description: Chooses two people to rank using the specified skill. If empty, chooses a random skill to rank. Page type: webl Render function: skillsrank.matchResults2 Module: skillsrank Page source: var choosePeople = fun(people, num) var sz = Size(people); var done = false; var i = 0; var j = 0; var x; var y; var res = [ ]; while !done and (j < 10) do x = Wub_RandomInt(sz-1); if !(people[x] member res) then res = res + [people[x]]; i = i + 1; else j = j + 1 end; done = (i >= num or i >= sz) end; res end; var skillSet; if Str_Trim(skill) == "" then skillSet = WubCall("cmdChooseRankSet", []); else skillSet = WubCall("cmdChooseRankSet", [skill]); end; var row = -1; var sz = Size(ToList(skillSet)); if sz > 1 then var i = 0; var done = false; while !done and (i < 10) do row = Wub_RandomInt(sz-1); i = i + 1; var token = ToList(skillSet)[row]; done = (Size(ToList(skillSet[token])) >= 2) end; if (!done) then row = -1; end else row = 0; if (Size(ToList(skillSet)) == 0) then row = -1 else var token = ToList(skillSet)[row]; if !(Size(ToList(skillSet[token])) >= 2) then row = -1 end end end; if (row != -1) then var token = ToList(skillSet)[row]; var pts = (Wub_GetVaultValue("rankpoints") ? 0); pts = ToInt(pts) + 2; Wub_SetVaultValue("rankpoints", ToString(pts)); [. skill=token, people=choosePeople(skillSet[token], 5) .] else "Not enough people found who match skills." end;