Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
public submit(): void {
this.loading = true;
const formRaw = this.configForm.getRawValue();
const configuration: SolverConfiguration = {
populationSize: defaultConfiguration.populationSize,
progressAccuracy: defaultConfiguration.progressAccuracy,
hqTarget: formRaw.hqTarget
};
const gcfParams: any = {
configuration: configuration,
recipe: this.recipe,
stats: { ...this.stats }
};
if (formRaw.seeded && this.seed.length > 0) {
gcfParams.seed = CraftingActionsRegistry.serializeRotation(this.seed);
}
// To debug using local function: http://localhost:5001/ffxivteamcraft/us-central1/solver
// Prod: https://us-central1-ffxivteamcraft.cloudfunctions.net/solver
this.http.post(`https://us-central1-ffxivteamcraft.cloudfunctions.net/solver `, gcfParams).subscribe(res => {
this.ref.close(CraftingActionsRegistry.deserializeRotation(res));
});
}
}
if (req.method === 'OPTIONS') {
// Send response to OPTIONS requests
res.status(204).send('');
} else {
const stats = new CrafterStats(
req.body.stats.jobId,
req.body.stats.craftsmanship,
req.body.stats.control,
req.body.stats.cp,
req.body.stats.specialist,
req.body.stats.level,
req.body.stats.levels
);
const solver = new Solver(req.body.recipe, stats, req.body.configuration);
const seed = req.body.seed ? CraftingActionsRegistry.deserializeRotation(req.body.seed) : undefined;
return res.json(CraftingActionsRegistry.serializeRotation(solver.run(seed)));
}
});