コード例 #1
0
ファイル: HackerScreen.java プロジェクト: bjasspa/Alite
  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());
  }