Skip to content

Commit

Permalink
Merge branch 'main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
dusek2 authored Mar 26, 2024
2 parents 46caca8 + b69d9c8 commit 752d07e
Show file tree
Hide file tree
Showing 35 changed files with 1,862 additions and 6 deletions.
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingArm.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://btc7drbnqg4ut"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_v7fc7"]

[resource]
script = ExtResource("1_v7fc7")
name = "Testing Arms"
itemType = 1
equipLocation = 2
damage = 0
healthBonus = 3
defenseBonus = 3
magicBonus = 3
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingChest.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://dxg7ymgixgo1h"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_b50x6"]

[resource]
script = ExtResource("1_b50x6")
name = "Testing Chest"
itemType = 1
equipLocation = 1
damage = 0
healthBonus = 10
defenseBonus = 10
magicBonus = 10
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingHelmet.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://u7ftew2fk1qq"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_e0vbw"]

[resource]
script = ExtResource("1_e0vbw")
name = "Testing Helmet"
itemType = 1
equipLocation = 0
damage = 0
healthBonus = 5
defenseBonus = 5
magicBonus = 5
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingHelmet2.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://cgd71ihob6xnu"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_xpd8c"]

[resource]
script = ExtResource("1_xpd8c")
name = "Testing Helmet2"
itemType = 1
equipLocation = 0
damage = 0
healthBonus = 7
defenseBonus = 2
magicBonus = 6
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingLeg.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://b3n0yao3ojbfb"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_pfysm"]

[resource]
script = ExtResource("1_pfysm")
name = "Testing Legs"
itemType = 1
equipLocation = 4
damage = 0
healthBonus = 2
defenseBonus = 2
magicBonus = 2
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingShoes.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://dfric3nfcx62q"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_nipv1"]

[resource]
script = ExtResource("1_nipv1")
name = "Testing Shoes"
itemType = 1
equipLocation = 5
damage = 0
healthBonus = 1
defenseBonus = 1
magicBonus = 1
13 changes: 13 additions & 0 deletions Game/LifeQuest/Items/TestingSword.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[gd_resource type="Resource" script_class="ItemResource" load_steps=2 format=3 uid="uid://dro5g6dmh7e31"]

[ext_resource type="Script" path="res://Scripts/Items/item.gd" id="1_4nbc1"]

[resource]
script = ExtResource("1_4nbc1")
name = "Testing Sword"
itemType = 1
equipLocation = 3
damage = 5
healthBonus = 0
defenseBonus = 0
magicBonus = 6
38 changes: 38 additions & 0 deletions Game/LifeQuest/Managers/ItemDatabase.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
extends Node

var items = Array()

func _ready():
#open the resource script in directory
var directory = DirAccess.open("res://Items")
directory.list_dir_begin()

var filename = directory.get_next()
#add all the item resources to the item array
while (filename):
if not directory.current_is_dir():
items.append(load("res://Items/%s" % filename))
filename = directory.get_next()

#loop through all items and return item if found
func get_item(item_name):
for i in items:
if i.name == item_name:
return i
return null

#loop through all items and return items of that type
func get_item_type(item_type):
var foundItems = Array()
for i in items:
if i.itemType == item_type:
foundItems.append(i)
return foundItems

#returns array of items that belong that that equipment type
func get_equip_type(equip_type):
var foundItems = Array()
for i in items:
if i.equipLocation == equip_type:
foundItems.append(i)
return foundItems
13 changes: 13 additions & 0 deletions Game/LifeQuest/Scripts/Items/item.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
extends Resource
class_name ItemResource

@export var name : String
enum ItemType { CONSUMABLE, EQUIPMENT, GENERIC }
enum EquipmentLocation { HEAD, CHEST, ARMS, HANDS, LEGS, FEET}
@export var itemType : ItemType
@export var equipLocation : EquipmentLocation
@export var damage : int = 0
@export var healthBonus : int = 0
@export var defenseBonus : int = 0
@export var magicBonus : int = 0

33 changes: 33 additions & 0 deletions Game/LifeQuest/character_scene.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
extends Node2D

var headPieces = Array()

# Called when the node enters the scene tree for the first time.
func _ready():
update_head_dropdown()
#will be default at index 0
update_head_stats(0)



#preform a get_equip_type call on data base that only returns type HEAD
func update_head_dropdown():
headPieces = ItemDatabase.get_equip_type(0)
#add each result to head optionMenue
for i in headPieces:
$HeadGearStats/HeadSelect.add_item(i.name)

func update_head_stats(index):
var text = "Health: %d" % headPieces[index].healthBonus
$HeadGearStats/Health.set_text(text)
text = "Damage Bonus: %d" % headPieces[index].damage
$HeadGearStats/Damage.set_text(text)
text = "Magic Bonus: %d" % headPieces[index].magicBonus
$HeadGearStats/Magic.set_text(text)
text = "Defense: %d" % headPieces[index].defenseBonus
$HeadGearStats/Defense.set_text(text)

#when a user selects an option
func _on_head_select_item_selected(index):
update_head_stats(index)

46 changes: 46 additions & 0 deletions Game/LifeQuest/character_scene.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[gd_scene load_steps=3 format=3 uid="uid://f83w1j385c0o"]

