added Drunkdriving effect
This commit is contained in:
parent
401eb696bd
commit
ed47373938
7 changed files with 61 additions and 24 deletions
|
|
@ -25,12 +25,14 @@ func _init():
|
|||
# print(id)
|
||||
|
||||
func can_attach_to_piece(piece: Pawn) -> bool:
|
||||
# print(unitWhitelist, " | ", piece.name , " | ", unitWhitelist.has(piece.name))
|
||||
if unitWhitelist.is_empty():
|
||||
return true
|
||||
return unitWhitelist.has(piece.name)
|
||||
|
||||
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||
if burned || (target_piece && !can_attach_to_piece(target_piece)):
|
||||
# print("CARD CANT APPLY AFFECT")
|
||||
return false
|
||||
|
||||
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_3: pass
|
||||
|
||||
return modify_moves()
|
||||
return true
|
||||
|
||||
func update_duration():
|
||||
if remaining_turns > 0:
|
||||
|
|
|
|||
|
|
@ -1,20 +1,60 @@
|
|||
class_name DrunkDrivingCard extends Card
|
||||
|
||||
func _init():
|
||||
super._init()
|
||||
# id = Utils.generate_guid()
|
||||
cardName = "Drunk Driving"
|
||||
rank = Rank.RANK_1
|
||||
duration = 1
|
||||
effectType = EffectType.SPECIAL_ACTION
|
||||
description = "Force Rook to move to opposite end"
|
||||
unitWhitelist = ["Rook"] # Can only be attached to Rooks
|
||||
description = "Force Rook to careen towards the enemy side, capturing all pieces in its path"
|
||||
unitWhitelist = ["Rook"]
|
||||
|
||||
func apply_effect(target_piece = null, board_flow = null, game_state = null):
|
||||
if !super.apply_effect(target_piece, board_flow, game_state):
|
||||
print("FAILED DEFAULT FN")
|
||||
return false
|
||||
|
||||
if target_piece:
|
||||
var current_pos = target_piece.get_parent().name.split("-")
|
||||
var target_x = current_pos[0]
|
||||
var target_y = "0" if target_piece.Item_Color == 0 else "7"
|
||||
return [target_x + "-" + target_y]
|
||||
if !target_piece or !board_flow or !game_state:
|
||||
print("FAILED DEFAULT FN 2")
|
||||
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
|
||||
|
|
@ -2,12 +2,11 @@ class_name HopscotchCard extends Card
|
|||
|
||||
func _init():
|
||||
super._init()
|
||||
# id = Utils.generate_guid()
|
||||
cardName = "HopScotch"
|
||||
rank = Rank.RANK_0
|
||||
effectType = EffectType.MOVEMENT_MODIFIER
|
||||
description = "Peice can move 5 times per turn"
|
||||
duration = 2 # Lasts for 2 turns
|
||||
duration = 2
|
||||
unitWhitelist = []
|
||||
|
||||
func modify_moves() -> Dictionary:
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ class_name DeckManager
|
|||
|
||||
const DoubleTimeCard = preload("res://Systems/Cards/Doubletime.gd")
|
||||
const HopscotchCard = preload("res://Systems/Cards/Hopscotch.gd")
|
||||
|
||||
const DrunkDrivingCard = preload("res://Systems/Cards/Drunkdriving.gd")
|
||||
|
||||
var deck: Array = []
|
||||
var hand: Array = []
|
||||
|
|
@ -24,8 +24,9 @@ func _init():
|
|||
|
||||
func initializeStartingDeck():
|
||||
deck.clear();
|
||||
for i in range(4):
|
||||
for i in range(3):
|
||||
deck.append(DoubleTimeCard.new())
|
||||
deck.append(DrunkDrivingCard.new())
|
||||
deck.append(HopscotchCard.new())
|
||||
shuffleDeck()
|
||||
drawStartingHand()
|
||||
|
|
@ -64,6 +65,7 @@ signal hand_updated
|
|||
|
||||
func playCard(card: Card, target_piece: Pawn, board_flow = null, game_state = null):
|
||||
if !hand.has(card):
|
||||
# print("Failed Play Card 1")
|
||||
return false
|
||||
if card.duration > 0:
|
||||
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
|
||||
# print("Failed Play Card 2")
|
||||
return false
|
||||
|
||||
func updateCardDurations():
|
||||
|
|
|
|||
|
|
@ -258,14 +258,6 @@ func applyTileEffects() -> void:
|
|||
if tile.has_effect():
|
||||
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:
|
||||
pass
|
||||
|
|
|
|||
|
|
@ -13,11 +13,13 @@ func _ready() -> void:
|
|||
|
||||
func enter(_previous: String, _data := {}) -> void:
|
||||
print("ENTERING STATE ", Constants.ATTACH_CARDS)
|
||||
if(game.currentPlayer == game.BLACK):
|
||||
_on_timer_timeout()
|
||||
if !game.boardContainer.is_connected("tile_pressed", handleTilePressed):
|
||||
game.boardContainer.connect("tile_pressed", handleTilePressed)
|
||||
|
||||
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()
|
||||
|
||||
func exit() -> void:
|
||||
|
|
|
|||
|
|
@ -42,7 +42,6 @@ func _init() -> void:
|
|||
add_child(duration_label)
|
||||
duration_label.hide()
|
||||
|
||||
|
||||
func update_appearance() -> void:
|
||||
# print("update_appearance")
|
||||
if !is_instance_valid(get_tree()) || !get_tree().get_root().has_node("Board"):
|
||||
|
|
|
|||
Loading…
Reference in a new issue