Giter VIP home page Giter VIP logo

pig-game's Introduction

PIG GAME

*PIG GAME is one project I learned from Jonas Schmedtmann.

BRIEF

A dice game | DEMO

KEYWORDS

DOM, JavaScript, Events

FEATURES

How To Play

  1. Click ROLL DICE button to randomly generate a dice number between 1-6;
  2. You can keep rolling the dice unless the dice number is 1 (see 4 to understand what would happen if the dice number is 1). All the dice numbers will add to your CURRENT score;
  3. You can choose either HOLD, which will add your CURRENT score to your PLAYER 1/2 score (your final score) and then switch to the other player, or ROLL DICE unless the dice number is 1 (taking own risk :).
  4. If the dice number is 1, you will automatically lose your CURRENT score and switch to the other player.

About Scores

Whosever final score reaches 100 will win the game!

Flowchart

Pig-game flowchart

graph TD
A([User: roll dice]) --> A1[Generate a random dice]
    A1 --> A2[Display dice]
    A2 --> A3{Is dice 1?}
    A3 -->|No|A4[Add dice to current score]
    A3 -->|Yes|D[Switch player]
    A4 --> A5[Display new score]

    B([User: hold score])--> B1[Add current score to total score]
    B1 --> B2{Score >= 100?}
    B2 -->|No|D
    B2 -->|Yes|B3[Current player wins!]


    C([User: reset game])--> C1[Set all scores to 0]
    C1 --> C2[Set player 1 as starting player]
Loading

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.