|
|
|
@ -19,11 +19,14 @@ fn setup(data) { |
|
|
|
// print(player.deck.cards); |
|
|
|
} |
|
|
|
} |
|
|
|
let drawed_card = data.piles.deck.cards.pop(); |
|
|
|
data.piles.placed.cards.push(drawed_card); |
|
|
|
// print(data.player_piles); |
|
|
|
// print(data.piles.deck); |
|
|
|
data.fw = true; |
|
|
|
data.next_plus4 = 0; |
|
|
|
data.selecting_color_plus4 = false; |
|
|
|
data.selecting_color = false; |
|
|
|
return data; |
|
|
|
} |
|
|
|
|
|
|
|
@ -52,7 +55,22 @@ fn on_click(data, card, action_author, current_player) { |
|
|
|
let c = data.pop_card(card); |
|
|
|
data.piles.placed.cards.push(c); |
|
|
|
data.player_piles[current_player.val].color_select.cards = []; |
|
|
|
data.next_plus4 = 1; |
|
|
|
data.next_plus4 += 1; |
|
|
|
data.player_piles[current_player.val].color_select.visible = false; |
|
|
|
data.player_piles[current_player.val].deck.visible = true; |
|
|
|
return [data, true]; |
|
|
|
}else{ |
|
|
|
return [data, false]; |
|
|
|
} |
|
|
|
}else if data.selecting_color { |
|
|
|
print(card); |
|
|
|
if card.pile_kind != "common" && card.pile_name == "color_select" { |
|
|
|
data.selecting_color = false; |
|
|
|
let c = data.pop_card(card); |
|
|
|
data.piles.placed.cards.push(c); |
|
|
|
data.player_piles[current_player.val].color_select.cards = []; |
|
|
|
data.player_piles[current_player.val].color_select.visible = false; |
|
|
|
data.player_piles[current_player.val].deck.visible = true; |
|
|
|
return [data, true]; |
|
|
|
}else{ |
|
|
|
return [data, false]; |
|
|
|
@ -60,9 +78,17 @@ fn on_click(data, card, action_author, current_player) { |
|
|
|
}else{ |
|
|
|
if card.pile_kind == "common" { |
|
|
|
if card.pile_name == "deck" { |
|
|
|
// Get a card from the deck |
|
|
|
let c = data.pop_card(card); |
|
|
|
data.player_piles[current_player.val].deck.cards.push(c); |
|
|
|
if data.next_plus4 == 0 { |
|
|
|
// Get a card from the deck |
|
|
|
data = draw(data, current_player); |
|
|
|
return [data, true]; // TODO: Turn shouldn't end on draw, if placeable, the card should be placed or kept |
|
|
|
}else{ |
|
|
|
for i in range(0, data.next_plus4*4) { |
|
|
|
data = draw(data, current_player); |
|
|
|
} |
|
|
|
data.next_plus4 = 0; |
|
|
|
return [data, true]; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
}else{ |
|
|
|
@ -76,10 +102,25 @@ fn on_click(data, card, action_author, current_player) { |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("R+4")); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("B+4")); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("Y+4")); |
|
|
|
|
|
|
|
data.player_piles[current_player.val].color_select.visible = true; |
|
|
|
data.player_piles[current_player.val].deck.visible = false; |
|
|
|
|
|
|
|
return [data, false]; |
|
|
|
} |
|
|
|
"COLORCHANGE" => if data.next_plus4 == 0 { |
|
|
|
|
|
|
|
data.selecting_color = true; |
|
|
|
data.pop_card(card); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("GCOLORCHANGE")); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("RCOLORCHANGE")); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("BCOLORCHANGE")); |
|
|
|
data.player_piles[current_player.val].color_select.cards.push(new_card("YCOLORCHANGE")); |
|
|
|
data.player_piles[current_player.val].color_select.visible = true; |
|
|
|
data.player_piles[current_player.val].deck.visible = false; |
|
|
|
|
|
|
|
return [data, false]; |
|
|
|
} |
|
|
|
_ => { |
|
|
|
_ => if data.next_plus4 == 0 { |
|
|
|
let last_card = data.piles.placed.cards[data.piles.placed.cards.len-1]; |
|
|
|
print(last_card); |
|
|
|
print(c); |
|
|
|
@ -103,4 +144,15 @@ fn on_click(data, card, action_author, current_player) { |
|
|
|
|
|
|
|
} |
|
|
|
return [data, false]; |
|
|
|
} |
|
|
|
|
|
|
|
fn draw(data, current_player) { |
|
|
|
if data.piles.deck.len == 0 { |
|
|
|
let s = data.piles.placed.cards.split(1); |
|
|
|
data.piles.placed.cards = s[0]; |
|
|
|
data.piles.deck = shuffle(s[1]); |
|
|
|
} |
|
|
|
let c = data.piles.deck.cards.pop(); |
|
|
|
data.player_piles[current_player.val].deck.cards.push(c); |
|
|
|
return data; |
|
|
|
} |