Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions ck+/data.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
{

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: blank lines in json

"feature_flags": {
"badge_boost": true
},
"encounter_pools": {
"fishing": [
{
Expand Down
29 changes: 17 additions & 12 deletions ck+/script/calc.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,18 +111,23 @@ function getDamage(attacker, defender, attackerStages, defenderStages, move, pla
// Badge boost
var attackerBoost = player || (attacker.transformStats !== undefined);
var defenderBoost = !player || (defender.transformStats !== undefined);
if (attackerBoost && !special && badges >= attackBadges) {
a = parseInt(a * 1.125);
}
if (defenderBoost && !special && badges >= defenseBadges) {
d = parseInt(d * 1.125);
}
if (attackerBoost && special && badges >= specialBadges) {
a = parseInt(a * 1.125);
}
if (defenderBoost && special && badges >= specialBadges) {
d = parseInt(d * 1.125);

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no double blank lines in method bodies


if (game_general_flags.badge_boost) {
if (attackerBoost && !special && badges >= attackBadges) {
a = parseInt(a * 1.125);
}
if (defenderBoost && !special && badges >= defenseBadges) {
d = parseInt(d * 1.125);
}
if (attackerBoost && special && badges >= specialBadges) {
a = parseInt(a * 1.125);
}
if (defenderBoost && special && badges >= specialBadges) {
d = parseInt(d * 1.125);
}
}

// Screens
if (player) {
if (!special && document.getElementById("enemy-reflect").checked) {
Expand Down Expand Up @@ -192,7 +197,7 @@ function getModdedDamage(v, attacker, defender, ap, dp, power, type, move, playe

// TODO if (weather)

if (player && badgeTypes.has(type) && badgeTypes.get(type) <= badges) {
if (player && game_general_flags.badge_boost && badgeTypes.has(type) && badgeTypes.get(type) <= badges) {
v = parseInt(v * 1.125);
}

Expand Down
11 changes: 11 additions & 0 deletions ck+/script/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,12 @@ var doubleHitMoves = new Set([
"bonemerang", "double-hit", "double-kick", "twineedle"
]);

//ADD GENERAL FLAGS OBJECT TO GLOBAL VARIABLES

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: space before comment text

const game_general_flags = {

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might be better to go with a shorter name? I imagine flags will be used all over the codebase so something like flags would probably same some time.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it, I tend to use longer names to avoid comments but, in this case, I used both of them. I'll try to use shorter names from now on.

badge_boost: true
}


function fetchData() {
fetch("./data.json")
.then(response => response.text())
Expand Down Expand Up @@ -315,6 +321,11 @@ function fetchData() {
addPoolInfo(j.encounters[i]);
}

//ADD GENERAL FLAGS TO DATA PARSE
const feature_flags = j.feature_flags;
game_general_flags.badge_boost = feature_flags.badge_boost;

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is good for now but in the future we might want to go with a more general case parsing solution, what do you think?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the parsing is fine, every data.json file will have a series of specific parameters that define how the calc should behave. Documentation of the parsing part should be the first one imo.



var pokemonDataList;
for (const p of pokemonByName.keys()) {
pokemonDataList += `<option value="${fullCapitalize(p)}" />`
Expand Down
4 changes: 2 additions & 2 deletions ck+/script/display.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ function displayCalcPokemon(root, poke, opponent, right) {
if (opponent) {
var mySpe = getModifiedStat(poke, getStages(myStages), "spe");
var theirSpe = getModifiedStat(opponent, getStages(theirStages), "spe");
if (badges >= speedBadges) {
if (game_general_flags.badge_boost && badges >= speedBadges) {
if (player || poke.transformStats) {
mySpe = parseInt(mySpe * 1.125);
}
Expand Down Expand Up @@ -211,7 +211,7 @@ function prettyRolls(rolls) {
function displayCalcStat(div, poke, stat, player = false) {
var s = getPokeStat(poke, stat);
var o = s;
if (badges >= speedBadges && stat == "spe") {
if (game_general_flags.badge_boost && badges >= speedBadges && stat == "spe") {
if (player || poke.transformStats) {
s = parseInt(s * 1.125);
}
Expand Down