Advertisement
Guest User

Voting Demo

a guest
Aug 26th, 2011
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. world
  2.     name = "Voting Demo - Your Favorite Melee Weapon"
  3.     hub = "ComplexRobot.VotingDemo"
  4.     hub_password = /* password removed */
  5.    
  6. mob
  7.     Stat()
  8.         statpanel("Poll")
  9.         stat(POLL_QUESTION, "")
  10.         stat("------------------", "")
  11.         var/list/votes = GetVotes()
  12.         var/list/percs = Percentages(votes)
  13.         for (var/X in votes)
  14.             stat(X, "[percs[X]]% ([votes[X]])")
  15.            
  16. proc
  17.     GetVotes()
  18.         var/params = world.GetScores(, POLL_SCORE_NAME)
  19.         if (isnull(params))
  20.             return list()
  21.         params = params2list(params)
  22.         var/val
  23.         for (var/X in params)
  24.             val = params2list(world.GetScores(X, POLL_SCORE_NAME))
  25.             params[X] = text2num(val[POLL_SCORE_NAME])
  26.         return params
  27.     Percentages(list/L)
  28.         var/total = 0
  29.         var/list/result = new
  30.         for (var/X in L)
  31.             total += L[X]
  32.         for (var/X in L)
  33.             result[X] = round(100 * L[X] / (total || 1), 1)
  34.         return result
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement