Package ch.sahits.game.openpatrician.model.building

Examples of ch.sahits.game.openpatrician.model.building.ITradingOffice


  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    int availableAmountCity = city.getCity().getWare(ware).getAmount();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    if (availableAmountCity>0 && office!=null){
      int amount2Move = dialog.getAmount(availableAmountCity); // This is ware specific size
      int avgPrice = ware.computeBuyPrice(availableAmountCity, amount2Move);
      // check if this is afforable
      final long cash = city.getPlayer().getCompany().getCash();
      if (cash<(long)avgPrice*amount2Move){
        int amountAprox = (int) (cash/avgPrice); // approx amount we can afford
        if (amountAprox>0){
          int tempPrice = ware.computeBuyPrice(availableAmountCity, amountAprox);
          while (amountAprox*tempPrice+tempPrice<cash){
            int newTempPrice = ware.computeBuyPrice(availableAmountCity, amountAprox++);
            if (amountAprox*newTempPrice>cash){
              // we cannot afford another item
              break;
            }
            tempPrice=newTempPrice;
          }
          avgPrice=tempPrice;
          amount2Move=amountAprox;
        } else {
          return; // cannot buy anything
        }
      }
      int movedAmount = city.getCity().move(ware, -amount2Move,city.getPlayer());
      if (amount2Move!=-movedAmount){
        avgPrice = ware.computeBuyPrice(city.getCity().getWare(ware).getAmount()+movedAmount, movedAmount);
        amount2Move=movedAmount;
      }
      int loaded = office.move(ware, amount2Move,avgPrice);
      city.getPlayer().updateCash(-avgPrice*loaded);
    }
  }
 
View Full Code Here


      y += 5*positions.lineHeight;
      ICity cityModel = city.getCity();
      y += (int)Math.rint(positions.titleHeigth*2/3);
     
     
      ITradingOffice office = city.getPlayer().findTradingOffice(cityModel);
      IStorage storage = office.getStorage();
     
      drawRow(g2d, y, positions.xNumbers, String.valueOf(office.getStored()/10));
      y += positions.lineHeight;

      drawRow(g2d, y, positions.xNumbers, String.valueOf(office.getCapacity()/10));
      y += positions.lineHeight;
     
      int additional = office.getStored()-office.getCapacity();
      if (additional<0) additional = 0;
      drawRow(g2d, y, positions.xNumbers, String.valueOf(additional/10));
      y += positions.lineHeight;
     
      drawRow(g2d, y, positions.xNumbers, String.valueOf(storage.getRentOutStorage()));
View Full Code Here

  }

  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    if (office!=null) {
      int amountInStorage = office.getWare(ware).getAmount();
      if (amountInStorage > 0) {
        int availableAmountCity = city.getCity().getWare(ware).getAmount();
        int amount2Move = dialog.getAmount(amountInStorage);
        final int avgPrice;
        if (dialog.getMovableAmount() == ETransferAmount.MAX) {
          avgPrice = ware.getMaxValueSell();
        } else {
          avgPrice = ware.computeSellPrice(availableAmountCity,amount2Move);
        }
        city.getCity().move(ware, amount2Move,city.getPlayer()); // The price here is irrelevant
        int sold = office.move(ware, -amount2Move);
        city.getPlayer().updateCash(avgPrice * sold);
      } // end stored amount
    } // end office
  }
View Full Code Here

      y += positions.titleHeigth;
      int leftBorderX = getBounds().x+getInset().left;
      int x = leftBorderX + 20;
      ICity cityModel = city.getCity();
      IShip ship = city.getActiveShip();
      ITradingOffice office = city.getPlayer().findTradingOffice(cityModel);
      y += (int)Math.rint(positions.titleHeigth*2/3);
     
      synchronized (type) { // Avoid change of the type during rendering of one screen
        drawSubTitle(g2d, y, barrel, x, cityModel, ship, office);
        BufferedImage waxSeal = loader.getImage("waxseal");
View Full Code Here

      y += positions.lineHeight;
      y += positions.lineHeight;
      y += positions.lineHeight;
     
      // TODO fill in the data
      ITradingOffice office = city.getPlayer().findTradingOffice(cityModel);
      drawRentalIncome(g2d,office,coin,y);

      y += positions.lineHeight;
      drawWageCosts(g2d,office,coin,y);
View Full Code Here

  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    IShip ship = city.getActiveShip();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    int availableAmountStorage = office.getWare(ware).getAmount();
    if (availableAmountStorage>0 && office!=null){
      int amount2Move = dialog.getAmount(availableAmountStorage); // This is ware specific size
      int avgPrice = office.getWare(ware).getAVGPrice();
      int moved = office.move(ware, -amount2Move,avgPrice);
      ship.load(ware, moved, avgPrice);
    }
  }
