Guest User

Choicescript Hangman Coding Challenge

a guest
Jul 7th, 2013
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.57 KB | None | 0 0
  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. C:/files/programs/hangman.pf
  195. *line_break
  196. *line_break
  197.  
  198. *gosub hangman_parse
  199.  
  200.  
  201. *choice
  202. *if (hmvictory) #YOU WIN!!
  203. *goto hang_man_top
  204. *if (hm_lives = 0) #YOU LOSE!!
  205. *goto hang_man_top
  206. *if ((hm_lives != 0) and (hmvictory != true)) #Guess a Letter
  207. *label guess_letter
  208. *gosub hangman_parse
  209. What letter?
  210. *temp str
  211. *input_text str
  212. *comment convert input to lowercase:
  213. *script temps.str = temps.str.toLowerCase();
  214. *temp n 1
  215. *temp count 0
  216. *temp this_letter
  217. *label check_letter_loop
  218. *set this_letter ({"l"&n})
  219. *if (this_letter != str)
  220. *if (n < 26)
  221. *set n + 1
  222. *goto check_letter_loop
  223. *line_break
  224. Error: '${str}' is not a letter.
  225. *line_break
  226. *goto guess_letter
  227. *comment reset n
  228. *set n 1
  229. *label guess_letter_loop
  230. *set this_letter {("hmletter_"&n)}
  231. *if (this_letter = str)
  232. *setref (("hmletter_"&n)&"_found") true
  233. *set count + 1
  234. *if (n < hmletter_count)
  235. *set n + 1
  236. *goto guess_letter_loop
  237. ${count} letters matched.
  238. *if (count = 0)
  239. *line_break
  240. Life lost.
  241. *line_break
  242. *set hm_lives - 1
  243. *line_break
  244. *goto hang_man_top
  245. *if ((hm_lives != 0) and (hmvictory != true)) #Guess the Word
  246. *gosub hangman_parse
  247. What do you think the word is?
  248. *temp str
  249. *input_text str
  250. *comment convert input to lowercase:
  251. *script temps.str = temps.str.toLowerCase();
  252. *if (str = hmword)
  253. *set hmvictory true
  254. *comment show all letters
  255. *temp n 1
  256. *label guessed_word_loop
  257. *setref (("hmletter_"&n)&"_found") true
  258. *if (n != hmletter_count)
  259. *set n + 1
  260. *goto guessed_word_loop
  261. *goto hang_man_top
  262. *else
  263. *set hm_lives 0
  264. *goto hang_man_top
  265. #Start Over
  266. *goto hm_reset
  267. #QUIT
  268. *goto_scene act0
  269. *set hm_lives - 1
  270. *goto hang_man_top
  271.  
  272. *label hangman_parse
  273. The Word:
  274. *temp n 1
  275. *temp count 0
  276. *label hmword_print_loop
  277. *temp this_letter {(("hmletter_"&n)&"_found")}
  278. *if (this_letter != true)
  279. _
  280. *if (this_letter)
  281. *set this_letter {("hmletter_"&n)}
  282. *set count + 1
  283. ${this_letter}
  284. *if (n < hmletter_count)
  285. *set n + 1
  286. *goto hmword_print_loop
  287. *if (count = hmletter_count)
  288. *set hmvictory true
  289. *line_break
  290. *line_break
  291. *if (hm_lives < 5)
  292. _____
  293. *line_break
  294. *if (hm_lives < 6)
  295. |/
  296. *if (hm_lives < 4)
  297. |
  298. *line_break
  299. *if (hm_lives < 7)
  300. |
  301. *if (hm_lives < 3)
  302. (x)
  303. *line_break
  304. *if (hm_lives < 8)
  305. |
  306. *if (hm_lives < 2)
  307. /|\
  308. *line_break
  309. *if (hm_lives < 9)
  310. |
  311. *if (hm_lives < 1)
  312. / \
  313. *line_break
  314. *if (hm_lives < 10)
  315. |\_
  316. *line_break
  317. *line_break
  318. Lives: ${hm_lives}
  319. *line_break
  320. *line_break
  321.  
  322. *return
Advertisement
Add Comment
Please, Sign In to add comment