Search in sources :

Example 6 with ResourcePile

use of spacesettlers.objects.resources.ResourcePile in project spacesettlers by amymcgovern.

the class Ship method deepClone.

/**
 * Deep copy of a ship (used for security)
 * @return
 */
public Ship deepClone() {
    Ship newShip = new Ship(teamName, teamColor, getPosition().deepCopy());
    newShip.setAlive(isAlive);
    newShip.resources = new ResourcePile();
    newShip.addResources(resources);
    newShip.lastRespawnCounter = lastRespawnCounter;
    newShip.numBeacons = numBeacons;
    newShip.energy = energy;
    newShip.respawnCounter = respawnCounter;
    newShip.graphic = new ShipGraphics(newShip, teamColor);
    newShip.currentAction = currentAction;
    newShip.numWeaponsInAir = numWeaponsInAir;
    newShip.id = id;
    newShip.maxEnergy = maxEnergy;
    newShip.currentPowerups = new LinkedHashSet<SpaceSettlersPowerupEnum>(currentPowerups);
    newShip.weaponCapacity = weaponCapacity;
    newShip.hitsInflicted = hitsInflicted;
    newShip.killsInflicted = killsInflicted;
    newShip.killsReceived = killsReceived;
    newShip.damageInflicted = damageInflicted;
    newShip.carryingFlag = carryingFlag;
    newShip.numFlags = numFlags;
    newShip.isShielded = isShielded;
    newShip.numCores = numCores;
    if (this.flag != null) {
        newShip.flag = flag.deepClone();
    }
    return newShip;
}
Also used : ResourcePile(spacesettlers.objects.resources.ResourcePile) ShipGraphics(spacesettlers.graphics.ShipGraphics) SpaceSettlersPowerupEnum(spacesettlers.objects.powerups.SpaceSettlersPowerupEnum)

Example 7 with ResourcePile

use of spacesettlers.objects.resources.ResourcePile in project spacesettlers by amymcgovern.

the class PurchaseCosts method reset.

/**
 * Put the costs back to their initial values
 */
public void reset() {
    costs.put(PurchaseTypes.BASE, new ResourcePile(250, 300, 450));
    costs.put(PurchaseTypes.SHIP, new ResourcePile(500, 1000, 500));
    costs.put(PurchaseTypes.NOTHING, new ResourcePile(0, 0, 0));
    costs.put(PurchaseTypes.POWERUP_DOUBLE_BASE_HEALING_SPEED, new ResourcePile(1000, 1000, 500));
    costs.put(PurchaseTypes.POWERUP_DOUBLE_MAX_ENERGY, new ResourcePile(750, 1000, 500));
    costs.put(PurchaseTypes.POWERUP_DOUBLE_WEAPON_CAPACITY, new ResourcePile(250, 1000, 1000));
    costs.put(PurchaseTypes.POWERUP_EMP_LAUNCHER, new ResourcePile(0, 750, 250));
    costs.put(PurchaseTypes.POWERUP_SHIELD, new ResourcePile(0, 1500, 500));
}
Also used : ResourcePile(spacesettlers.objects.resources.ResourcePile)

Example 8 with ResourcePile

use of spacesettlers.objects.resources.ResourcePile in project spacesettlers by amymcgovern.

the class Team method deepCopy.

/**
 * Make a deep copy for security
 *
 * @return
 */
public Team deepCopy() {
    Team newTeam = new Team(teamClient, ladderName, maxNumberShips);
    for (Ship ship : teamShips) {
        newTeam.addShip(ship.deepClone());
    }
    newTeam.teamBaseIDs.addAll(this.teamBaseIDs);
    newTeam.costToPurchase = costToPurchase.deepCopy();
    newTeam.totalResources = new ResourcePile(totalResources);
    newTeam.availableResources = new ResourcePile(availableResources);
    newTeam.totalHitsInflicted = this.totalHitsInflicted;
    newTeam.totalKillsInflicted = this.totalKillsInflicted;
    newTeam.totalKillsReceived = this.totalKillsReceived;
    newTeam.totalDamageInflicted = this.totalDamageInflicted;
    newTeam.totalDamageReceived = this.totalDamageReceived;
    newTeam.totalFlagsCollected = this.totalFlagsCollected;
    newTeam.totalCoresCollected = this.totalCoresCollected;
    return newTeam;
}
Also used : ResourcePile(spacesettlers.objects.resources.ResourcePile) Ship(spacesettlers.objects.Ship)

Example 9 with ResourcePile

use of spacesettlers.objects.resources.ResourcePile in project spacesettlers by amymcgovern.

the class ResourcesPanel method updateData.

public void updateData(SpaceSettlersSimulator simulator, String teamName) {
    Team team = null;
    for (Team curTeam : simulator.getTeams()) {
        if (curTeam.getLadderName().equalsIgnoreCase(teamName)) {
            team = curTeam;
            break;
        }
    }
    ResourcePile avail = team.getAvailableResources();
    ResourcePile total = team.getTotalResources();
    waterAvail.setText("" + avail.getResourceQuantity(ResourceTypes.WATER));
    fuelAvail.setText("" + avail.getResourceQuantity(ResourceTypes.FUEL));
    metalsAvail.setText("" + avail.getResourceQuantity(ResourceTypes.METALS));
    waterTotal.setText("" + total.getResourceQuantity(ResourceTypes.WATER));
    fuelTotal.setText("" + total.getResourceQuantity(ResourceTypes.FUEL));
    metalsTotal.setText("" + total.getResourceQuantity(ResourceTypes.METALS));
}
Also used : ResourcePile(spacesettlers.objects.resources.ResourcePile) Team(spacesettlers.clients.Team)

Aggregations

ResourcePile (spacesettlers.objects.resources.ResourcePile)9 Ship (spacesettlers.objects.Ship)4 UUID (java.util.UUID)2 AbstractActionableObject (spacesettlers.objects.AbstractActionableObject)2 Asteroid (spacesettlers.objects.Asteroid)2 Base (spacesettlers.objects.Base)2 SpaceSettlersPowerupEnum (spacesettlers.objects.powerups.SpaceSettlersPowerupEnum)2 Position (spacesettlers.utilities.Position)2 HashMap (java.util.HashMap)1 LinkedHashSet (java.util.LinkedHashSet)1 Map (java.util.Map)1 ExecutionException (java.util.concurrent.ExecutionException)1 RejectedExecutionException (java.util.concurrent.RejectedExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1 AbstractAction (spacesettlers.actions.AbstractAction)1 DoNothingAction (spacesettlers.actions.DoNothingAction)1 PurchaseCosts (spacesettlers.actions.PurchaseCosts)1 PurchaseTypes (spacesettlers.actions.PurchaseTypes)1 Team (spacesettlers.clients.Team)1