Giter VIP home page Giter VIP logo

ts-blackjack's Introduction

Simple implementation of blackjack in the TypeScript type system.

Example usage:

import { Deal, Double, Play, Hit, Stand } from "./cards-utils";

// Seed for "random", "shuffling" of deck
type StartingSeed = 9;

type Hand = Play<StartingSeed>;
/*
type Hand = {
    winBonus: 1;
    currentPoints: 19;
    shoeIndex: 13;
    player: ["2", "3"];
    dealer: ["4", "5"];
    status: "Player turn, hit or stand?";
}
*/

type Round1 = Hit<Hand>;
type Round2 = Hit<Round1>;
type Round3 = Stand<Round2>;

/*
type Round3 = {
    winBonus: 0;
    currentPoints: 21;
    shoeIndex: 17;
    player: ["2", "3", "7", "8"];
    dealer: ["4", "5", "9"];
    status: "YOU WIN! (Dealer: 18, You: 20)";
}
*/

type Hand2 = Deal<Round3>;
type Round4 = Hit<Hand2>;

/*
type Round4 = {
    winBonus: 0;
    currentPoints: 20;
    shoeIndex: 22;
    player: ["J", "6", "7"];
    dealer: ["K", "A"];
    status: "PLAYER BUST! (Dealer: 21, You: 23)";
}
*/

type Hand3 = Deal<Round4>;
type Round5 = Stand<Hand3>;

/*
type Round5 = {
    winBonus: 0;
    currentPoints: 19;
    shoeIndex: 28;
    player: ["8", "9"];
    dealer: ["10", "4", "5"];
    status: "YOU LOSE! (Dealer: 19, You: 17)";
}
*/

ts-blackjack's People

Contributors

dvail avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.