diff --git a/cards/colored/b+4.png b/cards/colored/b+4.png new file mode 100644 index 0000000..b84ece4 Binary files /dev/null and b/cards/colored/b+4.png differ diff --git a/cards/b0.png b/cards/colored/b0.png similarity index 100% rename from cards/b0.png rename to cards/colored/b0.png diff --git a/cards/b1.png b/cards/colored/b1.png similarity index 100% rename from cards/b1.png rename to cards/colored/b1.png diff --git a/cards/b2.png b/cards/colored/b2.png similarity index 100% rename from cards/b2.png rename to cards/colored/b2.png diff --git a/cards/b3.png b/cards/colored/b3.png similarity index 100% rename from cards/b3.png rename to cards/colored/b3.png diff --git a/cards/colored/g+4.png b/cards/colored/g+4.png new file mode 100644 index 0000000..bebaf8b Binary files /dev/null and b/cards/colored/g+4.png differ diff --git a/cards/g0.png b/cards/colored/g0.png similarity index 100% rename from cards/g0.png rename to cards/colored/g0.png diff --git a/cards/g1.png b/cards/colored/g1.png similarity index 100% rename from cards/g1.png rename to cards/colored/g1.png diff --git a/cards/g2.png b/cards/colored/g2.png similarity index 100% rename from cards/g2.png rename to cards/colored/g2.png diff --git a/cards/g3.png b/cards/colored/g3.png similarity index 100% rename from cards/g3.png rename to cards/colored/g3.png diff --git a/cards/colored/r+4.png b/cards/colored/r+4.png new file mode 100644 index 0000000..3d2e203 Binary files /dev/null and b/cards/colored/r+4.png differ diff --git a/cards/r0.png b/cards/colored/r0.png similarity index 100% rename from cards/r0.png rename to cards/colored/r0.png diff --git a/cards/r1.png b/cards/colored/r1.png similarity index 100% rename from cards/r1.png rename to cards/colored/r1.png diff --git a/cards/r2.png b/cards/colored/r2.png similarity index 100% rename from cards/r2.png rename to cards/colored/r2.png diff --git a/cards/r3.png b/cards/colored/r3.png similarity index 100% rename from cards/r3.png rename to cards/colored/r3.png diff --git a/cards/colored/y+4.png b/cards/colored/y+4.png new file mode 100644 index 0000000..bd3ec49 Binary files /dev/null and b/cards/colored/y+4.png differ diff --git a/cards/y0.png b/cards/colored/y0.png similarity index 100% rename from cards/y0.png rename to cards/colored/y0.png diff --git a/cards/y1.png b/cards/colored/y1.png similarity index 100% rename from cards/y1.png rename to cards/colored/y1.png diff --git a/cards/y2.png b/cards/colored/y2.png similarity index 100% rename from cards/y2.png rename to cards/colored/y2.png diff --git a/cards/y3.png b/cards/colored/y3.png similarity index 100% rename from cards/y3.png rename to cards/colored/y3.png diff --git a/game.json b/game.json index 0f970f8..2e4dffb 100644 --- a/game.json +++ b/game.json @@ -7,57 +7,27 @@ "script": "game.rhai", "default_back": "cards/back.png", "available_cards": { - "B0": { - "image": "cards/b0.png" - }, - "R0": { - "image": "cards/r0.png" - }, - "G0": { - "image": "cards/b0.png" - }, - "Y0": { - "image": "cards/y0.png" - }, - "B1": { - "image": "cards/b1.png" - }, - "R1": { - "image": "cards/r1.png" - }, - "G1": { - "image": "cards/b1.png" - }, - "Y1": { - "image": "cards/y1.png" - }, - "B2": { - "image": "cards/b2.png" - }, - "R2": { - "image": "cards/r2.png" - }, - "G2": { - "image": "cards/b2.png" - }, - "Y2": { - "image": "cards/y2.png" - }, - "B3": { - "image": "cards/b3.png" - }, - "R3": { - "image": "cards/r3.png" - }, - "G3": { - "image": "cards/b3.png" - }, - "Y3": { - "image": "cards/y3.png" - }, - "+4": { - "image": "cards/+4.png" - } + "Y1": { "image": "cards/colored/y1.png", "color": "Y", "number": "1" }, + "G1": { "image": "cards/colored/g1.png", "color": "G", "number": "1" }, + "G0": { "image": "cards/colored/g0.png", "color": "G", "number": "0" }, + "G2": { "image": "cards/colored/g2.png", "color": "G", "number": "2" }, + "B0": { "image": "cards/colored/b0.png", "color": "B", "number": "0" }, + "B1": { "image": "cards/colored/b1.png", "color": "B", "number": "1" }, + "Y3": { "image": "cards/colored/y3.png", "color": "Y", "number": "3" }, + "R2": { "image": "cards/colored/r2.png", "color": "R", "number": "2" }, + "R0": { "image": "cards/colored/r0.png", "color": "R", "number": "0" }, + "Y2": { "image": "cards/colored/y2.png", "color": "Y", "number": "2" }, + "G3": { "image": "cards/colored/g3.png", "color": "G", "number": "3" }, + "R3": { "image": "cards/colored/r3.png", "color": "R", "number": "3" }, + "Y0": { "image": "cards/colored/y0.png", "color": "Y", "number": "0" }, + "B2": { "image": "cards/colored/b2.png", "color": "B", "number": "2" }, + "B3": { "image": "cards/colored/b3.png", "color": "B", "number": "3" }, + "R1": { "image": "cards/colored/r1.png", "color": "R", "number": "1" }, + "G+4": { "image": "cards/colored/g+4.png", "color": "G", "number": "+4" }, + "R+4": { "image": "cards/colored/r+4.png", "color": "R", "number": "+4" }, + "Y+4": { "image": "cards/colored/y+4.png", "color": "Y", "number": "+4" }, + "B+4": { "image": "cards/colored/b+4.png", "color": "B", "number": "+4" }, + "+4": { "image": "cards/+4.png", "color": "N", "number": "+4" } }, "piles": { "deck": { @@ -80,11 +50,16 @@ "G3", "Y3", "+4" - ] + ], + "face_down": true }, "placed": {} }, "player_piles": { - "deck": {} + "deck": { + "cards": ["+4"] + }, + "color_select": { + } } } \ No newline at end of file diff --git a/game.rhai b/game.rhai index f1311b6..93bef25 100644 --- a/game.rhai +++ b/game.rhai @@ -22,6 +22,8 @@ fn setup(data) { // print(data.player_piles); // print(data.piles.deck); data.fw = true; + data.next_plus4 = 0; + data.selecting_color_plus4 = false; return data; } @@ -41,24 +43,65 @@ fn turn_start(data, player) { } fn on_click(data, card, action_author, current_player) { + // TODO handle next_plus4 if action_author == current_player { - if card.pile_kind == "common" { - if card.pile_name == "deck" { - // Get a card from the deck - + if data.selecting_color_plus4 { + print(card); + if card.pile_kind != "common" && card.pile_name == "color_select" { + data.selecting_color_plus4 = false; let c = data.pop_card(card); - - data.player_piles[current_player.val].deck.cards.push(c); - + print(c); + data.piles.placed.cards.push(c); + data.player_piles[current_player.val].color_select.cards = []; + data.next_plus4 = 1; + return [data, true]; + }else{ + return [data, false]; } }else{ - if card.pile_name == "deck" { - let c = data.pop_card(card); - print(c[0]); - data.piles.placed.cards.push(c); + 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); + + } + }else{ + if card.pile_name == "deck" { + let c = data.get_card(card); + switch c.kind { + "+4" => { + data.selecting_color_plus4 = true; + data.pop_card(card); + data.player_piles[current_player.val].color_select.cards.push(new_card("G+4")); + 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")); + + return [data, false]; + } + _ => { + let last_card = data.piles.placed.cards[data.piles.placed.cards.len-1]; + print(last_card); + print(c); + if last_card.other.color == c.other.color { + data.pop_card(card); + data.piles.placed.cards.push(c); + return [data, true]; + }else if last_card.other.number == c.other.number { + data.pop_card(card); + data.piles.placed.cards.push(c); + return [data, true]; + }else { + return [data, false]; + } + } + } + } } } return [data, true]; + } return [data, false]; } \ No newline at end of file diff --git a/gen_json.py b/gen_json.py new file mode 100644 index 0000000..ce427f1 --- /dev/null +++ b/gen_json.py @@ -0,0 +1,10 @@ +import os + +# Open a file +path = r"cards/colored" +files = os.scandir(path) +for file in files: + card = file.name[:-4].upper() + color = card[0] + number = card[1:] + print(f'"{card}": {{ "image": "cards/colored/{file.name}", "color": "{color}", "number": "{number}" }},') \ No newline at end of file