From a0b2e2a815b2574f61f9bf97a40042dd8dc557e4 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Tue, 23 Apr 2024 20:09:48 -0400 Subject: [PATCH 01/14] 4/23/24 --- Character.java | 19 +++++++++++++++++++ Museum.java | 28 ++++++++++++++++++++++++++++ Room.java | 40 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 87 insertions(+) create mode 100644 Character.java create mode 100644 Museum.java create mode 100644 Room.java diff --git a/Character.java b/Character.java new file mode 100644 index 00000000..c29747f7 --- /dev/null +++ b/Character.java @@ -0,0 +1,19 @@ +public class Character { + public class Charcter{ + public String name; + public String whereAreYou; + } + + public void fight(){ + if(/*something in your hand */){ + if(/* There is a creature near you */){ + return /*hit whatever is in front of you */ + } + else{ + //say you have nothing in your hand and gets hit by creature + } + } + + } + } +} diff --git a/Museum.java b/Museum.java new file mode 100644 index 00000000..066e38db --- /dev/null +++ b/Museum.java @@ -0,0 +1,28 @@ +public class Museum { + + private String name; + private int nFloors; + + public Museum(String name, int nFloors) { + if (name != null) { this.name = name; } + if (nFloors < 1){ + throw new RuntimeException("Cannot construct a building with fewer than 1 floor."); + } + this.nFloors = nFloors; + } + public String getName() { + return this.name; + } + + public int getFloors() { + return this.nFloors; + } + + public String toString() { + return this.name + " is a " + this.nFloors + " story building."; + } + public static void main(String[] args) { + Museum fordHall = new Museum("Ford Hall", 4); + System.out.println(fordHall); + } +} \ No newline at end of file diff --git a/Room.java b/Room.java new file mode 100644 index 00000000..14562919 --- /dev/null +++ b/Room.java @@ -0,0 +1,40 @@ +import java.util.ArrayList; + +public class Room extends Museum{ + private String name; + private ArrayList characters; + private Map matrix; + + public Room(String name, int nFloors, ArrayList characters, Map matrix) { + super(name, nFloors); + this.name = name; + this.characters = characters; + this.matrix = null; + + } + + public Map create(){ + + } + + private class Map(){ + private String[][] map; + private int[] enter = [0,2]; + private int[] exit = [0,4]; + + private Map(int x, int y){ + this.x = x; + this.y = y; + String[][] map = new String[x][y]; + } + + private void populate(int x, String[] row){ + this.map[x] = row; + } + + private void check(int x, int y){ + if + + } + } +} From e6edd3beebccd49e7d318c1a165d86b8fc039d5d Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 23 Apr 2024 20:21:59 -0400 Subject: [PATCH 02/14] name change plus added file --- Character | 3 +++ Character.java => User.java | 4 +--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 Character rename Character.java => User.java (86%) diff --git a/Character b/Character new file mode 100644 index 00000000..05760cd3 --- /dev/null +++ b/Character @@ -0,0 +1,3 @@ +public Class Character { + +} \ No newline at end of file diff --git a/Character.java b/User.java similarity index 86% rename from Character.java rename to User.java index c29747f7..26e2ca3f 100644 --- a/Character.java +++ b/User.java @@ -1,8 +1,6 @@ -public class Character { - public class Charcter{ +public class User { public String name; public String whereAreYou; - } public void fight(){ if(/*something in your hand */){ From 0434a7cbb43f28ae7bd2d53ad712b7aae9d72293 Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 23 Apr 2024 20:57:31 -0400 Subject: [PATCH 03/14] user and main edits --- Main | 3 +++ User.java | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Main diff --git a/Main b/Main new file mode 100644 index 00000000..7dc19b4d --- /dev/null +++ b/Main @@ -0,0 +1,3 @@ +public class Main { + //initializing objects +} \ No newline at end of file diff --git a/User.java b/User.java index 26e2ca3f..8eba2bfa 100644 --- a/User.java +++ b/User.java @@ -1,7 +1,41 @@ +import java.util.ArrayList; + +// initialize in main for objects and coordinates and anything that will be used across files + public class User { - public String name; - public String whereAreYou; + public String userName; + public String whereAreYou; + ArrayList inventory = new ArrayList(); + +/* will hold off until map is ready*/ + public void go(forward, backwards, left, right) { + + } + + public void take() { + if (//object is there to take//) { + if (//inventory.size() == 0)//) { + inventory.add(//object); + //object must be deleted from coordinates// + } + System.out.println("You already have an object in your inventory... you can only have one!"); + } + System.out.println("There is currently nothing to take!"); + } + public void drop() { + if (//inventory.size() == 0 //) { + System.out.println("You have successfully dropped" + object + "!"); + // object added to new coordinates + } + System.out.println("There is nothing to pick up!"); + } + + public void inventory() { + System.out.println("You currently have"+ inventory +"in your inventory"); + } + +/* user can fight any creatures */ public void fight(){ if(/*something in your hand */){ if(/* There is a creature near you */){ @@ -13,5 +47,8 @@ public void fight(){ } } + + + } } From 5070298230ce06ab74034a09a6016d9071051a74 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Tue, 23 Apr 2024 21:15:15 -0400 Subject: [PATCH 04/14] hello --- Map.java | 26 ++++++++++++++++++++++++++ Museum.java | 2 ++ Room.java | 25 ------------------------- 3 files changed, 28 insertions(+), 25 deletions(-) create mode 100644 Map.java diff --git a/Map.java b/Map.java new file mode 100644 index 00000000..09645cd4 --- /dev/null +++ b/Map.java @@ -0,0 +1,26 @@ +public class Map { + +private String[][] map; +private int x; +private int y; +private String place; +private int[] enter = [0,2]; +private int[] exit = [0,4]; + + + +public Map(int x, int y){ + this.x = x; + this.y = y; + String[][] map = new String[x][y]; + +} +public String printMap(String[][] map){ + String[][] midievalRoom = new String[x][y]; + String[] row1 = new String[place]; + row1.add["door"]; + + System.out.print(map); +} +} + diff --git a/Museum.java b/Museum.java index 066e38db..7460c7f0 100644 --- a/Museum.java +++ b/Museum.java @@ -21,6 +21,8 @@ public int getFloors() { public String toString() { return this.name + " is a " + this.nFloors + " story building."; } + + //check location public static void main(String[] args) { Museum fordHall = new Museum("Ford Hall", 4); System.out.println(fordHall); diff --git a/Room.java b/Room.java index 14562919..54a2de62 100644 --- a/Room.java +++ b/Room.java @@ -12,29 +12,4 @@ public Room(String name, int nFloors, ArrayList characters, Map matri this.matrix = null; } - - public Map create(){ - - } - - private class Map(){ - private String[][] map; - private int[] enter = [0,2]; - private int[] exit = [0,4]; - - private Map(int x, int y){ - this.x = x; - this.y = y; - String[][] map = new String[x][y]; - } - - private void populate(int x, String[] row){ - this.map[x] = row; - } - - private void check(int x, int y){ - if - - } - } } From 15c56424a9e6ed2c1ccc3ba9c59d5256ceb68b10 Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 23 Apr 2024 21:28:02 -0400 Subject: [PATCH 05/14] updated user info --- Character | 2 +- Main | 1 + User.java | 58 ++++++++++++++++++++++++++++++++++++++++++++----------- 3 files changed, 49 insertions(+), 12 deletions(-) diff --git a/Character b/Character index 05760cd3..d0c726b0 100644 --- a/Character +++ b/Character @@ -1,3 +1,3 @@ public Class Character { - + // creatures include painting, knight } \ No newline at end of file diff --git a/Main b/Main index 7dc19b4d..fdf5d59a 100644 --- a/Main +++ b/Main @@ -1,3 +1,4 @@ public class Main { //initializing objects + // objects which are sword, rope, hammer, armor } \ No newline at end of file diff --git a/User.java b/User.java index 8eba2bfa..7c20005c 100644 --- a/User.java +++ b/User.java @@ -1,5 +1,7 @@ import java.util.ArrayList; +import javax.sound.sampled.SourceDataLine; + // initialize in main for objects and coordinates and anything that will be used across files public class User { @@ -36,19 +38,53 @@ public void inventory() { } /* user can fight any creatures */ - public void fight(){ - if(/*something in your hand */){ - if(/* There is a creature near you */){ - return /*hit whatever is in front of you */ - } - else{ - //say you have nothing in your hand and gets hit by creature + public void fight() { + if (//user near creature) { + if (creature == knight) { + if (//inventory != 0) { + if (inventory.contains(sword)) { + System.out.println("You fight"); + // 95% chance of winning, else you die + } + if (inventory.contains(rope)) { + System.out.println("You fight"); + // 50% chance of winning + } + if (inventory.contains(hammer)) { + System.out.println("You fight"); + // 75% chance of winning + } + // else its armor + System.out.println("You fight"); + // does not do much for you, 30% chance, all it does is protect you } - } + System.out.println("You cannot fight" + creature "you have nothing to fight it with!"); + System.out.println("If you want to keep fighting with your bare hands... type FIGHT!"); + System.out.println("...but the odds are not in your favor..."); + // scanner? make it a 25% + // put position back to starting... die? + } + if (creature == painting) { + // all the painting is, is annoying and loud + if (//inventory != 0) { + if (inventory.contains(sword)) { + System.out.println("You slice up the painting"); + } + if (inventory.contains(rope)) { + // you do not win, rope vs a painting = stupid + } + if (inventory.contains(hammer)) { + // brutal... but ok + } + // else its armor + // you also lose bc armor vs painting does nothing + } + } + // if you have nothing to fight the painting with, you can just take it + // off the wall and place it face down on the ground, shutting it up } - - - + System.out.println("There is nothing to fight here!"); } + } From 3026aa7126da337cd501e39ad99598338f0b7432 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Wed, 24 Apr 2024 18:50:36 -0400 Subject: [PATCH 06/14] 04/24/24 --- Map.java | 65 ++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/Map.java b/Map.java index 09645cd4..ad5df8c7 100644 --- a/Map.java +++ b/Map.java @@ -1,26 +1,59 @@ +import java.util.ArrayList; + public class Map { -private String[][] map; -private int x; -private int y; -private String place; -private int[] enter = [0,2]; -private int[] exit = [0,4]; +// private String[][] map; +// private int x; +// private int y; +// private String place; +// private int[] enter = [0,2]; +// private int[] exit = [0,4]; -public Map(int x, int y){ - this.x = x; - this.y = y; - String[][] map = new String[x][y]; +// public Map(int x, int y){ +// this.x = x; +// this.y = y; +// String[][] map = new String[x][y]; -} -public String printMap(String[][] map){ - String[][] midievalRoom = new String[x][y]; - String[] row1 = new String[place]; - row1.add["door"]; +// } +public static void main(String[] args){ + ArrayList> midievalRoom = new ArrayList(); + ArrayList mRowOne; + ArrayList mRowTwo; + ArrayList mRowThree; + ArrayList mRowFour; + + midievalRoom.add(mRowOne); + midievalRoom.add(mRowTwo); + midievalRoom.add(mRowThree); + midievalRoom.add(mRowFour); + + ArrayList mRowOne = new ArrayList(); + mRowOne.add("Door"); + mRowOne.add("Blocked"); + mRowOne.add("Blocked"); + mRowOne.add("Blocked"); + + ArrayList mRowTwo = new ArrayList(); + mRowTwo.add("Empty"); + mRowTwo.add("Empty"); + mRowTwo.add("Object"); + mRowTwo.add("Blocked"); + + ArrayList mRowThree = new ArrayList(); + mRowThree.add("Trap"); + mRowThree.add("Empty"); + mRowThree.add("Empty"); + mRowThree.add("Blocked"); + + ArrayList mRowFour = new ArrayList(); + mRowFour.add("Blocked"); + mRowFour.add("Character"); + mRowFour.add("Empty"); + mRowFour.add("Door"); - System.out.print(map); + System.out.print(midievalRoom); } } From ef52081a7679b7e927a45d99fdb4a308b3d1b4e2 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Sun, 28 Apr 2024 15:06:50 -0400 Subject: [PATCH 07/14] um --- Main | 4 ---- Main.java | 46 ++++++++++++++++++++++++++++++++++++++++++++++ Map.java | 39 ++++++++++++++++----------------------- Museum.java | 12 ++++++------ Room.java | 16 ++++++++++++++++ 5 files changed, 84 insertions(+), 33 deletions(-) delete mode 100644 Main create mode 100644 Main.java diff --git a/Main b/Main deleted file mode 100644 index fdf5d59a..00000000 --- a/Main +++ /dev/null @@ -1,4 +0,0 @@ -public class Main { - //initializing objects - // objects which are sword, rope, hammer, armor -} \ No newline at end of file diff --git a/Main.java b/Main.java new file mode 100644 index 00000000..0fa30162 --- /dev/null +++ b/Main.java @@ -0,0 +1,46 @@ +public class Main { + //initializing objects + // objects which are sword, rope, hammer, armor + + String[] objects = {"Sword", "Rope", "Armor", "Hammer"}; + static String[][] midievalRoom = { + {"Door", "Blocked", "Blocked", "Blocked"}, + {"Empty", "Empty", "Sword", "Blocked"}, + {"Trap", "Empty", "Empty", "Blocked"}, + {"Blocked", "Character", "Empty", "Door"} + }; + static String[][] jewelryRoom = { + {"Door", "Blocked", "Blocked", "Blocked"}, + {"Empty", "Hammer", "Empty", "Empty"}, + {"Trap", "Empty", "Empty", "Rope"}, + {"Blocked", "Blocked", "Blocked", "Door"} + }; + static String[][] paintingRoom = { + {"Door", "Character", "Blocked", "Trap"}, + {"Empty", "Trap", "Rope", "Trap"}, + {"Empty", "Empty", "Empty", "Sword"}, + {"Hammer", "Empty", "Trap", "Door"} + }; + + public static boolean checkRoom(String[][] String[][], int i, int j){ + if(String[i][j].contains("Blocked") == true){ + Room.roomBlocked(true); + } + if(String[i][j].contains("Empty") == true){ + Room.roomEmpty(true); + } + if(String[i][j].contains("Trap") == true){ + Room.roomTrap(true); + } + if((String[i][j].contains("Door") == true)){ + Room.roomDoor(true); + } + } + + public static void main(String[] args) { + Object check = checkRoom(jewelryRoom, 1, 0); + System.out.println(check); + + + +} \ No newline at end of file diff --git a/Map.java b/Map.java index ad5df8c7..4640443c 100644 --- a/Map.java +++ b/Map.java @@ -2,32 +2,20 @@ public class Map { -// private String[][] map; -// private int x; -// private int y; -// private String place; -// private int[] enter = [0,2]; -// private int[] exit = [0,4]; +private ArrayList>> Map; +private int x; +private int y; +private String place; -// public Map(int x, int y){ -// this.x = x; -// this.y = y; -// String[][] map = new String[x][y]; +public Map(int x, int y, String[][] map){ + this.x = x; + this.y = y; + String[][] map = new String[x][y]; -// } -public static void main(String[] args){ +} ArrayList> midievalRoom = new ArrayList(); - ArrayList mRowOne; - ArrayList mRowTwo; - ArrayList mRowThree; - ArrayList mRowFour; - - midievalRoom.add(mRowOne); - midievalRoom.add(mRowTwo); - midievalRoom.add(mRowThree); - midievalRoom.add(mRowFour); ArrayList mRowOne = new ArrayList(); mRowOne.add("Door"); @@ -52,8 +40,13 @@ public static void main(String[] args){ mRowFour.add("Character"); mRowFour.add("Empty"); mRowFour.add("Door"); + + midievalRoom.add(mRowOne); + midievalRoom.add(mRowTwo); + midievalRoom.add(mRowThree); + midievalRoom.add(mRowFour); - System.out.print(midievalRoom); -} + System.out.print(midievalRoom.get(1).get(0)); + } diff --git a/Museum.java b/Museum.java index 7460c7f0..b8df55a0 100644 --- a/Museum.java +++ b/Museum.java @@ -1,25 +1,25 @@ public class Museum { private String name; - private int nFloors; + private int nRooms; - public Museum(String name, int nFloors) { + public Museum(String name, int nRooms) { if (name != null) { this.name = name; } - if (nFloors < 1){ + if (nRooms < 1){ throw new RuntimeException("Cannot construct a building with fewer than 1 floor."); } - this.nFloors = nFloors; + this.nRooms = nRooms; } public String getName() { return this.name; } public int getFloors() { - return this.nFloors; + return this.nRooms; } public String toString() { - return this.name + " is a " + this.nFloors + " story building."; + return this.name + " is a " + this.nRooms + " story building."; } //check location diff --git a/Room.java b/Room.java index 54a2de62..10d83373 100644 --- a/Room.java +++ b/Room.java @@ -12,4 +12,20 @@ public Room(String name, int nFloors, ArrayList characters, Map matri this.matrix = null; } + public static String roomBlocked(boolean isBlocked){ + return "Sorry, this space is blocked, try moving somewhere else!"; + } + + public static String roomEmpty(boolean isEmpty){ + return "This space is empty, keep going!"; + } + + public static String roomTrap(boolean isTrap){ + // make it so that their coordinates reset back to the front of the room + return "Oh no! It's a trap. You just reset in the game. Back to square one!"; + } + public static String roomDoor(boolean isDoor){ + // make it so they have an option of what room they wish to enter + return "Looks like you're at a door! What room do you want to enter?"; + } } From 9fc4dcf00caa75c7134fac306baf73b423b34919 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Sun, 28 Apr 2024 20:41:13 -0400 Subject: [PATCH 08/14] yas --- Main.java | 43 ++++++++++++++++++++++++++++++++++++------- Map.java | 38 +------------------------------------- Room.java | 2 ++ User.java | 17 ++++++++++++++++- 4 files changed, 55 insertions(+), 45 deletions(-) diff --git a/Main.java b/Main.java index 0fa30162..b8afe49a 100644 --- a/Main.java +++ b/Main.java @@ -1,3 +1,5 @@ +import java.util.Scanner; + public class Main { //initializing objects // objects which are sword, rope, hammer, armor @@ -16,12 +18,25 @@ public class Main { {"Blocked", "Blocked", "Blocked", "Door"} }; static String[][] paintingRoom = { - {"Door", "Character", "Blocked", "Trap"}, - {"Empty", "Trap", "Rope", "Trap"}, - {"Empty", "Empty", "Empty", "Sword"}, - {"Hammer", "Empty", "Trap", "Door"} + {"Door", "Character", "Blocked", "Trap"}, + {"Empty", "Trap", "Rope", "Trap"}, + {"Empty", "Empty", "Empty", "Sword"}, + {"Hammer", "Empty", "Trap", "Door"} }; + public static int coordChecker(int row, int collumn, String action){ + for(action){ + if(action == "forward"){ + + } + } + } + + /*/ + how do I get this to pin point the specific coordinates and then + have it read whatever is in the coordinates + */ + public static boolean checkRoom(String[][] String[][], int i, int j){ if(String[i][j].contains("Blocked") == true){ Room.roomBlocked(true); @@ -32,14 +47,28 @@ public static boolean checkRoom(String[][] String[][], int i, int j){ if(String[i][j].contains("Trap") == true){ Room.roomTrap(true); } - if((String[i][j].contains("Door") == true)){ + if(String[i][j].contains("Door") == true){ Room.roomDoor(true); } + if(String[i][j].contains("Charcter") == true){ + //vharcter class + } + else{ + User. + + } + } public static void main(String[] args) { - Object check = checkRoom(jewelryRoom, 1, 0); - System.out.println(check); + Scanner gameScanner = new Scanner(System.in); // Create a Scanner object + System.out.println("Hello! Welcome to Escape the Museum! Where would you like to go?"); + System.out.println("HINT: You can use the verb 'go' to move and specify the direction: forward, right, left, backward"); + + String inpuString = gameScanner.nextLine(); // Read user input + System.out.println(); // Output user input + } +} diff --git a/Map.java b/Map.java index 4640443c..a08ee4f8 100644 --- a/Map.java +++ b/Map.java @@ -10,43 +10,7 @@ public class Map { public Map(int x, int y, String[][] map){ - this.x = x; - this.y = y; - String[][] map = new String[x][y]; - -} - ArrayList> midievalRoom = new ArrayList(); - - ArrayList mRowOne = new ArrayList(); - mRowOne.add("Door"); - mRowOne.add("Blocked"); - mRowOne.add("Blocked"); - mRowOne.add("Blocked"); - - ArrayList mRowTwo = new ArrayList(); - mRowTwo.add("Empty"); - mRowTwo.add("Empty"); - mRowTwo.add("Object"); - mRowTwo.add("Blocked"); - - ArrayList mRowThree = new ArrayList(); - mRowThree.add("Trap"); - mRowThree.add("Empty"); - mRowThree.add("Empty"); - mRowThree.add("Blocked"); - - ArrayList mRowFour = new ArrayList(); - mRowFour.add("Blocked"); - mRowFour.add("Character"); - mRowFour.add("Empty"); - mRowFour.add("Door"); - - midievalRoom.add(mRowOne); - midievalRoom.add(mRowTwo); - midievalRoom.add(mRowThree); - midievalRoom.add(mRowFour); - - System.out.print(midievalRoom.get(1).get(0)); + } diff --git a/Room.java b/Room.java index 10d83373..a12aee05 100644 --- a/Room.java +++ b/Room.java @@ -12,6 +12,8 @@ public Room(String name, int nFloors, ArrayList characters, Map matri this.matrix = null; } + + public static String roomBlocked(boolean isBlocked){ return "Sorry, this space is blocked, try moving somewhere else!"; } diff --git a/User.java b/User.java index 7c20005c..83c787f1 100644 --- a/User.java +++ b/User.java @@ -10,7 +10,22 @@ public class User { ArrayList inventory = new ArrayList(); /* will hold off until map is ready*/ - public void go(forward, backwards, left, right) { + public void go(String inputString) { + for(inputString) //i dont really know + if(inputString.contains("go")){ + if(inputString.contains("forward")){ + Main.coordChecker(0, 1, "forward"); + } + if(inputString.contains("backward")){ + Main.coordChecker(0, 1, "backward"); + } + if(inputString.contains("left")){ + Main.coordChecker(1, 0, "left"); + } + if(inputString.contains("right")){ + Main.coordChecker(1, 0, "right"); + } + } } From 404ede2450a57a9c1e02b55862ebda8640ea06b4 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Mon, 29 Apr 2024 16:41:55 -0400 Subject: [PATCH 09/14] mhm --- Main.java | 89 +++++++++++++++++++++++++++++++++++++++---------------- Map.java | 3 -- User.java | 10 ++++--- 3 files changed, 70 insertions(+), 32 deletions(-) diff --git a/Main.java b/Main.java index b8afe49a..c1db98ef 100644 --- a/Main.java +++ b/Main.java @@ -3,54 +3,87 @@ public class Main { //initializing objects // objects which are sword, rope, hammer, armor + + private static int playerPosx; + private static int playerPosy; + + playerPosx = 0; + playerPosy = 0; String[] objects = {"Sword", "Rope", "Armor", "Hammer"}; - static String[][] midievalRoom = { + static String[][] midievalRoom = { {"Door", "Blocked", "Blocked", "Blocked"}, {"Empty", "Empty", "Sword", "Blocked"}, {"Trap", "Empty", "Empty", "Blocked"}, {"Blocked", "Character", "Empty", "Door"} }; - static String[][] jewelryRoom = { - {"Door", "Blocked", "Blocked", "Blocked"}, - {"Empty", "Hammer", "Empty", "Empty"}, - {"Trap", "Empty", "Empty", "Rope"}, - {"Blocked", "Blocked", "Blocked", "Door"} + // static String[][] jewelryRoom = { + // {"Door", "Blocked", "Blocked", "Blocked"}, + // {"Empty", "Hammer", "Empty", "Empty"}, + // {"Trap", "Empty", "Empty", "Rope"}, + // {"Blocked", "Blocked", "Blocked", "Door"} + // }; + // static String[][] paintingRoom = { + // {"Door", "Character", "Blocked", "Trap"}, + // {"Empty", "Trap", "Rope", "Trap"}, + // {"Empty", "Empty", "Empty", "Sword"}, + // {"Hammer", "Empty", "Trap", "Door"} }; - static String[][] paintingRoom = { - {"Door", "Character", "Blocked", "Trap"}, - {"Empty", "Trap", "Rope", "Trap"}, - {"Empty", "Empty", "Empty", "Sword"}, - {"Hammer", "Empty", "Trap", "Door"} - }; - - public static int coordChecker(int row, int collumn, String action){ - for(action){ - if(action == "forward"){ - - } + public static void getSpot(int x, int y) { + // Check if coordinates are within the map bounds + String[][] medievalRoom; + if (x >= 0 && x < medievalRoom.length && y >= 0 && y < medievalRoom[0].length) { + Main.checkRoom(medievalRoom[x][y]); + } else { + System.out.println("Coordinates out of bounds."); } - } /*/ how do I get this to pin point the specific coordinates and then have it read whatever is in the coordinates */ - public static boolean checkRoom(String[][] String[][], int i, int j){ - if(String[i][j].contains("Blocked") == true){ + public static void playerGo(String direction){ + if(direction.contains("forward")){ + if(playerPosy++ < 3 ){ + playerPosy = playerPosy++; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("backward")){ + if(playerPosy-- > 0){ + playerPosy = playerPosy--; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("left")){ + if(playerPosx++ < 3){ + playerPosx = playerPosx++; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("right")){ + if(playerPosx-- < 0){ + playerPosx = playerPosx--; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + } + + public static void checkRoom(String coordinates){ + if(String[][].equals("Blocked") == true){ Room.roomBlocked(true); } - if(String[i][j].contains("Empty") == true){ + if(String[][].equals("Empty") == true){ Room.roomEmpty(true); } - if(String[i][j].contains("Trap") == true){ + if(String[][].equals("Trap") == true){ Room.roomTrap(true); } - if(String[i][j].contains("Door") == true){ + if(String[][].equals("Door") == true){ Room.roomDoor(true); } - if(String[i][j].contains("Charcter") == true){ + if(String[][].equals("Charcter") == true){ //vharcter class } else{ @@ -61,6 +94,12 @@ public static boolean checkRoom(String[][] String[][], int i, int j){ } public static void main(String[] args) { + + int x = 1; + int y = 2; + String spot = getSpot(x, y); + System.out.println("Spot at coordinates (" + x + ", " + y + "): " + spot); + Scanner gameScanner = new Scanner(System.in); // Create a Scanner object System.out.println("Hello! Welcome to Escape the Museum! Where would you like to go?"); System.out.println("HINT: You can use the verb 'go' to move and specify the direction: forward, right, left, backward"); diff --git a/Map.java b/Map.java index a08ee4f8..46790168 100644 --- a/Map.java +++ b/Map.java @@ -7,9 +7,6 @@ public class Map { private int y; private String place; - - -public Map(int x, int y, String[][] map){ } diff --git a/User.java b/User.java index 83c787f1..519e31c9 100644 --- a/User.java +++ b/User.java @@ -13,17 +13,19 @@ public class User { public void go(String inputString) { for(inputString) //i dont really know if(inputString.contains("go")){ + int x = 0; + int y = 0; if(inputString.contains("forward")){ - Main.coordChecker(0, 1, "forward"); + ; } if(inputString.contains("backward")){ - Main.coordChecker(0, 1, "backward"); + ; } if(inputString.contains("left")){ - Main.coordChecker(1, 0, "left"); + ; } if(inputString.contains("right")){ - Main.coordChecker(1, 0, "right"); + ; } } From 43313276bb2c5c07d57ae8acdb798dcc952ddda6 Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 30 Apr 2024 11:36:55 -0400 Subject: [PATCH 10/14] swapped files- trial --- Character | 69 ++++++++++++++++++++++++++++++++++- Main.java | 107 ++++++++++-------------------------------------------- Map.java | 41 ++++++++++++++++++++- Room.java | 2 - User.java | 45 +++++++++-------------- 5 files changed, 146 insertions(+), 118 deletions(-) diff --git a/Character b/Character index d0c726b0..e1503575 100644 --- a/Character +++ b/Character @@ -1,3 +1,70 @@ +java.util.Random +java.until.ArrayList public Class Character { - // creatures include painting, knight + /* + * things that characters can do, such as the knight, painting, etc + */ + private int characterLocation; + ArrayList numberList = new ArrayList(); + + /* + * the character can fight the user under certain circumstances + * sword, rope, hammer, armor... change so that it is just knight and portait + */ + public void fightUser () { + if (//user is at the right place where the character is) { + System.out.println("would you like to fight?", //character); + if (// if user decided to fight) { + System.out.println(""); + if (chanceOfSurvival() == true){ + //character dies, drops a treasure + super.inventory.add(//object) + } + //return to begining of game, you lost the fight + } + // if user does not decide to fight back + } + } + + + private void knight () { + + } + /* + * the chance of survival based off a non-changing number input + * @param number, the set number that helps determine chances + * @return a boolean t/f that shows survival of the user + */ + private boolean chanceOfSurvival (int number) { + // if input number 3 + int randomNumber = rand.nextInt(10) + if (number == 3) { + if (randomNumber <= 9) { + return true; + } + return false; + } + // if input number 2 + if (number == 2) { + if (randomNumber <= 6) { + return true; + } + return false; + } + // if inout number 1 + if (number == 1) { + if (randomNumber <= 4) { + return true; + } + return false; + } + // if input number 0, always a win + if (number == 0) { + if (randomNumber <= 1) { + return true; + } + return false; + } + System.out.println("need to input valid number"); + } } \ No newline at end of file diff --git a/Main.java b/Main.java index c1db98ef..2af90f54 100644 --- a/Main.java +++ b/Main.java @@ -1,114 +1,47 @@ -import java.util.Scanner; - public class Main { //initializing objects // objects which are sword, rope, hammer, armor - - private static int playerPosx; - private static int playerPosy; - - playerPosx = 0; - playerPosy = 0; String[] objects = {"Sword", "Rope", "Armor", "Hammer"}; - static String[][] midievalRoom = { + static String[][] midievalRoom = { {"Door", "Blocked", "Blocked", "Blocked"}, {"Empty", "Empty", "Sword", "Blocked"}, {"Trap", "Empty", "Empty", "Blocked"}, {"Blocked", "Character", "Empty", "Door"} }; - // static String[][] jewelryRoom = { - // {"Door", "Blocked", "Blocked", "Blocked"}, - // {"Empty", "Hammer", "Empty", "Empty"}, - // {"Trap", "Empty", "Empty", "Rope"}, - // {"Blocked", "Blocked", "Blocked", "Door"} - // }; - // static String[][] paintingRoom = { - // {"Door", "Character", "Blocked", "Trap"}, - // {"Empty", "Trap", "Rope", "Trap"}, - // {"Empty", "Empty", "Empty", "Sword"}, - // {"Hammer", "Empty", "Trap", "Door"} + static String[][] jewelryRoom = { + {"Door", "Blocked", "Blocked", "Blocked"}, + {"Empty", "Hammer", "Empty", "Empty"}, + {"Trap", "Empty", "Empty", "Rope"}, + {"Blocked", "Blocked", "Blocked", "Door"} + }; + static String[][] paintingRoom = { + {"Door", "Character", "Blocked", "Trap"}, + {"Empty", "Trap", "Rope", "Trap"}, + {"Empty", "Empty", "Empty", "Sword"}, + {"Hammer", "Empty", "Trap", "Door"} }; - public static void getSpot(int x, int y) { - // Check if coordinates are within the map bounds - String[][] medievalRoom; - if (x >= 0 && x < medievalRoom.length && y >= 0 && y < medievalRoom[0].length) { - Main.checkRoom(medievalRoom[x][y]); - } else { - System.out.println("Coordinates out of bounds."); - } - - /*/ - how do I get this to pin point the specific coordinates and then - have it read whatever is in the coordinates - */ - - public static void playerGo(String direction){ - if(direction.contains("forward")){ - if(playerPosy++ < 3 ){ - playerPosy = playerPosy++; - checkRoom(midievalRoom[playerPosx][playerPosy]); - } - } - if(direction.contains("backward")){ - if(playerPosy-- > 0){ - playerPosy = playerPosy--; - checkRoom(midievalRoom[playerPosx][playerPosy]); - } - } - if(direction.contains("left")){ - if(playerPosx++ < 3){ - playerPosx = playerPosx++; - checkRoom(midievalRoom[playerPosx][playerPosy]); - } - } - if(direction.contains("right")){ - if(playerPosx-- < 0){ - playerPosx = playerPosx--; - checkRoom(midievalRoom[playerPosx][playerPosy]); - } - } - } - public static void checkRoom(String coordinates){ - if(String[][].equals("Blocked") == true){ + public static boolean checkRoom(String[][] String[][], int i, int j){ + if(String[i][j].contains("Blocked") == true){ Room.roomBlocked(true); } - if(String[][].equals("Empty") == true){ + if(String[i][j].contains("Empty") == true){ Room.roomEmpty(true); } - if(String[][].equals("Trap") == true){ + if(String[i][j].contains("Trap") == true){ Room.roomTrap(true); } - if(String[][].equals("Door") == true){ + if((String[i][j].contains("Door") == true)){ Room.roomDoor(true); } - if(String[][].equals("Charcter") == true){ - //vharcter class - } - else{ - User. - - } - } public static void main(String[] args) { + Object check = checkRoom(jewelryRoom, 1, 0); + System.out.println(check); - int x = 1; - int y = 2; - String spot = getSpot(x, y); - System.out.println("Spot at coordinates (" + x + ", " + y + "): " + spot); - - Scanner gameScanner = new Scanner(System.in); // Create a Scanner object - System.out.println("Hello! Welcome to Escape the Museum! Where would you like to go?"); - System.out.println("HINT: You can use the verb 'go' to move and specify the direction: forward, right, left, backward"); - - String inpuString = gameScanner.nextLine(); // Read user input - System.out.println(); // Output user input - } -} - + } \ No newline at end of file diff --git a/Map.java b/Map.java index 46790168..4640443c 100644 --- a/Map.java +++ b/Map.java @@ -7,7 +7,46 @@ public class Map { private int y; private String place; - + + +public Map(int x, int y, String[][] map){ + this.x = x; + this.y = y; + String[][] map = new String[x][y]; + +} + ArrayList> midievalRoom = new ArrayList(); + + ArrayList mRowOne = new ArrayList(); + mRowOne.add("Door"); + mRowOne.add("Blocked"); + mRowOne.add("Blocked"); + mRowOne.add("Blocked"); + + ArrayList mRowTwo = new ArrayList(); + mRowTwo.add("Empty"); + mRowTwo.add("Empty"); + mRowTwo.add("Object"); + mRowTwo.add("Blocked"); + + ArrayList mRowThree = new ArrayList(); + mRowThree.add("Trap"); + mRowThree.add("Empty"); + mRowThree.add("Empty"); + mRowThree.add("Blocked"); + + ArrayList mRowFour = new ArrayList(); + mRowFour.add("Blocked"); + mRowFour.add("Character"); + mRowFour.add("Empty"); + mRowFour.add("Door"); + + midievalRoom.add(mRowOne); + midievalRoom.add(mRowTwo); + midievalRoom.add(mRowThree); + midievalRoom.add(mRowFour); + + System.out.print(midievalRoom.get(1).get(0)); } diff --git a/Room.java b/Room.java index a12aee05..10d83373 100644 --- a/Room.java +++ b/Room.java @@ -12,8 +12,6 @@ public Room(String name, int nFloors, ArrayList characters, Map matri this.matrix = null; } - - public static String roomBlocked(boolean isBlocked){ return "Sorry, this space is blocked, try moving somewhere else!"; } diff --git a/User.java b/User.java index 519e31c9..fe7b8577 100644 --- a/User.java +++ b/User.java @@ -9,28 +9,7 @@ public class User { public String whereAreYou; ArrayList inventory = new ArrayList(); -/* will hold off until map is ready*/ - public void go(String inputString) { - for(inputString) //i dont really know - if(inputString.contains("go")){ - int x = 0; - int y = 0; - if(inputString.contains("forward")){ - ; - } - if(inputString.contains("backward")){ - ; - } - if(inputString.contains("left")){ - ; - } - if(inputString.contains("right")){ - ; - } - } - - } - + public void take() { if (//object is there to take//) { if (//inventory.size() == 0)//) { @@ -42,6 +21,7 @@ public void take() { System.out.println("There is currently nothing to take!"); } + // reset where it originally was public void drop() { if (//inventory.size() == 0 //) { System.out.println("You have successfully dropped" + object + "!"); @@ -51,6 +31,18 @@ public void drop() { } public void inventory() { + if(inventory.contains("Hammer")) { + System.out.println(""); + } + if(inventory.contains("Sword")) { + + } + if(inventory.contains("Rope")) { + + } + if(inventory.contains("Armor")) { + + } System.out.println("You currently have"+ inventory +"in your inventory"); } @@ -59,15 +51,15 @@ public void fight() { if (//user near creature) { if (creature == knight) { if (//inventory != 0) { - if (inventory.contains(sword)) { + if (inventory.contains("Sword")) { System.out.println("You fight"); // 95% chance of winning, else you die } - if (inventory.contains(rope)) { + if (inventory.contains("Rope")) { System.out.println("You fight"); // 50% chance of winning } - if (inventory.contains(hammer)) { + if (inventory.contains("Hammer")) { System.out.println("You fight"); // 75% chance of winning } @@ -75,7 +67,7 @@ public void fight() { System.out.println("You fight"); // does not do much for you, 30% chance, all it does is protect you } - System.out.println("You cannot fight" + creature "you have nothing to fight it with!"); + System.out.println("You cannot fight" + creature + "you have nothing to fight it with!"); System.out.println("If you want to keep fighting with your bare hands... type FIGHT!"); System.out.println("...but the odds are not in your favor..."); // scanner? make it a 25% @@ -95,7 +87,6 @@ public void fight() { } // else its armor // you also lose bc armor vs painting does nothing - } } // if you have nothing to fight the painting with, you can just take it From 14bfca402f7088bfd0dfb37550a31abe6d6e79c5 Mon Sep 17 00:00:00 2001 From: lilyaalta Date: Tue, 30 Apr 2024 11:41:20 -0400 Subject: [PATCH 11/14] new --- Character | 69 ++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) diff --git a/Character b/Character index d0c726b0..e1503575 100644 --- a/Character +++ b/Character @@ -1,3 +1,70 @@ +java.util.Random +java.until.ArrayList public Class Character { - // creatures include painting, knight + /* + * things that characters can do, such as the knight, painting, etc + */ + private int characterLocation; + ArrayList numberList = new ArrayList(); + + /* + * the character can fight the user under certain circumstances + * sword, rope, hammer, armor... change so that it is just knight and portait + */ + public void fightUser () { + if (//user is at the right place where the character is) { + System.out.println("would you like to fight?", //character); + if (// if user decided to fight) { + System.out.println(""); + if (chanceOfSurvival() == true){ + //character dies, drops a treasure + super.inventory.add(//object) + } + //return to begining of game, you lost the fight + } + // if user does not decide to fight back + } + } + + + private void knight () { + + } + /* + * the chance of survival based off a non-changing number input + * @param number, the set number that helps determine chances + * @return a boolean t/f that shows survival of the user + */ + private boolean chanceOfSurvival (int number) { + // if input number 3 + int randomNumber = rand.nextInt(10) + if (number == 3) { + if (randomNumber <= 9) { + return true; + } + return false; + } + // if input number 2 + if (number == 2) { + if (randomNumber <= 6) { + return true; + } + return false; + } + // if inout number 1 + if (number == 1) { + if (randomNumber <= 4) { + return true; + } + return false; + } + // if input number 0, always a win + if (number == 0) { + if (randomNumber <= 1) { + return true; + } + return false; + } + System.out.println("need to input valid number"); + } } \ No newline at end of file From 390ae9134ad73571e9c4f20c43978ec78887efbe Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 30 Apr 2024 12:00:22 -0400 Subject: [PATCH 12/14] please work again <3 --- Main.java | 107 ++++++++++++++++++++++++++++++++++++++++++++---------- Map.java | 44 +--------------------- User.java | 47 ++++++++++++++---------- 3 files changed, 117 insertions(+), 81 deletions(-) diff --git a/Main.java b/Main.java index 2af90f54..543d59c5 100644 --- a/Main.java +++ b/Main.java @@ -1,47 +1,114 @@ +mport java.util.Scanner; + public class Main { //initializing objects // objects which are sword, rope, hammer, armor + + private static int playerPosx; + private static int playerPosy; + + playerPosx = 0; + playerPosy = 0; String[] objects = {"Sword", "Rope", "Armor", "Hammer"}; - static String[][] midievalRoom = { + static String[][] midievalRoom = { {"Door", "Blocked", "Blocked", "Blocked"}, {"Empty", "Empty", "Sword", "Blocked"}, {"Trap", "Empty", "Empty", "Blocked"}, {"Blocked", "Character", "Empty", "Door"} }; - static String[][] jewelryRoom = { - {"Door", "Blocked", "Blocked", "Blocked"}, - {"Empty", "Hammer", "Empty", "Empty"}, - {"Trap", "Empty", "Empty", "Rope"}, - {"Blocked", "Blocked", "Blocked", "Door"} - }; - static String[][] paintingRoom = { - {"Door", "Character", "Blocked", "Trap"}, - {"Empty", "Trap", "Rope", "Trap"}, - {"Empty", "Empty", "Empty", "Sword"}, - {"Hammer", "Empty", "Trap", "Door"} + // static String[][] jewelryRoom = { + // {"Door", "Blocked", "Blocked", "Blocked"}, + // {"Empty", "Hammer", "Empty", "Empty"}, + // {"Trap", "Empty", "Empty", "Rope"}, + // {"Blocked", "Blocked", "Blocked", "Door"} + // }; + // static String[][] paintingRoom = { + // {"Door", "Character", "Blocked", "Trap"}, + // {"Empty", "Trap", "Rope", "Trap"}, + // {"Empty", "Empty", "Empty", "Sword"}, + // {"Hammer", "Empty", "Trap", "Door"} }; + public static void getSpot(int x, int y) { + // Check if coordinates are within the map bounds + String[][] medievalRoom; + if (x >= 0 && x < medievalRoom.length && y >= 0 && y < medievalRoom[0].length) { + Main.checkRoom(medievalRoom[x][y]); + } else { + System.out.println("Coordinates out of bounds."); + } + + /*/ + how do I get this to pin point the specific coordinates and then + have it read whatever is in the coordinates + */ + + public static void playerGo(String direction){ + if(direction.contains("forward")){ + if(playerPosy++ < 3 ){ + playerPosy = playerPosy++; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("backward")){ + if(playerPosy-- > 0){ + playerPosy = playerPosy--; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("left")){ + if(playerPosx++ < 3){ + playerPosx = playerPosx++; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + if(direction.contains("right")){ + if(playerPosx-- < 0){ + playerPosx = playerPosx--; + checkRoom(midievalRoom[playerPosx][playerPosy]); + } + } + } - public static boolean checkRoom(String[][] String[][], int i, int j){ - if(String[i][j].contains("Blocked") == true){ + public static void checkRoom(String coordinates){ + if(String[][].equals("Blocked") == true){ Room.roomBlocked(true); } - if(String[i][j].contains("Empty") == true){ + if(String[][].equals("Empty") == true){ Room.roomEmpty(true); } - if(String[i][j].contains("Trap") == true){ + if(String[][].equals("Trap") == true){ Room.roomTrap(true); } - if((String[i][j].contains("Door") == true)){ + if(String[][].equals("Door") == true){ Room.roomDoor(true); } + if(String[][].equals("Charcter") == true){ + //vharcter class + } + else{ + User. + + } + } public static void main(String[] args) { - Object check = checkRoom(jewelryRoom, 1, 0); - System.out.println(check); - + int x = 1; + int y = 2; + String spot = getSpot(x, y); + System.out.println("Spot at coordinates (" + x + ", " + y + "): " + spot); + + Scanner gameScanner = new Scanner(System.in); // Create a Scanner object + System.out.println("Hello! Welcome to Escape the Museum! Where would you like to go?"); + System.out.println("HINT: You can use the verb 'go' to move and specify the direction: forward, right, left, backward"); + + String inpuString = gameScanner.nextLine(); // Read user input + System.out.println(); // Output user input + } +} + } \ No newline at end of file diff --git a/Map.java b/Map.java index 4640443c..9405c0e9 100644 --- a/Map.java +++ b/Map.java @@ -7,46 +7,6 @@ public class Map { private int y; private String place; - - -public Map(int x, int y, String[][] map){ - this.x = x; - this.y = y; - String[][] map = new String[x][y]; - -} - ArrayList> midievalRoom = new ArrayList(); - - ArrayList mRowOne = new ArrayList(); - mRowOne.add("Door"); - mRowOne.add("Blocked"); - mRowOne.add("Blocked"); - mRowOne.add("Blocked"); - - ArrayList mRowTwo = new ArrayList(); - mRowTwo.add("Empty"); - mRowTwo.add("Empty"); - mRowTwo.add("Object"); - mRowTwo.add("Blocked"); - - ArrayList mRowThree = new ArrayList(); - mRowThree.add("Trap"); - mRowThree.add("Empty"); - mRowThree.add("Empty"); - mRowThree.add("Blocked"); - - ArrayList mRowFour = new ArrayList(); - mRowFour.add("Blocked"); - mRowFour.add("Character"); - mRowFour.add("Empty"); - mRowFour.add("Door"); - - midievalRoom.add(mRowOne); - midievalRoom.add(mRowTwo); - midievalRoom.add(mRowThree); - midievalRoom.add(mRowFour); - - System.out.print(midievalRoom.get(1).get(0)); + -} - +} \ No newline at end of file diff --git a/User.java b/User.java index fe7b8577..4cb0f33d 100644 --- a/User.java +++ b/User.java @@ -9,7 +9,28 @@ public class User { public String whereAreYou; ArrayList inventory = new ArrayList(); - +/* will hold off until map is ready*/ + public void go(String inputString) { + for(inputString) //i dont really know + if(inputString.contains("go")){ + int x = 0; + int y = 0; + if(inputString.contains("forward")){ + ; + } + if(inputString.contains("backward")){ + ; + } + if(inputString.contains("left")){ + ; + } + if(inputString.contains("right")){ + ; + } + } + + } + public void take() { if (//object is there to take//) { if (//inventory.size() == 0)//) { @@ -21,7 +42,6 @@ public void take() { System.out.println("There is currently nothing to take!"); } - // reset where it originally was public void drop() { if (//inventory.size() == 0 //) { System.out.println("You have successfully dropped" + object + "!"); @@ -31,18 +51,6 @@ public void drop() { } public void inventory() { - if(inventory.contains("Hammer")) { - System.out.println(""); - } - if(inventory.contains("Sword")) { - - } - if(inventory.contains("Rope")) { - - } - if(inventory.contains("Armor")) { - - } System.out.println("You currently have"+ inventory +"in your inventory"); } @@ -51,15 +59,15 @@ public void fight() { if (//user near creature) { if (creature == knight) { if (//inventory != 0) { - if (inventory.contains("Sword")) { + if (inventory.contains(sword)) { System.out.println("You fight"); // 95% chance of winning, else you die } - if (inventory.contains("Rope")) { + if (inventory.contains(rope)) { System.out.println("You fight"); // 50% chance of winning } - if (inventory.contains("Hammer")) { + if (inventory.contains(hammer)) { System.out.println("You fight"); // 75% chance of winning } @@ -67,7 +75,7 @@ public void fight() { System.out.println("You fight"); // does not do much for you, 30% chance, all it does is protect you } - System.out.println("You cannot fight" + creature + "you have nothing to fight it with!"); + System.out.println("You cannot fight" + creature "you have nothing to fight it with!"); System.out.println("If you want to keep fighting with your bare hands... type FIGHT!"); System.out.println("...but the odds are not in your favor..."); // scanner? make it a 25% @@ -87,6 +95,7 @@ public void fight() { } // else its armor // you also lose bc armor vs painting does nothing + } } // if you have nothing to fight the painting with, you can just take it @@ -95,4 +104,4 @@ public void fight() { System.out.println("There is nothing to fight here!"); } -} +} \ No newline at end of file From 5ed6128e068fd296da4a70d28c628a9c1847ec40 Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 30 Apr 2024 12:06:06 -0400 Subject: [PATCH 13/14] fixed the import --- Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Main.java b/Main.java index 543d59c5..c1db98ef 100644 --- a/Main.java +++ b/Main.java @@ -1,4 +1,4 @@ -mport java.util.Scanner; +import java.util.Scanner; public class Main { //initializing objects From 275cb8044b1e1695a7534517a135452419069d64 Mon Sep 17 00:00:00 2001 From: adlug Date: Tue, 30 Apr 2024 20:12:17 -0400 Subject: [PATCH 14/14] user, character, main edits --- Character | 60 +++++++++++++++++++++++++++++++++++++++++-------------- User.java | 36 +++++++++++++-------------------- 2 files changed, 59 insertions(+), 37 deletions(-) diff --git a/Character b/Character index e1503575..7540633c 100644 --- a/Character +++ b/Character @@ -1,21 +1,11 @@ java.util.Random java.until.ArrayList public Class Character { - /* - * things that characters can do, such as the knight, painting, etc - */ + private int characterLocation; ArrayList numberList = new ArrayList(); - /* - * the character can fight the user under certain circumstances - * sword, rope, hammer, armor... change so that it is just knight and portait - */ public void fightUser () { - if (//user is at the right place where the character is) { - System.out.println("would you like to fight?", //character); - if (// if user decided to fight) { - System.out.println(""); if (chanceOfSurvival() == true){ //character dies, drops a treasure super.inventory.add(//object) @@ -26,8 +16,48 @@ public Class Character { } } - + // when a character is at the spot where the knight is private void knight () { + System.out.println("You have bumped into a knight in shining armor!"); + System.out.println("You notice that it seems to be moving on its own a little... but you go to steal its helmet...."); + System.out.println("When it grabs your arm! Do you A) talk to it or B) fight?"); + if (scanner ans == a){ + //you talk to it.. 50% chance it yells for the gaurd... if it does, 10% chance you are arrested on the spot + //if it does yell, you have a 25% chance to hide and succeed, 75% chance to escape and start over, and 10% chance the gaurd doesn't hear you + } + if (scanner ans == b) { + // check inventory + if (inventory.contains("Hammer")) { + if(chanceOfSurvival(2) == true) { + System.out.println("With your hammer, you had a haigher than half chance of winning"); + System.out.println("You decide to valiantly battle this knight, hitting this thin sheet of human-shaped metal right where it hurts..."); + System.out.println("And you win! Congrats. You can go about your theivery, but don't forget to add your new trophy to your sachel!"); + //super.steal.object + } + // if it is false, die + System.out.println("you decided to fight without any weapons...?"); + } + if (inventory.contains("Rope")) { + if(chanceOfSurvival(0) == true) { + System.out.println(""); + } + System.out.println("you decided to fight without any weapons...?"); + } + if (inventory.contains("Sword")) { + if(chanceOfSurvival(3) == true) { + System.out.println(""); + } + System.out.println("you decided to fight without any weapons...?"); + } + if (inventory.contains("Armor")) { + if(chanceOfSurvival(1) == true) { + System.out.println(""); + } + System.out.println("you decided to fight without any weapons...?"); + } + //else you try to fistfight + } + } /* @@ -46,19 +76,19 @@ public Class Character { } // if input number 2 if (number == 2) { - if (randomNumber <= 6) { + if (randomNumber <= 7) { return true; } return false; } // if inout number 1 if (number == 1) { - if (randomNumber <= 4) { + if (randomNumber <= 5) { return true; } return false; } - // if input number 0, always a win + // if input number 0 very low chance if (number == 0) { if (randomNumber <= 1) { return true; diff --git a/User.java b/User.java index 4cb0f33d..b9cd2421 100644 --- a/User.java +++ b/User.java @@ -8,28 +8,7 @@ public class User { public String userName; public String whereAreYou; ArrayList inventory = new ArrayList(); - -/* will hold off until map is ready*/ - public void go(String inputString) { - for(inputString) //i dont really know - if(inputString.contains("go")){ - int x = 0; - int y = 0; - if(inputString.contains("forward")){ - ; - } - if(inputString.contains("backward")){ - ; - } - if(inputString.contains("left")){ - ; - } - if(inputString.contains("right")){ - ; - } - } - - } + ArrayList sachel = new ArrayList(); public void take() { if (//object is there to take//) { @@ -42,6 +21,19 @@ public void take() { System.out.println("There is currently nothing to take!"); } + public void steal() { + if (//object is there to take//) { + if (//object is not already in the list) { + if (//object is smth to be stolen) { + sachel.add(//object); + } + System.out.println("You can't steal this object, try taking it!"); + } + System.out.println("You already have an object in your inventory... you can only have one!"); + } + System.out.println("There is currently nothing to take!"); + } + public void drop() { if (//inventory.size() == 0 //) { System.out.println("You have successfully dropped" + object + "!");