Skip to content

Commit

Permalink
Merge branch 'dev-3'
Browse files Browse the repository at this point in the history
Fix numerous small bugs
  • Loading branch information
Geyserexe committed Aug 9, 2020
2 parents 16e31a6 + bbac20a commit f9e356f
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 30 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -10,7 +10,7 @@ In order to run the teambuilder, open Terminal / cmd, cd into the builderbot fil
#### Config Info ####

- "teamNumber" controls the number of teams built. Whenever multiple teams are built, they'll be exported in a bulk format.
- "cutoff" controls the threshold at which the builder will allow a given pokemon onto a team, resulting in potentially less reliable builds at lower levels, but overly similar builds at higher levels
- "cutoff" controls the threshold at which the builder will allow a given pokemon onto a team, resulting in potentially less reliable builds at lower levels, but overly similar builds at higher levels. Cutoff 10 is likely to results in glitchy or inconsistent building.
- "teamLength" controls the number of Pokémon in a team, on the off chance that you want more / fewer than 6
- "tier" controls the team tiers when building in bulk. While it doesn't actually impact the building process, it's good practice to make sure it lines up with the gen setting below.
- "gen" controls which gen the builder builds for. Current options are gen7 and natdex.
Expand Down
21 changes: 17 additions & 4 deletions src/builders/gen7balancebuilder.js
Expand Up @@ -29,6 +29,9 @@ function tryBuild() {
util.init(stats);
return (buildTeam());
} catch (err) {
if(String(err).includes("RangeError")){
return ("error: recurseThreshold too high - try again or lower it.");
}
return (`error: ${err}`);
}
}
Expand Down Expand Up @@ -154,29 +157,39 @@ function buildTeam() {
}

for (let i = 0; i < team.length; i++) {
if (team[i] == null) {
throw ("cutoff too high");
}
let set = team[i].set;
let moves = "";
for (let a = 0; a < set.moves.length; a++) {
moves += `\n- ${set.moves[a]}`
moves += `\n- ${set.moves[a]}`;
}
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`;
}

for (let [key, value] of Object.entries(stats.ints)) {
if (value < config.recurseThreshold && config.teamNumber === 1) {
if (recursions > 1250 || (config.startMon.set && recursions > 1000)) {
throw ("recurseThreshold too high")
throw ("recurseThreshold too high");
}
recursions++;
teamString = buildTeam();
break;
} else if (key.toLowerCase() === "breaker" && value < config.breakerThreshold && config.teamNumber === 1) {
if (recursions > 1250 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("breakerThreshold too high")
throw ("breakerThreshold too high");
}
recursions++;
teamString = buildTeam();
break;
} else if (key.toLowerCase() === "defog" && value == false && config.teamNumber === 1) {
if (recursions > 1250 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high");
}
recursions++
teamString = buildTeam();
break;
}
}
}
Expand Down
16 changes: 11 additions & 5 deletions src/builders/gen7stallbuilder.js
Expand Up @@ -31,6 +31,9 @@ function tryBuild() {
return buildTeam();
}
catch (err) {
if(String(err).includes("RangeError")){
return ("error: recurseThreshold or breakerThreshold too high - try again or lower them.");
}
return (`error: ${err}`);
}
}
Expand All @@ -44,7 +47,7 @@ function buildTeam() {
team = [];

if (config.teamNumber > 1) {
teamString += `=== [${config.tier}] team${b} ===\n\n`;
teamString += `=== [${config.tier}] team${i} ===\n\n`;
}

prepTeam();
Expand All @@ -55,7 +58,7 @@ function buildTeam() {
let options = [];
for (let b = 0; b < sets.length; b++) {
if (!stats.defog && sets[b].defog && a < config.teamLength - 2 && util.isValid(sets[b], team)) {
options.push(sets[b])
options.push(sets[b]);
}
if (sets[b][priority] >= config.cutoff && util.isValid(sets[b], team) && sets[b].breaker < 5) {
if ((!stats.rocks) || (stats.rocks && !sets[b].rocks)) {
Expand All @@ -69,7 +72,7 @@ function buildTeam() {
for (let [key, value] of Object.entries(stats.ints)) {
if (value < config.recurseThreshold && config.teamNumber === 1) {
if (recursions > 3200 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high - lower it or try again")
throw ("recurseThreshold too high - lower it or try again");
}
recursions++;
teamString = buildTeam();
Expand All @@ -78,12 +81,15 @@ function buildTeam() {
}

for (let a = 0; a < team.length; a++) {
if(team[a] == null){
throw("cutoff too high");
}
let set = team[a].set;
let moves = "";
for(let b = 0; b < set.moves.length; b++){
moves += `\n- ${set.moves[b]}`
moves += `\n- ${set.moves[b]}`;
}
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`;
}
}

