Compare commits

...

2 commits

Author SHA1 Message Date
c127574e51 added queen to drunkdriving 2025-01-31 22:29:44 -06:00
ed47373938 added Drunkdriving effect 2025-01-31 22:28:44 -06:00
7 changed files with 61 additions and 24 deletions

View file

@ -25,12 +25,14 @@ func _init():
# print(id) # print(id)
func can_attach_to_piece(piece: Pawn) -> bool: func can_attach_to_piece(piece: Pawn) -> bool:
# print(unitWhitelist, " | ", piece.name , " | ", unitWhitelist.has(piece.name))
if unitWhitelist.is_empty(): if unitWhitelist.is_empty():
return true return true
return unitWhitelist.has(piece.name) return unitWhitelist.has(piece.name)
func apply_effect(target_piece = null, board_flow = null, game_state = null): func apply_effect(target_piece = null, board_flow = null, game_state = null):
if burned || (target_piece && !can_attach_to_piece(target_piece)): if burned || (target_piece && !can_attach_to_piece(target_piece)):
# print("CARD CANT APPLY AFFECT")
return false return false
remaining_turns = duration remaining_turns = duration
@ -42,7 +44,7 @@ func apply_effect(target_piece = null, board_flow = null, game_state = null):
Rank.RANK_2: pass Rank.RANK_2: pass
Rank.RANK_3: pass Rank.RANK_3: pass
return modify_moves() return true
func update_duration(): func update_duration():
if remaining_turns > 0: if remaining_turns > 0:

View file

@ -1,20 +1,60 @@
class_name DrunkDrivingCard extends Card class_name DrunkDrivingCard extends Card
func _init(): func _init():
super._init() super._init()
# id = Utils.generate_guid()
cardName = "Drunk Driving" cardName = "Drunk Driving"
rank = Rank.RANK_1 rank = Rank.RANK_1
duration = 1
effectType = EffectType.SPECIAL_ACTION effectType = EffectType.SPECIAL_ACTION
description = "Force Rook to move to opposite end" description = "Force peice to careen towards the enemy side, capturing all pieces in its path"
unitWhitelist = ["Rook"] # Can only be attached to Rooks unitWhitelist = ["Rook", "Queen"]
func apply_effect(target_piece = null, board_flow = null, game_state = null): func apply_effect(target_piece = null, board_flow = null, game_state = null):
if !super.apply_effect(target_piece, board_flow, game_state): if !super.apply_effect(target_piece, board_flow, game_state):
print("FAILED DEFAULT FN")
return false return false
if target_piece: if !target_piece or !board_flow or !game_state:
var current_pos = target_piece.get_parent().name.split("-") print("FAILED DEFAULT FN 2")
var target_x = current_pos[0] return false
var target_y = "0" if target_piece.Item_Color == 0 else "7"
return [target_x + "-" + target_y]
return false var current_pos = target_piece.get_parent().name.split("-")
var current_x = int(current_pos[0])
var current_y = int(current_pos[1])
var target_y = 7 if target_piece.Item_Color == 1 else 0
var y_direction = 1 if target_y > current_y else -1
var tiles_to_check = []
var y = current_y + y_direction
while y != target_y + y_direction:
tiles_to_check.append(str(current_x) + "-" + str(y))
y += y_direction
for tile_name in tiles_to_check:
var tile = board_flow.get_node(tile_name)
if tile.get_child_count() > 0:
var piece_to_capture = tile.get_child(0)
game_state.updatePoints(piece_to_capture)
piece_to_capture.queue_free()
var final_tile = board_flow.get_node(str(current_x) + "-" + str(target_y))
target_piece.reparent(final_tile)
target_piece.position = Vector2(25, 25)
game_state.currentlyMovingPiece = target_piece
burned = true
game_state.resolveMoveEffects();
game_state.stateMachine.transitionToNextState(Constants.POST_MOVE)
return true

View file

