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!