承接 fust/cards 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fust/cards

Composer 安装命令:

composer require fust/cards

包简介

A deck of standard cards to build any card game

README 文档

README

#Cards. Build a Card game in minutes.

A standard 52-card deck is provided by default, but one can customize to build any deck needed. Create Bridge, BlackJack, Pocker and more...

Installation

Pull in the package through Composer.

Run composer require fust/cards

Usage

To start using the deck...

$d = new Deck;

$d->shuffle();

//deal... an array of cards
$hand1 = $d->drawHand(10);
$hand2 = $d->drawHand(10);

//draw a single card
$card = deck->draw();

//do something with card
$value = $card->value();
$suit = $card->suit();

//special card?
if($card->isFaceCard()){...}

//cards left in the deck
$deck->count(); 

When the game is over, simply reset the deck by shuffle(ing). The deck now has all the cards (including drawn).

//start a new game...
$deck->shuffle();

To customise the deck of cards (i.e. which cards are part of the deck) one can implement the CardProvider interface

class MyGameDeckProvider implements CardProvider{
    
    public function getCards(){

        //return an array of card for MyGame 
	}
}
//...
$deck = new Deck(new MyGameDeckProvider);

You may also want to look at:

  • Shuffleable for shuffling the cards
  • CardProvider for providig cards to the deck

The current implementation doen't let putting cards back into the deck after drawing them. Shuffle resets the deck

统计信息

  • 总下载量: 70
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 2
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-01-19

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固