diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..6149caa Binary files /dev/null and b/.DS_Store differ diff --git a/.github/workflows/jekyll-gh-pages.yml b/.github/workflows/jekyll-gh-pages.yml index 68fdd1e..2547858 100644 --- a/.github/workflows/jekyll-gh-pages.yml +++ b/.github/workflows/jekyll-gh-pages.yml @@ -42,7 +42,10 @@ jobs: source: ./ destination: ./_site - name: Upload artifact - uses: actions/upload-pages-artifact@v1 + uses: actions/upload-pages-artifact@v3 + with: + name: github-pages + path: ./_site # Deployment job deploy: @@ -54,4 +57,4 @@ jobs: steps: - name: Deploy to GitHub Pages id: deployment - uses: actions/deploy-pages@v2 + uses: actions/deploy-pages@v4 diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml index b2b5b5a..f87c618 100644 --- a/.github/workflows/jekyll.yml +++ b/.github/workflows/jekyll.yml @@ -34,11 +34,10 @@ jobs: - name: Checkout uses: actions/checkout@v4 - name: Setup Ruby - uses: ruby/setup-ruby@8575951200e472d5f2d95c625da0c7bec8217c42 # v1.161.0 + uses: ruby/setup-ruby@v1 with: - ruby-version: '3.1' # Not needed with a .ruby-version file - bundler-cache: true # runs 'bundle install' and caches installed gems automatically - cache-version: 0 # Increment this number if you need to re-download cached gems + ruby-version: '3.1' + bundler-cache: true - name: Setup Pages id: pages uses: actions/configure-pages@v4 @@ -50,6 +49,9 @@ jobs: - name: Upload artifact # Automatically uploads an artifact from the './_site' directory by default uses: actions/upload-pages-artifact@v3 + with: + name: github-pages + path: ./_site # Deployment job deploy: diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..35f53e3 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,8 @@ +{ + "cSpell.words": [ + "gmodal", + "insidehouse", + "passmodal", + "phishmodal" + ] +} \ No newline at end of file diff --git a/README.md b/README.md index 0dbe05c..031a78b 100644 --- a/README.md +++ b/README.md @@ -1,183 +1,9 @@ -# IMPORTANT +# READ ME -- Go to settings and configure pages, deploy from the branch, and then select the root folder. IF YOU DO NOT DO THIS YOUR PAGE WILL NOT BUILD. +## Description +Codemaxxers is a web-based RPG game we made for Del Norte Highschool's APCSP, APCSA, and CSSE classes. Our goal was to make an interactive way that current and future classes could learn while having fun. We have a single-player mode that emphasizes our Pokemon inspired fight. Our multiplayer mode is meant for friends to prove who is the better coder. -- Incase of issues with the user for your repository not being able to be resolved resulting in the page not building do the following: instead of the usual `repository: yourNameHere` in the repository section write `repository: usr/yourNameHere` - -## File Names - -- To name a file, use the following structure (Note that dates should never be in the future and should always be in the format YYYY-MM-DD): - -- Make sure that notebooks are in the notebook folder and posts are in the posts folder. - - - For markdown files in _posts: - - year-month-day-fileName.md - - GOOD EXAMPLE: 2021-08-02-First-Day.md - - BAD EXAMPLE: 2021-8-2-first-day.md - - BAD EXAMPLE: first-day.md - - BAD EXAMPLE: 2069-12-31-First-Day.md - - - For jupyter notebooks in _notebooks: - - year-month-day-fileName.ipynb - - GOOD EXAMPLE: 2021-08-02-First-Day.ipynb - - BAD EXAMPLE: 2021-8-2-first-day.ipynb - - BAD EXAMPLE: first-day.ipynb - - BAD EXAMPLE: 2069-12-31-First-Day.ipynb - - -## NIGHTHAWK-Pages CHANGES - -### NEW FOR NIGHTHAWK-Pages - TAGS - -- Tags are used to organize pages by their tag the way to add tags is to add the following to your front matter such as the example seen here `categories: [C1.4]` each item in the same category will be lumped together to be seen easily on the tags page. - -### NEW FOR NIGHTHAWK-Pages - SEARCH -- All pages can be searched for using the built in search bar. This search bar will search for any word in the title of a page or in the page itself. This allows for easily finding pages and information that you are looking for. However, sometimes this may not be desirable so to hide a page from search you can add `search_exclude: true` to the front matter of the page. This will hide the page from appearing when the viewer uses search. - -### NEW FOR NIGHTHAWK-Pages - NAVIGATION BAR - -- To add pages to the navigation bar add them to general main directory then add the alpha tag that will order them in the way that you desire such as AA Being the first page and ZZ being the last page. - -### NEW FOR NIGHTHAWK-Pages - HOME PAGE - -- There is a new designed home page with all pages having images and a description of what the page is about. This is to help the viewer understand what the page is about and what they can expect to find on the page. The way to add images to a page is to have the following front matter `image: /images/file.jpg` and then the name of the image that you want to use. The image must be in the `images` folder. Furthermore if you would like the file to not show up on the main page `hide: true` can be added to the front matter. - -### NEW FOR NIGHTHAWK-Pages - SASS CHANGES - -- NIGHTHAWK-Pages supports a variety of different themes that are each overlaid on top of minima. To use each theme, go to the custom-styles.scss file and simply uncomment the theme you want to use. To toggle the theme off, comment the line that imports the theme in the file. To add your own themes, find the desired theme’s Github repository and make a new folder in the sass directory that’s named the name of your theme. Copy the import statement format from the other styles on custom-styles.scss, add your own import statement, and you're done. Note that adding your own themes may cause things to break and a given theme’s compatibility with NIGHTHAWK-Pages may be suboptimal. To add your own styling twist, add your own .scss file to custom-styles via import. Here is an example import `@import "minima/NIGHTHAWK-Pages-styles";`. Note that you can also add your own SCSS in the file itself in area labeled specifically for that purpose. Also you can mix different styles together in NIGHTHAWK-Pages however the effects may vary. - -### NEW FOR NIGHTHAWK-Pages - INCLUDES - -- NIGHTHAWK-Pages uses liquid to import many common page elements that are present throughout the repository. These common elements are imported from the _includes directory. If you want to add one of these common elements, use liquid syntax to import the desired element to your file. Here’s an example of liquid syntax used to import: `{%- include post_list.html -%}` Note that the liquid syntax is surrounded by curly braces and percent signs. This can be used anywhere in the repository. - -### NEW FOR NIGHTHAWK-Pages - LAYOUTS -- To create your own page layout, make your own html page inside the _layouts directory, and when you want to use that layout in a file, use the following front matter `layout: [your layout here]` Using another pre-existing layout uses the same front matter syntax as defined above. This layout will have to be written in your own custom liquid defining the structure of the page. - - -### NEW FOR NIGHTHAWK-Pages - CONFIG.YML - -- NIGHTHAWK-Pages allows for social links to be added at the bottom of every page, along with other things. To change the pre-set social links and names, go to the _config.yml file and change the desired category to the desired nomenclature. There are only a few supported social links that you can choose from. - - -## Blog site using GitHub Pages and Jekyll - -> This site is intended for Students. This is to record plans, complete hacks, and do work for your learnings. - -- This can be customized to support computer science as you work through pathway (JavaScript, Python/Flask, Java/Spring) -- All tangible artifact work is in a _posts|_notebooks. -- Front matter (aka meta data) in ipynb and md files is used to organize information according to week and column in running web site. - -## GitHub Pages -All `GitHub Pages` websites are managed on GitHub infrastructure. GitHub uses `Jekyll` to transform your content into static websites and blogs. Each time we change files in GitHub it initiates a GitHub Action that rebuilds and publishes the site with Jekyll. -- GitHub Pages is powered by: [Jekyll](https://jekyllrb.com/). -- Published teacher website: [nighthawkcoders.github.io/teacher](https://nighthawkcoders.github.io/teacher/) - -## Preparing a Preview Site - -In all development, it is recommended to test your code before deployment. The GitHub Pages development process is optimized by testing your development on your local machine, prior to files on GitHub - -Development Cycle. For GitHub pages, the tooling described below will create a development cycle `make-code-save-preview`. In the development cycle, it is a requirement to preview work locally, prior to doing a VSCode `commit` to git. - -Deployment Cycle. In the deployment cycle, `sync-github-action-review`, it is a requirement to complete the development cycle prior to doing a VSCode `sync`. The sync triggers github repository update. The action starts the jekyll build to publish the website. Any step can have errors and will require you to do a review. - -### WSL and/or Ubuntu installation requirements - -- The result of these step is Ubuntu tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/ubuntu/) -- Run scripts in scripts directory of student repo: setup_ubuntu.sh and activate.sh. Expected name of the repository to run these scripts is 'student'. - -### MacOs installation requirements - -- Ihe result of these step are MacOS tools to run preview server. These procedures were created using [jekyllrb.com](https://jekyllrb.com/docs/installation/macos/). Run scripts in scripts directory of student repo: setup_macos.sh and activate_macos.sh. Expected name of the repository to run these scripts is 'student'. - -### Preview - -- The result of these step is server running on: http://0.0.0.0:4100/teacher/. Regeneration messages will run in terminal on any save. Press the Enter or Return key in the terminal at any time to enter commands. - -- Complete installation - -```bash -bundle install -``` - -- Run Server. This requires running terminal commands `make`, `make stop`, `make clean`, or `make convert` to manage the running server. Logging of details will appear in terminal. A `Makefile` has been created in project to support commands and start processes. - - - Start preview server in terminal - - ```bash - cd ~/vscode/teacher # my project location, adapt as necessary - make - ``` - - - Terminal output of shows server address. Cmd or Ctl click http location to open preview server in browser. Example Server address message... - - ```text - Server address: http://0.0.0.0:4100/teacher/ - ``` - - - Save on ipynb or md activiates "regeneration". Refresh browser to see updates. Example terminal message... - ``` - Regenerating: 1 file(s) changed at 2023-07-31 06:54:32 - _notebooks/2024-01-04-cockpit-setup.ipynb - ``` - - - Terminal message are generated from background processes. Click return or enter to obtain prompt and use terminal as needed for other tasks. Alway return to root of project `cd ~/vscode/teacher` for all "make" actions. - - - - Stop preview server, but leave constructed files in project for your review. - - ```bash - make stop - ``` - - - Stop server and "clean" constructed files, best choice when renaming files to eliminate potential duplicates in constructed files. - - ```bash - make clean - ``` - - - Test notebook conversions, best choice to see if IPYNB conversion is acting up. - - ```bash - make convert - ``` - -### Meta Data (Front Matter) - -- Meta data also known as front matter is a set of key value pairs that can provide additional information to github pages about .md and .ipynb files. This can and probably will be used in other file types (ie doc, pdf), if we added them to the system. - -- In the front matter you can also define things like a title and description for the page. Additional front matter is defined to place content on "Computer Science Lab Notebook" page. The `courses:` key will place data on a specific page with the nested `week:` placing data on a specific row on the page. The `type:` key in front matter will place blog under the plans, hacks(ToDo), and tangibles column. - -- In our files the front matter is defined at the top of the page or the first markdown cell. - - - First open one of the .md or .ipynb files already included in either your _posts|_notebooks folder. - - - In the .md file you should notice something similar to this at the top of the page. To see this in your .ipynb files you will need to double click the markdown cell at the top of the file. - - ```yaml - --- - toc: true - comments: false - layout: post - title: Daily Plan Sample - description: Example Blog!!! This shows planning and notes from hacks. - type: plans - courses: { compsci: {week: 0} } - --- - ``` - -- Front matter will always have '---' at the top and bottom to distinguish it and each key value pair will be separated by a ':'. - -- Here we can modify things like the title and description. - -- The type value will tells us which column this is going to appear under, supported values: `plans`, `hacks`, `tangibles`. - -- The courses tells us which menu item it will be under, in this case the `compsci` menu, and the `week` tells it what row (week) it will appear under that menu. - -- In our examples, hacks(ToDo) contains references to our IPYNB files; these are stored in GitHub under the `_notebooks` folder. The plans and tangibles contains references to our MD files; these are stored in GitHub under the `_posts` folder. - -### Key files in Computer Science Lab Notebook - -- `compsci.md` - this is the "Computer Science Lab Notebook" page and is the link `https://nighthawkcoders.github.io/student/compsci`. It contains the Title and Number of units on the page. -- `_data/compsci.yml` - this contains the supporting data that helps organize the units on the page. -- `_layouts`\schedule.html - this contains code, in the Liquid language, that generates the HTML for all the rows and columns. -- fyi, the schedule.html could work for another type of page. For instance, you could make a csa.md, _data/csa.yml, and tag files with `csa: {week: 0}` under courses. \ No newline at end of file +# Table of Contents +- [Multiplayer]() +- [Fight feature]() +- [Main game]() diff --git a/_includes/side-bar.html b/_includes/side-bar.html index 55defe5..b80d07a 100644 --- a/_includes/side-bar.html +++ b/_includes/side-bar.html @@ -1,8 +1,10 @@ + +
' + " " + (parseInt(data.statsArray[0][0]) + parseInt(data.statsArray[0][1]));
+
+ var characterDamageElement = document.getElementById('characterDamage');
+ characterDamageElement.innerHTML = '
' + " " + (parseInt(data.statsArray[1][0]) + parseInt(data.statsArray[1][1]));
+
+ // DISPLAY INVENTORY
+ var inventoryDiv = document.getElementById('inventory');
+ for (var i = 0; i < data.inventory.length; i++) {
+ var itemId = data.inventory[i];
+ var itemType;
+ var itemRange = Math.floor(itemId / 1000); // Determine the range based on item ID
+
+ if (itemRange >= 1 && itemRange < 2) {
+ itemType = 'armor';
+ } else if (itemRange >= 2 && itemRange < 3) {
+ itemType = 'weapons';
+ } else if (itemRange >= 3 && itemRange < 4) {
+ itemType = 'accessories';
+ } else {
+ // Invalid item ID
+ continue;
+ }
+
+ var inventorySection = document.querySelector('.inventory' + itemType.charAt(0).toUpperCase() + itemType.slice(1)); // Get corresponding inventory section
+ var itemImg = document.createElement('img');
+ itemImg.src = "https://codemaxxers.github.io/codemaxxerFrontend/game/img/" + itemType + "/" + itemId + ".png";
+ itemImg.style.width = "80px"; // Adjust the width as needed
+ itemImg.style.height = "auto"; // Adjust the height as needed
+ itemImg.style.marginRight = "10px"; // Adjust margin as needed
+ itemImg.draggable = true; // Enable dragging
+ itemImg.dataset.inventoryID = itemId; // Store item ID as data attribute
+
+ inventorySection.appendChild(itemImg);
+ }
+ // END OF DISPLAY OF INVENTORY
+
+
+
+
+ var flexContainer = document.querySelector('.flex-container');
+
+ // IF ARMOR IS EQUIPPED, ADD TO EQUIPPED GEAR
+ if (data.armorGearIdEquipped != 0) {
+ var flexContainer = document.querySelector('.flex-container');
+ var armorDiv = document.createElement('armorDiv');
+ armorDiv.innerHTML = `
+ Armor
+Weapon
++
Go back to island
"; + } else if (eHealth < 1) { + updateHealthEnemy.innerHTML = `Health: Defeated`; + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + + var requestOptions = { + method: 'POST', + headers: myHeaders, + redirect: 'follow', + credentials: 'include' + }; + //Adding points to the account + fetch(uri + `/api/person/addPoints${course}?points=${totalPoints}`, requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + //Re-direct to island + alert.style = ""; + enemyIMG.classList = "death"; + alertBox.innerHTML = "You WonGo back to island
"; + return; + } +} + +function leave() { + if (health < StartingHealth / 2) { + alert("Running Away Failed"); + } +} + +function GetEnemy() { + console.log(userLevel); + + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + + var requestOptions = { + method: 'GET', + headers: myHeaders, + credentials: 'include', // Include this line for cross-origin requests with credentials + redirect: 'follow' + }; + + fetch(uri + "/api/enemies", requestOptions) + .then(response => response.json()) // Convert response to JSON format + .then(result => { + console.log(result); // Log the result for debugging purposes + + // Filter enemies based on user's level or lower + let filteredEnemies = result.filter(enemy => parseInt(enemy.level) <= parseInt(userLevel)); + + if (filteredEnemies.length > 0) { + // Loop through filtered enemies to populate enemyIds array and update enemy health + filteredEnemies.forEach(enemy => { + enemyIds.push(enemy.id); // Add enemy ID to the array + }); + + // Get a random enemy ID from the enemyIds array + let randomEnemyIndex = Math.floor(Math.random() * filteredEnemies.length); + + // Get the random enemy object + let randomEnemy = filteredEnemies[randomEnemyIndex]; + + // Updating Values depending on the fetched enemy + eHealth = randomEnemy.health; + eAttack = randomEnemy.attack; + eDefense = randomEnemy.defense; + eName = randomEnemy.name; + enemyName.innerHTML = `Enemy: ${eName}`; + + //Update Img + enemyIMG.src = enemyIMG.src + `${eName}.png` + setTimeout(function() { + enemyIMG.classList.add('visible'); + }, 100); + + updateHealthEnemy.innerHTML = `Health: ${eHealth}`; + + } else { + console.log("No enemies found at or below user's level."); + } + }) + .catch(error => console.log('error', error)); +} + +function Battle(attack) { + questionBox.style = ""; + fetchQuestion(attack); // Call fetchQuestion with the attack value + // Check if the player or enemy has been defeated + if (health <= 0) { + alert.style = ""; + playerIMG.classList = "death"; + alertBox.innerHTML = "You LostGo back to island
"; + } else if (eHealth < 1) { + updateHealthEnemy.innerHTML = `Enemy: Defeated`; + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + + var requestOptions = { + method: 'POST', + headers: myHeaders, + redirect: 'follow', + credentials: 'include' + }; + //Adding points to the account + fetch(uri + `/api/person/addPointsCSA?points=${totalPoints}`, requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + //Re-direct to island + alert.style = ""; + enemyIMG.classList = "death"; + alertBox.innerHTML = "You WonGo back to island
"; + return; + } +} + +function GetLevel() { + var requestOptions = { + method: 'GET', + mode: 'cors', + cache: 'default', + credentials: 'include', + }; + +fetch(uri + "/api/person/jwt", requestOptions) + .then(response => { + if (!response.ok) { + const errorMsg = 'Login error: ' + response.status; + console.log(errorMsg); + + switch (response.status) { + case 401: + alert("Please log into or make an account"); + // window.location.href = "login"; + break; + case 403: + alert("Access forbidden. You do not have permission to access this resource."); + break; + case 404: + alert("User not found. Please check your credentials."); + break; + // Add more cases for other status codes as needed + default: + alert("Login failed. Please try again later."); + } + + return Promise.reject('Login failed'); + } + return response.json(); + // Success!!! + }) + .then(data => { + userLevel = data.accountLevel; // Set the innerHTML to just the numeric value + username.innerHTML = data.name; + levelUpdate.innerHTML = "Lv. " + userLevel; + console.log(data.accountLevel); + + health = data.totalHealth; + updateHealth.innerHTML = `Health: ${data.totalHealth}`; + + // updateDamage.innerHTML = '
' + data.totalDamage;
+ // console.log(data.totalDamage);
+ // damage = data.totalDamage;
+ console.log(userLevel);
+ return userLevel;
+ })
+ .catch(error => console.log('error', error));
+}
+
+function getDamage() {
+ var requestOptions = {
+ method: 'GET',
+ mode: 'cors',
+ cache: 'default',
+ credentials: 'include',
+ };
+
+ fetch(uri + "/api/person/jwt", requestOptions)
+ .then(response => response.json()) // Convert response to JSON format
+ .then(data => {
+ damage = data.totalDamage;
+ console.log("Fetched damage:", damage); // For debugging
+ // If the element needs to be updated immediately after fetching
+ updateDamage.innerHTML = `Damage: ${damage}`;
+ })
+ .catch(error => console.log('error', error));
+}
+
+function getWeapon() {
+ var requestOptions = {
+ method: 'GET',
+ mode: 'cors',
+ cache: 'default',
+ credentials: 'include',
+ };
+
+ fetch(uri + "/api/person/getWeaponInventory", requestOptions)
+ .then(response => {
+ if (!response.ok) {
+ const errorMsg = 'Login error: ' + response.status;
+ console.log(errorMsg);
+
+ switch (response.status) {
+ case 401:
+ alert("Please log into or make an account");
+ break;
+ case 403:
+ alert("Access forbidden. You do not have permission to access this resource.");
+ break;
+ case 404:
+ alert("User not found. Please check your credentials.");
+ break;
+ default:
+ alert("Login failed. Please try again later.");
+ }
+
+ return Promise.reject('Login failed');
+ }
+ return response.json();
+ })
+ .then(data => {
+ if (data.weaponGearIdEquipped == null || data.weaponGearIdEquipped == 0) {
+ return;
+ }
+ fetchWeaponStats(data.weaponGearIdEquipped[0])
+ .then(weapon => {
+ var weaponNameElement = document.getElementById("weaponNameValue");
+ weapon = weapon.name;
+ weaponNameElement.innerHTML = `${weapon}`;
+ var moveDamage = document.getElementById("damage");
+ moveDamage.innerHTML = `Damage: ${weapon.damageAdded}`;
+ damage = weapon.damageAdded;
+ })
+ .catch(error => {
+ console.log('error', error);
+ });
+ })
+ .catch(error => console.log('error', error));
+}
+
+function fetchWeaponStats(weaponID) {
+ return fetch('gear.json')
+ .then(response => {
+ if (!response.ok) {
+ throw new Error('Failed to fetch weapon stats');
+ }
+ return response.json();
+ })
+ .then(data => {
+ const weaponStats = data.items.find(item => item.gearID === weaponID);
+ if (!weaponStats) {
+ throw new Error('Weapon stats not found');
+ }
+ return weaponStats;
+ });
+}
+
+document.addEventListener("DOMContentLoaded", () => {
+
+ const requestOptions = {
+ method: "GET",
+ redirect: "follow",
+ credentials: "include"
+ };
+
+ fetch(uri + "/api/person/getWeaponInventory", requestOptions)
+ .then((response) => response.text())
+ .then((result) => console.log(result))
+ .catch((error) => console.error(error));
+});
+
+let numKeys = 1;
+
+function removeKey() {
+ document.getElementById("keyPopup").style.display = "block";
+
+ if(keyNumber > 0){
+ const myHeaders = new Headers();
+
+ var requestOptions = {
+ method: 'POST',
+ headers: myHeaders,
+ redirect: 'follow',
+ credentials: 'include'
+ };
+ //Adding points to the account
+ fetch(uri + `/api/person/removeKey?numKeys=${numKeys}`, requestOptions)
+ .then(response => response.text())
+ .then(result => console.log(result))
+ .catch(error => console.log('key removed failed', error));
+ return;
+ }
+}
+
+function closeKeyPopup() {
+ document.getElementById("keyPopup").style.display = "none";
+}
+
+let currentQuestionHint = null;
+
+function useHint(){
+ document.getElementById("keyPopup").style.display = "none";
+ removeKey();
+ var hintMenu = document.getElementById('hint-box');
+ hintMenu.innerHTML = hint;
+
+ document.getElementById("hint-text").innerText = currentQuestionHint;
+ // var myHeaders = new Headers();
+ // myHeaders.append("Content-Type", "application/json");
+
+ // var requestOptions = {
+ // method: 'GET',
+ // headers: myHeaders,
+ // credentials: 'include',
+ // redirect: 'follow'
+ // };
+
+ // fetch(uri + `/api/questions/QuestionById/${currentQuestionId}`, requestOptions)
+ // .then(response => response.json())
+ // .then(result => {
+ // console.log(result); // debugging
+ // // update hint text
+ // console.log(result.hint);
+ // document.getElementById("hint-text").innerText = result.hint;
+
+ // })
+ // .catch(error => console.log('error', error));
+}
+
+function useSkip(){
+ document.getElementById("keyPopup").style.display = "none";
+ removeKey();
+
+ fetchQuestion(damage);
+ console.log("question skipped");
+}
+
+function useDmg(){
+ document.getElementById("keyPopup").style.display = "none";
+ removeKey();
+
+ damage += 10;
+ console.log("Damage +10, current damage: " + damage);
+
+ updateDamage.innerHTML = `Damage: ${damage}`;
+}
diff --git a/assets/js/multiplayer.js b/assets/js/multiplayer.js
new file mode 100644
index 0000000..169b5d4
--- /dev/null
+++ b/assets/js/multiplayer.js
@@ -0,0 +1,497 @@
+var uri;
+if (location.hostname === "localhost") {
+ uri = "http://localhost:8032";
+} else if (location.hostname === "127.0.0.1") {
+ uri = "http://localhost:8032";
+} else {
+ uri = "https://codemaxxerbackend.onrender.com";
+}
+
+html = `
+
' + " " + (parseInt(data.statsArray[0][0]) + parseInt(data.statsArray[0][1]));
+
+ var characterDamageElement = document.getElementById('characterDamage');
+ characterDamageElement.innerHTML = '
' + " " + (parseInt(data.statsArray[1][0]) + parseInt(data.statsArray[1][1]));
+
+ // DISPLAY INVENTORY
+ var inventoryDiv = document.getElementById('inventory');
+ for (var i = 0; i < data.inventory.length; i++) {
+ var itemId = data.inventory[i];
+ var itemType;
+ var itemRange = Math.floor(itemId / 1000); // Determine the range based on item ID
+
+ if (itemRange >= 1 && itemRange < 2) {
+ itemType = 'armor';
+ } else if (itemRange >= 2 && itemRange < 3) {
+ itemType = 'weapons';
+ } else if (itemRange >= 3 && itemRange < 4) {
+ itemType = 'accessories';
+ } else {
+ // Invalid item ID
+ continue;
+ }
+
+ var inventorySection = document.querySelector('.inventory' + itemType.charAt(0).toUpperCase() + itemType.slice(1)); // Get corresponding inventory section
+ var itemImg = document.createElement('img');
+ itemImg.src = "https://codemaxxers.github.io/codemaxxerFrontend/game/img/" + itemType + "/" + itemId + ".png";
+ itemImg.style.width = "80px"; // Adjust the width as needed
+ itemImg.style.height = "auto"; // Adjust the height as needed
+ itemImg.style.marginRight = "10px"; // Adjust margin as needed
+ itemImg.draggable = true; // Enable dragging
+ itemImg.dataset.inventoryID = itemId; // Store item ID as data attribute
+
+ inventorySection.appendChild(itemImg);
+ }
+ // END OF DISPLAY OF INVENTORY
+
+
+
+
+ var flexContainer = document.querySelector('.flex-container');
+
+ // IF ARMOR IS EQUIPPED, ADD TO EQUIPPED GEAR
+ if (data.armorGearIdEquipped != 0) {
+ var flexContainer = document.querySelector('.flex-container');
+ var armorDiv = document.createElement('armorDiv');
+ armorDiv.innerHTML = `
+ Armor
+Weapon
++
Go back to island
"; + } else if (eHealth < 1) { + updateHealthEnemy.innerHTML = `Health: Defeated`; + var myHeaders = new Headers(); + myHeaders.append("Content-Type", "application/json"); + + var requestOptions = { + method: 'POST', + headers: myHeaders, + redirect: 'follow', + credentials: 'include' + }; + //Adding points to the account + fetch(uri + `/api/person/addPoints${course}?points=${totalPoints}`, requestOptions) + .then(response => response.text()) + .then(result => console.log(result)) + .catch(error => console.log('error', error)); + //Re-direct to island + alert.style = ""; + enemyIMG.classList = "death"; + alertBox.innerHTML = "You WonGo back to island
"; + return; + } +} \ No newline at end of file diff --git a/cbscript.js b/cbscript.js new file mode 100644 index 0000000..538050e --- /dev/null +++ b/cbscript.js @@ -0,0 +1,100 @@ +const video = document.getElementById("video"); +const output = document.getElementById("output"); +const assignProfileBtn = document.getElementById("assignProfileBtn"); +const profileImgContainer = document.getElementById("profileImgContainer"); + +let isProfileAssigned = false; +let ageAndGenderData = null; + +Promise.all([ + faceapi.nets.tinyFaceDetector.loadFromUri("models"), + faceapi.nets.faceLandmark68Net.loadFromUri("models"), + faceapi.nets.faceRecognitionNet.loadFromUri("models"), + faceapi.nets.faceExpressionNet.loadFromUri("models"), + faceapi.nets.ageGenderNet.loadFromUri("models"), +]).then(webCam); + +function webCam() { + navigator.mediaDevices + .getUserMedia({ + video: true, + audio: false, + }) + .then((stream) => { + video.srcObject = stream; + }) + .catch((error) => { + console.log(error); + }); +} + +video.addEventListener("play", () => { + const canvas = faceapi.createCanvasFromMedia(video); + document.body.append(canvas); + + faceapi.matchDimensions(canvas, { height: video.height, width: video.width }); + + setInterval(async () => { + const detection = await faceapi + .detectAllFaces(video, new faceapi.TinyFaceDetectorOptions()) + .withFaceLandmarks() + .withFaceExpressions().withAgeAndGender(); + + canvas.getContext("2d").clearRect(0, 0, canvas.width, canvas.height); + + const resizedDetections = faceapi.resizeResults(detection, { + height: video.height, + width: video.width, + }); + + faceapi.draw.drawDetections(canvas, resizedDetections); + faceapi.draw.drawFaceLandmarks(canvas, resizedDetections); + + displayAgeAndGender(resizedDetections); + }, 100); +}); + +function getProfileImage(age, gender) { + let ageRange; + if (age < 18) { + ageRange = "baby_child"; + } else if (age < 60) { + ageRange = "young_adult"; + } else { + ageRange = "elder"; + } + + let genderPrefix = gender === "male" ? "male_" : "female_"; + let profileImage = `images/profilePics/custom/${genderPrefix}${ageRange}.png`; + return profileImage; +} + +function displayAgeAndGender(detections) { + output.innerHTML = ""; + detections.forEach((det) => { + const age = Math.round(det.age); + const gender = det.gender.charAt(0).toUpperCase() + det.gender.slice(1); + const p = document.createElement("p"); + p.textContent = `${age} year old ${gender}`; + output.appendChild(p); + + ageAndGenderData = { age, gender }; + }); +} + +assignProfileBtn.addEventListener("click", () => { + if (ageAndGenderData) { + const { age, gender } = ageAndGenderData; + const profileImage = getProfileImage(age, gender); + renderProfileImage(profileImage); + isProfileAssigned = true; + } +}); + +function renderProfileImage(imageSrc) { + profileImgContainer.innerHTML = ""; + const image = new Image(); + image.src = imageSrc; + image.className = "profileImage"; + profileImgContainer.appendChild(image); +} diff --git a/cc-assistant.html b/cc-assistant.html new file mode 100644 index 0000000..6425b41 --- /dev/null +++ b/cc-assistant.html @@ -0,0 +1,201 @@ +--- +layout: profile +search_exclude: true +permalink: bot +--- + + + + + + + + + + +
+
+
+
+
+Your score is:
+ +Loading...
+Loading...
+Loading...
+Loading...
+Predicted AP Score will appear here
+=n.outWidth||Math.floor(M)!==M))D+=b.get(w,N,_,M,C);}}}y.set(D*x,w,E,R,I,C);}return y.toTensor()},o.prototype.maxPool3d=function(t,e){return Hh(t,"maxPool3d"),this.pool3d(t,e,"max").toFloat()},o.prototype.maxPool3dPositions=function(t,e){for(var n=dr(e.outShape,"int32"),r=e.strideDepth,o=e.strideHeight,a=e.strideWidth,i=e.dilationDepth,s=e.dilationHeight,u=e.dilationWidth,c=e.effectiveFilterDepth,l=e.effectiveFilterHeight,h=e.effectiveFilterWidth,f=e.padInfo.front,d=e.padInfo.top,p=e.padInfo.left,v=this.bufferSync(t),m=0;m=r/o)throw new Error("Invalid indices: "+v+" does not index into "+n);for(var x=0;x