From c22e4ede60c947055d94de2d51d8c023dfd239ff Mon Sep 17 00:00:00 2001 From: Sidibaba23 <142639349+Sidibaba23@users.noreply.github.com> Date: Sat, 12 Jul 2025 22:59:53 -0400 Subject: [PATCH 1/5] Update README.txt (by Sidibaba) --- .../README.txt | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/README.txt b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/README.txt index adf6f5a..c702e5f 100644 --- a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/README.txt +++ b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/README.txt @@ -1,6 +1,6 @@ -Basic Functionality of TextBased Adventure Game - Lost Residence +Basic Functionality of TextBased Adventure Game - TerraCraft -The rooms file consists of 34 rooms. +The rooms file consists of 30 rooms. Each Room contains: @@ -56,4 +56,3 @@ Eact .txt file need to be located outside the src directory in the project folde --STATS (HP): This will allow the player to see all the details about their stats (HP, Attack, Location, and Score).-- --The keyword command [PACK] is also used to look inside the player's backpack!-- - From 2ca908df2f9dbcfc2179ff1b6a34ab3a03532e38 Mon Sep 17 00:00:00 2001 From: Sidibaba23 <142639349+Sidibaba23@users.noreply.github.com> Date: Sun, 13 Jul 2025 06:30:19 -0400 Subject: [PATCH 2/5] Update puzzles.txt I have 10 puzzles - Sid --- .../puzzles.txt | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/puzzles.txt b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/puzzles.txt index 78efc81..3366935 100644 --- a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/puzzles.txt +++ b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/puzzles.txt @@ -1 +1,12 @@ CREATE TABLE PUZZLE(puzzleID integer not Null Primary Key autoincrement, description text null, ItemToSolve text null, hint text null, roomID int null, solved int null, playerID int not null); FOREIGN KEY (playerID) REFERENCES PLAYER (playerID); +INSERT INTO PUZZLE (description, ItemToSolve, hint, roomID, solved, playerID) VALUES +('I have hands but no arms and a face but no eyes. What am I?', 'A clock', 'Look at the wall to tell time.', 1, 0, 1), +('What has to be broken before you can use it?', 'An egg', 'You eat it for breakfast.', 1, 0, 1), +('I have four legs and a back but no head. What am I?', 'A chair', 'You sit on me.', 1, 0, 1), +('I come down but never go up. What am I?', 'Rain', 'Check the sky.', 1, 0, 1), +('What begins with T, ends with T, and has T in it?', 'A teapot', 'Think of something that boils.', 1, 0, 1), +('What is full of holes but still holds water?', 'A sponge', 'You clean dishes with it.', 1, 0, 1), +('What has feet but can’t walk?', 'A ruler', 'Used for measuring.', 1, 0, 1), +('What comes once in a minute, twice in a moment, but never in a thousand years?', 'The letter M', 'It''s a letter.', 1, 0, 1), +('What goes up but never comes down?', 'Your age', 'Think about birthdays.', 1, 0, 1), +('What is white, cold, and falls from the sky in winter?', 'Snow', 'Wear a coat when it happens.', 1, 0, 1); From 77782d4bde4fa8730ba26cba84d4f9d599127822 Mon Sep 17 00:00:00 2001 From: Sidibaba23 <142639349+Sidibaba23@users.noreply.github.com> Date: Sun, 13 Jul 2025 07:00:59 -0400 Subject: [PATCH 3/5] Update items.txt Sid changed it --- .../items.txt | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/items.txt b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/items.txt index e561058..6ec9a35 100644 --- a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/items.txt +++ b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/items.txt @@ -1 +1,7 @@ -CREATE TABLE ITEM(itemID integer not null primary key autoincrement, roomID int not null, inInventory int not null, itemName text not null, itemDesc text not null, playerID int not null, canHeal int not null, healValue int null, FOREIGN KEY (roomID) REFERENCES ROOM(roomNumber) FOREIGN KEY (playerID) REFERENCES PLAYER (playerID)); \ No newline at end of file +CREATE TABLE ITEM(itemID integer not null primary key autoincrement, roomID int not null, inInventory int not null, itemName text not null, itemDesc text not null, playerID int not null, canHeal int not null, healValue int null, FOREIGN KEY (roomID) REFERENCES ROOM(roomNumber) FOREIGN KEY (playerID) REFERENCES PLAYER (playerID)); +INSERT INTO ITEM (roomID, inInventory, itemName, itemDesc, playerID, canHeal, healValue) VALUES +(1, 0, 'Healing Potion', 'Restores health — player gets to live longer', 1, 1, 20), +(2, 0, 'Magic Scroll', 'Reveals hint for puzzle — shows puzzle clue', 1, 0, NULL), +(3, 0, 'Shield of Light', 'Blocks next monster attack — one-time protection', 1, 0, NULL), +(4, 0, 'Compass', 'Shows all exits in current room — helpful for navigation', 1, 0, NULL), +(5, 0, 'Weapons', 'Player can pick up swords or axes — helpful for combat', 1, 0, NULL); From c99926dd628e26f618d87cbf90433ecf14351422 Mon Sep 17 00:00:00 2001 From: Sidibaba23 <142639349+Sidibaba23@users.noreply.github.com> Date: Sun, 13 Jul 2025 14:41:46 -0400 Subject: [PATCH 4/5] Update Adventure.java Sid changed it --- .../src/view/Adventure.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/view/Adventure.java b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/view/Adventure.java index 37a5cee..8ee5499 100644 --- a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/view/Adventure.java +++ b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/view/Adventure.java @@ -1,8 +1,7 @@ /**Class: Adventure.java - * @author Kyle Williams, Bradley Iverson, Miranda Darlington, Rick Price + * @author Sidibaba Simpara, Malik Key, Britney Familia, Angelica Jones * @version 1.0 - * Course: ITEC 3860, Spring 2022 - * Written: 02/18 - 03/11 + * Course: ITEC 3860, Summer 2025 * * * This class houses the main method and is the starting point of the program. From d7b461a4862633c27c55751267076a4b8d3a27a5 Mon Sep 17 00:00:00 2001 From: Sidibaba23 <142639349+Sidibaba23@users.noreply.github.com> Date: Mon, 14 Jul 2025 09:39:12 -0400 Subject: [PATCH 5/5] Update DB.java --- .../src/model/DB.java | 71 +++++++++++-------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/model/DB.java b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/model/DB.java index 6620dfc..1dbc10a 100644 --- a/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/model/DB.java +++ b/338511-2599598 - Kyle Williams - May 2, 2022 1258 AM - LostResidenceFinal/src/model/DB.java @@ -1,21 +1,18 @@ package model; import java.sql.Connection; +import java.sql.DriverManager; import java.sql.ResultSet; import java.sql.SQLException; import java.sql.Statement; /** * Class : DB.java - * @author: Rick Price - * @updated: Hyesung Park + * @author: Sidibaba Simpara, Malik Key, Britney Familia, Angelica Jones * @version: 2.0 - * Course: ITEC 3860 - * updated: March 26, 2022 - * This class controls basic DB functionality - * Purpose:Has Query and Update DB + * Purpose: Controls basic DB functionality (Query and Update DB) */ -abstract public class DB { +public abstract class DB { protected String dbName = "Game.db"; protected String sJdbc; protected String sDriverName; @@ -24,44 +21,49 @@ abstract public class DB { protected int timeout = 5; /** - * Method: queryDB - * Purpose: read from the database - * @param sql + * Initializes the database connection. + */ + public void initConnection() { + try { + Class.forName("org.sqlite.JDBC"); // optional in newer JDBC versions + sDbUrl = "jdbc:sqlite:" + dbName; + conn = DriverManager.getConnection(sDbUrl); + } catch (ClassNotFoundException | SQLException e) { + System.err.println("Failed to connect to database: " + e.getMessage()); + } + } + + /** + * Query the database. + * @param sql SQL SELECT statement * @return ResultSet * @throws SQLException */ public ResultSet queryDB(String sql) throws SQLException { - ResultSet rs = null; Statement stmt = conn.createStatement(); stmt.setQueryTimeout(timeout); - rs = stmt.executeQuery(sql); - return rs; + return stmt.executeQuery(sql); } /** - * Method: updateDB - * Purpose: Updates the database - * @param SQL - * @return boolean + * Execute a database update (INSERT, UPDATE, DELETE). + * @param SQL update statement + * @return boolean success * @throws SQLException */ public boolean updateDB(String SQL) throws SQLException { Statement stmt = conn.createStatement(); - boolean success = stmt.execute(SQL); - return success; + return stmt.execute(SQL); } /** - * Method: count - * Purpose: Gets the count of records in the specified table - * @param table - * @return int + * Get the count of records in the specified table. */ public int count(String table) { int cnt = 0; try { Statement stmt = conn.createStatement(); - String sql = "Select count(*) as count from \"" + table + "\""; + String sql = "SELECT COUNT(*) AS count FROM \"" + table + "\""; ResultSet rs = stmt.executeQuery(sql); cnt = rs.getInt(1); } catch (SQLException sqe) { @@ -71,17 +73,13 @@ public int count(String table) { } /** - * Method: getMaxValue - * Purpose: Gets max value for a particular field in a particular table - * @param columnName - * @param table - * @return int + * Get max value for a column in a table. */ public int getMaxValue(String columnName, String table) { int max = 0; try { Statement stmt = conn.createStatement(); - String sql = "Select MAX(" + columnName + ") from " + table; + String sql = "SELECT MAX(" + columnName + ") FROM " + table; ResultSet rs = stmt.executeQuery(sql); max = rs.getInt(1); } catch (SQLException sqe) { @@ -89,4 +87,17 @@ public int getMaxValue(String columnName, String table) { } return max; } + + /** + * Close the database connection safely. + */ + public void close() { + try { + if (conn != null && !conn.isClosed()) { + conn.close(); + } + } catch (SQLException e) { + System.err.println("Failed to close DB: " + e.getMessage()); + } + } }