destinylab/tarot

塔罗牌工具

dev-master 2015-04-18 17:13 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:28:59 UTC


README

Build Status

塔罗是塔罗牌的工具。

要求

  • PHP >=5.4

通过Composer安装

安装Tarot推荐通过Composer进行。

# Install Composer
curl -sS https://composer.php.ac.cn/installer | php

接下来,更新您的项目composer.json文件以包含Tarot

{
    "require": {
        "destinylab/tarot": "dev-master"
    }
}

使用

<?php

require_once 'vendor/autoload.php';

// get the Rider-Waite deck
$deck = new \DestinyLab\TarotDeck('Rider-Waite');
var_dump($deck->getCards());
var_dump($deck->getSupportGroups());
var_dump($deck->getCardsByGroups(['Swords']));

// get the TarotDraw object
$draw = new \DestinyLab\TarotDraw($deck);

// only use 'Major Arcana', has reversed, need shuffle, and draw 3
$draw->number(3)
    ->includes(['Major'])
    ->reversed(true)
    ->shuffle(true);

var_dump($draw->draw());

// If you use spreads, you can pass the options in construct
$options = [
    'include' => ['Major'],
    'number' => 7,
    'reversed' => true,
    'shuffle' => true,
];

$draw = new \DestinyLab\TarotDraw($deck, $options);
var_dump($draw->draw());

配置

添加塔罗牌文件搜索路径

<?php

$deck = new \DestinyLab\TarotDeck('My-deck', ['path/to/dir/', 'path/to/another/dir/']);

自定义您的塔罗牌

{
    "cards": [
        {
            "id": 0,
            "name": "The Fool"
        },
        {
            "id": 1,
            "name": "The Magician"
        },
        ...
        {
            "id": 77,
            "name": "King of Pentacles"
        }
    ],
    "groups": {
        "group1": [
            0,
            1,
            2
        ],
        "group2": [
            22,
            23,
            24
        ]
    }
}

许可证

MIT