From 5ccdcef1d64d6c111d2211cec67bf62c68bb1efc Mon Sep 17 00:00:00 2001 From: Robbie Antenesse Date: Wed, 31 Jul 2019 21:51:01 -0600 Subject: [PATCH] Initial commit with card generation --- cards.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ index.html | 15 ++++++++++++++ player.js | 16 +++++++++++++++ 3 files changed, 88 insertions(+) create mode 100644 cards.js create mode 100644 index.html create mode 100644 player.js diff --git a/cards.js b/cards.js new file mode 100644 index 0000000..fb1c7d6 --- /dev/null +++ b/cards.js @@ -0,0 +1,57 @@ +var cardColors = [ + 'red', + 'blue', + 'yellow', + 'black', + 'white', +]; +var cardShapes = [ + 'triangle', + 'square', + 'pentagon', +] + +var maxValue = 10; + +function createCard(id, rareChance) { + id = typeof id !== 'undefined' ? id : generateId(); + rarechance = typeof rareChance !== 'undefined' ? rareChance : 0.25; + var color = cardColors[Math.floor(Math.random() * (cardColors.length - (Math.random() < rareChance ? 0 : 2)))]; + var shape = cardShapes[Math.floor(Math.random() * (cardShapes.length - (Math.random() < rareChance ? 0 : 1)))]; + var value1 = Math.floor(Math.random() * maxValue) + 1; + var value2 = Math.floor(Math.random() * maxValue) + 1; + + return { + id: id, + color: color, + shape: shape, + value1: value1, + value2: value2, + }; +} + +function generateId() { + var id = ''; + for (var i = 0; i < 5; i++) { + id += Math.floor(Math.random() * 10).toString(); + } + return parseInt(id); +} + +function createPack() { + var cards = []; + for (var i = 0; i < 5; i++) { + cards.push(createCard(undefined, i > 2 ? 0.5 : undefined)); + } + return cards; +} + +function generateDatabase() { + var db = []; + for (var i = 0; i < 99999; i++) { + db.push(createCard(i + 1, 0.5)); + } + console.log(db); + var uriContent = "data:application/octet-stream," + encodeURIComponent(JSON.stringify(db)); + var newWindow = window.open(uriContent, 'cardDb.json'); +} \ No newline at end of file diff --git a/index.html b/index.html new file mode 100644 index 0000000..61adfb0 --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + カードス! (Kaadosu!) + + + + + + + \ No newline at end of file diff --git a/player.js b/player.js new file mode 100644 index 0000000..9ef270e --- /dev/null +++ b/player.js @@ -0,0 +1,16 @@ +function Player () { + this.collection = []; // Cards + this.decks = [ + // { + // name: 'Deck Name', + // cards: [], // Card ids + // } + ]; +} +Player.prototype.checkCurrency = function (type) { + if (typeof type !== 'undefined') { + for (var i = 0; i < this.collection.length; i++) { + + } + } +} \ No newline at end of file