Advertisement
Guest User

Untitled

a guest
Jan 24th, 2018
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 30.00 KB | None | 0 0
  1. Module globalvar
  2. Public grid(9, 9), XInput, OInput As String
  3. Public X, Y, PX, PY, Gridprop(9, 9), PYB, RANVal, CAHP, BSHP, CRHP, DEHP, SBHP, AllEShipHP, STP, XB, YB As Integer
  4.  
  5. Public RAN As New Random
  6. Public KILLED, WON As Boolean
  7. Public Start As Boolean = True
  8. End Module
  9.  
  10. Module Module1
  11. Sub initial()
  12. For i = 0 To 9
  13. For c = 0 To 9
  14. grid(i, c) = "≈"
  15. Next
  16. Next
  17. Console.ForegroundColor = ConsoleColor.DarkGreen
  18.  
  19. Console.WriteLine("
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31. __ __ _____ _____ _ ___ __ _ _ _ ___ __
  32. │ \/ \_ _│_ _│ │ │ __/' _/│ ││ │ │ _ \/' _/
  33. │ -< /\ ││ │ │ │ │ │_│ _|`._`.│ >< │ │ v_/`._`.
  34. │__/_||_││_│ │_│ │___│___│___/│_││_│_│_│ │___/
  35. ╞═══════════════════════════════════════════════╡")
  36. Console.ReadLine()
  37. Call Main()
  38. End Sub
  39. Sub Main()
  40. Console.Clear()
  41. If Start = True Then
  42. Start = False
  43. Call initial()
  44. Else
  45. Console.ForegroundColor = ConsoleColor.DarkGray
  46. Console.WriteLine("
  47. ╔═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╦═══╗")
  48. For a = 0 To 9
  49. PY = a
  50. Console.Write(" ║")
  51. For b = 0 To 9
  52. PX = b
  53. If Gridprop(PX, PY) = 0 Then 'UW
  54. Console.ForegroundColor = ConsoleColor.DarkCyan
  55. ElseIf Gridprop(PX, PY) = 1 Then 'one of your ships destroyed cell
  56. Console.ForegroundColor = ConsoleColor.Red
  57. ElseIf Gridprop(PX, PY) = 2 Then 'Miss
  58. Console.ForegroundColor = ConsoleColor.Blue
  59. ElseIf Gridprop(PX, PY) = 3 Then 'SUB
  60. Console.ForegroundColor = ConsoleColor.Green
  61. ElseIf Gridprop(PX, PY) = 4 Then 'this indicates a UW cell that has an enemy ship in it
  62. Console.ForegroundColor = ConsoleColor.DarkCyan
  63. ElseIf Gridprop(PX, PY) = 5 Then 'this indicates a UW cell that the AI has had a miss shot in
  64. Console.ForegroundColor = ConsoleColor.DarkCyan
  65. ElseIf Gridprop(PX, PY) = 6 Then 'DES
  66. Console.ForegroundColor = ConsoleColor.Green
  67. ElseIf Gridprop(PX, PY) = 7 Then 'BAT
  68. Console.ForegroundColor = ConsoleColor.Green
  69. ElseIf Gridprop(PX, PY) = 8 Then 'CRU
  70. Console.ForegroundColor = ConsoleColor.Green
  71. ElseIf Gridprop(PX, PY) = 9 Then 'CAR
  72. Console.ForegroundColor = ConsoleColor.Green
  73. ElseIf Gridprop(PX, PY) = 10 Then 'HIT
  74. Console.ForegroundColor = ConsoleColor.Red
  75. End If
  76. If PX < 9 Then
  77. Console.Write(" " & grid(PX, PY))
  78. Console.ForegroundColor = ConsoleColor.DarkGray
  79. Console.Write(" ║")
  80. Else
  81. PYB = PY + 1
  82. Console.Write(" " & grid(PX, PY))
  83. Console.ForegroundColor = ConsoleColor.DarkGray
  84. Console.Write(" ║ ")
  85. Console.ForegroundColor = ConsoleColor.White
  86. Console.Write(PYB)
  87. If PY = 0 Then
  88. Console.ForegroundColor = ConsoleColor.DarkCyan
  89. Console.Write(" ≈")
  90. Console.ForegroundColor = ConsoleColor.White
  91. Console.Write(" = Undiscovered Water")
  92. ElseIf PY = 1 Then
  93. Console.ForegroundColor = ConsoleColor.Red
  94. Console.Write(" X")
  95. Console.ForegroundColor = ConsoleColor.White
  96. Console.Write(" = A Hit")
  97. ElseIf PY = 2 Then
  98. Console.ForegroundColor = ConsoleColor.Blue
  99. Console.Write(" o")
  100. Console.ForegroundColor = ConsoleColor.White
  101. Console.Write(" = A Miss")
  102. ElseIf PY = 3 Then
  103. Console.ForegroundColor = ConsoleColor.Green
  104. Console.Write(" «")
  105. Console.ForegroundColor = ConsoleColor.White
  106. Console.Write(" = A Ship")
  107. ElseIf PY = 4 Then
  108. Console.ForegroundColor = ConsoleColor.Red
  109. Console.Write(" «")
  110. Console.ForegroundColor = ConsoleColor.White
  111. Console.Write(" = Damaged Ship")
  112. ElseIf PY = 5 Then
  113. Console.Write(" Carrier HP: ")
  114. If CAHP = 5 Then
  115. Console.ForegroundColor = ConsoleColor.DarkGreen
  116. Console.Write(" ▓▓▓▓▓")
  117. ElseIf CAHP = 4 Then
  118. Console.ForegroundColor = ConsoleColor.DarkGreen
  119. Console.Write(" ▓▓▓▓")
  120. Console.ForegroundColor = ConsoleColor.DarkRed
  121. Console.Write("▓")
  122. ElseIf CAHP = 3 Then
  123. Console.ForegroundColor = ConsoleColor.DarkGreen
  124. Console.Write(" ▓▓▓")
  125. Console.ForegroundColor = ConsoleColor.DarkRed
  126. Console.Write("▓▓")
  127. ElseIf CAHP = 2 Then
  128. Console.ForegroundColor = ConsoleColor.DarkGreen
  129. Console.Write(" ▓▓")
  130. Console.ForegroundColor = ConsoleColor.DarkRed
  131. Console.Write("▓▓▓")
  132. ElseIf CAHP = 1 Then
  133. Console.ForegroundColor = ConsoleColor.DarkGreen
  134. Console.Write(" ▓")
  135. Console.ForegroundColor = ConsoleColor.DarkRed
  136. Console.Write("▓▓▓▓")
  137. Else
  138. Console.ForegroundColor = ConsoleColor.DarkRed
  139. Console.Write(" ▓▓▓▓▓")
  140. End If
  141. ElseIf PY = 6 Then
  142. Console.Write(" Battleship HP:")
  143. If BSHP = 4 Then
  144. Console.ForegroundColor = ConsoleColor.DarkGreen
  145. Console.Write(" ▓▓▓▓")
  146. ElseIf BSHP = 3 Then
  147. Console.ForegroundColor = ConsoleColor.DarkGreen
  148. Console.Write(" ▓▓▓")
  149. Console.ForegroundColor = ConsoleColor.DarkRed
  150. Console.Write("▓")
  151. ElseIf BSHP = 2 Then
  152. Console.ForegroundColor = ConsoleColor.DarkGreen
  153. Console.Write(" ▓▓")
  154. Console.ForegroundColor = ConsoleColor.DarkRed
  155. Console.Write("▓▓")
  156. ElseIf BSHP = 1 Then
  157. Console.ForegroundColor = ConsoleColor.DarkGreen
  158. Console.Write(" ▓")
  159. Console.ForegroundColor = ConsoleColor.DarkRed
  160. Console.Write("▓▓▓")
  161. Else
  162. Console.ForegroundColor = ConsoleColor.DarkRed
  163. Console.Write(" ▓▓▓▓")
  164. End If
  165. ElseIf PY = 7 Then
  166. Console.Write(" Cruiser HP: ")
  167. If CRHP = 3 Then
  168. Console.ForegroundColor = ConsoleColor.DarkGreen
  169. Console.Write(" ▓▓▓")
  170. ElseIf CRHP = 2 Then
  171. Console.ForegroundColor = ConsoleColor.DarkGreen
  172. Console.Write(" ▓▓")
  173. Console.ForegroundColor = ConsoleColor.DarkRed
  174. Console.Write("▓")
  175. ElseIf CRHP = 1 Then
  176. Console.ForegroundColor = ConsoleColor.DarkGreen
  177. Console.Write(" ▓")
  178. Console.ForegroundColor = ConsoleColor.DarkRed
  179. Console.Write("▓▓")
  180. Else
  181. Console.ForegroundColor = ConsoleColor.DarkRed
  182. Console.Write(" ▓▓▓")
  183. End If
  184. ElseIf PY = 8 Then
  185. Console.Write(" Destroyer HP: ")
  186. If DEHP = 2 Then
  187. Console.ForegroundColor = ConsoleColor.DarkGreen
  188. Console.Write(" ▓▓")
  189. ElseIf DEHP = 1 Then
  190. Console.ForegroundColor = ConsoleColor.DarkGreen
  191. Console.Write(" ▓")
  192. Console.ForegroundColor = ConsoleColor.DarkRed
  193. Console.Write("▓")
  194. Else
  195. Console.ForegroundColor = ConsoleColor.DarkRed
  196. Console.Write(" ▓▓")
  197. End If
  198. ElseIf PY = 9 Then
  199. Console.Write(" Submarine HP: ")
  200. If SBHP = 1 Then
  201. Console.ForegroundColor = ConsoleColor.DarkGreen
  202. Console.Write(" ▓")
  203. Else
  204. Console.ForegroundColor = ConsoleColor.DarkRed
  205. Console.Write(" ▓")
  206. End If
  207. End If
  208. Console.ForegroundColor = ConsoleColor.DarkGray
  209. End If
  210. Next
  211. If PY < 9 Then
  212. Console.WriteLine("
  213. ╠═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╬═══╣")
  214. Else
  215. Console.WriteLine("
  216. ╚═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╩═══╝")
  217. End If
  218. Next
  219. End If
  220. Console.ForegroundColor = ConsoleColor.White
  221. Console.WriteLine(" A B C D E F G H I J")
  222. If STP = 5 Then
  223. Call AIBplace()
  224. Else
  225. Call ShipPlaceChoice()
  226. End If
  227.  
  228. End Sub
  229. Sub ShipPlaceChoice()
  230. If STP = 0 Then
  231. Console.WriteLine("
  232. Place your sub.")
  233. Console.WriteLine(" What column would you like to choose?")
  234. XInput = Console.ReadLine.ToLower()
  235. If XInput = "a" Then
  236. X = 0
  237. ElseIf XInput = "b" Then
  238. X = 1
  239. ElseIf XInput = "c" Then
  240. X = 2
  241. ElseIf XInput = "d" Then
  242. X = 3
  243. ElseIf XInput = "e" Then
  244. X = 4
  245. ElseIf XInput = "f" Then
  246. X = 5
  247. ElseIf XInput = "g" Then
  248. X = 6
  249. ElseIf XInput = "h" Then
  250. X = 7
  251. ElseIf XInput = "i" Then
  252. X = 8
  253. ElseIf XInput = "j" Then
  254. X = 9
  255. Else
  256. Console.WriteLine(" Invalid input.")
  257. Call ShipPlaceChoice()
  258. End If
  259. Console.WriteLine("
  260. What row would you like to choose?")
  261. Y = Console.ReadLine()
  262. If Y > 10 Then
  263. Y = 10
  264. ElseIf Y < 1 Then
  265. Y = 1
  266. End If
  267. Y = Y - 1
  268. If grid(X, Y) = "«" Then
  269. Console.WriteLine(" You have already placed a Ship in that cell.")
  270. Call ShipPlaceChoice()
  271. Else
  272. STP = 1
  273. Gridprop(X, Y) = 3
  274. grid(X, Y) = "«"
  275. End If
  276. SBHP = 1
  277. ElseIf STP = 1 Then
  278. Console.WriteLine("
  279. Place Your Destroyer.")
  280. Console.WriteLine(" What orientation is the ship verticle or horizontal? (H/V)")
  281. OInput = Console.ReadLine.ToLower()
  282. Console.WriteLine(" What column would you like to choose?")
  283. XInput = Console.ReadLine.ToLower()
  284. If XInput = "a" Then
  285. X = 0
  286. ElseIf XInput = "b" Then
  287. X = 1
  288. ElseIf XInput = "c" Then
  289. X = 2
  290. ElseIf XInput = "d" Then
  291. X = 3
  292. ElseIf XInput = "e" Then
  293. X = 4
  294. ElseIf XInput = "f" Then
  295. X = 5
  296. ElseIf XInput = "g" Then
  297. X = 6
  298. ElseIf XInput = "h" Then
  299. X = 7
  300. ElseIf XInput = "i" Then
  301. X = 8
  302. ElseIf XInput = "j" Then
  303. X = 9
  304. Else
  305. Console.WriteLine(" Invalid input.")
  306. Call ShipPlaceChoice()
  307. End If
  308. Console.WriteLine("
  309. What row would you like to choose?")
  310. Y = Console.ReadLine()
  311. If Y > 10 Then
  312. Y = 10
  313. ElseIf Y < 1 Then
  314. Y = 1
  315. End If
  316. Y = Y - 1
  317. If OInput = "h" Then
  318. If X = 0 Or 1 Then
  319. XB = X + 1
  320. If Gridprop(XB, Y) = 3 Then
  321. Console.WriteLine(" You have already placed a ship there.")
  322. Call ShipPlaceChoice()
  323. Else
  324. Gridprop(X, Y) = 6
  325. Gridprop(XB, Y) = 6
  326. grid(X, Y) = "«"
  327. grid(XB, Y) = "«"
  328. STP = 2
  329.  
  330. End If
  331. Else
  332. XB = X - 1
  333. Gridprop(X, Y) = 6
  334. Gridprop(XB, Y) = 6
  335. grid(X, Y) = "«"
  336. grid(XB, Y) = "«"
  337. STP = 2
  338. End If
  339. Else
  340.  
  341. If Y = 0 Then
  342. YB = Y + 1
  343. If Gridprop(X, YB) = 3 Then
  344. Console.WriteLine(" You have already placed a ship there.")
  345. Call ShipPlaceChoice()
  346. Else
  347. Gridprop(X, Y) = 6
  348. Gridprop(X, YB) = 6
  349. grid(X, Y) = "«"
  350. grid(X, YB) = "«"
  351. STP = 2
  352.  
  353. End If
  354. Else
  355. YB = Y - 1
  356. Gridprop(X, Y) = 6
  357. Gridprop(X, YB) = 6
  358. grid(X, Y) = "«"
  359. grid(X, YB) = "«"
  360. STP = 2
  361. End If
  362. End If
  363. DEHP = 2
  364. ElseIf STP = 2 Then
  365. Console.WriteLine("
  366. Place Your Cruiser.")
  367. Console.WriteLine(" What orientation is the ship verticle or horizontal? (H/V)")
  368. OInput = Console.ReadLine.ToLower()
  369. Console.WriteLine(" What column would you like to choose?")
  370. XInput = Console.ReadLine.ToLower()
  371. If XInput = "a" Then
  372. X = 0
  373. ElseIf XInput = "b" Then
  374. X = 1
  375. ElseIf XInput = "c" Then
  376. X = 2
  377. ElseIf XInput = "d" Then
  378. X = 3
  379. ElseIf XInput = "e" Then
  380. X = 4
  381. ElseIf XInput = "f" Then
  382. X = 5
  383. ElseIf XInput = "g" Then
  384. X = 6
  385. ElseIf XInput = "h" Then
  386. X = 7
  387. ElseIf XInput = "i" Then
  388. X = 8
  389. ElseIf XInput = "j" Then
  390. X = 9
  391. Else
  392. Console.WriteLine(" Invalid input.")
  393. Call ShipPlaceChoice()
  394. End If
  395. Console.WriteLine("
  396. What row would you like to choose?")
  397. Y = Console.ReadLine()
  398. If Y > 10 Then
  399. Y = 10
  400. ElseIf Y < 1 Then
  401. Y = 1
  402. End If
  403. Y = Y - 1
  404. If OInput = "h" Then
  405. If X = 0 Then
  406. XB = X + 1
  407. If Gridprop(XB, Y) = 3 Or Gridprop(XB + 1, Y) = 3 Then
  408. Console.WriteLine(" You have already placed a ship there.")
  409. Call ShipPlaceChoice()
  410. Else
  411. Gridprop(X, Y) = 7
  412. Gridprop(XB, Y) = 7
  413. Gridprop(XB + 1, Y) = 7
  414. grid(X, Y) = "«"
  415. grid(XB, Y) = "«"
  416. grid(XB + 1, Y) = "«"
  417. STP = 3
  418.  
  419. End If
  420. Else
  421. XB = X - 1
  422. Gridprop(X, Y) = 7
  423. Gridprop(XB, Y) = 7
  424. Gridprop(XB - 1, Y) = 7
  425. grid(X, Y) = "«"
  426. grid(XB, Y) = "«"
  427. grid(XB - 1, Y) = "«"
  428. STP = 3
  429. End If
  430. Else
  431. If Y = 0 Then
  432. YB = Y + 1
  433. If Gridprop(X, YB) = 3 Or Gridprop(X, YB + 1) = 3 Then
  434. Console.WriteLine(" You have already placed a ship there.")
  435. Call ShipPlaceChoice()
  436. Else
  437. Gridprop(X, Y) = 7
  438. Gridprop(X, YB) = 7
  439. Gridprop(X, YB + 1) = 7
  440. grid(X, Y) = "«"
  441. grid(X, YB) = "«"
  442. grid(X, YB + 1) = "«"
  443. STP = 3
  444. End If
  445. Else
  446. YB = Y - 1
  447. Gridprop(X, Y) = 7
  448. Gridprop(X, YB) = 7
  449. Gridprop(X, YB - 1) = 7
  450. grid(X, Y) = "«"
  451. grid(X, YB) = "«"
  452. grid(X, YB - 1) = "«"
  453. STP = 3
  454. End If
  455.  
  456. End If
  457. CRHP = 3
  458. ElseIf STP = 3 Then
  459. Console.WriteLine("
  460. Place Your Battleship.")
  461. Console.WriteLine(" What orientation is the ship verticle or horizontal? (H/V)")
  462. OInput = Console.ReadLine.ToLower()
  463. Console.WriteLine(" What column would you like to choose?")
  464. XInput = Console.ReadLine.ToLower()
  465. If XInput = "a" Then
  466. X = 0
  467. ElseIf XInput = "b" Then
  468. X = 1
  469. ElseIf XInput = "c" Then
  470. X = 2
  471. ElseIf XInput = "d" Then
  472. X = 3
  473. ElseIf XInput = "e" Then
  474. X = 4
  475. ElseIf XInput = "f" Then
  476. X = 5
  477. ElseIf XInput = "g" Then
  478. X = 6
  479. ElseIf XInput = "h" Then
  480. X = 7
  481. ElseIf XInput = "i" Then
  482. X = 8
  483. ElseIf XInput = "j" Then
  484. X = 9
  485. Else
  486. Console.WriteLine(" Invalid input.")
  487. Call ShipPlaceChoice()
  488. End If
  489. Console.WriteLine("
  490. What row would you like to choose?")
  491. Y = Console.ReadLine()
  492. If Y > 10 Then
  493. Y = 10
  494. ElseIf Y < 1 Then
  495. Y = 1
  496. End If
  497. Y = Y - 1
  498. If OInput = "h" Then
  499. If X = 0 Then
  500. XB = X + 1
  501. If Gridprop(XB, Y) = 3 Or Gridprop(XB + 1, Y) = 3 Or Gridprop(XB + 2, Y) = 3 Then
  502. Console.WriteLine(" You have already placed a ship there.")
  503. Call ShipPlaceChoice()
  504. Else
  505. Gridprop(X, Y) = 8
  506. Gridprop(XB, Y) = 8
  507. Gridprop(XB + 1, Y) = 8
  508. Gridprop(XB + 2, Y) = 8
  509. grid(X, Y) = "«"
  510. grid(XB, Y) = "«"
  511. grid(XB + 1, Y) = "«"
  512. grid(XB + 2, Y) = "«"
  513. STP = 4
  514.  
  515. End If
  516. Else
  517. XB = X - 1
  518. Gridprop(X, Y) = 8
  519. Gridprop(XB, Y) = 8
  520. Gridprop(XB - 1, Y) = 8
  521. Gridprop(XB - 2, Y) = 8
  522. grid(X, Y) = "«"
  523. grid(XB, Y) = "«"
  524. grid(XB - 1, Y) = "«"
  525. grid(XB - 2, Y) = "«"
  526. STP = 4
  527. End If
  528. Else
  529. If Y = 0 Then
  530. YB = Y + 1
  531. If Gridprop(X, YB) = 3 Or Gridprop(X, YB + 1) = 3 Or Gridprop(X, YB + 2) = 3 Then
  532. Console.WriteLine(" You have already placed a ship there.")
  533. Call ShipPlaceChoice()
  534. Else
  535. Gridprop(X, Y) = 8
  536. Gridprop(X, YB) = 8
  537. Gridprop(X, YB + 1) = 8
  538. Gridprop(X, YB + 2) = 8
  539. grid(X, Y) = "«"
  540. grid(X, YB) = "«"
  541. grid(X, YB + 1) = "«"
  542. grid(X, YB + 2) = "«"
  543. STP = 4
  544. End If
  545. Else
  546. YB = Y - 1
  547. Gridprop(X, Y) = 8
  548. Gridprop(X, YB) = 8
  549. Gridprop(X, YB - 1) = 8
  550. Gridprop(X, YB - 2) = 8
  551. grid(X, Y) = "«"
  552. grid(X, YB) = "«"
  553. grid(X, YB - 1) = "«"
  554. grid(X, YB - 2) = "«"
  555. STP = 4
  556. End If
  557.  
  558. End If
  559. BSHP = 4
  560. ElseIf STP = 4 Then
  561. Console.WriteLine("
  562. Place Your Carrier.")
  563. Console.WriteLine(" What orientation is the ship verticle or horizontal? (H/V)")
  564. OInput = Console.ReadLine.ToLower()
  565. Console.WriteLine(" What collum would you like to choose?")
  566. XInput = Console.ReadLine.ToLower()
  567. If XInput = "a" Then
  568. X = 0
  569. ElseIf XInput = "b" Then
  570. X = 1
  571. ElseIf XInput = "c" Then
  572. X = 2
  573. ElseIf XInput = "d" Then
  574. X = 3
  575. ElseIf XInput = "e" Then
  576. X = 4
  577. ElseIf XInput = "f" Then
  578. X = 5
  579. ElseIf XInput = "g" Then
  580. X = 6
  581. ElseIf XInput = "h" Then
  582. X = 7
  583. ElseIf XInput = "i" Then
  584. X = 8
  585. ElseIf XInput = "j" Then
  586. X = 9
  587. Else
  588. Console.WriteLine(" Invalid input.")
  589. Call ShipPlaceChoice()
  590. End If
  591. Console.WriteLine("
  592. What row would you like to choose?")
  593. Y = Console.ReadLine()
  594. If Y > 10 Then
  595. Y = 10
  596. ElseIf Y < 1 Then
  597. Y = 1
  598. End If
  599. Y = Y - 1
  600. If OInput = "h" Then
  601. If X = 0 Then
  602. XB = X + 1
  603. If Gridprop(XB, Y) = 3 Or Gridprop(XB + 1, Y) = 3 Or Gridprop(XB + 2, Y) = 3 Or Gridprop(XB + 3, Y) = 3 Then
  604. Console.WriteLine(" You have already placed a ship there.")
  605. Call ShipPlaceChoice()
  606. Else
  607. Gridprop(X, Y) = 9
  608. Gridprop(XB, Y) = 9
  609. Gridprop(XB + 1, Y) = 9
  610. Gridprop(XB + 2, Y) = 9
  611. Gridprop(XB + 3, Y) = 9
  612. grid(X, Y) = "«"
  613. grid(XB, Y) = "«"
  614. grid(XB + 1, Y) = "«"
  615. grid(XB + 2, Y) = "«"
  616. grid(XB + 2, Y) = "«"
  617. STP = 5
  618.  
  619. End If
  620. Else
  621. XB = X - 1
  622. Gridprop(X, Y) = 9
  623. Gridprop(XB, Y) = 9
  624. Gridprop(XB - 1, Y) = 9
  625. Gridprop(XB - 2, Y) = 9
  626. Gridprop(XB - 3, Y) = 9
  627. grid(X, Y) = "«"
  628. grid(XB, Y) = "«"
  629. grid(XB - 1, Y) = "«"
  630. grid(XB - 2, Y) = "«"
  631. grid(XB - 3, Y) = "«"
  632. STP = 5
  633. End If
  634. Else
  635. If Y = 0 Then
  636. YB = Y + 1
  637. If Gridprop(X, YB) = 3 Or Gridprop(X, YB + 1) = 3 Or Gridprop(X, YB + 2) = 3 Or Gridprop(X, YB + 3) = 3 Then
  638. Console.WriteLine(" You have already placed a ship there.")
  639. Call ShipPlaceChoice()
  640. Else
  641. Gridprop(X, Y) = 9
  642. Gridprop(X, YB) = 9
  643. Gridprop(X, YB + 1) = 9
  644. Gridprop(X, YB + 2) = 9
  645. Gridprop(X, YB + 3) = 9
  646. grid(X, Y) = "«"
  647. grid(X, YB) = "«"
  648. grid(X, YB + 1) = "«"
  649. grid(X, YB + 2) = "«"
  650. grid(X, YB + 3) = "«"
  651. STP = 5
  652. End If
  653. Else
  654. YB = Y - 1
  655. Gridprop(X, Y) = 9
  656. Gridprop(X, YB) = 9
  657. Gridprop(X, YB - 1) = 9
  658. Gridprop(X, YB - 2) = 9
  659. Gridprop(X, YB - 3) = 9
  660. grid(X, Y) = "«"
  661. grid(X, YB) = "«"
  662. grid(X, YB - 1) = "«"
  663. grid(X, YB - 2) = "«"
  664. grid(X, YB - 3) = "«"
  665. STP = 5
  666. End If
  667.  
  668. End If
  669. CAHP = 5
  670. End If
  671. Call Main()
  672. End Sub
  673. Sub AIBplace()
  674. X = RAN.Next(0, 9)
  675. Y = RAN.Next(0, 9)
  676. Console.WriteLine(X & " X")
  677. Console.WriteLine(Y & " Y")
  678. Console.ReadLine()
  679.  
  680. End Sub
  681. Sub Battle()
  682. Console.WriteLine("Battle!")
  683. Console.WriteLine(" What collum would you like to choose?")
  684. XInput = Console.ReadLine.ToLower()
  685. If XInput = "a" Then
  686. X = 0
  687. ElseIf XInput = "b" Then
  688. X = 1
  689. ElseIf XInput = "c" Then
  690. X = 2
  691. ElseIf XInput = "d" Then
  692. X = 3
  693. ElseIf XInput = "e" Then
  694. X = 4
  695. ElseIf XInput = "f" Then
  696. X = 5
  697. ElseIf XInput = "g" Then
  698. X = 6
  699. ElseIf XInput = "h" Then
  700. X = 7
  701. ElseIf XInput = "i" Then
  702. X = 8
  703. ElseIf XInput = "j" Then
  704. X = 9
  705. Else
  706. Console.WriteLine(" Invalid input.")
  707. Call ShipPlaceChoice()
  708. End If
  709. Console.WriteLine("
  710. What row would you like to choose?")
  711. Y = Console.ReadLine()
  712. If Y > 10 Then
  713. Y = 10
  714. ElseIf Y < 1 Then
  715. Y = 1
  716. End If
  717. Y = Y - 1
  718. If Gridprop(X, Y) = 0 Then
  719. Gridprop(X, Y) = 2
  720. grid(X, Y) = "o"
  721. ElseIf Gridprop(X, Y) = 1 Then
  722. Console.WriteLine(" That is where one of your ships lay in ruins not a target.")
  723. Console.ReadLine()
  724. Call Battle()
  725. ElseIf Gridprop(X, Y) = 2 Then
  726. Console.WriteLine(" You have already attacked this cell.")
  727. Console.ReadLine()
  728. Call Battle()
  729. ElseIf Gridprop(X, Y) = 3 Then
  730. Console.WriteLine(" *REMOVE FEATURE AFTER TESTING* your sub is hit.")
  731. Console.ReadLine()
  732. Gridprop(X, Y) = 1
  733. SBHP = 0
  734. ElseIf Gridprop(X, Y) = 4 Then
  735. Console.WriteLine("HIT!")
  736. Console.ReadLine()
  737. Gridprop(X, Y) = 10
  738. AllEShipHP = AllEShipHP - 1
  739. ElseIf Gridprop(X, Y) = 5 Then
  740. Console.WriteLine(" *REMOVE FEATURE AFTER TESTING* your Destroyer is hit.")
  741. Console.ReadLine()
  742. Gridprop(X, Y) = 1
  743. DEHP = DEHP - 1
  744.  
  745. End If
  746. Call Main()
  747. End Sub
  748. End Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement