Advertisement
xKevinn

MC Macros - Hangman

Nov 2nd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.81 KB | None | 0 0
  1. IFMATCHES(%@&chatclean%,"%@&regex%\.newgame",&name,1)
  2. IF(%&name% = %PLAYER%)
  3. UnSet(@&hfinal)
  4. UnSet(@&blank[])
  5. UnSet(@&character[])
  6. UnSet(@&hfound)
  7. UnSet(@&hinprogress)
  8.  
  9. Echo(&7&oCreating new puzzle...)
  10. PROMPT(@&hstring,$$?,"Enter the phrase you want people to guess (no numbers):")
  11. PROMPT(@&topic,$$?,"Enter the topic for \"%@&hstring%\"")
  12. PROMPT(@#hlives,$$?,"How many lives should be allowed?")
  13. Set(@#hlivesleft,%@#hlives%)
  14. IF(@&hstring = "")
  15. Stop
  16. ENDIF
  17.  
  18. @&hstringsave = %@&hstring%
  19. DO
  20. IFMATCHES(%@&hstring%,"..")
  21. MATCH(%@&hstring%,"(.)(.+)",{@&hletter,@&hstring})
  22. IFMATCHES(%@&hletter%,(?-i)[A-Za-z])
  23. Push(@&blank[],"_")
  24. Push(@&character[],%@&hletter%)
  25. ENDIF
  26. IFMATCHES(%@&hletter%," ")
  27. Push(@&blank[]," ")
  28. Push(@&character[],%@&hletter%)
  29. ENDIF
  30. ELSE
  31. Break
  32. ENDIF
  33. LOOP
  34.  
  35. MATCH(%@&hstring%,"(.)",{@&hletter})
  36. IFMATCHES(%@&hletter%,(?-i)[A-Za-z])
  37. Push(@&blank[],"_")
  38. Push(@&character[],%@&hletter%)
  39. ENDIF
  40. IFMATCHES(%@&hletter%," ")
  41. Push(@&blank[]," ")
  42. Push(@&character[],%@&hletter%)
  43. ENDIF
  44.  
  45. FOREACH(@&blank[],&character,#count)
  46. @&hfinal = %@&hfinal%%&character%
  47. NEXT
  48. @&hcomplete = "false"
  49. Echo(&aPuzzle: &6%@&hfinal% &aTopic: &6%@&topic% &aLives: &6%@#hlives%)
  50. Echo(&aUse &6.guess [letter] &aor &6.solve [guess] &ato play)
  51. ENDIF
  52. ENDIF
  53.  
  54. IFMATCHES(%@&chatclean%,"%@&regex%\.guess ([A-Za-z]{1,1})",&guess,2)
  55. MATCH(%@&chatclean%,"%@&regex%\.guess (.+)",&guesser,1)
  56. IF(@&hcomplete != "true")
  57. IF(@&hinprogress != "true")
  58. @&hinprogress = "true"
  59.  
  60. @&hfound = "false"
  61. FOREACH(@&character[],&character,#count)
  62. IFMATCHES(%&character%,%&guess%)
  63. Set(@&blank[%#count%],%@&character[%#count%]%)
  64. @&hfound = "true"
  65. ENDIF
  66. NEXT
  67.  
  68. UnSet(@&hfinal)
  69.  
  70. IF(@&hfound = "false")
  71. Dec(@#hlivesleft)
  72. ENDIF
  73.  
  74. IF(@&hfound = "false")
  75. FOREACH(@&blank[],&character,#count)
  76. @&hfinal = %@&hfinal%%&character%
  77. NEXT
  78. IF(@#hlivesleft = 0)
  79. Echo(&cGame over. Answer: %@&hstringsave%)
  80. @&hinprogress = "false"
  81. @&hcomplete = "true"
  82. ELSE
  83. Echo("&c\"%&guess%\" is not in the puzzle. &aLives: &6%@#hlivesleft%")
  84. Echo(&aPuzzle: &6%@&hfinal% &aTopic: &6%@&topic%)
  85. @&hinprogress = "false"
  86. ENDIF
  87. ELSE
  88.  
  89. IF(@#hlivesleft = 0)
  90. Echo(&cGame over. Answer: %@&hstringsave%)
  91. @&hinprogress = "false"
  92. @&hcomplete = "true"
  93. ELSE
  94. FOREACH(@&blank[],&character,#count)
  95. @&hfinal = %@&hfinal%%&character%
  96. NEXT
  97.  
  98. IF(@&hstringsave = %@&hfinal%)
  99. Echo(&a%&guesser% wins! Answer: %@&hstringsave%)
  100. @&hinprogress = "false"
  101. @&hcomplete = "true"
  102. ELSE
  103. Echo("&a\"%&guess%\" is in the puzzle. &aLives: &6%@#hlivesleft%")
  104. Echo(&aPuzzle: &6%@&hfinal% &aTopic: &6%@&topic%)
  105. @&hinprogress = "false"
  106. ENDIF
  107. ENDIF
  108. ENDIF
  109. ENDIF
  110. ENDIF
  111. ENDIF
  112.  
  113. IFMATCHES(%@&chatclean%,"%@&regex%\.solve (.+)",&solver,1)
  114. IFMATCHES(%@&chatclean%,"%@&regex%\.solve (.+)",&solve,2)
  115. IF(@&hcomplete != "true")
  116. IF(@&hinprogress != "true")
  117. UnSet(&final)
  118. FOREACH(@&character[],&letter,#count)
  119. &final = %&final%%&letter%
  120. NEXT
  121. IFMATCHES(%&solve%,%&final%)
  122. Echo(&a%&solver% successfully solved the puzzle!)
  123. @&hcomplete = "true"
  124. ELSE
  125. Dec(@#hlivesleft)
  126. IF(@#hlivesleft < 1)
  127. Echo(&cGame over. Answer: %@&hstringsave%)
  128. ELSE
  129. Echo(&c%&solver% did not solve the puzzle correctly. &aLives: &6%@#hlivesleft%)
  130. ENDIF
  131. ENDIF
  132. ENDIF
  133. ENDIF
  134. ENDIF
  135. ENDIF
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement