hand logic in own scene, cpu skeleton
This commit is contained in:
@@ -15,10 +15,7 @@ var shield_active = true;
|
||||
var move_direction = Vector2.ZERO;
|
||||
var target = Vector2.ZERO # The position of the player's cursor.
|
||||
|
||||
const drawpile = [];
|
||||
@export var hand = [];
|
||||
const discard_pile = [];
|
||||
var active_card_index = -1;
|
||||
@export var hand;
|
||||
|
||||
var screen_size # Size of the game window.
|
||||
var action_state = ActionState.None
|
||||
@@ -68,32 +65,13 @@ func charge():
|
||||
charge_level = max(charge_level - charge_rate * 2, 0);
|
||||
|
||||
func dash():
|
||||
var card = hand.get(active_card_index);
|
||||
var card = hand.get_active_card();
|
||||
if not card or dash_on_cooldown:
|
||||
return;
|
||||
|
||||
card.discard(self); # Must set move_state at start and end of dash
|
||||
hand.discard(self); # Must set move_state at start and end of dash
|
||||
dash_on_cooldown = true;
|
||||
|
||||
func play_card():
|
||||
if active_card_index >= 0 and active_card_index < hand.size():
|
||||
var card = hand[active_card_index];
|
||||
card.play(self);
|
||||
|
||||
func cycle_card(index_shift):
|
||||
if hand.size() > 0:
|
||||
active_card_index = (active_card_index + index_shift) % hand.size();
|
||||
else:
|
||||
draw_card();
|
||||
|
||||
func discard_active_card():
|
||||
if active_card_index >= 0 and active_card_index < hand.size():
|
||||
var card = hand[active_card_index];
|
||||
discard_pile.append(card);
|
||||
hand.remove_at(active_card_index);
|
||||
active_card_index = min(active_card_index, hand.size() - 1);
|
||||
draw_card();
|
||||
|
||||
func draw_card():
|
||||
if drawpile.size() == 0:
|
||||
shuffle_deck();
|
||||
@@ -103,14 +81,6 @@ func draw_card():
|
||||
if active_card_index == -1:
|
||||
active_card_index = 0;
|
||||
|
||||
# TODO: Reboot mechanics
|
||||
func shuffle_deck():
|
||||
for card in discard_pile:
|
||||
drawpile.append(card);
|
||||
discard_pile.clear();
|
||||
drawpile.shuffle();
|
||||
active_card_index = 0;
|
||||
|
||||
func _ready():
|
||||
screen_size = get_viewport_rect().size
|
||||
while (hand.size() < hand_size and drawpile.size() > 0):
|
||||
@@ -141,14 +111,3 @@ func _process(delta):
|
||||
move_state = MoveState.Still;
|
||||
|
||||
move_and_slide();
|
||||
|
||||
# Handle action_state
|
||||
if Input.is_action_pressed("play_card"):
|
||||
play_card();
|
||||
|
||||
if Input.is_action_just_pressed("cycle_card_left"):
|
||||
action_state = ActionState.Cycling;
|
||||
cycle_card(-1);
|
||||
elif Input.is_action_just_pressed("cycle_card_right"):
|
||||
action_state = ActionState.Cycling;
|
||||
cycle_card(1);
|
||||
|
||||
Reference in New Issue
Block a user