Browse Source

Add simplified game

main
ThePerkinrex 5 years ago
parent
commit
b4340411e4
No known key found for this signature in database GPG Key ID: FD81DE6D75E20917
  1. 1
      .gitignore
  2. BIN
      cards/+4.png
  3. BIN
      cards/b0.png
  4. BIN
      cards/back.png
  5. BIN
      cards/r0.png
  6. 29
      game.json
  7. 62
      game.rhai

1
.gitignore

@ -0,0 +1 @@
.cache

BIN
cards/+4.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 33 KiB

BIN
cards/b0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
cards/back.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 93 KiB

BIN
cards/r0.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 49 KiB

29
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": {}
}
}

62
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];
}
Loading…
Cancel
Save