@ -2,12 +2,11 @@ class_name HopscotchCard extends Card
func _init(): func _init():
super._init() super._init()
# id = Utils.generate_guid()
cardName = "HopScotch" cardName = "HopScotch"
rank = Rank.RANK_0 rank = Rank.RANK_0
effectType = EffectType.MOVEMENT_MODIFIER effectType = EffectType.MOVEMENT_MODIFIER
description = "Peice can move 5 times per turn" description = "Peice can move 5 times per turn"
duration = 2 # Lasts for 2 turns duration = 2
unitWhitelist = [] unitWhitelist = []
func modify_moves() -> Dictionary: func modify_moves() -> Dictionary:

View file

@ -3,7 +3,7 @@ class_name DeckManager
const DoubleTimeCard = preload("res://Systems/Cards/Doubletime.gd") const DoubleTimeCard = preload("res://Systems/Cards/Doubletime.gd")
const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd") const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd")
const DrunkDrivingCard = preload("res://Systems/Cards/Drunkdriving.gd")
var deck: Array = [] var deck: Array = []
var hand: Array = [] var hand: Array = []
@ -24,8 +24,9 @@ func _init():
func initializeStartingDeck(): func initializeStartingDeck():
deck.clear(); deck.clear();
for i in range(4): for i in range(3):
deck.append(DoubleTimeCard.new()) deck.append(DoubleTimeCard.new())
deck.append(DrunkDrivingCard.new())
deck.append(HopscotchCard.new()) deck.append(HopscotchCard.new())
shuffleDeck() shuffleDeck()
drawStartingHand() drawStartingHand()
@ -64,6 +65,7 @@ signal hand_updated
func playCard(card: Card, target_piece: Pawn, board_flow = null, game_state = null): func playCard(card: Card, target_piece: Pawn, board_flow = null, game_state = null):
if !hand.has(card): if !hand.has(card):
# print("Failed Play Card 1")
return false return false
if card.duration > 0: if card.duration > 0:
attached_cards[target_piece.get_instance_id()] = card attached_cards[target_piece.get_instance_id()] = card
@ -76,6 +78,7 @@ func playCard(card: Card, target_piece: Pawn, board_flow = null, game_state = nu
return true return true
# print("Failed Play Card 2")
return false return false
func updateCardDurations(): func updateCardDurations():

View file

@ -258,14 +258,6 @@ func applyTileEffects() -> void:
if tile.has_effect(): if tile.has_effect():
tile.apply_effect(piece) tile.apply_effect(piece)
func attachSelectedCards() -> void:
# Logic for attaching selected cards to pieces
var selectedCard = cardDisplay.getSelectedCard()
if selectedCard and selectedNode:
var piece = get_node("Flow/" + selectedNode).get_child(0)
if piece and selectedCard.can_attach_to_piece(piece) and !deckManager.attached_cards.has(get_instance_id()):
deckManager.playCard(selectedCard, piece, boardContainer, self)
func applyCardEffects() -> void: func applyCardEffects() -> void:
pass pass

View file

@ -13,11 +13,13 @@ func _ready() -> void:
func enter(_previous: String, _data := {}) -> void: func enter(_previous: String, _data := {}) -> void:
print("ENTERING STATE ", Constants.ATTACH_CARDS) print("ENTERING STATE ", Constants.ATTACH_CARDS)
if(game.currentPlayer == game.BLACK):
_on_timer_timeout()
if !game.boardContainer.is_connected("tile_pressed", handleTilePressed): if !game.boardContainer.is_connected("tile_pressed", handleTilePressed):
game.boardContainer.connect("tile_pressed", handleTilePressed) game.boardContainer.connect("tile_pressed", handleTilePressed)
timer.start(ATTACHMENT_PHASE_DURATION) timer.start(ATTACHMENT_PHASE_DURATION)
if game.deckManager.hand.is_empty() or (game.currentPlayer == game.BLACK): if game.deckManager.hand.is_empty():
complete_attachment_phase() complete_attachment_phase()
func exit() -> void: func exit() -> void:

View file

@ -42,7 +42,6 @@ func _init() -> void:
add_child(duration_label) add_child(duration_label)
duration_label.hide() duration_label.hide()
func update_appearance() -> void: func update_appearance() -> void:
# print("update_appearance") # print("update_appearance")
if !is_instance_valid(get_tree()) || !get_tree().get_root().has_node("Board"): if !is_instance_valid(get_tree()) || !get_tree().get_root().has_node("Board"):