diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1998c29 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.cache \ No newline at end of file diff --git a/cards/+4.png b/cards/+4.png new file mode 100644 index 0000000..74ff386 Binary files /dev/null and b/cards/+4.png differ diff --git a/cards/b0.png b/cards/b0.png new file mode 100644 index 0000000..578ca48 Binary files /dev/null and b/cards/b0.png differ diff --git a/cards/back.png b/cards/back.png new file mode 100644 index 0000000..78f7bde Binary files /dev/null and b/cards/back.png differ diff --git a/cards/r0.png b/cards/r0.png new file mode 100644 index 0000000..2b1aca0 Binary files /dev/null and b/cards/r0.png differ diff --git a/game.json b/game.json new file mode 100644 index 0000000..a3886b2 --- /dev/null +++ b/game.json @@ -0,0 +1,29 @@ +{ + "name": "LibreUNO", + "version": "0.1.0", + "authors": ["ThePerkinrex"], + "script": "game.rhai", + "default_back": "cards/back.png", + "available_cards": { + "B0": { + "image": "cards/b0.png" + }, + "R0": { + "image": "cards/r0.png" + }, + "+4": { + "image": "cards/+4.png" + } + }, + "piles": { + "deck": { + "cards": [ + "B0", "R0", "+4" + ] + }, + "placed": {} + }, + "player_piles": { + "deck": {} + } +} \ No newline at end of file diff --git a/game.rhai b/game.rhai new file mode 100644 index 0000000..1408796 --- /dev/null +++ b/game.rhai @@ -0,0 +1,62 @@ +fn setup(data) { + print("Setting up UNO for " + data.players + " players"); + + // print(data.piles.deck); + + data.piles.deck = shuffle(data.piles.deck); + + // print(data.piles.deck); + + // print(data.player_piles); + + for i in range(0, 2) { + // print(i); + for player_idx in range(0, data.player_piles.len) { + // print("Deck" + player); + let drawed_card = data.piles.deck.cards.pop(); + // print(player.deck.cards); + data.player_piles[player_idx].deck.cards.push(drawed_card); + // print(player.deck.cards); + } + } + // print(data.player_piles); + // print(data.piles.deck); + data.fw = true; + return data; +} + +fn turn_end(data, player) { + print("Turn for " + player + " ending"); + if data.fw { + player.add(1); + }else{ + player.sub(1); + } + return [data, player]; +} + +fn turn_start(data, player) { + print("Turn for " + player + " starting"); + return data; +} + +fn on_click(data, card, action_author, current_player) { + if action_author == current_player { + 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[player.val].deck.cards.push(c); + + } + }else{ + if card.pile_name == "deck" { + let c = data.pop_card(card); + data.piles.placed.cards.push(c); + } + } + return [data, true]; + } + return [data, false]; +} \ No newline at end of file