Skip to content

Commit

Permalink
Merge pull request #25 from IRONKLADD/NewScoring
Browse files Browse the repository at this point in the history
New scoring
  • Loading branch information
DeanTupper committed May 5, 2015
2 parents 4ebb7a4 + 9f4ba04 commit fa916cd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/core/Configuration.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,24 @@ function Configuration(width, height, colors, magnitudes, specials, types, turns

this.getRandomShell = function() {
return new Shell(Util.selectRandom(colors),
Util.selectRandom(magnitudes),
weightedMagnitude(),
Util.selectRandom(types),
Util.selectRandom(specials));
}
function weightedMagnitude(){
var weights = new Map([]);
weights.set(1, .40);
weights.set(2, .30);
weights.set(3, .15);
weights.set(4, .10);
weights.set(5, .05);
var p = 1 - Math.random();
for(var i = 1; i <= 5 ; i++){
var current = weights.get(i)
p = p - current;
if(p <= 0){
return i;
}
}
}
}
3 changes: 2 additions & 1 deletion src/gameTypes/Bombi/GameType.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ function BombiGameType(players, config) {
else if (shell.color === color) {
shell.type = Bombi.EMPTYSHELL;
shell.color = "trans";
player.score = player.score + 10;
player.score = player.score + (shell.magnitude*10);
renderer.explodeShell(row, col);
}
}
Expand Down Expand Up @@ -212,6 +212,7 @@ function BombiGameType(players, config) {
if(bombs !== undefined && bombs.length !== 0){
bombs.forEach(function (bomb) {
detonate(bomb, player);
player.score = player.score + 40
});
}
}
Expand Down

0 comments on commit fa916cd

Please sign in to comment.