How to use @ffxiv-teamcraft/simulator - 10 common examples

To help you get started, we’ve selected a few @ffxiv-teamcraft/simulator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / components / solver-popup / solver-popup.component.ts View on Github external
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));
    });
  }
}
github ffxiv-teamcraft / ffxiv-teamcraft / functions / index.js View on Github external
res.set('Access-Control-Max-Age', '3600');
  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)));
  }
});
github ffxiv-teamcraft / ffxiv-teamcraft / functions / index.js View on Github external
exports.solver = functions.runWith(runtimeOpts).https.onRequest((req, res) => {
  res.set('Access-Control-Allow-Methods', 'POST');
  res.set('Access-Control-Allow-Origin', '*');
  res.set('Access-Control-Allow-Headers', '*');
  res.set('Access-Control-Max-Age', '3600');
  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)));
  }
});
github ffxiv-teamcraft / ffxiv-teamcraft / functions / index.js View on Github external
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)));
  }
});
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / components / macro-popup / macro-popup.component.ts View on Github external
this.rotation.forEach((action, actionIndex) => {
      let macroFragment = this.macro[this.macro.length - 1];
      // One macro is 15 lines, if this one is full, create another one.
      // Alternatively, if breaking before Byregots Blessing is enabled, split there too.
      if ((this.breakBeforeByregotsBlessing && action.is(ByregotsBlessing)) || macroFragment.length >= this.maxMacroLines) {
        this.macro.push(this.macroLock ? ['/mlock'] : []);
        macroFragment = this.macro[this.macro.length - 1];
      }
      if (action.getIds()[0] === -1) {
        macroFragment.push(`/statusoff "${this.i18n.getName(this.l12n.getAction(new FinalAppraisal().getIds()[0]))}"`);
        totalLength++;
      } else {
        let actionName = this.i18n.getName(this.l12n.getAction(action.getIds()[0]));
        if (actionName.indexOf(' ') > -1 || this.translator.currentLang === 'ko') {
          actionName = `"${actionName}"`;
        }
        macroFragment.push(`/ac ${actionName} `);
        totalLength++;
      }

      let doneWithChunk: boolean;
      if (this.breakBeforeByregotsBlessing && actionIndex < this.rotation.length - 1 && this.rotation[actionIndex+1].is(ByregotsBlessing)) {
        doneWithChunk = true;
      } else if (macroFragment.length === 14 && this.addEcho && this.rotation.length > totalLength + 1) {
        doneWithChunk = true;
      }
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / rotation-tips / tips / use-byregot-blessing-high-iq-stacks.ts View on Github external
matches(simulationResult: SimulationResult): boolean {
    const blessingIndex = simulationResult.steps.findIndex(step => step.action.is(ByregotsBrow));
    const clone = simulationResult.simulation.clone();
    clone.run(true, blessingIndex - 1);
    return clone.getBuff(Buff.INNER_QUIET) && clone.getBuff(Buff.INNER_QUIET).stacks > 6 && simulationResult.simulation.quality < simulationResult.simulation.recipe.quality;
  }
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / rotation-tips / tips / use-byregot-brow-5-stacks.ts View on Github external
matches(simulationResult: SimulationResult): boolean {
    const blessingIndex = simulationResult.steps.findIndex(step => step.action.is(ByregotsBlessing));
    const clone = simulationResult.simulation.clone();
    clone.run(true, blessingIndex - 1);
    return clone.getBuff(Buff.INNER_QUIET) && clone.getBuff(Buff.INNER_QUIET).stacks === 5;
  }
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / rotation-tips / tips / use-byregot-brow-low-iq-stacks.ts View on Github external
matches(simulationResult: SimulationResult): boolean {
    const blessingIndex = simulationResult.steps.findIndex(step => step.action.is(ByregotsBlessing));
    const clone = simulationResult.simulation.clone();
    clone.run(true, blessingIndex - 1);
    return clone.getBuff(Buff.INNER_QUIET) && clone.getBuff(Buff.INNER_QUIET).stacks < 6 && simulationResult.simulation.quality < simulationResult.simulation.recipe.quality;
  }
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / rotation-tips / tips / use-patient-touch-faster.ts View on Github external
return patientTouchIndexes.some(index => {
      const clone = simulationResult.simulation.clone();
      clone.run(true, index);
      return clone.getBuff(Buff.INNER_QUIET) && clone.getBuff(Buff.INNER_QUIET).stacks > 1;
    });
  }
github ffxiv-teamcraft / ffxiv-teamcraft / apps / client / src / app / pages / simulator / components / rotation-panel / rotation-panel.component.ts View on Github external
openMacroPopup(simulation: Simulation): void {
    this.dialog.create({
      nzContent: MacroPopupComponent,
      nzComponentParams: {
        rotation: CraftingActionsRegistry.deserializeRotation(this.rotation.rotation),
        job: this.rotation.recipe.job,
        simulation: simulation.clone(),
        food: this.foods.find(f => this.rotation.food && f.itemId === this.rotation.food.id && f.hq === this.rotation.food.hq),
        medicine: this.medicines.find(f => this.rotation.medicine && f.itemId === this.rotation.medicine.id && f.hq === this.rotation.medicine.hq),
        freeCompanyActions: this.freeCompanyActions.filter(action => this.rotation.freeCompanyActions.indexOf(action.actionId) > -1)
      },
      nzTitle: this.translate.instant('SIMULATOR.Generate_ingame_macro'),
      nzFooter: null
    });
  }