Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Legacy code #60

Open
coyotte508 opened this issue Apr 16, 2021 · 0 comments
Open

Legacy code #60

coyotte508 opened this issue Apr 16, 2021 · 0 comments
Milestone

Comments

@coyotte508
Copy link
Member

This issue is to track what to remove on a major version:

      case Command.Decline: {
          if (command.data.offers) {
            ret.push({
              label: `Decline ${command.data.offers[0].offer}`,
              command: `${Command.Decline} ${command.data.offers[0].offer}`,
              warning:
                command.data.offers[0].offer === "tech" ? "Are you sure you want to decline a tech tile?" : undefined,
            });
          } else {
            // LEGACY CODE
            // TODO: Remove when games are updated
            ret.push({
              label: `Decline ${command.data.offer}`,
              command: `${Command.Decline} ${command.data.offer}`,
            });
          }
          break;
        }
[Command.ChargePower](player: PlayerEnum, income: string) {
    const leechCommand = this.availableCommand.data;
    // leech rewards are including +t, if needed and in the right sequence
    const leechRewards = Reward.parse(income);

    // Handles legacy stuff. To remove when all games with old engine have ended
    if (!leechCommand.offers) {
      leechCommand.offers = [{ offer: leechCommand.offer, cost: leechCommand.cost }];
    }

    const offer = leechCommand.offers.find((ofr) => ofr.offer === income);

    assert(
      offer,
      `Cannot leech ${income}. Possible leeches: ${leechCommand.offers.map((ofr) => ofr.offer).join(" - ")}`
    );

    this.player(player).gainRewards(leechRewards, Command.ChargePower);
    this.player(player).payCosts(Reward.parse(offer.cost), Command.ChargePower);
  }
// Legacy map generation, to keep old tests valid
    const oldGen = [
      "Gianluigi-Buffon",
      "randomSeed",
      "12",
      "9876",
      "yellow-paint-8951",
      "green-jeans-8458",
      "Fastgame01",
      "zadbd",
      "bosco-marcuzzo3",
      "Alex-Del-Pieroooooo",
      "SGAMBATA",
      "djfjjv4k",
      "randomSeed2",
      "randomseed",
      "polite-food-8474",
      "green-jeans-8458",
      "waiting-fabs-1",
      "curious-stay-2150",
      "Three",
      "GaiaRocks",
      "SalmurOnTheBoard",
    ].includes(this.seed);

    const [hexagon, ...hexagons] = conf.sectors.map((val: SectorInMapConfiguration, i) => {
      const def = (conf.mirror || oldGen ? rSectors : sectors)[val.sector].map;
      if (!val.center) {
        val.center = centers[i];
      }
      const center = val.center;

      return Sector.create(def, val.sector, center).rotateRight(val.rotation, center);
    });
// Due to legacy issues

const reverseSide = (side: string) => {
  return (
    side[0] +
    side.slice(1, 12).split("").reverse().join("") +
    side[12] +
    side.slice(13, 18).split("").reverse().join("") +
    side[18]
  );
};

const rSectors = keyBy(
  [s1, s2, s3, s4, s5, s5b, s6, s6b, s7, s7b, s8, s9, s10].map((s) => ({ name: s.name, map: reverseSide(s.map) })),
  "name"
);
  /** Fix old options passed. To remove when legacy data is no more in database */
  sanitizeOptions() {
    // if (get(this.options, "map.map")) {
    //   this.options.map.sectors = get(this.options, "map.map");
    //   set(this.options, "map.map", undefined);
    // }
  }
  it("should render as faded when given legacy data", async () => {
    const action = BoardActionEnum.Power1;
    const store = makeTestStore();
    store.state.gaiaViewer.data.boardActions[action] = PlayerEnum.Player5;
    const { container } = render(BoardAction, {
      props: {
        action,
      },
      store,
    });

    expect(container.querySelector(".faded")).to.not.be.null;
  });
    // Legacy value
    if ((player.settings.autoChargePower as AutoCharge | 0) === 0) {
      player.settings.autoChargePower = "decline-cost";
    }
    // LEGACY CODE
    // TODO: Remove when games are updated (also remove player !== Player.Player5)
    for (const key of Object.keys(engine.boardActions)) {
      const action = engine.boardActions[key];
      if (typeof action == "boolean") {
        engine.boardActions[key] = action ? null : PlayerEnum.Player5;
      }
    }
  static fromData(data: Record<string, any>) {
    const engine = new Engine();
    delete engine.version; // here
  • The Auction behavior
@coyotte508 coyotte508 added this to the Breaking milestone Apr 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant