Advertisement
Guest User

Untitled

a guest
Oct 26th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.47 KB | None | 0 0
  1. --[[ Global Variables --]]
  2. --Setting up the start button
  3. print('starting')
  4. start_button = {}
  5. start_button_guid = '9df5e8'
  6.  
  7. --Setting up all the boards of different sizes
  8. five_board = {}
  9. five_board_guid = 'f6027b'
  10. six_board = {}
  11. six_board_guid = '74cc28'
  12. seven_board = {}
  13. seven_board_guid = '4a8b42'
  14. --I don't have the ninth and tenth boards but the eight is mostly the same
  15. eight_board = {}
  16. eight_board_guid = '5fb4ae'
  17.  
  18. --Setting up the decks and role cards
  19. --Decks
  20. arthur_deck = {}
  21. arthur_deck_guid = '18f8a7'
  22. mordred_deck = {}
  23. mordred_deck_guid = '1b644e'
  24. --Role cards
  25. merlin_card = {}
  26. merlin_card_guid = 'edf463'
  27. assassin_card = {}
  28. assassin_card_guid = 'b87f2f'
  29. percival_card = {}
  30. percival_card_guid = '64e82b'
  31. morgana_card = {}
  32. morgana_card_guid = '5fe648'
  33. oberon_card = {}
  34. oberon_card_guid = '72d3dc'
  35. mordred_card = {}
  36. mordred_card_guid = '1f357e'
  37.  
  38. arthur_max = 0
  39. mordred_max = 0
  40.  
  41. --Setting up the yes and no vote cards
  42. yes_deck = {}
  43. yes_deck_guid = 'd258bd'
  44. no_deck = {}
  45. no_deck_guid = '8b3daf'
  46.  
  47. --Setting up hidden zones
  48. select_zone = {}
  49. select_zone_guid = '765404'
  50. trash_zone = {}
  51. trash_zone_guid = '49803a'
  52. move_zone= {}
  53. move_zone_guid = '388ffd'
  54.  
  55. num_players = 0
  56. timNum = 0
  57. roles = {}
  58. print('global variables set')
  59.  
  60. --[[ The OnLoad function. Called when a game finishes loading. --]]
  61. function onload()
  62. print('onload function started')
  63. --Setting up the button that deals the roles out when pressed
  64. start_button = getObjectFromGUID(start_button_guid)
  65.  
  66. local button = {}
  67. button.click_function = "startGame"
  68. button.label = 'Start'
  69. button.function_owner = nil
  70. --Not sure where this is going yet, let's put it in and see
  71. button.position = {0, 0, 0}
  72. button.rotation = {0,0,0}
  73. button.width = 1600
  74. button.height = 1000
  75. button.font_size = 500
  76.  
  77. --Creates a button object called button with the properties above
  78. start_button.createButton(button)
  79. print('button created')
  80.  
  81. --Setting up the boards and cards, linking them with the guids
  82. five_board = getObjectFromGUID(five_board_guid)
  83. six_board = getObjectFromGUID(six_board_guid)
  84. seven_board = getObjectFromGUID(seven_board_guid)
  85. eight_board = getObjectFromGUID(eight_board_guid)
  86.  
  87. --Setting up the decks and cards now
  88. arthur_deck = getObjectFromGUID(arthur_deck_guid)
  89. mordred_deck = getObjectFromGUID(mordred_deck_guid)
  90. merlin_card = getObjectFromGUID(merlin_card_guid)
  91. assassin_card = getObjectFromGUID(assassin_card_guid)
  92. percival_card = getObjectFromGUID(percival_card_guid)
  93. morgana_card = getObjectFromGUID(morgana_card_guid)
  94. oberon_card = getObjectFromGUID(oberon_card_guid)
  95. mordred_card = getObjectFromGUID(mordred_card_guid)
  96.  
  97. --Setting up yes and no votes
  98. yes_deck = getObjectFromGUID(yes_deck_guid)
  99. no_deck = getObjectFromGUID(no_deck_guid)
  100.  
  101. --Setting up hidden zones that select/delete cards
  102. --view these zones with the zone script option the right clicking
  103. --the guids will be put into chat
  104. select_zone = getObjectFromGUID(select_zone_guid)
  105. trash_zone = getObjectFromGUID(trash_zone_guid)
  106. move_zone = getObjectFromGUID(move_zone_guid)
  107. print('guids are guid to go')
  108. end
  109.  
  110. function startGame()
  111. players = getSeatedPlayers()
  112. setup(#players)
  113. destroyObject(start_button)
  114. end
  115.  
  116. --Setup Function
  117.  
  118. function setup (np)
  119. if np > 4 and np < 11 then
  120. --We need to find out what/how many cards are in the select zone
  121. arthur_count = 0
  122. local inZone = select_zone.getObjects()
  123. for i, j in ipairs(inZone) do
  124. if(j.getDescription() == 'Arthur') then
  125. arthur_count = arthur_count + 1
  126. end
  127. end
  128.  
  129. --figuring out the max arthur and mordred on each team
  130. if(np == 5) then
  131. arthur_max = 3
  132. mordred_max = 2
  133. --Setting up the board and destroying the ones we do not need
  134. five_board.setPosition({0, 1, 5})
  135. five_board.lock()
  136. destroyObject(six_board)
  137. destroyObject(seven_board)
  138. destroyObject(eight_board)
  139. elseif(np == 6) then
  140. arthur_max = 4
  141. mordred_max = 2
  142. six_board.setPosition({0, 1, 5})
  143. six_board.lock()
  144. destroyObject(five_board)
  145. destroyObject(seven_board)
  146. destroyObject(eight_board)
  147. elseif(np == 7) then
  148. arthur_max = 4
  149. mordred_max = 3
  150. seven_board.setPosition({0, 1, 5})
  151. seven_board.lock()
  152. destroyObject(five_board)
  153. destroyObject(six_board)
  154. destroyObject(eight_board)
  155. elseif(np == 8) then
  156. arthur_max = 5
  157. mordred_max = 3
  158. eight_board.setPosition({0, 1, 5})
  159. eight_board.lock()
  160. destroyObject(five_board)
  161. destroyObject(six_board)
  162. destroyObject(seven_board)
  163. elseif(np == 9) then
  164. arthur_max = 6
  165. mordred_max = 3
  166. eight_board.setPosition({0, 1, 5})
  167. eight_board.lock()
  168. destroyObject(five_board)
  169. destroyObject(six_board)
  170. destroyObject(seven_board)
  171. else
  172. arthur_max = 6
  173. mordred_max = 4
  174. eight_board.setPosition({0, 1, 5})
  175. eight_board.lock()
  176. destroyObject(five_board)
  177. destroyObject(six_board)
  178. destroyObject(seven_board)
  179. end
  180.  
  181. --# returns the number of things in the list/array i don't know honestly
  182. print("There are " .. arthur_count .. " special servants of Arthur and " .. (#inZone - arthur_count) .. " minions of mordred.")
  183. if((#inZone - arthur_count) > arthur_max) then
  184. print('Too many minions of Mordred! Remove some.')
  185. elseif(arthur_count > mordred_max) then
  186. print('Too many servants of Arthur! Remove some.')
  187. else
  188. print('Legal number of Servants anad Minions!')
  189. --Setting the max number of servants and minions
  190. --Moving the cards in select zone to move zone
  191. --setting up parameters for the cards to move to
  192. local params = {}
  193. params.position = {-30, 1.5, -15}
  194.  
  195. --Moving the normal cards into the move zone
  196. arthur_deck.shuffle()
  197. mordred_deck.shuffle()
  198.  
  199. mordred_count = #inZone - arthur_count
  200. --This number depends on the max number of mordred
  201. while(mordred_count < mordred_max) do
  202. mordred_deck.takeObject(params)
  203. mordred_count = mordred_count + 1
  204. end
  205. --This number depends on the max number of arthur
  206. while(arthur_count < arthur_max) do
  207. arthur_deck.takeObject(params)
  208. arthur_count = arthur_count + 1
  209. end
  210. for i, j in ipairs(inZone) do
  211. j.flip()
  212. end
  213. number_of_cards_in_zone = #inZone
  214. print(number_of_cards_in_zone)
  215. --sleep(1, setup2())
  216. sleep(1, 'grabRoles')
  217.  
  218. end
  219. else
  220. print('Not Enough Players!')
  221. end
  222. end
  223.  
  224. --this fucntion will bring the cards together
  225. function grabRoles()
  226. print('grabbing roles!')
  227. local inZone = select_zone.getObjects()
  228. for i, j in ipairs(inZone) do
  229. j.setPosition({-30, 1.5, -15})
  230. end
  231. sleep(1, 'shuffleCards')
  232. return 1
  233. end
  234.  
  235. function shuffleCards()
  236. local inZone = move_zone.getObjects()
  237. print('shuffling the deck!')
  238. inZone[1].shuffle()
  239. sleep(1, 'dealCards')
  240. return 1
  241. end
  242.  
  243. function dealCards()
  244. local inZone = move_zone.getObjects()
  245. print('dealing the cards')
  246. for i, j in ipairs(players) do
  247. local tempCard = inZone[1].dealToColorWithOffset({0,0,0}, false, j)
  248. if tempCard == nil then
  249. print ('nil')
  250. end
  251. playerHand = getPlayerHandPositionAndRotation(j)
  252. roles[j] = tempCard.getName()
  253. print('trying to print the roles as they are dealt')
  254. print(roles[j])
  255. end
  256. for i, j in ipairs(players) do
  257. yes_deck.dealToAll(1)
  258. no_deck.dealToAll(1)
  259. end
  260.  
  261.  
  262. function sleep(n, to_do)
  263. Timer.destroy('t' .. timNum)
  264. timNum = timNum + 1
  265. timer = {}
  266. timer.identifier = 't' .. timNum
  267. timer.delay = n
  268. timer.function_name = to_do
  269. timer.repetitions = 1
  270. Timer.create(timer)
  271. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement