Giter Club home page Giter Club logo

basmalottery's Introduction

Basmalottery

"Here's something to think about: How come you never see a headline like 'Psychic Wins Lottery'?" - Jay Leno

This is a challenge given to a friend who is taking a web development course and I've decided to do the challenge as well.

Instructions for Development

Build a webpage which does the following:

* The user starts with $10 in virtual money.
* The user enters 4 distinct numbers between 1 and 10, inclusive. (see hint)
* The user presses a button which costs them $2, and the computer generates four distinct random numbers between 1 and 10 inclusive which are shown to the user.
* The user wins money based on n, where n is the number of numbers they guessed correctly. No winnings given if there are no matches. For example, you could do (0 = $0, 1 = $2, 2 = $4, 3 = $16, 4 = $64) or something similar.

## Details

1. Players cannot go into debt. Make sure the player has the money to pay for the lottery ticket. Display an error message if the user has run out of money.
2. Players should be able to play the same numbers over and over, but can change them if they want.
3. There is no upper limit to the amount you can win.
4. Make sure the user has entered valid numbers before they are allowed to play. Display an error message if the user has entered an invalid number.
5. Display an error message if the user has entered two of the same number

## Above and Beyond

1. Make the page beautiful
2. Allow the player to purchase more than one "ticket" before rolling the numbers.
3. Display an animation when the player rolls new numbers.
4. Use localstorage to keep track of the current high score.

Liberties Taken

  1. I'm utilizing frameworks rather than reinventing the wheel with vanilla JavaScript. For this project I'll be using jQuery for field and DOM manipulation as well as Underscore for utility and templating.
  2. I've used (2^n)^2 as my winnings formula, where n is the number of matching numbers. If there are no matches, the script prevents running the formula as 2^0^2, because anything to a zero power is one.
  3. Only having numbers 1 through 10 gave users too high of odds for winning, which made it nearly impossible to ever reach a zero balance. I'm allowing numbers 1-50 instead and up to 10 tickets active at a time.
  4. LocalStorage is used to store the Player's Balance, rather than a "high score", so a player can return to the game later and pick back up.

basmalottery's People

Contributors

ryanbarr avatar

Stargazers

 avatar

Watchers

 avatar James Cloos 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.