rorywalsh/wizard

Moving player out of dealer object

Opened this issue · 1 comments

@Robzon33 Now that the dealer class is a first class citizen, I think we should do the same with the players. We can continue to update the dealer so he knows what the players are doing, but having them a children of the dealer makes no sense and clutters things up....

For example, this looks, and reads really bad:

dealer.getPlayer(id).playACard(dealer, card);

..this looks a little cleaner:

player[id].playACard(dealer, card);

Or we could always pass the dealer object to the player class when we instantiate it so it reads like this:

player[id].playACard(card);

This definitely looks better to me. The dealer doesn't own the players, but it must moderate them. Likewise the players should be aware of the dealer, but should also be independent of it.

In this case we shall be sharing both the players and dealer objects between the host and player scripts rather than one all encompassing game object as we do now.

I've created a new develop2 branch in which I'm going to explore this. I'll let you know how it goes..

I've made quite a few changes here in terms of project structure. I've also refactored quite a lot of code. I've removed all GUI code from the main library source. To that end I've put all abstract class into a cardsjs folder and all GUI code into the main public folder. The following readme's might help give you an idea of what the new layout looks like:

https://github.com/rorywalsh/wizard/tree/develop2/public/cardsjs
https://github.com/rorywalsh/wizard/tree/develop2/public

I think this it much cleaner. Let me know what you think. Note that I have put the base game class, and the extended game families into a single js file.