An open API service indexing awesome lists of open source software.

https://github.com/davidemodolo/imnabbocards

Draw random cards with custom probability and (un)limited uses. Made for the Twitch Streamer ImNabbo.
https://github.com/davidemodolo/imnabbocards

card-draw dart flutter random

Last synced: 2 months ago
JSON representation

Draw random cards with custom probability and (un)limited uses. Made for the Twitch Streamer ImNabbo.

Awesome Lists containing this project

README

        


FlutterIcon
DartIcon
WindowsIcon

----

**Before running:**
1. put all `.png` in the `data\flutter_assets\assets\cards` folder (at least one card; no whitespace characters in the names);
2. put the four .mp3 files in the `data\flutter_assets\assets` folder (`default.mp3`, `positive.mp3`, `negative.mp3`, `funny.mp3`);
3. write the RGB color for the background in the `data\flutter_assets\assets\colorRGB.txt` file;
4. start the program.

IMPORTANT: the program will not run if there isn't at least one card and all the needed files.

**Setup:**
- long press on a card to add/remove (enable/disable) it from the pool;
- single press on a card to increase its rarity (1 to 6 and back);
- set the number of times a card can be drawn, set as `-1` if unlimited;
- set the marker of each card as **A**, **B** or **All** (by clicking the button);
- set the sound to be played when drawn (by clicking the button);

**Draw steps:**
1. randomly select a rarity;
2. randomly select a card of such rarity;
3. play the related `.mp3` sound;
4. 1.5s animation "from the right" that makes the drawn card appear;
5. the card stays for 45 seconds;
6. hide the card;
7. add the drawn card to the log file;
8. reduce by one the number of uses left and disable the card if it reaches `0`.

If there isn't any available card of the randomly selected rarity, it first checks the lower rarities and then the higher rarities.
> _e.g.: if Rarity 4 is selected and it has no cards, the check order is 3-2-1-5-6. If there isn't any card available, it returns the first card whether is active/drawable or not._

If no card is found (so there isn't any card avaliable), it returns the card at index 0.

The pool can be made by **A** cards, **B** cards or **All**.

**Functions:**
- DRAW: draws a card, shows it and, after 45 seconds, hides it
- ALL/A/B: set the marker from which draw the random card
- LAST: pop the last card from the stack (it remains until **CLEAR**)
- CLEAR: hide the current big card
- INDEX: set the index of a specific card
- SHOW: show the card of the specified index that ovverides the last card (it remains until **CLEAR**)

Folders structure:

*TODO*

JSON structure:
```
{
"cards": [
{
"path": "path_to_card_image.png",
"rarity": 1, // from 1 to 5, 0 if the card is new
"active": true, // if active in the card pool
"uses": 1, // uses left
"marker": 1 // 1 = A, 2 = B
},
.
.
.
]
}

```