Expand Down
27 changes: 20 additions & 7 deletions src/builders/natdexbalancebuilder.js
Expand Up @@ -30,6 +30,9 @@ function tryBuild() {
util.init(stats);
return (buildTeam());
} catch (err) {
if(String(err).includes("RangeError")){
return ("error: recurseThreshold or breakerThreshold too high - try again or lower them.");
}
return (`error: ${err}`);
}
}
Expand Down Expand Up @@ -119,9 +122,9 @@ function buildTeam() {
} else {
if (config.breakerWeight < 3) {
if (sets[a].set.ability.toLowerCase().includes("bounce")) {
pruneArray.push(sets[a])
pruneArray.push(sets[a]);
} else if ((sets[a][priority] >= config.cutoff) && (sets[a].breaker <= config.breakerWeight)) {
pruneArray.push(sets[a])
pruneArray.push(sets[a]);
}
} else if (sets[a][priority] >= config.cutoff) {
pruneArray.push(sets[a]);
Expand Down Expand Up @@ -186,29 +189,39 @@ function buildTeam() {
}

for (let i = 0; i < team.length; i++) {
if (team[i] == null) {
throw ("cutoff too high");
}
let set = team[i].set;
let moves = "";
for (let a = 0; a < set.moves.length; a++) {
moves += `\n- ${set.moves[a]}`
moves += `\n- ${set.moves[a]}`;
}
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`;
}

for (let [key, value] of Object.entries(stats.ints)) {
if (key.toLowerCase() != "breaker" && value < config.recurseThreshold && config.teamNumber === 1) {
if (recursions > 1250 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high")
throw ("recurseThreshold too high");
}
recursions++;
teamString = buildTeam();
break;
} else if (key.toLowerCase() === "breaker" && value < config.breakerThreshold && config.teamNumber === 1) {
if (recursions > 1250 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("breakerThreshold too high")
if (recursions > 1000 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("breakerThreshold too high");
}
recursions++;
teamString = buildTeam();
break;
} else if (key.toLowerCase() === "defog" && value == false && config.teamNumber === 1) {
if (recursions > 1250 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high");
}
recursions++
teamString = buildTeam();
break;
}
}
}
Expand Down
26 changes: 18 additions & 8 deletions src/builders/natdexstallbuilder.js
Expand Up @@ -31,6 +31,9 @@ function tryBuild() {
return buildTeam();
}
catch (err) {
if(String(err).includes("RangeError")){
return ("error: recurseThreshold too high - try again or lower it.");
}
return (`error: ${err}`);
}
}
Expand All @@ -44,7 +47,7 @@ function buildTeam() {
team = [];

if (config.teamNumber > 1) {
teamString += `=== [${config.tier}] team${b} ===\n\n`;
teamString += `=== [${config.tier}] team${i} ===\n\n`;
}

prepTeam();
Expand All @@ -55,7 +58,7 @@ function buildTeam() {
let options = [];
for (let b = 0; b < sets.length; b++) {
if (!stats.defog && sets[b].defog && a < config.teamLength - 2 && util.isValid(sets[b], team)) {
options.push(sets[b])
options.push(sets[b]);
}
if (sets[b][priority] >= config.cutoff && util.isValid(sets[b], team)) {
if ((!stats.rocks) || (stats.rocks && !sets[b].rocks)) {
Expand All @@ -69,24 +72,31 @@ function buildTeam() {
for (let [key, value] of Object.entries(stats.ints)) {
if (value < config.recurseThreshold && config.teamNumber === 1) {
if (recursions > 3200 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high - lower it or try again")
throw ("recurseThreshold too high - lower it or try again");
}
recursions++;
teamString = buildTeam();
break;
} else if (key.toLowerCase() === "defog" && value == false && config.teamNumber === 1) {
if (recursions > 3200 || ((config.coreMode && config.startMon.set) && recursions > 500)) {
throw ("recurseThreshold too high");
}
recursions++
teamString = buildTeam();
break;
}
}

for (let a = 0; a < team.length; a++) {
if(team[a] == null){
throw("cutoff too high")
if (team[a] == null) {
throw ("cutoff too high");
}
let set = team[a].set;
let moves = "";
for (let a = 0; a < set.moves.length; a++) {
moves += `\n- ${set.moves[a]}`
for (let b = 0; b < set.moves.length; b++) {
moves += `\n- ${set.moves[b]}`;
}
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`;
}
}

Expand Down
9 changes: 6 additions & 3 deletions src/builders/offensebuilder.js
Expand Up @@ -44,19 +44,22 @@ function buildTeam() {
}
reps++;
if (reps > 10) {
throw ("Error finding breakers. Add more or try again.")
throw ("Error finding breakers. Add more or try again.");
}
}
}
}

for (let i = 0; i < team.length; i++) {
if(team[i] == null){
throw("cutoff too high");
}
let set = team[i].set;
let moves = "";
for (let a = 0; a < set.moves.length; a++) {
moves += `\n- ${set.moves[a]}`
moves += `\n- ${set.moves[a]}`;
}
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`
teamString += `${set.name} @ ${set.item}\nAbility: ${set.ability}\nEVs: ${set.evs}\n${set.nature} Nature${moves}\n\n`;
}
}
return (teamString);
Expand Down
4 changes: 2 additions & 2 deletions src/mon-sets/natdexsets.json
Expand Up @@ -928,13 +928,13 @@
"Refresh"
]
},
"breaker": 6,
"breaker": 5,
"ogreCheck": 5,
"donCheck": 0,
"ygodCheck": 1,
"xernCheck": 0,
"rayCheck": 2,
"zygCheck": 6,
"zygCheck": 5,
"zacCheck": 1,
"mega": false,
"z": false,
Expand Down

0 comments on commit f9e356f

Please sign in to comment.