From 5c20512317b334f3b9ab861d75998dd630394298 Mon Sep 17 00:00:00 2001 From: fdai7729 Date: Fri, 9 Feb 2024 03:52:03 +0000 Subject: [PATCH] Update src/main/c/Template/Battleship_game.c --- src/main/c/Template/Battleship_game.c | 50 +++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/src/main/c/Template/Battleship_game.c b/src/main/c/Template/Battleship_game.c index 1a33994..1999e97 100644 --- a/src/main/c/Template/Battleship_game.c +++ b/src/main/c/Template/Battleship_game.c @@ -659,6 +659,56 @@ int* coorgenerator() { } } + shipcoor[15] = co; + + shipdirect = rand() % 2; + + if (a == 1) { + if (shipdirect == 0) { + co -= 1; + shipcoor[16] = co; + } + if (shipdirect == 1) { + co -= 10; + shipcoor[16] = co; + } + } + if (a == 2) { + if (shipdirect == 0) { + co -= 1; + shipcoor[16] = co; + } + if (shipdirect == 1) { + co += 10; + shipcoor[16] = co; + } + } + if (a == 3) { + if (shipdirect == 0) { + co += 1; + shipcoor[16] = co; + } + if (shipdirect == 1) { + co -= 10; + shipcoor[16] = co; + } + } + if (a == 4) { + if (shipdirect == 0) { + co += 1; + shipcoor[16] = co; + } + if (shipdirect == 1) { + co += 10; + shipcoor[16] = co; + } + } + + for (int i = 0; i < 17; i++) { + + returnarr[i] = shipcoor[i]; + } + return returnarr; }