What objects would get defined in a Bridge scoring app (Javascript)

Posted by Alex Mcp on Stack Overflow See other posts from Stack Overflow or by Alex Mcp
Published on 2010-03-21T03:23:36Z Indexed on 2010/03/21 3:31 UTC
Read the original article Hit count: 364

Filed under:
|
|
|

I'm writing a Bridge (card game) scoring application as practice in javascript, and am looking for suggestions on how to set up my objects. I'm pretty new to OO in general, and would love a survey of how and why people would structure a program to do this (the "survey" begets the CW mark. Additionally, I'll happily close this if it's out of range of typical SO discussion).

The platform is going to be a web-app for webkit on the iPhone, so local storage is an option. My basic structure is like this:

var Team = {
    player1: ,
    player2: ,
    vulnerable: ,  //this is a flag for whether or 
                   //not you've lost a game yet, affects scoring
    scoreAboveLine: ,
    scoreBelowLine: 
    gamesWon: 
};

var Game = {
    init: ,//function to get old scores and teams from DB
    currentBid: ,
    score: , //function to accept whether bid was made and apply to Teams{}
    save: //auto-run that is called after each game to commit to DB
};

So basically I'll instantiate two teams, and then run loops of game.currentBid() and game.score. Functionally the scoring is working fine, but I'm wondering if this is how someone else would choose to break down the scoring of Bridge, and if there are any oversights I've made with regards to OO-ness and how I've abstracted the game.

Thanks!

© Stack Overflow or respective owner

Related posts about oop

Related posts about JavaScript