var deck = []; var card = { 'numb' : '0', 'suit' : 'none' } var turn = 1 var game = { targetGrid1 : [], targetGrid2 : [], shipsGrid1 : [], shipsGrid2 : [], ships1 : [ { 'type': 'pt', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 2 }, { 'type': 'sub', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 3 }, { 'type': 'battle', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 4 }, { 'type': 'carrier', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 5 } ], ships2 : [ { 'type': 'pt', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 2 }, { 'type': 'sub', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 3 }, { 'type': 'battle', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 4 }, { 'type': 'carrier', 'start': {'let': z, 'num': 0} , 'end': {'let': z, 'num': 0}, 'length' : 5 } ], turn : -1, /// set -1, -2 are setup pick1 : {'let': z, 'num': 0}, pick2 : {'let': z, 'let': 0}, createGrid () { // create red console.log('createDeck'); for (i = 0; i < 13; i++) { this.deck.push({ 'numb' : i, 'suit' : 'red', 'show' : 0 }); }; // create blue for (i = 0; i < 13; i++) { console.log(i); this.deck.push({ 'numb' : i, 'suit' : 'blue', 'show' : 0 }); }; }, shuffleDeck (a) { var j, x, i; for (i = a.length; i; i--) { j = Math.floor(Math.random() * i); x = a[i - 1]; a[i - 1] = a[j]; a[j] = x; } }, showDeck () { var body = document.getElementsByTagName('body'); var el = document.createElement("div"); el.innerHTML = '
'; }, init () { this.createDeck(); this.shuffleDeck(this.deck); this.showDeck(); }, end () { } }; game.init();