Code Search for Developers
 
 
  

Building.java from Magellan-Client at Krugle


Show Building.java syntax highlighted

/*
 *  Copyright (C) 2000-2004 Roger Butenuth, Andreas Gampe,
 *                          Stefan Goetz, Sebastian Pappert,
 *                          Klaas Prause, Enno Rehling,
 *                          Sebastian Tusk, Ulrich Kuester,
 *                          Ilja Pavkovic
 *
 * This file is part of the Eressea Java Code Base, see the
 * file LICENSING for the licensing information applying to
 * this file.
 *
 */

package com.eressea;

import com.eressea.rules.BuildingType;

/**
 * A <code>Building</code> found in Atlantis reports.
 *
 * @author $author$
 * @version $Revision: 299 $
 */
public class Building extends UnitContainer implements HasRegion {
	/** Size of the building. */
	private int size = 0;

	/** Costs for the building. Could depend on size, so don't put it into the UnitContType. */
	private int cost = 0;
	
	private String trueBuildingType = null; 

	/**
	 * Creates the Object for a building.
	 *
	 * @see com.eressea.UnitContainer#UnitContainer(ID, GameData)
	 */
	public Building(ID id, GameData data) {
		super(id, data);
	}

	/**
	 * DOCUMENT ME!
	 *
	 * @return the size of the building.
	 */
	public int getSize() {
		return size;
	}

	/**
	 * DOCUMENT ME!
	 *
	 * @param iSize set the size of the building.
	 */
	public void setSize(int iSize) {
		size = iSize;
	}

	/**
	 * DOCUMENT ME!
	 *
	 * @return the cost of the building.
	 */
	public int getCost() {
		return cost;
	}

	/**
	 * DOCUMENT ME!
	 *
	 * @param iCost set the cost for the building.
	 */
	public void setCost(int iCost) {
		cost = iCost;
	}

	/** The region this building is in. */
	private Region region = null;

	/**
	 * Sets the region this building is in. If this building already has a region set, this method
	 * takes care of removing it from that region.
	 *
	 * @param region the region to the the building into.
	 */
	public void setRegion(Region region) {
		// remove the building from a prior location
		if(this.region != null) {
			this.region.removeBuilding(this);
		}

		// set the new region and add the building
		this.region = region;

		if(this.region != null) {
			this.region.addBuilding(this);
		}
	}

	/**
	 * Returns the <code>BuildingType</code> of this building.
	 *
	 * @return the <code>BuildingType</code> of this building
	 */
	public BuildingType getBuildingType() {
		return (BuildingType) getType();
	}

	/**
	 * Get the region where this building is located.
	 *
	 * @return the region the building is in.
	 */
	public Region getRegion() {
		return region;
	}
	
	/**
	 * Sets the trueBuildingType which es not realy a type but
	 * just a String
	 * only occurance now "Traumschlößchen",wahrerTyp
	 * Fiete 20060910
	 * 
	 * @param trueBuildingType  as string
	 */
	
	public void setTrueBuildingType(String trueBuildingType){
		this.trueBuildingType = trueBuildingType;
	}
	/**
	 * Gets the trueBuildingType which es not realy a type but
	 * just a String
	 * only occurance now "Traumschlößchen",wahrerTyp
	 * Fiete 20060910
	 * 
	 * 
	 * @return String = trueBuildingType
	 */
	public String getTrueBuildingType() {
		return this.trueBuildingType;
	}
	

	/**
	 * Merges buildings. The new one get the name, comments etc. from the current one, effects etc.
	 * are added, not written over.
	 *
	 * @param curGD current GameData
	 * @param curBuilding the current Building
	 * @param newGD new GameData
	 * @param newBuilding the new Building
	 *
	 * @see UnitContainer#merge
	 */
	public static void merge(GameData curGD, Building curBuilding, GameData newGD,
							 Building newBuilding) {
		UnitContainer.merge(curGD, curBuilding, newGD, newBuilding);

		if(curBuilding.getCost() != -1) {
			newBuilding.setCost(curBuilding.getCost());
		}

		if(curBuilding.getRegion() != null) {
			newBuilding.setRegion(newGD.getRegion((CoordinateID) curBuilding.getRegion().getID()));
		}

		if(curBuilding.getSize() != -1) {
			newBuilding.setSize(curBuilding.getSize());
		}
		
		// Fiete 20060910
		// added support for wahrerTyp
		if (curBuilding.getTrueBuildingType()!=null) {
			newBuilding.setTrueBuildingType(curBuilding.getTrueBuildingType());
		}
		
	}

	/**
	 * Returns a String representation of the Building object.
	 *
	 * @return the Building object as string.
	 */
	public String toString() {
		// Fiete 20060910
		// added support for wahrer Typ
		if (this.trueBuildingType==null){
			return getName() + " (" + id + "), " + this.getType() + " (" + this.getSize() + ")";
		} else {
			return this.trueBuildingType + ": " + getName() + " (" + id + "), " + this.getType() + " (" + this.getSize() + ")";
		}
	}
}




See more files for this project here

Magellan-Client

The Magellan Client is basicly a GUI for the pbem game eressea but can be used for other pbems based on \"atlantis\" too.

Project homepage: http://sourceforge.net/projects/magellan-client
Programming language(s): Java
License: other

  completion/
    AutoCompletion.java
    Completer.java
    CompleterSettingsProvider.java
    Completion.java
    OrderParser.java
  cr/
    Loader.java
  demo/
    actions/
      AbortAction.java
      AddCRAction.java
      AddSelectionAction.java
      ArmyStatsAction.java
      ChangeFactionConfirmationAction.java
      ConfirmAction.java
      ECheckAction.java
      EresseaOptionsAction.java
      ExpandSelectionAction.java
      ExportCRAction.java
      ExternalModuleAction.java
      FactionStatsAction.java
      FileHistoryAction.java
      FileSaveAction.java
      FileSaveAsAction.java
      FillSelectionAction.java
      FindAction.java
      FindPreviousUnconfirmedAction.java
      HelpAction.java
      InfoAction.java
      InvertSelectionAction.java
      IslandAction.java
      MapSaveAction.java
      MenuAction.java
      OpenCRAction.java
      OpenOrdersAction.java
      OpenSelectionAction.java
      OptionAction.java
      QuitAction.java
      RedoAction.java
    desktop/
    Client.java
    ClientPreferences.java
    EMapDetailsPanel.java
    EMapOverviewPanel.java
    FindDialog.java
    MagellanUndoManager.java
    SetOriginDialog.java
  event/
  extern/
  gamebinding/
  io/
  main/
  relation/
  resource/
  rules/
  skillchart/
  swing/
  tasks/
  util/
  Alliance.java
  Battle.java
  Border.java
  Building.java
  CombatSpell.java
  CompleteData.java
  CoordinateID.java
  Described.java
  DescribedObject.java
  EntityID.java
  Faction.java
  GameData.java
  Group.java
  HasRegion.java
  HotSpot.java
  ID.java
  Identifiable.java
  IntegerID.java
  Island.java
  Item.java
  LongID.java
  LuxuryPrice.java
  Message.java
  MissingData.java
  Named.java
  NamedObject.java
  Potion.java
  Region.java
  RegionResource.java
  Related.java
  RelatedObject.java
  Rules.java
  Scheme.java
  Ship.java
  Sign.java
  Skill.java
  Spell.java
  StringID.java
  TempUnit.java
  Unique.java
  Unit.java
  UnitContainer.java
  UnitID.java
  ZeroUnit.java