mrmikemcguire / Blackjack

1 stars 6 forks source link

table.js - use of the word selector #2

Open mrmikemcguire opened 8 years ago

mrmikemcguire commented 8 years ago

@gabesullice

In lines 3 & 5, am I right that I should be putting my HTML selector (in my case, '#table') where you have (selector)?

var Table = function (selector)
    {
    this.$board = $(selector);
    }
gabesullice commented 8 years ago

https://github.com/mrmikemcguire/Blackjack/pull/1#discussion-diff-43140394

When game gets created, part of its constructor is to initialize a new Table instance. selector is an argument in this case, so, you wouldn't want to replace it, but just pass it the '#table' selector.

The table selector is hardcoded in the Game constructor, but that constructor also takes an argument, options, which would override the hardcoded one in the constructor.

That would look something like this in blackjack or app.js:

var game = new Game({
  table: "#table",
  numPlayers: "2",
  deck: deck,
  startingPoints: 1000
});

That let's you create a game with different players, different decks (you could use three for instance), and different points to start.