[ext_resource type="Script" path="res://character_scene.gd" id="1_emrmp"]
[ext_resource type="Texture2D" uid="uid://cptyomp81xx1f" path="res://tempCharOutline.png" id="1_yabyc"]

[node name="characterScene" type="Node2D"]
position = Vector2(550, 350)
scale = Vector2(0.5, 0.5)
script = ExtResource("1_emrmp")

[node name="BodyModel" type="Sprite2D" parent="."]
texture = ExtResource("1_yabyc")

[node name="HeadGearStats" type="GridContainer" parent="."]
anchors_preset = 8
anchor_left = 0.5
anchor_top = 0.5
anchor_right = 0.5
anchor_bottom = 0.5
offset_left = -24.0
offset_top = -580.0
offset_right = 49.0
offset_bottom = -452.0
grow_horizontal = 2
grow_vertical = 2

[node name="HeadSelect" type="OptionButton" parent="HeadGearStats"]
layout_mode = 2

[node name="Health" type="Label" parent="HeadGearStats"]
layout_mode = 2
text = "Health: "

[node name="Damage" type="Label" parent="HeadGearStats"]
layout_mode = 2
text = "Damage: "

[node name="Magic" type="Label" parent="HeadGearStats"]
layout_mode = 2
text = "Magic: "

[node name="Defense" type="Label" parent="HeadGearStats"]
layout_mode = 2
text = "Defense: "

[connection signal="item_selected" from="HeadGearStats/HeadSelect" to="." method="_on_head_select_item_selected"]
4 changes: 4 additions & 0 deletions Game/LifeQuest/project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ run/main_scene="res://main.tscn"
config/features=PackedStringArray("4.2", "GL Compatibility")
config/icon="res://icon.svg"

[autoload]

ItemDatabase="*res://Managers/ItemDatabase.gd"

[rendering]

renderer/rendering_method="gl_compatibility"
Expand Down
Binary file added Game/LifeQuest/tempCharOutline.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions Game/LifeQuest/tempCharOutline.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cptyomp81xx1f"
path="res://.godot/imported/tempCharOutline.png-da1471d592e63cb08ba099150ad056e4.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://tempCharOutline.png"
dest_files=["res://.godot/imported/tempCharOutline.png-da1471d592e63cb08ba099150ad056e4.ctex"]

[params]

compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
compress/hdr_compression=1
compress/normal_map=0
compress/channel_pack=0
mipmaps/generate=false
mipmaps/limit=-1
roughness/mode=0
roughness/src_normal=""
process/fix_alpha_border=true
process/premult_alpha=false
process/normal_map_invert_y=false
process/hdr_as_srgb=false
process/hdr_clamp_exposure=false
process/size_limit=0
detect_3d/compress_to=1
6 changes: 4 additions & 2 deletions app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@
"@types/node": "^16.11.14",
"@types/react": "^18.0.28",
"@types/react-dom": "^18.0.11",
"axios": "^1.6.8",
"cors": "^2.8.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.2.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4",
"react-router-dom": "^6.2.1"
"web-vitals": "^2.1.4"
},
"scripts": {
"start": "react-scripts start",
Expand Down
2 changes: 2 additions & 0 deletions app/src/components/PageContent.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ const PageContent = ({
className={styles.pageContent}
id="page_content"
style={pageContentStyle}
data-testid="page-content" // testing purpose

/>
);
};
Expand Down
45 changes: 41 additions & 4 deletions app/src/pages/Login.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,51 @@
import styles from "./Login.css"
import React, { useState } from 'react';
import axios from "axios"
import { useState } from 'react';
import { useNavigate } from "react-router-dom";

const Login = () => {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const navigate = useNavigate()

const sendSubmit = (foo) => {
async function sendSubmit(foo) {

foo.preventDefault();
console.log(email);
console.log(password);

try{
axios.defaults.baseURL = 'http://localhost:9000';

await axios.get('/login')
.then(function (response) {
// handle success
console.log(response);
})
.catch(function (error) {
// handle error
console.log(error);
})
.finally(function () {
// always executed
});

//Login, needs to be tested
/*
await axios.post("http//localhost:9000/login",{
email, password
})
.then(result => {
console.log(result)
if(result.data === "Success") {
navigate('/home')
}
})
.catch(err => console.log(err))
*/
}
catch(foo){
console.log(foo)
}

}

return (
Expand Down
33 changes: 33 additions & 0 deletions app/src/tests/BackButtonIcon.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import '@testing-library/jest-dom';
import BackButtonIcon from '../components/BackButtonIcon';

describe('BackButtonIcon', () => {
it('renders the icon', () => {
render(
<BackButtonIcon
groupIconWidth="50px"
groupIconHeight="50px"
groupIconPosition="absolute"
groupIconTop="10px"
groupIconRight="20px"
groupIconBottom="30px"
groupIconLeft="40px"
groupIconMaxHeight="100%"
/>
);
const icon = screen.getByRole('img');
expect(icon).toHaveAttribute('src', '/group.svg');
expect(icon).toHaveStyle({
width: '50px',
height: '50px',
position: 'absolute',
top: '10px',
right: '20px',
bottom: '30px',
left: '40px',
maxHeight: '100%',
});
});
});
Loading

0 comments on commit 752d07e

Please sign in to comment.