-
Notifications
You must be signed in to change notification settings - Fork 11
Feature: Add badge boost flag in data.json #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| { | ||
|
|
||
| "feature_flags": { | ||
| "badge_boost": true | ||
| }, | ||
| "encounter_pools": { | ||
| "fishing": [ | ||
| { | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
|
|
||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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) { | ||
|
|
@@ -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); | ||
| } | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -218,6 +218,12 @@ var doubleHitMoves = new Set([ | |
| "bonemerang", "double-hit", "double-kick", "twineedle" | ||
| ]); | ||
|
|
||
| //ADD GENERAL FLAGS OBJECT TO GLOBAL VARIABLES | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: space before comment text |
||
| const game_general_flags = { | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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()) | ||
|
|
@@ -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; | ||
|
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)}" />` | ||
|
|
||
There was a problem hiding this comment.
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