TinyPortal

Development => Block Codes => Topic started by: evilicy on February 15, 2008, 02:23:21 AM

Title: Tarot - 3 card spread
Post by: evilicy on February 15, 2008, 02:23:21 AM
As the title says  :D On page refresh shows 3 random cards no dupes. Hold your mouse over each card for a brief description (uses rollovers).

Install:

1. Download and extract the major_arcana.zip and upload the folder to site root (or change paths) 
2. Download and extract the cards.dat.zip and upload to site root (or change paths)
3. In a php article / block <----  :uglystupid2: add the following code:


function random_card($cards)
{
// holds the last used card
static $exclude = array();
$max = count($cards) - 1;

$o = mt_rand(0, $max);

if(count($exclude) > 0)
{
while(array_search($o, $exclude) !== false)
{
$o = mt_rand(0, $max);
}
}
$exclude[] = $o;
return $cards[$o];
}
$file = file_get_contents('cards.dat');
// splits $file into an array
$cards = preg_split("/(\r\n|\n)/", $file, NULL, PREG_SPLIT_NO_EMPTY);

echo random_card($cards)."\n";
echo random_card($cards)."\n";
echo random_card($cards)."\n";


temp demo at:
http://www.darkvoid.org/test2.php

card images (http://www.darkvoid.org/major_arcana.zip)
cards.dat (http://www.darkvoid.org/cards.dat.zip)
Title: Re: Tarot - 3 card spread
Post by: Lord Anubis on February 15, 2008, 02:55:45 AM
Where's the packs?
Title: Re: Tarot - 3 card spread
Post by: evilicy on February 15, 2008, 03:05:53 AM
oops sorry about that. They are there now.
Title: Re: Tarot - 3 card spread
Post by: Lord Anubis on February 15, 2008, 03:06:37 AM
Thanks :)

Looks like a neat lil script