rorywalsh/wizard

Update

Opened this issue · 5 comments

Hi Rory,

step by step i'm diving into the card game developing world, and javascript. Doing some developing on my own branch. Hopefully i can present it to you next weekend. If you are curious, have a look at my new branch.

Man, that's going to be a big project.... :)

I know 🙉 I'll take a look at your branch ;)

This looks interesting. So the new base card class becomes the new game state object? Or should there continue to be a game state class? The utility functions currently in the game state class could become part of the CardGame base class perhaps? Functions like dealCards() should probably be declared in the extended class based on the type of game, but what about those other methods, like findBestCard, best straight etc? Perhaps we can just create a static class for those kinds of things. They probably don't belong in a game class per say?

Hi @Robzon33 I just had another look now. i guess in host.js, under this approach instead of doing something like this:

function setup() {
    //create out game object
    game = new GameState();
    //add cards to game 
    game.addCards(Cards.createDeck(8, 7, 'French-suited', ['diamonds', 'clubs', 'spades', 'hearts'], []));
}

We just do:

function setup() {
    //create out game object
    game = new MaoMao();
}

And what of our abstract player class? Should each game class have its own dedicated extension of player?

I think we should keep that game state object, which holds the instance of the game. The host should tell the game state object, what kind of game we're playing (maybe via dropdown in the beginning).

Then the game state object will fetch the game rules. This is, i think, the tricky part. I dont know how to do that by now, but i feel like just try to get as far as possible with this approach.

Maybe it's going to look like this. Not sure so far....

function setup() {
    //create out game object
    gameState = new GameState();
    //select game
    gameState.setGame(new MaoMao(...));
}

@Robzon33 I just pushed through a crazy 8s branch. It builds on your latest branch. Crazy 8s is also a shedding game, so it shares some likeness to MoaMoa. I added a crazy 8 player type too, but I'm not sure if we need an extended player for each game type? Is it too much? I'm also not sure about this:

game.setGameType(new CrazyEights());

It reads a little strange. Perhaps game.createNewGame(new CrazyEights()) would be more intuitive? I also added a turnCardFromDeck() method, and anew discardPile member function. The discard pile represents the cards players have put down, or the ones that have been turned over from the deck. For now I'm putting these in the game state object.

Defining the rules is going to be really hard. I'm not sure we will be able to come up with some kind of generic way of doing it?