Advertisement
Guest User

Choicescript Hangman Coding Challenge

a guest
Jul 7th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. *title Choicescript Hangman Coding Challenge
  2. *temp l1 "a"
  3. *temp l2 "b"
  4. *temp l3 "c"
  5. *temp l4 "d"
  6. *temp l5 "e"
  7. *temp l6 "f"
  8. *temp l7 "g"
  9. *temp l8 "h"
  10. *temp l9 "i"
  11. *temp l10 "j"
  12. *temp l11 "k"
  13. *temp l12 "l"
  14. *temp l13 "m"
  15. *temp l14 "n"
  16. *temp l15 "o"
  17. *temp l16 "p"
  18. *temp l17 "q"
  19. *temp l18 "r"
  20. *temp l19 "s"
  21. *temp l20 "t"
  22. *temp l21 "u"
  23. *temp l22 "v"
  24. *temp l23 "w"
  25. *temp l24 "x"
  26. *temp l25 "y"
  27. *temp l26 "z"
  28.  
  29. *label hm_reset
  30.  
  31. *temp hm_lives 10
  32. *temp n
  33. *temp hmvictory false
  34. *rand n 1 10
  35. *gotoref "hmword_"&n
  36.  
  37. *label hmword_1
  38. *temp hmword "dog"
  39. *temp hmletter_count 3
  40. *temp hmletter_1 "d"
  41. *temp hmletter_1_found false
  42. *temp hmletter_2 "o"
  43. *temp hmletter_2_found false
  44. *temp hmletter_3 "g"
  45. *temp hmletter_3_found false
  46. *goto hang_man_top
  47.  
  48. *label hmword_2
  49. *temp hmword "cat"
  50. *temp hmletter_count 3
  51. *temp hmletter_1 "c"
  52. *temp hmletter_1_found false
  53. *temp hmletter_2 "a"
  54. *temp hmletter_2_found false
  55. *temp hmletter_3 "t"
  56. *temp hmletter_3_found false
  57. *goto hang_man_top
  58.  
  59. *label hmword_3
  60. *temp hmword "fish"
  61. *temp hmletter_count 4
  62. *temp hmletter_1 "f"
  63. *temp hmletter_1_found false
  64. *temp hmletter_2 "i"
  65. *temp hmletter_2_found false
  66. *temp hmletter_3 "s"
  67. *temp hmletter_3_found false
  68. *temp hmletter_4 "h"
  69. *temp hmletter_4_found false
  70. *goto hang_man_top
  71.  
  72. *label hmword_4
  73. *temp hmword "shark"
  74. *temp hmletter_count 5
  75. *temp hmletter_1 "s"
  76. *temp hmletter_1_found false
  77. *temp hmletter_2 "h"
  78. *temp hmletter_2_found false
  79. *temp hmletter_3 "a"
  80. *temp hmletter_3_found false
  81. *temp hmletter_4 "r"
  82. *temp hmletter_4_found false
  83. *temp hmletter_5 "k"
  84. *temp hmletter_5_found false
  85. *goto hang_man_top
  86.  
  87. *label hmword_5
  88. *temp hmword "horse"
  89. *temp hmletter_count 5
  90. *temp hmletter_1 "h"
  91. *temp hmletter_1_found false
  92. *temp hmletter_2 "o"
  93. *temp hmletter_2_found false
  94. *temp hmletter_3 "r"
  95. *temp hmletter_3_found false
  96. *temp hmletter_4 "s"
  97. *temp hmletter_4_found false
  98. *temp hmletter_5 "e"
  99. *temp hmletter_5_found false
  100. *goto hang_man_top
  101.  
  102. *label hmword_6
  103. *temp hmword "rabbit"
  104. *temp hmletter_count 6
  105. *temp hmletter_1 "r"
  106. *temp hmletter_1_found false
  107. *temp hmletter_2 "a"
  108. *temp hmletter_2_found false
  109. *temp hmletter_3 "b"
  110. *temp hmletter_3_found false
  111. *temp hmletter_4 "b"
  112. *temp hmletter_4_found false
  113. *temp hmletter_5 "i"
  114. *temp hmletter_5_found false
  115. *temp hmletter_6 "t"
  116. *temp hmletter_6_found false
  117. *goto hang_man_top
  118.  
  119. *label hmword_7
  120. *temp hmword "mouse"
  121. *temp hmletter_count 5
  122. *temp hmletter_1 "m"
  123. *temp hmletter_1_found false
  124. *temp hmletter_2 "o"
  125. *temp hmletter_2_found false
  126. *temp hmletter_3 "u"
  127. *temp hmletter_3_found false
  128. *temp hmletter_4 "s"
  129. *temp hmletter_4_found false
  130. *temp hmletter_5 "e"
  131. *temp hmletter_5_found false
  132. *goto hang_man_top
  133.  
  134. *label hmword_8
  135. *temp hmword "badger"
  136. *temp hmletter_count 6
  137. *temp hmletter_1 "b"
  138. *temp hmletter_1_found false
  139. *temp hmletter_2 "a"
  140. *temp hmletter_2_found false
  141. *temp hmletter_3 "d"
  142. *temp hmletter_3_found false
  143. *temp hmletter_4 "g"
  144. *temp hmletter_4_found false
  145. *temp hmletter_5 "e"
  146. *temp hmletter_5_found false
  147. *temp hmletter_6 "r"
  148. *temp hmletter_6_found false
  149. *goto hang_man_top
  150.  
  151. *label hmword_9
  152. *temp hmword "elephant"
  153. *temp hmletter_count 8
  154. *temp hmletter_1 "e"
  155. *temp hmletter_1_found false
  156. *temp hmletter_2 "l"
  157. *temp hmletter_2_found false
  158. *temp hmletter_3 "e"
  159. *temp hmletter_3_found false
  160. *temp hmletter_4 "p"
  161. *temp hmletter_4_found false
  162. *temp hmletter_5 "h"
  163. *temp hmletter_5_found false
  164. *temp hmletter_6 "a"
  165. *temp hmletter_6_found false
  166. *temp hmletter_7 "n"
  167. *temp hmletter_7_found false
  168. *temp hmletter_8 "t"
  169. *temp hmletter_8_found false
  170. *goto hang_man_top
  171.  
  172. *label hmword_10
  173. *temp hmword "meerkat"
  174. *temp hmletter_count 7
  175. *temp hmletter_1 "m"
  176. *temp hmletter_1_found false
  177. *temp hmletter_2 "e"
  178. *temp hmletter_2_found false
  179. *temp hmletter_3 "e"
  180. *temp hmletter_3_found false
  181. *temp hmletter_4 "r"
  182. *temp hmletter_4_found false
  183. *temp hmletter_5 "k"
  184. *temp hmletter_5_found false
  185. *temp hmletter_6 "a"
  186. *temp hmletter_6_found false
  187. *temp hmletter_7 "t"
  188. *temp hmletter_7_found false
  189. *goto hang_man_top
  190.  
  191.  
  192.  
  193. *label hang_man_top
  194.  
  195. *gosub hangman_parse
  196.  
  197.  
  198. *choice
  199. *if (hmvictory) #YOU WIN!!
  200. *goto hang_man_top
  201. *if (hm_lives = 0) #YOU LOSE!!
  202. *goto hang_man_top
  203. *if ((hm_lives != 0) and (hmvictory != true)) #Guess a Letter
  204. *label guess_letter
  205. *gosub hangman_parse
  206. What letter?
  207. *temp str
  208. *input_text str
  209. *comment convert input to lowercase:
  210. *script temps.str = temps.str.toLowerCase();
  211. *temp n 1
  212. *temp count 0
  213. *temp this_letter
  214. *label check_letter_loop
  215. *set this_letter ({"l"&n})
  216. *if (this_letter != str)
  217. *if (n < 26)
  218. *set n + 1
  219. *goto check_letter_loop
  220. *line_break
  221. Error: '${str}' is not a letter.
  222. *line_break
  223. *goto guess_letter
  224. *comment reset n
  225. *set n 1
  226. *label guess_letter_loop
  227. *set this_letter {("hmletter_"&n)}
  228. *if (this_letter = str)
  229. *setref (("hmletter_"&n)&"_found") true
  230. *set count + 1
  231. *if (n < hmletter_count)
  232. *set n + 1
  233. *goto guess_letter_loop
  234. ${count} letters matched.
  235. *if (count = 0)
  236. *line_break
  237. Life lost.
  238. *line_break
  239. *set hm_lives - 1
  240. *line_break
  241. *goto hang_man_top
  242. *if ((hm_lives != 0) and (hmvictory != true)) #Guess the Word
  243. *gosub hangman_parse
  244. What do you think the word is?
  245. *temp str
  246. *input_text str
  247. *comment convert input to lowercase:
  248. *script temps.str = temps.str.toLowerCase();
  249. *if (str = hmword)
  250. *set hmvictory true
  251. *comment show all letters
  252. *temp n 1
  253. *label guessed_word_loop
  254. *setref (("hmletter_"&n)&"_found") true
  255. *if (n != hmletter_count)
  256. *set n + 1
  257. *goto guessed_word_loop
  258. *goto hang_man_top
  259. *else
  260. *set hm_lives 0
  261. *goto hang_man_top
  262. #Start Over
  263. *goto hm_reset
  264. #QUIT
  265. *goto_scene act0
  266. *set hm_lives - 1
  267. *goto hang_man_top
  268.  
  269. *label hangman_parse
  270. The Word:
  271. *temp n 1
  272. *temp count 0
  273. *label hmword_print_loop
  274. *temp this_letter {(("hmletter_"&n)&"_found")}
  275. *if (this_letter != true)
  276. _
  277. *if (this_letter)
  278. *set this_letter {("hmletter_"&n)}
  279. *set count + 1
  280. ${this_letter}
  281. *if (n < hmletter_count)
  282. *set n + 1
  283. *goto hmword_print_loop
  284. *if (count = hmletter_count)
  285. *set hmvictory true
  286. *line_break
  287. *line_break
  288. *if (hm_lives < 5)
  289. _____
  290. *line_break
  291. *if (hm_lives < 6)
  292. |/
  293. *if (hm_lives < 4)
  294. |
  295. *line_break
  296. *if (hm_lives < 7)
  297. |
  298. *if (hm_lives < 3)
  299. (x)
  300. *line_break
  301. *if (hm_lives < 8)
  302. |
  303. *if (hm_lives < 2)
  304. /|\
  305. *line_break
  306. *if (hm_lives < 9)
  307. |
  308. *if (hm_lives < 1)
  309. / \
  310. *line_break
  311. *if (hm_lives < 10)
  312. |\_
  313. *line_break
  314. *line_break
  315. Lives: ${hm_lives}
  316. *line_break
  317. *line_break
  318.  
  319. *return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement