starting post game structure

This commit is contained in:
2ManyProjects 2025-03-10 15:43:07 -05:00
parent 6e5272e37d
commit 78098b1a69
8 changed files with 55 additions and 22 deletions

View file

@ -22,6 +22,9 @@ func _init():
initializeStartingDeck()
# initializeStartingBank()
func set_hand_size(size: int):
hand_size = size
func initializeStartingDeck():
deck.clear();
# for i in range(2):

View file

@ -49,6 +49,7 @@ var has_opponent = true;
@onready var p1String: RichTextLabel = $Player1Points
@onready var p2String: RichTextLabel = $Player2Points
@onready var gold: int = 75
@onready var player: Player
@onready var deckManager: DeckManager
@onready var tileManager: TileManager
@onready var cameraController: CameraController
@ -84,6 +85,7 @@ var boss_turn_index = null
# ===========================================================================
func _ready() -> void:
print("ChessGame _ready() called")
# Only set up paths and window size initially
if OS.get_name() == "Windows":
@ -106,6 +108,7 @@ func _ready() -> void:
call_deferred("initialize_game_system")
turnIndicator.visible = false
deckManager = DeckManager.new()
player = Player.new(85, 2, 0, self)
# 2rnbqkbnr1R/2ppp1pppp2/5p6/75/66/66/66/66/66/66/2PPPPPPPP2/2RNBQKBN3 b KQkq - 0 3
# clear prev wind conditions?
func _on_new_game_requested(options = {}):
@ -772,7 +775,7 @@ func updatePointsAndCapture(capturedPiece: Pawn, animate: bool = true) -> void:
if animate:
animatePieceCapture(capturedPiece)
if Turn == 0: # Player's turn
gold += capturedPiece.Points;
player.add_gold(capturedPiece.Points)
p1Points += capturedPiece.Points
p1String.text = str(p1Points)

View file

@ -524,7 +524,7 @@ func get_node_description(node_data):
func update_gold_display():
var game = get_node_or_null("/root/Board") as ChessGame
if gold_label:
gold_label.text = str(game.gold) + " GOLD"
gold_label.text = str(game.player.get_gold()) + " GOLD"

View file

@ -141,10 +141,9 @@ func _on_shop_open_requested(options):
options = {}
if "gold" in options:
if game and "gold" in game:
options["gold"] = game.gold
else:
options["gold"] = player_gold
options["gold"] = game.player.get_gold()
if mapScreen:
mapScreen.visible = false
if shopScreen:
shopScreen.visible = true
shopScreen.initialize(options)
@ -153,10 +152,7 @@ func _on_shop_open_requested(options):
func _on_shop_back_pressed():
if shopScreen:
shopScreen.visible = false
if game and "gold" in game:
game.gold = shopScreen.player_gold
else:
player_gold = shopScreen.player_gold
game.player.set_gold(shopScreen.player_gold)
# Show game menu again
if not back_to_map and gameMenuScreen:
@ -167,10 +163,7 @@ func _on_shop_back_pressed():
emit_signal("shop_closed")
func _on_shop_card_purchased(card, price):
if game and "gold" in game:
game.gold -= price
else:
player_gold -= price
game.player.remove_gold(price)
# Forward the signal
emit_signal("card_purchased", card, price)
@ -192,10 +185,7 @@ func _on_reward_open_requested(options):
if "gold" in options:
if game and "gold" in game:
options["gold"] = game.gold
else:
options["gold"] = player_gold
options["gold"] = game.player.get_gold()
if rewardScreen:
rewardScreen.visible = true
rewardScreen.initialize(options)

View file

@ -0,0 +1,36 @@
extends Node
class_name Player
var attached_cards: Dictionary = {}
var attached_effects: Dictionary = {}
var hand_size: int = 2
var gold: int = 70
var tokens: int = 0
var game: ChessGame
func _init(g: int, size: int, tok: int, gm: ChessGame):
print("INIT PLAYER CHARACTER")
gold = g
tokens = tok
game = gm
update_deck_hand_size(size)
func update_deck_hand_size(size: int):
hand_size = size
if "deckManager" in game:
game.deckManager.set_hand_size(hand_size)
func get_gold() -> int :
return gold
func add_gold(g: int) -> void :
gold += g
func remove_gold(g: int) -> void :
gold -= g
func set_gold(g: int) -> void :
gold = g

View file

@ -0,0 +1 @@
uid://bulvkisinp2ur

View file

@ -80,8 +80,8 @@ func initialize(options = null):
if options.has("is_escape") and options.is_escape is bool:
is_escape = options.is_escape
if options.has("reward") and options.reward.has("gold") and options.reward.gold is int:
board.gold += options.reward.gold
player_gold = board.gold
board.player.add_gold(options.reward.gold)
player_gold = board.player.get_gold()
if options.has("reward") and options.reward.has("selection_limit") and options.reward.selection_limit is int:
card_selection_limit = options.reward.selection_limit
@ -102,7 +102,7 @@ func initialize(options = null):
if card_preview:
card_preview.hide_preview()
player_gold = board.gold
player_gold = board.player.get_gold()
# Update display
update_gold_display()
populate_carousel()

View file

@ -73,7 +73,7 @@ func initialize(options = null):
player_gold = options.gold
else:
var board = get_node_or_null("/root/Board") as ChessGame
player_gold = board.gold
player_gold = board.player.get_gold()
if options.has("cards") and options.cards is Array:
available_cards = options.cards.duplicate()
if options.has("is_escape") and options.is_escape is bool: