Game Development Reference
In-Depth Information
Fifty points are rewarded for a Fakezee. This same function is used to check for bonus Fakezees. To receive a
bonus Fakezee, the player must have previously rolled a Fakezee and scored on the Fakezee category, respectively.
In the getScore function, a case for the type bonus calls on this same function to check the dice. The result is
multiplied by 2 and returned back to the game. This gives a score of either 100 or 0. Later, in the section “Using the
Scoring Class,” this bonus check will be added to the game logic.
The Complete Scoring Class
The Scoring class is now complete and ready to be used in the game. Listing 7-40 shows the entire Scoring object,
which resides in the file Scoring . js .
Listing 7-40. Scoring.js, the Complete Scoring Class
var Scoring = {
dice:[],
btnKey:null
};
Scoring.getScore = function (type, dice, key) {
dice.sort();
this.dice = dice;
this.btnKey = key;
switch (type) {
case 'ones':
case 'twos':
case 'threes':
case 'fours':
case 'fives':
case 'sixes':
return this.getNumberScore();
break;
case 'threeKind':
case 'fourKind':
return this.getKinds();
break;
case 'small':
case 'large':
this.dice = this.uniqueArray(this.dice);
return this.getStraights();
break;
case 'fullHouse':
return this.getFullHouse();
break;
case 'chance':
return this.getChance();
break;
case 'fakezee':
return this.getFakezee();
break;
 
Search WWH ::




Custom Search