当前位置: 首页 > 软件库 > 游戏/娱乐 > >

deck-of-cards

Deck of Cards (old version)
授权协议 View license
开发语言 JavaScript
所属分类 游戏/娱乐
软件类型 开源软件
地区 不详
投 递 者 邢运良
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

HTML5 Deck of Cards

NEW VERSION COMING UP!

The new multiplayer Deck of Cards is released at https://deck.of.cards, but will have it's cards library open sourced soon here!

Old version

Pure vanilla JS (+ CSS3) – no dependencies, by Juha Lindstedt & contributors.

https://deck.of.cards/old

Install from Google Chrome Web Store

Frontside card graphics are slightly modified from Chris Aguilar's awesome Vector Playing Card Graphics Set.

Also check out my RE:DOM and HTML5 Node Garden projects!

Contributors

Code Contributors

This project exists thanks to all the people who contribute. [Contribute].

Financial Contributors

Become a financial contributor and help us sustain our community. [Contribute]

Individuals

Organizations

Support this project with your organization. Your logo will show up here with a link to your website. [Contribute]

License

LGPL if you use Chris Aguilar's vector playing cards. Otherwise MIT.

Download

Installation from npm

npm install deck-of-cards

Then add in your html file

  • In <head>:
<link rel="stylesheet" href="node_modules/deck-of-cards/example/example.css">
  • At the end of the <body>:
<script src="node_modules/deck-of-cards/dist/deck.min.js"></script>

Usage

Full example

<html>
    <head>
        <title>Cards</title>

        <link rel="stylesheet" href="node_modules/deck-of-cards/example/example.css">
    </head>
    <body>
        <script src="node_modules/deck-of-cards/dist/deck.min.js"></script>

        <div id="container"></div>

        <script>
            var $container = document.getElementById('container');

            // create Deck
            var deck = Deck();

            // add to DOM
            deck.mount($container);

            deck.cards.forEach(function (card, i) {
                card.setSide(Math.random() < 0.5 ? 'front' : 'back');

                // explode
                card.animateTo({
                    delay: 1000 + i * 2, // wait 1 second + i * 2 ms
                    duration: 500,
                    ease: 'quartOut',

                    x: Math.random() * window.innerWidth - window.innerWidth / 2,
                    y: Math.random() * window.innerHeight - window.innerHeight / 2
                });
            });
        </script>
    </body>
</html>

Available on JsFiddle: http://jsfiddle.net/x0gjood1/

Javascript API

Deck

// Instantiate a deck
var deck = Deck();

// display it in a html container
var $container = document.getElementById('container');
deck.mount($container);

Deck example: http://jsfiddle.net/ec4kcx1k/

// Flip all cards in deck
deck.flip();

// Sort cards
deck.sort();

// Shuffle
deck.shuffle();

// Display fan
deck.fan();

// Remove deck from html container, hide it
deck.unmount();

Shuffle cards and fan: http://jsfiddle.net/favbdkta/

Deck with jokers:

// Instanciate a deck with jokers
var deck = Deck(true);

Card

// Select the first card
var card = deck.cards[0];

// Add it to an html container
card.mount($container);

// Allow to move/drag it
card.enableDragging();
card.disableDragging();

// Allow to flip it
card.enableFlipping();
card.disableFlipping();

// Flip card
card.flip();

// Display card front or back
card.setSide('front');
card.setSide('back');

Draggable and flippable card: http://jsfiddle.net/cgz9mjts/

Card in deck

Remove a card from a deck

var deck = Deck();

// Remove 10 cards starting from the 6th
var removedCards = deck.cards.splice(5, 10);

removedCards.forEach(function (removedCard) {
    removedCard.unmount();
});

Deck without Clubs: http://jsfiddle.net/L25facxj/

Build instructions

npm install
npm start

(starts watching for changes..)

