Skip to content

Commit

Permalink
Addressed PR concerns
Browse files Browse the repository at this point in the history
Changed exception type to RangeError
Removed extraneous braces
Declared variables in one line where applicable
  • Loading branch information
0spooky2me committed Sep 24, 2018
1 parent 8965798 commit bdede0b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
15 changes: 6 additions & 9 deletions imports/api/HandScoreCalculator.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function jpn_dealin_delta(points,
loserWind,
riichiSticks) {
let winds = {};
Constants.WINDS.forEach(w => {winds[w] = 0});
Constants.WINDS.forEach(w => winds[w] = 0);

let handValue;
let bonusPoints = bonus * Constants.JPN_BONUS_POINTS;
Expand All @@ -42,7 +42,7 @@ function jpn_dealin_delta(points,
// Check to see if you have to count basic points
if (points < 5) {
if (fu === 20 || (points === 1 && fu === 25)) {
throw TypeError("Invalid points/fu combination");
throw RangeError("Invalid points/fu combination");
} else {
// Calculate hand value, if it's above a mangan, cap it there
let manganPayout = Constants.JPN_MANGAN_BASE_POINTS * multiplier;
Expand Down Expand Up @@ -74,17 +74,14 @@ function jpn_dealin_delta(points,
*/
function jpn_selfdraw_delta(points, fu, bonus, dealerWind, winnerWind, riichiSticks) {
let winds = {};
Constants.WINDS.forEach(w => {winds[w] = 0});
let basicPoints;
let nonDealerPays;
let dealerPays;
let currentBonus = bonus;
Constants.WINDS.forEach(w => winds[w] = 0);
let basicPoints, nonDealerPays, dealerPays;
let individualBonusPayout = Constants.JPN_BONUS_POINTS / 3;

// Check to see if you have to count basic points
if (points < 5) {
if ((points === 1 && (fu === 20 || fu === 25)) || (points === 2 && fu === 25)) {
throw TypeError("Invalid points/fu combination");
throw RangeError("Invalid points/fu combination");
} else {
// Calculate hand value, if it's above a mangan, cap it there
basicPoints = fu * Math.pow(2, 2 + points);
Expand Down Expand Up @@ -121,7 +118,7 @@ function jpn_selfdraw_delta(points, fu, bonus, dealerWind, winnerWind, riichiSti
*/
function jpn_mistake_delta(loser) {
let winds = {};
Constants.WINDS.forEach(w => {winds[w] = Constants.JPN_MISTAKE_POINTS / 3});
Constants.WINDS.forEach(w => winds[w] = Constants.JPN_MISTAKE_POINTS / 3);

winds[loser] = -Constants.JPN_MISTAKE_POINTS;
return winds;
Expand Down
6 changes: 3 additions & 3 deletions imports/ui/record-game/RecordJapaneseGame.js
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ function push_dealin_hand(template) {
var loserWind = GameRecordUtils.playerToDirection(Session.get("round_loser"));
var riichiSum = Session.get("free_riichi_sticks");
let seatDeltas = {};
Constants.WINDS.forEach(w => {seatDeltas[w] = 0});
Constants.WINDS.forEach(w => seatDeltas[w] = 0);

if (winnerWind == Constants.EAST) {
Session.set("eastPlayerWins", Number(Session.get("eastPlayerWins")) + 1);
Expand Down Expand Up @@ -879,7 +879,7 @@ function push_selfdraw_hand(template) {
var winnerWind = GameRecordUtils.playerToDirection(Session.get("round_winner"));
var riichiSum = Session.get("free_riichi_sticks");
let seatDeltas = {};
Constants.WINDS.forEach(w => {seatDeltas[w] = 0});
Constants.WINDS.forEach(w => seatDeltas[w] = 0);

if (winnerWind == Constants.EAST) {
Session.set("eastPlayerWins", Number(Session.get("eastPlayerWins")) + 1);
Expand Down Expand Up @@ -1095,7 +1095,7 @@ function push_split_pao_hand(template) {
var paoWind = GameRecordUtils.playerToDirection(Session.get("round_pao_player"));
var riichiSum = Session.get("free_riichi_sticks");
let seatDeltas = {};
Constants.WINDS.forEach(w => {seatDeltas[w] = 0});
Constants.WINDS.forEach(w => seatDeltas[w] = 0);

if (winnerWind == Constants.EAST) {
Session.set("eastPlayerWins", Number(Session.get("eastPlayerWins")) + 1);
Expand Down

0 comments on commit bdede0b

Please sign in to comment.