Skip to content

Commit

Permalink
Shop (#137)
Browse files Browse the repository at this point in the history
* Add shop Scene

* Allow card removal and buying cards
  • Loading branch information
JonaLam authored Dec 21, 2024
1 parent 3434537 commit fca8bb6
Show file tree
Hide file tree
Showing 32 changed files with 671 additions and 32 deletions.
124 changes: 97 additions & 27 deletions #Scenes/Events/shop/0.tscn
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
[gd_scene load_steps=4 format=3 uid="uid://b8hbst1klk5ng"]
[gd_scene load_steps=8 format=3 uid="uid://b8hbst1klk5ng"]

[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="1_7gwvp"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/ShopScene.gd" id="1_u1m6k"]
[ext_resource type="Script" path="res://#Scenes/Events/skipEventButton.gd" id="2_owx5q"]
[ext_resource type="PackedScene" uid="uid://cdt4k2reymt2i" path="res://Shop/shop_item_card.tscn" id="4_bbct0"]
[ext_resource type="Texture2D" uid="uid://c6fmkrnbs4mf6" path="res://Art/Background/0-0.test.CatTree.png" id="6_ppjdl"]
[ext_resource type="PackedScene" uid="uid://tfeo4epmhse0" path="res://Shop/shop_item_torch.tscn" id="11_3t8vb"]
[ext_resource type="Script" path="res://#Scenes/SceneScripts/CardRemoval.gd" id="12_1uxnd"]
[ext_resource type="Texture2D" uid="uid://dd06ocktximw7" path="res://Art/Menus/Trash-1.png" id="12_yofyg"]

[node name="Control" type="Control"]
layout_mode = 3
Expand All @@ -13,32 +17,98 @@ grow_horizontal = 2
grow_vertical = 2
script = ExtResource("1_u1m6k")

[node name="TextEdit" type="TextEdit" parent="."]
layout_mode = 0
offset_right = 1276.0
offset_bottom = 715.0
theme_override_font_sizes/font_size = 100
placeholder_text = "This is a placeholder
shop event"

[node name="TopBarOverlay" parent="." instance=ExtResource("1_7gwvp")]
layout_mode = 1

[node name="SkipEventButton" type="Button" parent="."]
[node name="ShopItems" type="Control" parent="."]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0

[node name="ShopItemTorch" parent="ShopItems" instance=ExtResource("11_3t8vb")]
offset_left = 835.0
offset_top = 116.0
offset_right = 835.0
offset_bottom = 116.0
amount = 5

[node name="Card" type="Control" parent="ShopItems"]
anchors_preset = 0
offset_right = 40.0
offset_bottom = 40.0

[node name="ShopItemCard" parent="ShopItems/Card" instance=ExtResource("4_bbct0")]
offset_left = 1111.0
offset_top = 496.0
offset_right = 1111.0
offset_bottom = 496.0
scale = Vector2(0.5, 0.5)

[node name="ShopItem" parent="ShopItems/Card" instance=ExtResource("4_bbct0")]
offset_left = 648.0
offset_top = 476.0
offset_right = 648.0
offset_bottom = 476.0
scale = Vector2(0.5, 0.5)

[node name="ShopItem2" parent="ShopItems/Card" instance=ExtResource("4_bbct0")]
offset_left = 891.0
offset_top = 486.0
offset_right = 891.0
offset_bottom = 486.0
scale = Vector2(0.5, 0.5)

[node name="CardRemoval" type="TextureButton" parent="ShopItems"]
layout_mode = 1
anchors_preset = 3
anchor_left = 1.0
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_left = -280.0
offset_top = -220.0
offset_right = -80.0
offset_bottom = -140.0
grow_horizontal = 0
grow_vertical = 0
theme_override_font_sizes/font_size = 26
text = "Skip this event"
script = ExtResource("2_owx5q")

[connection signal="pressed" from="SkipEventButton" to="SkipEventButton" method="_on_pressed"]
anchors_preset = -1
anchor_left = 1.00078
anchor_right = 1.00078
offset_left = 731.966
offset_top = 769.0
offset_right = 791.966
offset_bottom = 829.0
scale = Vector2(2.92, 2.92)
texture_normal = ExtResource("12_yofyg")
texture_pressed = ExtResource("12_yofyg")
texture_hover = ExtResource("12_yofyg")
texture_disabled = ExtResource("12_yofyg")
texture_focused = ExtResource("12_yofyg")
stretch_mode = 0
script = ExtResource("12_1uxnd")

[node name="CardRemoval" type="Control" parent="ShopItems/CardRemoval"]
anchors_preset = 0
offset_left = -27.0
offset_top = -11.0
offset_right = -27.0
offset_bottom = -11.0

[node name="ColorRect" type="ColorRect" parent="ShopItems/CardRemoval/CardRemoval"]
layout_mode = 0
offset_left = 23.5753
offset_top = 76.7534
offset_right = 86.5753
offset_bottom = 100.753

[node name="Label" type="Label" parent="ShopItems/CardRemoval/CardRemoval/ColorRect"]
layout_mode = 0
offset_left = -0.109672
offset_top = 0.602746
offset_right = 61.8903
offset_bottom = 23.6027
scale = Vector2(0.998719, 1.01696)
theme_override_colors/font_color = Color(0, 0, 0, 1)
text = "100"
horizontal_alignment = 1
vertical_alignment = 1

[node name="BackGround" type="TextureRect" parent="."]
z_index = -1
layout_mode = 0
offset_left = -53.0
offset_top = 10.0
offset_right = 1960.0
offset_bottom = 1111.0
mouse_filter = 2
texture = ExtResource("6_ppjdl")
expand_mode = 1
23 changes: 23 additions & 0 deletions #Scenes/SceneScripts/CardRemoval.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
extends CardPileUISetter

@onready var priceText : Label = $CardRemoval/ColorRect/Label
@onready var sceneRoot : Node = $"../.."

func _ready() -> void:
priceText.text = str(ShopManager.card_removal_price)
super()

func _pressed() -> void:
if(!InventoryManager.gold_component.can_afford(ShopManager.card_removal_price)):
return


var uiPile: Control = cardUI.instantiate()

uiPile.populate(get_name())
sceneRoot.add_child(uiPile)
queue_free()

func _on_button_pressed() -> void:

pass
17 changes: 17 additions & 0 deletions #Scenes/SceneScripts/ShopScene.gd
Original file line number Diff line number Diff line change
@@ -1,4 +1,21 @@
extends Control
class_name ShopScene

func _ready() -> void:

# This code has to happen after the map has done '.on_event_started' [br]
# so I just put a .1 delay on it
var timer : SceneTreeTimer = get_tree().create_timer(0.1)
timer.timeout.connect(_on_start_with_delay)


## This code has to happen after the map has done '.on_event_started' [br]
## so I just put a .1 delay on it
func _on_start_with_delay() -> void:
SaveManager.execute_save()

if(PlayerManager.player_room != null):
PlayerManager.player_room.room_event.on_event_ended()

func _stock_shop() -> void:
pass
4 changes: 2 additions & 2 deletions #Scenes/TestingScene.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
[ext_resource type="Texture2D" uid="uid://caemucaya30wh" path="res://Art/Card_layout/draw_pile.png" id="11_pw70x"]
[ext_resource type="Texture2D" uid="uid://d4muqvs3etnr8" path="res://Art/Card_layout/discard_pile.png" id="12_kxw48"]
[ext_resource type="Script" path="res://UI/EndTurnButton.gd" id="14_dpe64"]
[ext_resource type="PackedScene" path="res://#Scenes/TopBarOverlay.tscn" id="14_e54tj"]
[ext_resource type="PackedScene" uid="uid://bam77cwf4emyr" path="res://#Scenes/TopBarOverlay.tscn" id="14_e54tj"]
[ext_resource type="Script" path="res://UI/EnergyLabel.gd" id="14_nckre"]
[ext_resource type="Resource" path="res://Items/test_relic.tres" id="19_prw12"]
[ext_resource type="Resource" uid="uid://c5fh7bnfh3l4u" path="res://Items/test_relic.tres" id="19_prw12"]
[ext_resource type="Texture2D" uid="uid://bl5v3bgnntoc5" path="res://Art/Card_layout/energy_count.png" id="19_spyxg"]

[sub_resource type="GDScript" id="GDScript_g5yv1"]
Expand Down
Binary file added Art/Background/0-0.test.CatTree.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 Art/Background/0-0.test.CatTree.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://c6fmkrnbs4mf6"
path="res://.godot/imported/0-0.test.CatTree.png-85c2a2ddf3b5a611c2c6d4f74b8e8a51.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Background/0-0.test.CatTree.png"
dest_files=["res://.godot/imported/0-0.test.CatTree.png-85c2a2ddf3b5a611c2c6d4f74b8e8a51.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
Binary file added Art/Menus/Torch-1.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 Art/Menus/Torch-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://q8og304npj17"
path="res://.godot/imported/Torch-1.png-83e2f1112a740f117332d625f3e72da4.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Torch-1.png"
dest_files=["res://.godot/imported/Torch-1.png-83e2f1112a740f117332d625f3e72da4.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
Binary file added Art/Menus/Trash-1.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 Art/Menus/Trash-1.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dd06ocktximw7"
path="res://.godot/imported/Trash-1.png-ce07c71134e16d0aecc8b7d0db00fb11.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://Art/Menus/Trash-1.png"
dest_files=["res://.godot/imported/Trash-1.png-ce07c71134e16d0aecc8b7d0db00fb11.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
10 changes: 10 additions & 0 deletions Cards/CardWorld.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@ func init_card(in_card_data: CardBase) -> void:
card_cast_type = GlobalEnums.CardCastType.TARGET
break

## takes money and increases price of shop removal, should only be used when this is wanted
func remove_this_from_player_deck_with_price() -> void:
if(!InventoryManager.gold_component.can_afford(ShopManager.card_removal_price)):
return

ShopManager.remove_card_from_player_deck_with_price(card_data)

## this should be used most of the time we want to take a card from the player
func remove_this_from_player_deck_without_price() -> void:
ShopManager.remove_card_from_player_deck_without_price(card_data)

func _on_phase_changed(new_phase: GlobalEnums.CombatPhase, _old_phase: GlobalEnums.CombatPhase) -> void:
# enable clicks on card only if player is in attack phase
Expand Down
2 changes: 2 additions & 0 deletions Cards/Resource/Test Cards/Card_Energy.tres
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ energy_cost = 2
script = ExtResource("3_opvsg")
application_type = 0
card_title = "Gain 70 energy"
card_type = 0
card_description = "Gain 70 energy"
card_artist_name = "NULL"
card_effects_data = Array[ExtResource("2_dr7f0")]([SubResource("Resource_6gvxm")])
energy_info = SubResource("Resource_1hn6q")
3 changes: 3 additions & 0 deletions Global/DEBUG_VAR.gd
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ const DEBUG_ACTIVE_INVENTORY_DEBUG_BUTTONS : bool = false
## TO BE REMOVED after implmentation
const DEBUG_PRINT_EVENT_COUNT : bool = false

## Makes player start with a lot of gold
const DEBUG_START_WITH_A_LOT_OF_GOLD : bool = false

## Used in tests to use the same enemy group all the time
## It can't be a const because we change it inside the tests
var DEBUG_USE_TEST_ENEMY_GROUP: bool = false
10 changes: 10 additions & 0 deletions Items/test_consumable_2.tres
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[gd_resource type="Resource" script_class="Consumable" load_steps=2 format=3 uid="uid://qclftsxybsw"]

[ext_resource type="Script" path="res://Items/Consumable.gd" id="1_5ygqd"]

[resource]
resource_name = "Amoogus"
script = ExtResource("1_5ygqd")
name = "Golden apple"
description = "But she eated it"
image_path = "res://Art/Card_art/default_art.png"
2 changes: 1 addition & 1 deletion Items/test_relic.tres
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
script = ExtResource("1_pjxtd")
name = "Defualt Icon"
description = "test_desc"
sprite_path = "res://icon.svg"
sprite_path = "res://addons/gut/icon.png"
8 changes: 8 additions & 0 deletions Managers/InventoryManager.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ var relic_component : InventoryRelicComponent = InventoryRelicComponent.new()
var inventory_HUD : PackedScene = preload("res://InventoryComponents/InventoryHUD/inventory_hud.tscn")
var instanced_inventory_HUD : Node

func _ready() -> void:
if(DebugVar.DEBUG_START_WITH_A_LOT_OF_GOLD):
gold_component.add_gold(999999999)

func instance_inventory_HUD() -> void:
instanced_inventory_HUD = inventory_HUD.instantiate()
get_tree().current_scene.add_child(instanced_inventory_HUD)
Expand Down Expand Up @@ -43,6 +47,10 @@ func subtract_torch() -> void:
func init_data() -> void:
close_inventory_HUD()
gold_component = InventoryGoldComponent.new()

if(DebugVar.DEBUG_START_WITH_A_LOT_OF_GOLD):
gold_component.add_gold(999999999)

torch_component = InventoryTorchComponent.new()
consumable_component = InventoryConsumablesComponent.new()
relic_component = InventoryRelicComponent.new()
Expand Down
7 changes: 6 additions & 1 deletion Managers/RandomGenerator.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@ extends Node
# Set this to a value other than -1 to have deterministic randomness.
# Make sure to set back to -1 when done testing!
const GAME_SEED = -1

var randomNumberGenerator : RandomNumberGenerator

func _ready() -> void:
set_game_seed(GAME_SEED)
randomNumberGenerator = RandomNumberGenerator.new()
randomNumberGenerator.seed = GAME_SEED


func set_game_seed(given_seed: int = -1) -> void:
Expand All @@ -18,3 +20,6 @@ func set_game_seed(given_seed: int = -1) -> void:
seed(set_seed)

print("Seed set to: " + str(set_seed))

func get_random_int(min: int, max: int) -> int:
return randomNumberGenerator.randi_range(min, max)
Loading

0 comments on commit fca8bb6

Please sign in to comment.