Compare commits
3 Commits
e78466c44a
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
| ed22000186 | |||
| e3e60845d6 | |||
| d45b1b3617 |
@@ -86,6 +86,8 @@ offset_right = 405.0
|
|||||||
offset_bottom = 435.0
|
offset_bottom = 435.0
|
||||||
script = ExtResource("7_rwigh")
|
script = ExtResource("7_rwigh")
|
||||||
card_face_up = false
|
card_face_up = false
|
||||||
|
allow_card_movement = false
|
||||||
|
enable_drop_zone = false
|
||||||
sensor_texture = SubResource("CanvasTexture_unpya")
|
sensor_texture = SubResource("CanvasTexture_unpya")
|
||||||
metadata/_custom_type_script = "uid://6ams8uvg43gu"
|
metadata/_custom_type_script = "uid://6ams8uvg43gu"
|
||||||
|
|
||||||
@@ -120,7 +122,7 @@ offset_right = 1365.0
|
|||||||
offset_bottom = 435.0
|
offset_bottom = 435.0
|
||||||
script = ExtResource("7_rwigh")
|
script = ExtResource("7_rwigh")
|
||||||
card_face_up = false
|
card_face_up = false
|
||||||
allow_card_movement = false
|
enable_drop_zone = false
|
||||||
metadata/_custom_type_script = "uid://6ams8uvg43gu"
|
metadata/_custom_type_script = "uid://6ams8uvg43gu"
|
||||||
|
|
||||||
[node name="Player3Hand" type="Control" parent="CardManager" unique_id=1841661362]
|
[node name="Player3Hand" type="Control" parent="CardManager" unique_id=1841661362]
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
extends Resource
|
||||||
|
class_name Points
|
||||||
|
|
||||||
|
var team_1_points
|
||||||
|
var team_2_points
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
uid://dwabqnrusgyob
|
||||||
+88
-133
@@ -15,10 +15,13 @@ extends Node2D
|
|||||||
@onready var trumpbuttons = $ButtonsTrumpSelect
|
@onready var trumpbuttons = $ButtonsTrumpSelect
|
||||||
@onready var first_player = $CardManager/Player1PlayPile
|
@onready var first_player = $CardManager/Player1PlayPile
|
||||||
var trump : String
|
var trump : String
|
||||||
var rounds_played: int
|
var rounds_played : int
|
||||||
|
var team_1_points :int = 0
|
||||||
|
var team_2_points :int = 0
|
||||||
|
|
||||||
|
const DEAL_PAUSE = 0.5
|
||||||
|
|
||||||
signal dealt
|
signal dealt
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
trumpbuttons.trump.connect(define_trump.bind())
|
trumpbuttons.trump.connect(define_trump.bind())
|
||||||
player_1_pile.enable_drop_zone = false
|
player_1_pile.enable_drop_zone = false
|
||||||
@@ -41,7 +44,7 @@ func setup_game():
|
|||||||
player_4_hand.allow_movement = true
|
player_4_hand.allow_movement = true
|
||||||
|
|
||||||
# Deal initial hand
|
# Deal initial hand
|
||||||
const DEAL_PAUSE = 0.5
|
|
||||||
var deal_r: int =1
|
var deal_r: int =1
|
||||||
while true:
|
while true:
|
||||||
deal_cards_to_hand(3, player_1_hand)
|
deal_cards_to_hand(3, player_1_hand)
|
||||||
@@ -62,142 +65,94 @@ func setup_game():
|
|||||||
|
|
||||||
func define_trump(suit : String):
|
func define_trump(suit : String):
|
||||||
trump = suit
|
trump = suit
|
||||||
turn(first_player)
|
play_round()
|
||||||
|
|
||||||
func turn(first):
|
func play_round():
|
||||||
|
var player = first_player
|
||||||
rounds_played += 1
|
rounds_played += 1
|
||||||
if rounds_played == 10:
|
if rounds_played == 10:
|
||||||
count_points()
|
count_points()
|
||||||
return
|
return
|
||||||
first.sensor_visibility = true
|
var n : int = 1
|
||||||
first.enable_drop_zone = true
|
while true:
|
||||||
first._redraw_drop_zone()
|
await turn(player)
|
||||||
await first.played
|
if n == 4:
|
||||||
first.enable_drop_zone = false
|
break
|
||||||
first._redraw_drop_zone()
|
match player:
|
||||||
match first:
|
|
||||||
player_1_pile:
|
player_1_pile:
|
||||||
await get_tree().create_timer(0.2).timeout
|
player = player_2_pile
|
||||||
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_2_pile:
|
player_2_pile:
|
||||||
player_2_hand.allow_movement = false
|
player = player_3_pile
|
||||||
|
|
||||||
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_3_pile:
|
player_3_pile:
|
||||||
player_3_hand.allow_movement = false
|
player = player_4_pile
|
||||||
|
|
||||||
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_4_pile:
|
player_4_pile:
|
||||||
player_4_hand.allow_movement = false
|
player = player_1_pile
|
||||||
|
n += 1
|
||||||
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
|
|
||||||
get_turn_winner()
|
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():
|
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():
|
func get_turn_winner():
|
||||||
var cards = {
|
var cards = {
|
||||||
@@ -213,11 +168,11 @@ func get_turn_winner():
|
|||||||
if trump == cards[card]["suit"]:
|
if trump == cards[card]["suit"]:
|
||||||
match cards[card]["value"]:
|
match cards[card]["value"]:
|
||||||
11:
|
11:
|
||||||
cards[card]["value"] += 40
|
cards[card]["value"] += 80
|
||||||
9:
|
9:
|
||||||
cards[card]["value"] += 30
|
cards[card]["value"] += 50
|
||||||
_:
|
_:
|
||||||
cards[card]["value"] += 14
|
cards[card]["value"] += 20
|
||||||
print(cards[card]["value"])
|
print(cards[card]["value"])
|
||||||
elif trump == "Down":
|
elif trump == "Down":
|
||||||
for card in cards:
|
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 played_suit = first_player.get_top_cards(1)[0].card_info.suit
|
||||||
var highest_card: int
|
var highest_card: int
|
||||||
var highest_value: int
|
var highest_value: int = -15
|
||||||
for i in cards:
|
for i in cards:
|
||||||
var card = cards[i]
|
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_value = card["value"]
|
||||||
highest_card = i
|
highest_card = i
|
||||||
|
await get_tree().create_timer(DEAL_PAUSE).timeout
|
||||||
match highest_card:
|
match highest_card:
|
||||||
1:
|
1:
|
||||||
first_player = player_1_pile
|
first_player = player_1_pile
|
||||||
|
|||||||
Reference in New Issue
Block a user