jargon

Dungeon XAMPP-Builder ( just the GET regex )

Sep 22nd, 2021
2,141
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. $regex = '/^(?<linenumber>[0-9]{3,4}) DIM (?<graphic>[A-Z]{2})\((?<width>[0-9]+),(?<height>[0-9]+)\)\n[0-9]{3,4} OPEN"(?<filename>[.a-z0-9]+)" FOR INPUT AS (?<filemode>[[0-9]+)\n[0-9]{3,4} FOR (?<outerloop>[A-Z]+)=(?<outerlow>[0-9]+) TO (?&height):FOR (?<innerloop>[A-Z]+)=(?<innerlow>[0-9]+) TO (?&width)\n[0-9]{3,4} INPUT #(?&filemode),(?<pixvar>[A-Z]+):PSET\((?&innerloop),(?&outerloop)\),(?&pixvar)\n[0-9]{3,4} NEXT (?&innerloop):NEXT (?&outerloop)\n[0-9]{3,4} CLOSE (?&filemode)\n[0-9]{3,4} GET\((?&innerlow),(?&outerlow)\)-\((?&width),(?&height)\),(?&graphic)\n[0-9]{3,4} CLS$(*SKIP)(*F)|.+\n/m';
  4.  
  5. $subject = '10 KEY OFF:SCREEN 7,0,1,0:VIEW PRINT 1 TO 25:COLOR 15,0,0:CLS:MAP=2:X=8:Y=1
  6. 20 GOSUB 2000:CLS:PCOPY 1,2:DIM MAP(15,7)
  7. 100 C$=INKEY$:XM$="":YM$="":IF C$="" THEN C$=" "
  8. 105 IF C$=CHR$(27) THEN 10000
  9. 106 IF C$=CHR$(13) THEN 10000
  10. 108 XX=X:YY=Y
  11. 110 IF INSTR("123",C$)>0 THEN Y=Y+1
  12. 120 IF INSTR("789",C$)>0 THEN Y=Y-1
  13. 130 IF INSTR("369",C$)>0 THEN X=X+1
  14. 140 IF INSTR("147",C$)>0 THEN X=X-1
  15. 150 IF X<0 THEN X=0 ELSE IF X>319 THEN X=319
  16. 160 IF Y<0 THEN Y=0 ELSE IF Y>199 THEN Y=199
  17. 190 \'
  18. 195 \'IF TIMER-START>1 THEN START=TIMER:GS=1-GS:\'doors
  19. 196 IF TIMER-START2>.2 THEN START2=TIMER:GC=(GC MOD 4)+1:\'dereck
  20. 197 IF TIMER-START3>.5 THEN START3=TIMER:GY=1-GY:\'people
  21. 1000 \'
  22. 1010 PCOPY 2,1
  23. 1020 FOR TT=1 TO 7:FOR T=1 TO 15
  24. 1030 MAP(T,TT)=POINT(X+(T-8),Y+(TT-4))
  25. 1040 NEXT T:NEXT TT
  26. 1050 LINE(0,0)-(319,199),0,BF
  27. 1060 FOR TT=1 TO 7:FOR T=1 TO 15
  28. 1065 IF MAP(T,TT)=1 THEN PUT((T-1)*16,(TT-1)*16),GA
  29. 1070 IF MAP(T,TT)=2 AND (T=8 AND TT=3) THEN PUT((T-1)*16,(TT-1)*16),GB
  30. 1075 IF MAP(T,TT)=2 AND (T<>8 OR TT<>3) THEN PUT((T-1)*16,(TT-1)*16),GC
  31. 1080 IF MAP(T,TT)=3 THEN PUT((T-1)*16,(TT-1)*16),GD
  32. 1090 IF MAP(T,TT)=4 THEN PUT((T-1)*16,(TT-1)*16),GG
  33. 1096 IF MAP(T,TT)=5 THEN PUT((T-1)*16,(TT-1)*16),GH
  34. 1098 IF MAP(T,TT)=7 AND GY=0 THEN PUT((T-1)*16,(TT-1)*16),GE
  35. 1099 IF MAP(T,TT)=7 AND GY=1 THEN PUT((T-1)*16,(TT-1)*16),GF
  36. 1100 IF MAP(T,TT)=8 AND (GC=2 OR GC=4) THEN PUT((T-1)*16,(TT-1)*16),GI
  37. 1101 IF MAP(T,TT)=8 AND GC=1 THEN PUT((T-1)*16,(TT-1)*16),GJ
  38. 1102 IF MAP(T,TT)=8 AND GC=3 THEN PUT((T-1)*16,(TT-1)*16),GK
  39. 1109 NEXT T:NEXT TT
  40. 1110 GOSUB 5000
  41. 1111 PCOPY 1,0
  42. 1115 IF TIMER-DOORC=>2 AND DOORC<>0 THEN 10000
  43. 1120 GOTO 100
  44. 2000 \'
  45. 2010 DIM GA(16,16)
  46. 2015 OPEN"brick04.mem" FOR INPUT AS 1
  47. 2020 FOR TT=1 TO 16:FOR T=1 TO 16
  48. 2030 INPUT #1,R:PSET(T,TT),R
  49. 2040 NEXT T:NEXT TT
  50. 2045 CLOSE 1
  51. 2050 GET(1,1)-(16,16),GA
  52. 2051 CLS
  53. 2110 DIM GB(16,16)
  54. 2115 OPEN"door01.mem" FOR INPUT AS 1
  55. 2120 FOR TT=1 TO 16:FOR T=1 TO 16
  56. 2130 INPUT #1,R:PSET(T,TT),R
  57. 2140 NEXT T:NEXT TT
  58. 2145 CLOSE 1
  59. 2150 GET(1,1)-(16,16),GB
  60. 2151 CLS
  61. 2210 DIM GC(16,16)
  62. 2215 OPEN"door02.mem" FOR INPUT AS 1
  63. 2220 FOR TT=1 TO 16:FOR T=1 TO 16
  64. 2230 INPUT #1,R:PSET(T,TT),R
  65. 2240 NEXT T:NEXT TT
  66. 2245 CLOSE 1
  67. 2250 GET(1,1)-(16,16),GC
  68. 2251 CLS
  69. 2310 DIM GD(16,16)
  70. 2315 OPEN"tile01.mem" FOR INPUT AS 1
  71. 2320 FOR TT=1 TO 16:FOR T=1 TO 16
  72. 2330 INPUT #1,R:PSET(T,TT),R
  73. 2340 NEXT T:NEXT TT
  74. 2345 CLOSE 1
  75. 2350 GET(1,1)-(16,16),GD
  76. 2351 CLS
  77. 2410 DIM GE(16,16)
  78. 2415 OPEN"caveman1.mem" FOR INPUT AS 1
  79. 2420 FOR TT=1 TO 16:FOR T=1 TO 16
  80. 2430 INPUT #1,R:PSET(T,TT),R
  81. 2440 NEXT T:NEXT TT
  82. 2445 CLOSE 1
  83. 2450 GET(1,1)-(16,16),GE
  84. 2451 CLS
  85. 2510 DIM GR(16,16)
  86. 2515 OPEN"phillip1.mem" FOR INPUT AS 1
  87. 2520 FOR TT=1 TO 16:FOR T=1 TO 16
  88. 2530 INPUT #1,R:PSET(T,TT),R
  89. 2540 NEXT T:NEXT TT
  90. 2545 CLOSE 1
  91. 2550 GET(1,1)-(16,16),GR
  92. 2551 CLS
  93. 2610 DIM GS(16,16)
  94. 2615 OPEN"phillip2.mem" FOR INPUT AS 1
  95. 2620 FOR TT=1 TO 16:FOR T=1 TO 16
  96. 2630 INPUT #1,R:PSET(T,TT),R
  97. 2640 NEXT T:NEXT TT
  98. 2645 CLOSE 1
  99. 2650 GET(1,1)-(16,16),GS
  100. 2651 CLS
  101. 2710 DIM GT(16,16)
  102. 2715 OPEN"phillip3.mem" FOR INPUT AS 1
  103. 2720 FOR TT=1 TO 16:FOR T=1 TO 16
  104. 2730 INPUT #1,R:PSET(T,TT),R
  105. 2740 NEXT T:NEXT TT
  106. 2745 CLOSE 1
  107. 2750 GET(1,1)-(16,16),GT
  108. 2751 CLS
  109. 2810 DIM GF(16,16)
  110. 2815 OPEN"caveman2.mem" FOR INPUT AS 1
  111. 2820 FOR TT=1 TO 16:FOR T=1 TO 16
  112. 2830 INPUT #1,R:PSET(T,TT),R
  113. 2840 NEXT T:NEXT TT
  114. 2845 CLOSE 1
  115. 2850 GET(1,1)-(16,16),GF
  116. 2851 CLS
  117. 2910 DIM GG(16,16)
  118. 2915 OPEN"window01.mem" FOR INPUT AS 1
  119. 2920 FOR TT=1 TO 16:FOR T=1 TO 16
  120. 2930 INPUT #1,R:PSET(T,TT),R
  121. 2940 NEXT T:NEXT TT
  122. 2945 CLOSE 1
  123. 2950 GET(1,1)-(16,16),GG
  124. 2951 CLS
  125. 3010 DIM GH(16,16)
  126. 3015 OPEN"well01.mem" FOR INPUT AS 1
  127. 3020 FOR TT=1 TO 16:FOR T=1 TO 16
  128. 3030 INPUT #1,R:PSET(T,TT),R
  129. 3040 NEXT T:NEXT TT
  130. 3045 CLOSE 1
  131. 3050 GET(1,1)-(16,16),GH
  132. 3051 CLS
  133. 3110 DIM GI(16,16)
  134. 3115 OPEN"woman01.mem" FOR INPUT AS 1
  135. 3120 FOR TT=1 TO 16:FOR T=1 TO 16
  136. 3130 INPUT #1,R:PSET(T,TT),R
  137. 3140 NEXT T:NEXT TT
  138. 3145 CLOSE 1
  139. 3150 GET(1,1)-(16,16),GI
  140. 3151 CLS
  141. 3210 DIM GJ(16,16)
  142. 3215 OPEN"woman02.mem" FOR INPUT AS 1
  143. 3220 FOR TT=1 TO 16:FOR T=1 TO 16
  144. 3230 INPUT #1,R:PSET(T,TT),R
  145. 3240 NEXT T:NEXT TT
  146. 3245 CLOSE 1
  147. 3250 GET(1,1)-(16,16),GJ
  148. 3251 CLS
  149. 3310 DIM GK(16,16)
  150. 3315 OPEN"woman03.mem" FOR INPUT AS 1
  151. 3320 FOR TT=1 TO 16:FOR T=1 TO 16
  152. 3330 INPUT #1,R:PSET(T,TT),R
  153. 3340 NEXT T:NEXT TT
  154. 3345 CLOSE 1
  155. 3350 GET(1,1)-(16,16),GK
  156. 3351 CLS
  157. 3915 OPEN"map004.mem" FOR INPUT AS 1
  158. 3920 FOR TT=1 TO 32:FOR T=1 TO 64
  159. 3930 INPUT #1,R:PSET(T-1,TT-1),R
  160. 3940 NEXT T:NEXT TT
  161. 3945 CLOSE 1
  162. 3951 CLS
  163. 3999 RETURN
  164. 5000 \'
  165. 5001 IF (MAP(8,4)<>0) THEN X=XX:Y=YY:RETURN 1010
  166. 5010 \'LOCATE 20,1:PRINT X;",";Y;
  167. 5020 \'LINE((8-1)*16,(4-1)*16)-(8*16,4*16),15,B
  168. 5030 LINE((1-1)*16,(1-1)*16)-(15*16,7*16),15,B
  169. 5035 IF MAP(8,3)=2 AND DOORC=0 THEN DOORC=TIMER
  170. 5036 IF MAP(8,3)<>2 THEN DOORC=0
  171. 5040 IF GC=1 OR GC=3 THEN PUT((8-1)*16,(4-1)*16),GR,OR
  172. 5041 IF GC=2 THEN PUT((8-1)*16,(4-1)*16),GS,OR
  173. 5042 IF GC=4 THEN PUT((8-1)*16,(4-1)*16),GT,OR
  174. 5043 IF X=2 AND Y=7 THEN LOCATE 18,1:PRINT"Woman: This is the dart shop."
  175. 5044 IF X=7 AND Y=4 THEN LOCATE 18,1:PRINT"Man: Welcome to Mortstown."
  176. 5045 IF X=10 AND Y=6 THEN LOCATE 18,1:PRINT"Man: Water from these wells is free!"
  177. 5046 IF X=18 AND Y=8 THEN LOCATE 18,1:PRINT"Woman: The general store\'s owner is     missing."
  178. 5047 IF X=9 AND Y=14 THEN LOCATE 18,1:PRINT"Man: The blacksmith lives on the other  side of the river."
  179. 5048 IF X=4 AND Y=19 THEN LOCATE 18,1:PRINT"Man: Mort, the tavern keeper, enjoys    meeting new faces."
  180. 5049 IF X=8 AND Y=8 THEN LOCATE 18,1:PRINT"The water is very refreshing!"
  181. 5050 IF X=12 AND Y=16 THEN LOCATE 18,1:PRINT"The water is very refreshing!"
  182. 5051 IF X=16 AND Y=9 THEN LOCATE 18,1:PRINT"Lady: Welcome to Mortstown."
  183. 5999 RETURN
  184. 10000 \'
  185. 10010 PCOPY 0,1
  186. 10012 \'START=TIMER:WHILE TIMER-START<.5:WEND
  187. 10015 ST=5
  188. 10020 FOR T=0 TO 120 STEP ST:TT=TT+(.38)*ST
  189. 10030 LINE(0,0)-(T,199),0,BF
  190. 10035 LINE(120+(120-T),0)-(240,199),0,BF
  191. 10040 LINE(0,0)-(319,TT),0,BF
  192. 10045 LINE(0,56+(56-TT))-(319,112),0,BF
  193. 10046 LINE(T,TT)-(120+(120-T),56+(56-TT)),15,B
  194. 10047 LINE(240,0)-(319,199),0,BF
  195. 10050 PCOPY 1,0
  196. 10060 NEXT T
  197. 10061 PSET(120,56),0
  198. 10062 PCOPY 1,0
  199. 10070 \'
  200. 10080 IF X=5 AND Y=5 THEN CHAIN"town.bas"
  201. 10098 IF C$=CHR$(13) THEN TT=0:C$=" ":GOTO 105
  202. 10099 SCREEN 0,0,0,0:WIDTH 80:COLOR 15,1,1:CLS:END
  203. ';
  204.  
  205. $substitution = '{{omitted}}';
  206.  
  207. $result = preg_replace($regex, $substitution, $subject);
  208.  
  209. echo "The result of the substitution is ".$result;
  210.  
  211. ?>
RAW Paste Data