Ejemplo n.º 1
0
  private void assignState(Alite alite) {
    Player player = alite.getPlayer();
    GalaxyGenerator generator = alite.getGenerator();
    PlayerCobra cobra = alite.getCobra();

    player.setName(state.getCommanderName());
    generator.setCurrentGalaxy(state.getGalaxyNumber());
    boolean newGalaxy = generator.setCurrentSeed(state.getGalaxySeed(17));
    if (player.getCurrentSystem() == null
        || state.getCurrentSystem() != player.getCurrentSystem().getIndex()
        || newGalaxy) {
      player.setCurrentSystem(generator.getSystem(state.getCurrentSystem()));
    }
    player.setHyperspaceSystem(generator.getSystem(state.getHyperspaceSystem()));
    cobra.setFuel(state.getFuel());
    player.setCash(state.getCredits());
    player.setRating(Rating.values()[state.getRating()]);
    player.setLegalStatus(LegalStatus.values()[state.getLegalStatus()]);
    alite.setGameTime(state.getGameTime() * 1000000);
    player.setScore(state.getScore());
    cobra.setMissiles(state.getNumberOfMissiles());
    int extraEnergyUnit = state.getExtraEnergyUnit();
    setEquipped(cobra, EquipmentStore.extraEnergyUnit, extraEnergyUnit == 1);
    setEquipped(cobra, EquipmentStore.navalEnergyUnit, extraEnergyUnit == 2);
    setEquipped(cobra, EquipmentStore.largeCargoBay, state.isLargeCargoBay());
    setEquipped(cobra, EquipmentStore.ecmSystem, state.isECM());
    setEquipped(cobra, EquipmentStore.fuelScoop, state.isFuelScoop());
    setEquipped(cobra, EquipmentStore.escapeCapsule, state.isEscapeCapsule());
    setEquipped(cobra, EquipmentStore.energyBomb, state.isEnergyBomb());
    setEquipped(cobra, EquipmentStore.dockingComputer, state.isDockingComputer());
    setEquipped(cobra, EquipmentStore.galacticHyperdrive, state.isGalacticHyperdrive());
    setEquipped(cobra, EquipmentStore.cloakingDevice, state.isCloakingDevice());
    setEquipped(cobra, EquipmentStore.ecmJammer, state.isECMJammer());
    alite.setIntergalActive(state.isGalacticHyperdrive());
    setEquipped(cobra, EquipmentStore.retroRockets, state.isRetroRockets());
    // Punish player for cheating: If he enters values for all laser types,
    // accept the least powerful one only... (I.e. set military laser first and
    // overwrite it with lesser lasers if values are present...)
    equipLaser(15, null, cobra);
    equipLaser(state.getMilitaryLaser(), EquipmentStore.militaryLaser, cobra);
    equipLaser(state.getBeamLaser(), EquipmentStore.beamLaser, cobra);
    equipLaser(state.getMiningLaser(), EquipmentStore.miningLaser, cobra);
    equipLaser(state.getPulseLaser(), EquipmentStore.pulseLaser, cobra);
    InventoryItem[] inventory = cobra.getInventory();
    cobra.setTradeGood(
        TradeGoodStore.get().food(), Weight.grams(state.getFood()), inventory[0].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().textiles(),
        Weight.grams(state.getTextiles()),
        inventory[1].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().radioactives(),
        Weight.grams(state.getRadioactives()),
        inventory[2].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().slaves(), Weight.grams(state.getSlaves()), inventory[3].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().liquorWines(),
        Weight.grams(state.getLiquorWines()),
        inventory[4].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().luxuries(),
        Weight.grams(state.getLuxuries()),
        inventory[5].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().narcotics(),
        Weight.grams(state.getNarcotics()),
        inventory[6].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().computers(),
        Weight.grams(state.getComputers()),
        inventory[7].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().machinery(),
        Weight.grams(state.getMachinery()),
        inventory[8].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().alloys(), Weight.grams(state.getAlloys()), inventory[9].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().firearms(),
        Weight.grams(state.getFirearms()),
        inventory[10].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().furs(), Weight.grams(state.getFurs()), inventory[11].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().minerals(),
        Weight.grams(state.getMinerals()),
        inventory[12].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().gold(), Weight.grams(state.getGold()), inventory[13].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().platinum(),
        Weight.grams(state.getPlatinum()),
        inventory[14].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().gemStones(),
        Weight.grams(state.getGemStones()),
        inventory[15].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().alienItems(),
        Weight.grams(state.getAlienItems()),
        inventory[16].getPrice());
    cobra.setTradeGood(
        TradeGoodStore.get().medicalSupplies(),
        Weight.grams(state.getMedicalSupplies()),
        inventory[17].getPrice());
  }