Latest changes

  • 0.1.4 card.animateTo() -method added –> simplier modules! Simple example of usage
  • 0.1.3 JS animations (instead of CSS transitions)
  • 0.1.2 Backside graphics + setRankSuit (+ card.value -> card.rank!)
  • 0.1.1 Better organized modules + Chrome app
  • 0.1.0 Realistic face graphics, notice change of license for now..
  • 0.0.4 winning mode, simpler shuffling, CSS box-shadow change
  • 0.0.3 big refactoring – code now easier to follow and in smaller pieces
  • 0.0.2 made intro shorter & added "poker"
  • 0.0.1 initial version

Where's what?

css/ - CSS source (stylus + nib) of the example

chrome/ - Chrome Web Store app source

dist/ - deck.js & deck.min.js

example/ - https://deck-of-cards.js.org

lib/ - JS (ES6) source of dist/deck.js - deck.js is also the main file

views/ - HTML source of the example

Note to self: todo

  • Make z-index temporary by reordering DOM elements between actions
  • Enhance API, make more flexible

Featured on

  • 链接 https://leetcode-cn.com/problems/x-of-a-kind-in-a-deck-of-cards/ 耗时 解题:33 min 题解:11 min 题意 给定一副牌,每张牌上都写着一个整数。 此时,你需要选定一个数字 X,使我们可以将整副牌按下述规则分成 1 组或更多组: 每组都有 X 张牌。 组内所有的牌上都写着相同的整数。 仅当你可选的 X >= 2 时返回

  • 题意: 一一个21点游戏。 1. 有三个牌堆,分别为1X,2X,3X。 2. 纸牌A的值为1,纸牌2-9的值与牌面面相同,10(T)、J、Q、K的值为10,而而joke(F)的值为 任意大大。 3. 一一列牌要按顺序放入入三个牌堆中。当某个牌堆的值超过21点时,不能在放牌;如果某个牌堆的 总值为21点时,这个排队讲会被清空;joke放上后这个牌堆的值立立即变为21点。 4. 成功放上一一张牌得50

  • unordered_map可类比于Python中的字典。其实现使用了哈希表,可以以O(1)的时间复杂度访问到对应元素,但缺点是有较高的额外空间复杂度。与之对应,STL中的map对应的数据结构是红黑树,红黑树内的数据时有序的,在红黑树上查找的时间复杂度是O(logN),相对于unordered_map的查询速度有所下降,但额外空间开销减小。   class Solution { public:   

  • In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Ea

  • In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, where: Ea

  • In a deck of cards, each card has an integer written on it. 在一副扑克牌中,每张牌上都写了一个整数 Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups

  • 题意:一个特殊21点游戏 具体http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2852 题解:建一个三维dp,表示三个卡槽分别为i,j,l分时最大的收益情况。     对所有当前状态dp,将下一个可能的状态存入f, 坑:~-1==0 #define _CRT_SECURE_NO_WARNINGS #include<cstri

  • 大意: n个红黑卡, 每天可以选择领取一块红币一块黑币, 或者买一张卡, 第$i$张卡的花费红币数$max(r_i-A,0)$, 花费黑币数$max(b_i-B,0)$, A为当前红卡数, B为当前黑卡数, 求买完所有卡最少天数.     这题挺巧妙的, 刚开始看花费的范围太大一直在想怎么贪心... 实际上注意到减费最多只有120, 可以按照减费进行dp即可 这题CF大神的最优解写了个模拟退火OR

  • Description: In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of car

  • 题目来源:https://leetcode.com/contest/weekly-contest-104/problems/x-of-a-kind-in-a-deck-of-cards/ 问题描述 914. X of a Kind in a Deck of Cards In a deck of cards, each card has an integer written on it. Retur

  • Problem - 1511C - Codeforces C. Yet Another Card Deck time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output You have a card deck of nn cards, nu

  • Solution 朴素思路 f [ i ] [ j ] f[i][j] f[i][j] 表示取卡状态为 i i i,用了 j j j 颗红宝石,最少用蓝宝石的数量。 瞄一眼数据 1 e 7 1e7 1e7,完全不可做。。。 可以反着思考, f [ i ] [ j ] f[i][j] f[i][j] 表示取卡状态为 i i i,省了 j j j 颗红宝石,最多省蓝宝石的数量。为什么可以反着来?首先注

  • You are given an integer array deck where deck[i] represents the number written on the ith card. Partition the cards into one or more groups such that: Each group has exactly x cards where x > 1, and

  • Title:X of a Kind in a Deck of Cards    914 Difficulty:Easy 原题leetcode地址:https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/   1.  方法比较丑陋:将每个数出现的次数存入到Map中,判断Map的长度,再将Map中的value存入到List中,对List

  • Description In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of card

  • 914. X of a Kind in a Deck of Cards* https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/ 题目描述 In a deck of cards, each card has an integer written on it. Return true if and only if you can c

  • Deck of Cards 题目链接: D - Deck of Cards ZOJ - 2852 题意 按顺序给你很多的牌,牌的价值从1到10不等,有一张特殊的牌Joker可以代表尽可能大的值; 然后给你三个插槽,从他们有自己的序号1,2,3. 我们可以把多张牌插入插槽,但是其值不能大于21; 当插槽里面的牌值总和等于21时,可以将这里的牌都拿走。 每成功插入一张牌就奖励50元 如果操作4被执行,

  • Problem In a deck of cards, each card has an integer written on it. Return true if and only if you can choose X >= 2 such that it is possible to split the entire deck into 1 or more groups of cards, w

  • 问题链接:https://leetcode.com/problems/x-of-a-kind-in-a-deck-of-cards/ 能想到的就是求多个数的公约数(只会求两个数的),但我不会求呀,然后想的解法就比较暴力,就是先找到数字出现次数中的最小值min,然后从min到2开始搜索找到能够被所有出现次数记录整除的数字。代码如下: class Solution { public boole

 相关资料
  • Modern & extendable local web development studio DECK is powerful and high performant local web development studio unlike any other, install & try out more than 40+ open source stacks with editable Do

  • 有了Deck对象之后,把所有从属于Deck的函数放入其结构定义中也是情理之中的事了。看一下到目前为止我们定义的函数,很明显12.7节的printDeck函数可以作为候选加进来。下面将printDeck重写为成员函数: void Deck::print () const { for (int i = 0; i < cards.length(); i++) { cards[i].print

  • of

    of / just 函数签名: of(...values, scheduler: Scheduler): Observable 按顺序发出任意数量的值。 示例 示例 1: 发出数字序列 ( StackBlitz | jsBin | jsFiddle ) // RxJS v6+ import { of } from 'rxjs'; // 依次发出提供的任意数量的值 const source = of

  • 创建单个基本类型't'的新向量,其中't'是以下之一:int:long:float:double:byte:short:char或:boolean。 生成的向量通常符合向量的接口,但在内部存储未装箱的值。 语法 (Syntax) 以下是语法。 (vector-of t setofelements) Parameters - 't'是向量元素应该是的类型。 'Setofelements'是向量中包

  • of-admin 基于JFinal 框架开发,整合 spring + shiro + ehcache + freemarker 等框架,目标做更简单、方便、快速、管理平台、不涉及业务。目前版本v1.0 已经发布系统设置相关功能、微信管理、等相关功能。 项目演示 演示地址:https://ofsoft.cn/of-admin 账户:admin 密码:123456 请不要删除里面数据。 文档地址:ht

  • JS for of 循环是 ECMAScript6 中新添加的一个循环方式,与 for in 循环类似,也是普通 for 循环的一种变体。使用 for of 循环可以轻松的遍历数组或者其它可遍历的对象,例如字符串、对象等。 JS for of 循环的语法格式如下: for (variable of iterable) {     // 要执行的代码 } 其中,variable 为一个变量,每次循环