|
|
|
@@ -16,9 +16,12 @@ extends Node2D
|
|
|
|
|
@onready var first_player = $CardManager/Player1PlayPile
|
|
|
|
|
var trump : String
|
|
|
|
|
var rounds_played : int
|
|
|
|
|
var team_1_points :int = 0
|
|
|
|
|
var team_2_points :int = 0
|
|
|
|
|
|
|
|
|
|
const DEAL_PAUSE = 0.5
|
|
|
|
|
|
|
|
|
|
signal dealt
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
trumpbuttons.trump.connect(define_trump.bind())
|
|
|
|
|
player_1_pile.enable_drop_zone = false
|
|
|
|
@@ -41,7 +44,7 @@ func setup_game():
|
|
|
|
|
player_4_hand.allow_movement = true
|
|
|
|
|
|
|
|
|
|
# Deal initial hand
|
|
|
|
|
const DEAL_PAUSE = 0.5
|
|
|
|
|
|
|
|
|
|
var deal_r: int =1
|
|
|
|
|
while true:
|
|
|
|
|
deal_cards_to_hand(3, player_1_hand)
|
|
|
|
@@ -62,142 +65,94 @@ func setup_game():
|
|
|
|
|
|
|
|
|
|
func define_trump(suit : String):
|
|
|
|
|
trump = suit
|
|
|
|
|
turn(first_player)
|
|
|
|
|
play_round()
|
|
|
|
|
|
|
|
|
|
func turn(first):
|
|
|
|
|
func play_round():
|
|
|
|
|
var player = first_player
|
|
|
|
|
rounds_played += 1
|
|
|
|
|
if rounds_played == 10:
|
|
|
|
|
count_points()
|
|
|
|
|
return
|
|
|
|
|
first.sensor_visibility = true
|
|
|
|
|
first.enable_drop_zone = true
|
|
|
|
|
first._redraw_drop_zone()
|
|
|
|
|
await first.played
|
|
|
|
|
first.enable_drop_zone = false
|
|
|
|
|
first._redraw_drop_zone()
|
|
|
|
|
match first:
|
|
|
|
|
var n : int = 1
|
|
|
|
|
while true:
|
|
|
|
|
await turn(player)
|
|
|
|
|
if n == 4:
|
|
|
|
|
break
|
|
|
|
|
match player:
|
|
|
|
|
player_1_pile:
|
|
|
|
|
await get_tree().create_timer(0.2).timeout
|
|
|
|
|
player_1_hand.enable_drop_zone = false
|
|
|
|
|
|
|
|
|
|
player_2_pile.sensor_visibility = true
|
|
|
|
|
player_2_pile.enable_drop_zone = true
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
await player_2_pile.played
|
|
|
|
|
player_2_pile.enable_drop_zone = false
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
await get_tree().create_timer(0.2).timeout
|
|
|
|
|
player_2_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_3_pile.sensor_visibility = true
|
|
|
|
|
player_3_pile.enable_drop_zone = true
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
await player_3_pile.played
|
|
|
|
|
player_3_pile.enable_drop_zone = false
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
await get_tree().create_timer(0.2).timeout
|
|
|
|
|
player_3_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_4_pile.sensor_visibility = true
|
|
|
|
|
player_4_pile.enable_drop_zone = true
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
await player_4_pile.played
|
|
|
|
|
player_4_pile.enable_drop_zone = false
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
await get_tree().create_timer(0.2).timeout
|
|
|
|
|
player_4_hand.allow_movement = false
|
|
|
|
|
player = player_2_pile
|
|
|
|
|
player_2_pile:
|
|
|
|
|
player_2_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_3_pile.sensor_visibility = true
|
|
|
|
|
player_3_pile.enable_drop_zone = true
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
await player_3_pile.played
|
|
|
|
|
player_3_pile.enable_drop_zone = false
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_3_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_4_pile.sensor_visibility = true
|
|
|
|
|
player_4_pile.enable_drop_zone = true
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
await player_4_pile.played
|
|
|
|
|
player_4_pile.enable_drop_zone = false
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_4_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_1_pile.sensor_visibility = true
|
|
|
|
|
player_1_pile.enable_drop_zone = true
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
await player_1_pile.played
|
|
|
|
|
player_1_pile.enable_drop_zone = false
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_1_hand.allow_movement = false
|
|
|
|
|
player = player_3_pile
|
|
|
|
|
player_3_pile:
|
|
|
|
|
player_3_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_4_pile.sensor_visibility = true
|
|
|
|
|
player_4_pile.enable_drop_zone = true
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
await player_4_pile.played
|
|
|
|
|
player_4_pile.enable_drop_zone = false
|
|
|
|
|
player_4_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_4_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_1_pile.sensor_visibility = true
|
|
|
|
|
player_1_pile.enable_drop_zone = true
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
await player_1_pile.played
|
|
|
|
|
player_1_pile.enable_drop_zone = false
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_1_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_2_pile.sensor_visibility = true
|
|
|
|
|
player_2_pile.enable_drop_zone = true
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
await player_2_pile.played
|
|
|
|
|
player_2_pile.enable_drop_zone = false
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_2_hand.allow_movement = false
|
|
|
|
|
player = player_4_pile
|
|
|
|
|
player_4_pile:
|
|
|
|
|
player_4_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_1_pile.sensor_visibility = true
|
|
|
|
|
player_1_pile.enable_drop_zone = true
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
await player_1_pile.played
|
|
|
|
|
player_1_pile.enable_drop_zone = false
|
|
|
|
|
player_1_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_1_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_2_pile.sensor_visibility = true
|
|
|
|
|
player_2_pile.enable_drop_zone = true
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
await player_2_pile.played
|
|
|
|
|
player_2_pile.enable_drop_zone = false
|
|
|
|
|
player_2_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_2_hand.allow_movement = false
|
|
|
|
|
|
|
|
|
|
player_3_pile.sensor_visibility = true
|
|
|
|
|
player_3_pile.enable_drop_zone = true
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
await player_3_pile.played
|
|
|
|
|
player_3_pile.enable_drop_zone = false
|
|
|
|
|
player_3_pile._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
player_3_hand.allow_movement = false
|
|
|
|
|
player = player_1_pile
|
|
|
|
|
n += 1
|
|
|
|
|
get_turn_winner()
|
|
|
|
|
play_round()
|
|
|
|
|
|
|
|
|
|
func turn(player):
|
|
|
|
|
player.sensor_visibility = true
|
|
|
|
|
player.enable_drop_zone = true
|
|
|
|
|
player._redraw_drop_zone()
|
|
|
|
|
await player.played
|
|
|
|
|
player.enable_drop_zone = false
|
|
|
|
|
player._redraw_drop_zone()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func count_points():
|
|
|
|
|
print("end of round")
|
|
|
|
|
|
|
|
|
|
for i in team_1_stiche._held_cards:
|
|
|
|
|
match i[0].card_info["value"]:
|
|
|
|
|
6:
|
|
|
|
|
if trump == "Down":
|
|
|
|
|
team_1_points += 11
|
|
|
|
|
8:
|
|
|
|
|
if trump == "Top" or trump == "Down":
|
|
|
|
|
team_1_points += 8
|
|
|
|
|
9:
|
|
|
|
|
if i.card_info.suit == trump:
|
|
|
|
|
team_1_points += 14
|
|
|
|
|
10:
|
|
|
|
|
team_1_points += 10
|
|
|
|
|
11:
|
|
|
|
|
if i.card_info.suit == trump:
|
|
|
|
|
team_1_points += 20
|
|
|
|
|
else:
|
|
|
|
|
team_1_points += 2
|
|
|
|
|
12:
|
|
|
|
|
team_1_points += 3
|
|
|
|
|
13:
|
|
|
|
|
team_1_points += 4
|
|
|
|
|
14:
|
|
|
|
|
if trump != "Down":
|
|
|
|
|
team_1_points += 11
|
|
|
|
|
print(team_1_points)
|
|
|
|
|
for i in team_2_stiche._held_cards:
|
|
|
|
|
match i.card_info["value"]:
|
|
|
|
|
6:
|
|
|
|
|
if trump == "Down":
|
|
|
|
|
team_2_points += 11
|
|
|
|
|
8:
|
|
|
|
|
if trump == "Top" or trump == "Down":
|
|
|
|
|
team_2_points += 8
|
|
|
|
|
9:
|
|
|
|
|
if i.card_info.suit == trump:
|
|
|
|
|
team_2_points += 14
|
|
|
|
|
10:
|
|
|
|
|
team_2_points += 10
|
|
|
|
|
11:
|
|
|
|
|
if i.card_info.suit == trump:
|
|
|
|
|
team_2_points += 20
|
|
|
|
|
else:
|
|
|
|
|
team_2_points += 2
|
|
|
|
|
12:
|
|
|
|
|
team_2_points += 3
|
|
|
|
|
13:
|
|
|
|
|
team_2_points += 4
|
|
|
|
|
14:
|
|
|
|
|
if trump != "Down":
|
|
|
|
|
team_2_points += 11
|
|
|
|
|
print(team_2_points)
|
|
|
|
|
|
|
|
|
|
func get_turn_winner():
|
|
|
|
|
var cards = {
|
|
|
|
@@ -213,11 +168,11 @@ func get_turn_winner():
|
|
|
|
|
if trump == cards[card]["suit"]:
|
|
|
|
|
match cards[card]["value"]:
|
|
|
|
|
11:
|
|
|
|
|
cards[card]["value"] += 40
|
|
|
|
|
cards[card]["value"] += 80
|
|
|
|
|
9:
|
|
|
|
|
cards[card]["value"] += 30
|
|
|
|
|
cards[card]["value"] += 50
|
|
|
|
|
_:
|
|
|
|
|
cards[card]["value"] += 14
|
|
|
|
|
cards[card]["value"] += 20
|
|
|
|
|
print(cards[card]["value"])
|
|
|
|
|
elif trump == "Down":
|
|
|
|
|
for card in cards:
|
|
|
|
@@ -226,13 +181,13 @@ func get_turn_winner():
|
|
|
|
|
|
|
|
|
|
var played_suit = first_player.get_top_cards(1)[0].card_info.suit
|
|
|
|
|
var highest_card: int
|
|
|
|
|
var highest_value: int
|
|
|
|
|
var highest_value: int = -15
|
|
|
|
|
for i in cards:
|
|
|
|
|
var card = cards[i]
|
|
|
|
|
if card["suit"] == played_suit and card["value"] > highest_value:
|
|
|
|
|
if card["suit"] == played_suit and card["value"] > highest_value or card["suit"] == trump and card["value"] > highest_value:
|
|
|
|
|
highest_value = card["value"]
|
|
|
|
|
highest_card = i
|
|
|
|
|
|
|
|
|
|
await get_tree().create_timer(DEAL_PAUSE).timeout
|
|
|
|
|
match highest_card:
|
|
|
|
|
1:
|
|
|
|
|
first_player = player_1_pile
|
|
|
|
|