Skip to content

Commit

Permalink
Breakpoint and bulkpoint table wrapup, adjusted filters
Browse files Browse the repository at this point in the history
IV combo generator now accepts multiple filters to check for combinations that reach a minimum set of stats.
  • Loading branch information
pvpoke committed Jul 2, 2019
1 parent 3e8984c commit df05afe
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 15 deletions.
14 changes: 13 additions & 1 deletion src/battle.php
Expand Up @@ -141,12 +141,24 @@
<tr>
<td><span class="name name-fast">Move</span></td>
<td><span class="name">Minimum Attack</span></td>
<td><span class="name">Best Level &amp; IV's</span></td>
<td><span class="name">Top Level &amp; IV's</span></td>
</tr>
<tbody class="output">
</tbody>
</table>

<p><span class="name-attacker">Pokemon</span> can reach the following bulkpoints against this <span class="name-defender">Pokemon</span>:</p>

<table class="stats-table bulkpoints" cellspacing="0">
<tr>
<td><span class="name name-fast">Move</span></td>
<td><span class="name">Minimum Defense</span></td>
<td><span class="name">Top Level &amp; IV's</span></td>
</tr>
<tbody class="output">
</tbody>
</table>
<div class="golden-combination"></div>
</div>

<h2 class="center">Battle Stats</h2>
Expand Down
13 changes: 12 additions & 1 deletion src/css/style.css
Expand Up @@ -810,7 +810,18 @@ select, input {
font-size: 14px;
margin: 0;
padding: 5px;
border: 1px solid #000; }
border: none;
background: #333 !important;
color: #eee; }
.battle-results .battle-details .breakpoints-section .golden-combination .button {
display: inline-block;
font-size: 14px;
padding: 5px 15px;
margin: 0;
font-weight: bold;
border: none;
background: #333 !important;
color: #eee; }
.battle-results.multi {
text-align: left; }
.battle-results.multi .poke-search {
Expand Down
15 changes: 14 additions & 1 deletion src/css/style.scss
Expand Up @@ -1229,7 +1229,20 @@ select, input{
font-size:14px;
margin:0;
padding: 5px;
border: 1px solid #000;
border: none;
background:$color-off-black !important;
color:$color-off-white;
}

.golden-combination .button{
display:inline-block;
font-size:14px;
padding: 5px 15px;
margin:0;
font-weight:bold;
border: none;
background:$color-off-black !important;
color:$color-off-white;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/js/battle/Battle.js
Expand Up @@ -167,7 +167,7 @@ function Battle(){

var bonusMultiplier = 1.3;

var defense = (damage - 1) / (move.power * move.stab * effectiveness * 0.5 * bonusMultiplier * attack);
var defense = (move.power * move.stab * effectiveness * 0.5 * bonusMultiplier * attack) / (damage);

return defense;
}
Expand Down
38 changes: 34 additions & 4 deletions src/js/interface/Interface.js
Expand Up @@ -89,7 +89,7 @@ var InterfaceMaster = (function () {

$("body").on("click", ".rating-table a.rating.star", viewShieldBattle);
$("body").on("click", ".section.summary a.rating.star", viewBulkBattle);
$("body").on("click", ".breakpoints-section .stats-table .button", selectBreakpointIVs);
$("body").on("click", ".breakpoints-section .button", selectBreakpointIVs);

// Sandbox mode

Expand Down Expand Up @@ -656,7 +656,7 @@ var InterfaceMaster = (function () {
var attack = Math.round(breakpoints[i].attack * 100) / 100;

// Find the best combinations that reaches this value
var combinations = pokemon[0].generateIVCombinations("overall", 1, 2, "atk", attack);
var combinations = pokemon[0].generateIVCombinations("overall", 1, 2, [{stat: "atk", value: breakpoints[i].attack}]);

$(".stats-table.breakpoints .output").append("<tr class=\"toggle\"><td>"+breakpoints[i].damage+"</td><td>"+attack+"</td><td class=\"ivs\"><div class=\"button\" level=\""+combinations[0].level+"\" atk=\""+combinations[0].ivs.atk+"\" def=\""+combinations[0].ivs.def+"\" hp=\""+combinations[0].ivs.hp+"\">"+combinations[0].level+ " "+combinations[0].ivs.atk+"/"+combinations[0].ivs.def+"/"+combinations[0].ivs.hp+"</div></td></tr>");

Expand All @@ -666,9 +666,39 @@ var InterfaceMaster = (function () {

}

var bulkponts = pokemon[0].calculateBulkpoints(pokemon[1]);
var bulkpoints = pokemon[0].calculateBulkpoints(pokemon[1]);

$(".stats-table.bulkpoints .name-fast").html(pokemon[1].fastMove.name + " Damage");
$(".stats-table.bulkpoints .output").html('<tr></tr>');

console.log(bulkponts);
for(var i = 0; i < bulkpoints.length; i++){
var defense = Math.round(bulkpoints[i].defense * 100) / 100;

// Find the best combinations that reaches this value
var combinations = pokemon[0].generateIVCombinations("overall", 1, 2, [{stat: "def", value: bulkpoints[i].defense}]);

$(".stats-table.bulkpoints .output").append("<tr class=\"toggle\"><td>"+bulkpoints[i].damage+"</td><td>"+defense+"</td><td class=\"ivs\"><div class=\"button\" level=\""+combinations[0].level+"\" atk=\""+combinations[0].ivs.atk+"\" def=\""+combinations[0].ivs.def+"\" hp=\""+combinations[0].ivs.hp+"\">"+combinations[0].level+ " "+combinations[0].ivs.atk+"/"+combinations[0].ivs.def+"/"+combinations[0].ivs.hp+"</div></td></tr>");

if(bulkpoints[i].damage == pokemon[1].fastMove.damage){
$(".stats-table.bulkpoints .output tr").last().addClass("bold");
}

}

// Find a golden combination that reaches the best breakpoint and bulkpoint if one exists

var bestAttack = breakpoints[breakpoints.length-1].attack;
var bestDefense = bulkpoints[0].defense;
var combinations = pokemon[0].generateIVCombinations("overall", 1, 2, [
{stat: "atk", value: bestAttack},
{stat: "def", value: bestDefense}
]);

$(".breakpoints-section .golden-combination").html('');

if((combinations.length > 0)&&(breakpoints.length > 1)&&(bulkpoints.length > 1)){
$(".breakpoints-section .golden-combination").append("<p><div class=\"button\" level=\""+combinations[0].level+"\" atk=\""+combinations[0].ivs.atk+"\" def=\""+combinations[0].ivs.def+"\" hp=\""+combinations[0].ivs.hp+"\">"+combinations[0].level+ " "+combinations[0].ivs.atk+"/"+combinations[0].ivs.def+"/"+combinations[0].ivs.hp+"</div> "+pokemon[0].speciesName+" reaches its best breakpoint and best bulkpoint.</p>");
}

}

Expand Down
2 changes: 1 addition & 1 deletion src/js/interface/PokeSelect.js
Expand Up @@ -612,7 +612,7 @@ function PokeSelect(element, i){
// Turn maximize stats on and off

$el.find(".maximize-stats").on("click", function(e){
var sortStat = $(".maximize-section .check.on").first().attr("value");
var sortStat = $el.find(".maximize-section .check.on").first().attr("value");

selectedPokemon.maximizeStat(sortStat);

Expand Down
14 changes: 8 additions & 6 deletions src/js/pokemon/Pokemon.js
Expand Up @@ -216,7 +216,7 @@ function Pokemon(id, i, b){

// Generate an array of IV combinations sorted by stat

this.generateIVCombinations = function(sortStat, sortDirection, resultCount, minStat, minValue) {
this.generateIVCombinations = function(sortStat, sortDirection, resultCount, filters) {
var targetCP = battle.getCP();
var level = 40;
var atkIV = 15;
Expand Down Expand Up @@ -304,9 +304,11 @@ function Pokemon(id, i, b){

// Check if a minimum value must be reached

if(minStat){
if(combination[minStat] < minValue){
valid = false;
if(filters){
for(var i = 0; i < filters.length; i++){
if(combination[filters[i].stat] < filters[i].value){
valid = false;
}
}
}

Expand Down Expand Up @@ -356,12 +358,12 @@ function Pokemon(id, i, b){
var minDefense = self.generateIVCombinations("def", -1, 1)[0].def;
var maxDefense = self.generateIVCombinations("def", 1, 1)[0].def;
var minDamage = battle.calculateDamageByStats(attacker.stats.atk, maxDefense, effectiveness, attacker.fastMove);
var maxDamage = battle.calculateDamageByStats(attacker.stats.atk, maxDefense, effectiveness, attacker.fastMove);
var maxDamage = battle.calculateDamageByStats(attacker.stats.atk, minDefense, effectiveness, attacker.fastMove);

var breakpoints = [];

for(var i = minDamage; i <= maxDamage; i++){
var bulkpoint = battle.calculateBulkpoint(i, attacker.stats.atk, effectiveness, self.fastMove);
var bulkpoint = battle.calculateBulkpoint(i, attacker.stats.atk, effectiveness, attacker.fastMove);
breakpoints.push({
damage: i,
defense: bulkpoint
Expand Down

0 comments on commit df05afe

Please sign in to comment.