View Full Code Here

  @Override
  public void run() {
    ICityPlayerProxy city = dialog.getCityPlayerProxy();
    IShip ship = city.getActiveShip();
    int availableAmountShip = ship.getWare(ware).getAmount();
    ITradingOffice office = city.getPlayer().findTradingOffice(city.getCity());
    if (availableAmountShip>0 && office!=null){
      int amount2Move = dialog.getAmount(availableAmountShip); // This is ware specific size
      int avgPrice = ship.getWare(ware).getAVGPrice();
      int moved = ship.unload(ware, amount2Move);
      office.move(ware, moved,avgPrice);
    }

  }
View Full Code Here

   * @throws IOException
   * @throws FontFormatException
   */
  private void createTradeNotice(ICityPlayerProxy proxy) throws FontFormatException, IOException {
    ICity city = proxy.getCity();
    ITradingOffice office = proxy.getPlayer().findTradingOffice(city);
    IShip ship = proxy.getActiveShip();
    boolean city2ShipFlag = proxy.getActiveShip()!=null; // if true this is active
    boolean hasTradingOffice = office!=null;
    boolean hasWeapons = (city2ShipFlag&&hasTradingOffice&&office.hasWeapons()&&ship.getUpgradeSpaceReduction()>0&&ship.hasWeapons());
    EStringSelectionState city2ship;
    if (city2ShipFlag){
      city2ship = EStringSelectionState.ACTIVE;
    } else if (proxy.getPlayersShips().isEmpty()){
      // no active ship => disable
View Full Code Here

  }

  @Override
  public int getCostsPerDay() {
    ITradingOffice office = owner.findTradingOffice(city);
    int additional = office.getCapacity()-office.getStored();
    if (additional>=0) return 0; // empty space
    return (-additional/10+1)*RENT_COST_PER_DAY_AND_BALE;
  }
 
View Full Code Here

  }


  @Override
  public void notify(DateObject date) {   
    ITradingOffice office = player.findTradingOffice(city);
    int weekIndex = date.getDayInWeek();
    ISteward steward = office.getSteward();
    int dailyCost=0;
    if (steward!=null){
      dailyCost = (int) Math.rint(steward.getSalary()/7.0);
    }
    for (int i = weekIndex; i<stewardCostsDays.length;i++){
      this.stewardCostsDays[i] = dailyCost;
    }
    int sum = 0;
    for (int cost : stewardCostsDays) {
      sum += cost;
    }
    this.stewardCosts=sum;
   
    List<IBuilding> buildings = player.findBuildings(city,ITownHouse.class);
    dailyCost=0;
    for (IBuilding building : buildings) {
      dailyCost += ((ITownHouse)building).computeRentalIncome();
    }
    for (int i = weekIndex; i<rentalIncomeDays.length;i++){
      this.rentalIncomeDays[i] = dailyCost;
    }
    sum = 0;
    for (int cost : rentalIncomeDays) {
      sum += cost;
    }
    this.rentalIncome=sum;

    buildings = player.findBuildings(city);
    dailyCost=0;
    for (IBuilding building : buildings) {
      dailyCost += building.getPropertyTax();
    }
    for (int i = weekIndex; i<propertyTaxesDays.length;i++){
      this.propertyTaxesDays[i] = dailyCost;
    }
    sum = 0;
    for (int cost : propertyTaxesDays) {
      sum += cost;
    }
    this.propertyTaxes=sum;

    buildings = player.findBuildings(city,IWorkShop.class);
    IStorage storage = office.getStorage();
    dailyCost=0;
    for (IBuilding building : buildings) {
      dailyCost += (int)Math.rint(((IWorkShop)building).getSalaryPerWorker()/7.0);
    }
    for (int i = weekIndex; i<wageCostsDays.length;i++){
      this.wageCostsDays[i] = dailyCost+storage.getGuardCostsPerDay();
    }
    sum = 0;
    for (int cost : wageCostsDays) {
      sum += cost;
    }
    this.wageCosts=sum;
   
    IAutomatedTrading automaticTrading = office.getOfficeTrading();
    if (automaticTrading!=null){
      // TODO implement this when implementing office traiding
    } else {
      for (int i = weekIndex; i<officeTradingDays.length;i++){
        this.officeTradingDays[i] = 0;
View Full Code Here

TOP

Related Classes of ch.sahits.game.openpatrician.model.building.ITradingOffice

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.