Ejemplo n.º 2
0
  private void initializeState(Alite alite) {
    state = new HackerState();
    Player player = alite.getPlayer();
    GalaxyGenerator generator = alite.getGenerator();
    PlayerCobra cobra = alite.getCobra();

    state.setCommanderName(player.getName());
    state.setGalaxyNumber(generator.getCurrentGalaxy());
    state.setGalaxySeed(17, generator.getCurrentSeed());
    state.setCurrentSystem(
        player.getCurrentSystem() == null ? 0 : player.getCurrentSystem().getIndex());
    state.setHyperspaceSystem(
        player.getHyperspaceSystem() == null ? 0 : player.getHyperspaceSystem().getIndex());
    state.setFuel(cobra.getFuel());
    state.setCredits(player.getCash());
    state.setRating(player.getRating().ordinal());
    state.setLegalStatus(player.getLegalStatus().ordinal());
    state.setGameTime(alite.getGameTime() / 1000000);
    state.setScore(player.getScore());
    state.setNumberOfMissiles(cobra.getMissiles());
    state.setExtraEnergyUnit(
        cobra.isEquipmentInstalled(EquipmentStore.extraEnergyUnit)
            ? 1
            : cobra.isEquipmentInstalled(EquipmentStore.navalEnergyUnit) ? 2 : 0);
    state.setLargeCargoBay(cobra.isEquipmentInstalled(EquipmentStore.largeCargoBay));
    state.setECM(cobra.isEquipmentInstalled(EquipmentStore.ecmSystem));
    state.setFuelScoop(cobra.isEquipmentInstalled(EquipmentStore.fuelScoop));
    state.setEscapeCapsule(cobra.isEquipmentInstalled(EquipmentStore.escapeCapsule));
    state.setEnergyBomb(cobra.isEquipmentInstalled(EquipmentStore.energyBomb));
    state.setDockingComputer(cobra.isEquipmentInstalled(EquipmentStore.dockingComputer));
    state.setGalacticHyperdrive(cobra.isEquipmentInstalled(EquipmentStore.galacticHyperdrive));
    state.setRetroRockets(cobra.isEquipmentInstalled(EquipmentStore.retroRockets));
    state.setPulseLaser(getLaserValue(cobra, EquipmentStore.pulseLaser));
    state.setBeamLaser(getLaserValue(cobra, EquipmentStore.beamLaser));
    state.setMiningLaser(getLaserValue(cobra, EquipmentStore.miningLaser));
    state.setMilitaryLaser(getLaserValue(cobra, EquipmentStore.militaryLaser));
    state.setCloakingDevice(cobra.isEquipmentInstalled(EquipmentStore.cloakingDevice));
    state.setECMJammer(cobra.isEquipmentInstalled(EquipmentStore.ecmJammer));
    InventoryItem[] inventory = cobra.getInventory();
    state.setFood(inventory[0].getWeight().getWeightInGrams());
    state.setTextiles(inventory[1].getWeight().getWeightInGrams());
    state.setRadioactives(inventory[2].getWeight().getWeightInGrams());
    state.setSlaves(inventory[3].getWeight().getWeightInGrams());
    state.setLiquorWines(inventory[4].getWeight().getWeightInGrams());
    state.setLuxuries(inventory[5].getWeight().getWeightInGrams());
    state.setNarcotics(inventory[6].getWeight().getWeightInGrams());
    state.setComputers(inventory[7].getWeight().getWeightInGrams());
    state.setMachinery(inventory[8].getWeight().getWeightInGrams());
    state.setAlloys(inventory[9].getWeight().getWeightInGrams());
    state.setFirearms(inventory[10].getWeight().getWeightInGrams());
    state.setFurs(inventory[11].getWeight().getWeightInGrams());
    state.setMinerals(inventory[12].getWeight().getWeightInGrams());
    state.setGold(inventory[13].getWeight().getWeightInGrams());
    state.setPlatinum(inventory[14].getWeight().getWeightInGrams());
    state.setGemStones(inventory[15].getWeight().getWeightInGrams());
    state.setAlienItems(inventory[16].getWeight().getWeightInGrams());
    state.setMedicalSupplies(inventory[17].getWeight().getWeightInGrams());
    state.setHyperspaceJumpCounter(player.getJumpCounter());
    state.setIntergalacticJumpCounter(player.getIntergalacticJumpCounter());
    if (!player.getActiveMissions().isEmpty()) {
      state.setActiveMissionIndex(player.getActiveMissions().get(0).getId());
      // TODO add mission state, target, galaxy seed
    }
  }