XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

SpaceNinjaServer

A simple server for a small space ninja game

公开
关注 0 Fork 1 Star 0
返回提交历史

XFEstudio/SpaceNinjaServer

fix: account for infested enemySpec when validating sortie seed (#4261)

'difficulty' here was correct, but I removed it in attempting to fix it for 23418, which is FC_INFESTATION. Closes #4259 Reviewed-on: https://onlyg.it/OpenWF/SpaceNinjaServer/pulls/4261 Co-authored-by: Sainan <63328889+Sainan@users.noreply.github.com> Co-committed-by: Sainan <63328889+Sainan@users.noreply.github.com>

f319d581
Sainan <63328889+Sainan@users.noreply.github.com>
提交于

代码差异

1 个文件 +21 -11
Modified src/services/worldStateService.ts +21 -11
@@ -604,7 +604,7 @@ const pushTilesetModifiers = (modifiers: string[], tileset: TSortieTileset): voi
604 604 };
605 605
606 606 export const getSortie = (day: number, buildLabel: string): ISortie => {
607 // Seeds featuring CorpusIcePlanet to test seed validation: 23418, 71281
607 // Seeds featuring CorpusIcePlanet to test seed validation: 14197, 23418, 71281
608 608 const seed = new SRng(day).randomInt(0, 100_000);
609 609 logger.trace(`sortie seed: ${seed}`);
610 610 const rng = new SRng(seed);
@@ -717,7 +717,7 @@ export const getSortie = (day: number, buildLabel: string): ISortie => {
717 717 }
718 718
719 719 let clientSeed = rng.randomInt(0, 100_000);
720 while (!validateSortieSeed(clientSeed, selectedNodes)) {
720 while (!validateSortieSeed(clientSeed, enemyFaction, selectedNodes)) {
721 721 clientSeed = rng.randomInt(0, 100_000);
722 722 }
723 723
@@ -750,19 +750,20 @@ const SORTIE_FALLBACK_MISSION_TYPES: TMissionType[] = [
750 750 "MT_ARTIFACT"
751 751 ];
752 752
753 const validateSortieSeed = (seed: number, variants: ISortieMission[]): boolean => {
753 const validateSortieSeed = (seed: number, enemyFaction: TFaction, variants: ISortieMission[]): boolean => {
754 754 const rng = new SRng(seed);
755 755 for (const variant of variants) {
756 if (variant.missionType != "MT_ASSASSINATION") {
757 const tileset = ExportTilesets[variant.tileset];
756 let missionType = variant.missionType;
757 const tileset = ExportTilesets[variant.tileset];
758 if (missionType != "MT_ASSASSINATION") {
758 759 let missionPermutation = tileset.missions[variant.missionType];
759 760 if (!missionPermutation) {
760 761 const options = SORTIE_FALLBACK_MISSION_TYPES.filter(missionType => missionType in tileset.missions);
761 const replacementType = options[rng.randomInt(0, options.length - 1)];
762 missionPermutation = tileset.missions[replacementType]!;
763 /*logger.debug(
764 `${variant.missionType} not supported by ${variant.tileset}; picking ${replacementType} instead`
765 );*/
762 missionType = options[rng.randomInt(0, options.length - 1)];
763 missionPermutation = tileset.missions[missionType]!;
764 logger.trace(
765 `${variant.missionType} not supported by ${variant.tileset}; picking ${missionType} instead`
766 );
766 767 }
767 768 if (missionPermutation.enemySpecs?.length) {
768 769 rng.randomInt(1, missionPermutation.enemySpecs.length);
@@ -770,8 +771,17 @@ const validateSortieSeed = (seed: number, variants: ISortieMission[]): boolean =
770 771 if (missionPermutation.extraEnemySpecs?.length) {
771 772 rng.randomInt(1, missionPermutation.extraEnemySpecs.length);
772 773 }
774 rng.randomFloat(); // difficulty
773 775 }
774 if (variant.missionType != "MT_ARENA" && variant.missionType != "MT_JUNCTION") {
776 if (enemyFaction == "FC_INFESTATION" && tileset.faction != "FC_INFESTATION") {
777 // infested enemySpec
778 if (missionType == "MT_DEFENSE" || missionType == "MT_TERRITORY" || missionType == "MT_SURVIVAL") {
779 rng.randomInt(0, 1);
780 } else if (missionType != "MT_EXCAVATE") {
781 rng.randomInt(0, 3);
782 }
783 }
784 if (missionType != "MT_ARENA" && missionType != "MT_JUNCTION") {
775 785 const locationTextureIndex = rng.randomInt(0, 1);
776 786 if (variant.tileset == "CorpusIcePlanetTileset" || variant.tileset == "CorpusIcePlanetTilesetCaves") {
777 787 if (locationTextureIndex != 0) {