Unverified Commit 342fea6f authored by Juon Kawakami's avatar Juon Kawakami 🥗
Browse files

init

parent 54f6cedf
/*
* Last change: $Date: 2005/06/14 21:55:52 $
* $Revision: 1.9 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.log;
import java.io.*;
import java.util.*;
import rescuecore.*;
import rescuecore.commands.*;
public class LogVersion2 extends Log {
private Map<Integer,Update> updates;
private Map<Integer,Commands> commands;
private int maxTimestep;
private Map<String,String> config;
private Memory memory;
private int lastTime;
public LogVersion2(InputBuffer in) throws IOException {
updates = new HashMap<Integer,Update>();
commands = new HashMap<Integer,Commands>();
maxTimestep = 0;
config = new HashMap<String,String>();
// Load the preamble
int size = in.readInt();
int configEntries = in.readInt();
for (int i=0;i<configEntries;++i) {
String key = in.readString();
String value = in.readString();
config.put(key,value);
}
// Read all the commands and updates, using the old formats
Command c = null;
while (in.available()>0) {
Command[] newCommands = readCommands(in);
for (Command next : newCommands) {
if (next instanceof Update) {
Update u = (Update)next;
updates.put(u.getTime(),u);
maxTimestep = Math.max(maxTimestep,u.getTime());
}
else if (next instanceof Commands) {
Commands o = (Commands)next;
commands.put(o.getTime(),o);
maxTimestep = Math.max(maxTimestep,o.getTime());
}
else {
System.err.println("Unrecognised command in log: "+next);
}
}
}
getMemory(0);
}
public int getMaxTimestep() {
return maxTimestep;
}
public Update getUpdate(int timestep) {
return updates.get(timestep);
}
public Commands getCommands(int timestep) {
return commands.get(timestep);
}
public Map<String,String> getConfigValues() {
return new HashMap(config);
}
public Memory getMemory(int timestep) {
if (memory==null || lastTime > timestep) {
memory = new HashMemory();
lastTime = -1;
}
try {
// Apply all updates from the last time until the required time
for (int currentTime = lastTime+1;currentTime<=timestep && currentTime<maxTimestep;++currentTime) {
Update update = getUpdate(currentTime);
if (update!=null) memory.update(update);
}
lastTime = timestep;
}
catch (Exception e) {
e.printStackTrace();
}
return memory;
}
private Command[] readCommands(InputBuffer in) {
int totalSize = in.readInt();
return in.readCommands();
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_AMBULANCE_CENTER object
@see RescueConstants#TYPE_AMBULANCE_CENTER
*/
public class AmbulanceCenter extends Building {
public AmbulanceCenter() {
super();
}
public AmbulanceCenter(int x, int y, int floors, int attributes, boolean ignition, int fieryness, int brokenness, int[] entrances, int code, int ground, int total, int[] apexes, int temperature, int importance) {
super(x,y,floors,attributes,ignition,fieryness,brokenness,entrances,code,ground,total,apexes,temperature,importance);
}
public AmbulanceCenter(Building other) {
super(other);
}
public int getType() {
return RescueConstants.TYPE_AMBULANCE_CENTER;
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_AMBULANCE_TEAM object
@see RescueConstants#TYPE_AMBULANCE_TEAM
*/
public class AmbulanceTeam extends Humanoid {
public AmbulanceTeam() {
super();
}
public AmbulanceTeam(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury) {
super(pos,extra,dir,history,stam,health,dmg,bury);
}
public int getType() {
return RescueConstants.TYPE_AMBULANCE_TEAM;
}
}
/*
* Last change: $Date: 2004/05/04 03:40:13 $
* $Revision: 1.8 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Encapsulation of a TYPE_BUILDING object
@see RescueConstants#TYPE_BUILDING
*/
public class Building extends MotionlessObject {
private IntProperty x,y,floors, attributes, ignition, fieryness, brokenness, code, ground, total, temperature, importance;
private ArrayProperty entrances,apexes;
public Building() {
x = new IntProperty(RescueConstants.PROPERTY_X);
y = new IntProperty(RescueConstants.PROPERTY_Y);
floors = new IntProperty(RescueConstants.PROPERTY_FLOORS);
attributes = new IntProperty(RescueConstants.PROPERTY_BUILDING_ATTRIBUTES);
ignition = new IntProperty(RescueConstants.PROPERTY_IGNITION);
fieryness = new IntProperty(RescueConstants.PROPERTY_FIERYNESS);
brokenness = new IntProperty(RescueConstants.PROPERTY_BROKENNESS);
entrances = new ArrayProperty(RescueConstants.PROPERTY_ENTRANCES);
// shape = new IntProperty(RescueConstants.PROPERTY_BUILDING_SHAPE_ID);
code = new IntProperty(RescueConstants.PROPERTY_BUILDING_CODE);
ground = new IntProperty(RescueConstants.PROPERTY_BUILDING_AREA_GROUND);
total = new IntProperty(RescueConstants.PROPERTY_BUILDING_AREA_TOTAL);
apexes = new ArrayProperty(RescueConstants.PROPERTY_BUILDING_APEXES);
temperature = new IntProperty(RescueConstants.PROPERTY_BUILDING_TEMPERATURE);
importance = new IntProperty(RescueConstants.PROPERTY_BUILDING_IMPORTANCE);
}
public Building(Building other) {
this(other.getX(),other.getY(),other.getFloors(),other.getBuildingAttributes(),other.isIgnited(),other.getFieryness(),other.getBrokenness(),other.getEntrances(),other.getBuildingCode(),other.getGroundArea(),other.getTotalArea(),other.getApexes(),other.getTemperature(),other.getImportance());
}
public Building(int x, int y, int floors, int attributes, boolean ignition, int fieryness, int brokenness, int[] entrances, int code, int ground, int total, int[] apexes, int temperature,int importance) {
this.x = new IntProperty(RescueConstants.PROPERTY_X,x);
this.y = new IntProperty(RescueConstants.PROPERTY_Y,y);
this.floors = new IntProperty(RescueConstants.PROPERTY_FLOORS,floors);
this.attributes = new IntProperty(RescueConstants.PROPERTY_BUILDING_ATTRIBUTES,attributes);
this.ignition = new IntProperty(RescueConstants.PROPERTY_IGNITION,ignition);
this.fieryness = new IntProperty(RescueConstants.PROPERTY_FIERYNESS,fieryness);
this.brokenness = new IntProperty(RescueConstants.PROPERTY_BROKENNESS,brokenness);
this.entrances = new ArrayProperty(RescueConstants.PROPERTY_ENTRANCES,entrances);
// this.shape = new IntProperty(RescueConstants.PROPERTY_BUILDING_SHAPE_ID,shape);
this.code = new IntProperty(RescueConstants.PROPERTY_BUILDING_CODE,code);
this.ground = new IntProperty(RescueConstants.PROPERTY_BUILDING_AREA_GROUND,ground);
this.total = new IntProperty(RescueConstants.PROPERTY_BUILDING_AREA_TOTAL,total);
this.apexes = new ArrayProperty(RescueConstants.PROPERTY_BUILDING_APEXES,apexes);
this.temperature = new IntProperty(RescueConstants.PROPERTY_BUILDING_TEMPERATURE,temperature);
this.importance = new IntProperty(RescueConstants.PROPERTY_BUILDING_IMPORTANCE,importance);
}
public int getType() {
return RescueConstants.TYPE_BUILDING;
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_X:
case RescueConstants.PROPERTY_Y:
case RescueConstants.PROPERTY_FLOORS:
case RescueConstants.PROPERTY_BUILDING_ATTRIBUTES:
case RescueConstants.PROPERTY_IGNITION:
case RescueConstants.PROPERTY_FIERYNESS:
case RescueConstants.PROPERTY_BROKENNESS:
case RescueConstants.PROPERTY_ENTRANCES:
// case RescueConstants.PROPERTY_BUILDING_SHAPE_ID:
case RescueConstants.PROPERTY_BUILDING_CODE:
case RescueConstants.PROPERTY_BUILDING_AREA_GROUND:
case RescueConstants.PROPERTY_BUILDING_AREA_TOTAL:
case RescueConstants.PROPERTY_BUILDING_APEXES:
case RescueConstants.PROPERTY_BUILDING_IMPORTANCE:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_X:
return x;
case RescueConstants.PROPERTY_Y:
return y;
case RescueConstants.PROPERTY_FLOORS:
return floors;
case RescueConstants.PROPERTY_BUILDING_ATTRIBUTES:
return attributes;
case RescueConstants.PROPERTY_IGNITION:
return ignition;
case RescueConstants.PROPERTY_FIERYNESS:
return fieryness;
case RescueConstants.PROPERTY_BROKENNESS:
return brokenness;
case RescueConstants.PROPERTY_ENTRANCES:
return entrances;
// case RescueConstants.PROPERTY_BUILDING_SHAPE_ID:
// return shape;
case RescueConstants.PROPERTY_BUILDING_CODE:
return code;
case RescueConstants.PROPERTY_BUILDING_AREA_GROUND:
return ground;
case RescueConstants.PROPERTY_BUILDING_AREA_TOTAL:
return total;
case RescueConstants.PROPERTY_BUILDING_APEXES:
return apexes;
case RescueConstants.PROPERTY_BUILDING_TEMPERATURE:
return temperature;
case RescueConstants.PROPERTY_BUILDING_IMPORTANCE:
return importance;
}
return super.getProperty(property);
}
public int getX() {
return x.getValue();
}
public boolean setX(int newX, int timestamp, Object source) {
if (x.updateValue(newX,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_X,timestamp,source);
return true;
}
return false;
}
public int getY() {
return y.getValue();
}
public boolean setY(int newY, int timestamp, Object source) {
if (y.updateValue(newY,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_Y,timestamp,source);
return true;
}
return false;
}
public int getFloors() {
return floors.getValue();
}
public boolean setFloors(int f, int timestamp, Object source) {
if (floors.updateValue(f,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_FLOORS,timestamp,source);
return true;
}
return false;
}
public int getBuildingAttributes() {
return attributes.getValue();
}
public boolean setBuildingAttributes(int b, int timestamp, Object source) {
if (attributes.updateValue(b,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_ATTRIBUTES,timestamp,source);
return true;
}
return false;
}
public boolean isIgnited() {
return ignition.getValue() != 0;
}
public boolean setIgnition(boolean b, int timestamp, Object source) {
if (ignition.updateValue(b?1:0,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_IGNITION,timestamp,source);
return true;
}
return false;
}
public int getFieryness() {
return fieryness.getValue();
}
public boolean setFieryness(int f, int timestamp, Object source) {
if (fieryness.updateValue(f,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_FIERYNESS,timestamp,source);
return true;
}
return false;
}
public int getBrokenness() {
return brokenness.getValue();
}
public boolean setBrokenness(int b, int timestamp, Object source) {
if (brokenness.updateValue(b,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BROKENNESS,timestamp,source);
return true;
}
return false;
}
public int[] getEntrances() {
return entrances.getValues();
}
public boolean setEntrances(int[] e, int timestamp, Object source) {
if (entrances.updateValues(e,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_ENTRANCES,timestamp,source);
return true;
}
return false;
}
public void clearEntrances(int timestamp, Object source) {
entrances.clear();
firePropertyChanged(RescueConstants.PROPERTY_ENTRANCES,timestamp,source);
}
public void appendEntrances(int next, int timestamp, Object source) {
entrances.append(next);
firePropertyChanged(RescueConstants.PROPERTY_ENTRANCES,timestamp,source);
}
/*
public int getBuildingShapeID() {
return shape.getValue();
}
public boolean setBuildingShapeID(int s, int timestamp, Object source) {
if (shape.updateValue(s,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_SHAPE_ID,timestamp,source);
return true;
}
return false;
}
*/
public int getBuildingCode() {
return code.getValue();
}
public boolean setBuildingCode(int c, int timestamp, Object source) {
if (code.updateValue(c,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_CODE,timestamp,source);
return true;
}
return false;
}
public int getGroundArea() {
return ground.getValue();
}
public boolean setGroundArea(int a, int timestamp, Object source) {
if (ground.updateValue(a,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_AREA_GROUND,timestamp,source);
return true;
}
return false;
}
public int getTotalArea() {
return total.getValue();
}
public boolean setTotalArea(int a, int timestamp, Object source) {
if (total.updateValue(a,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_AREA_TOTAL,timestamp,source);
return true;
}
return false;
}
public int[] getApexes() {
return apexes.getValues();
}
public boolean setApexes(int[] a, int timestamp, Object source) {
if (apexes.updateValues(a,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_APEXES,timestamp,source);
return true;
}
return false;
}
public void clearApexes(int timestamp, Object source) {
apexes.clear();
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_APEXES,timestamp,source);
}
public void appendApex(int next, int timestamp, Object source) {
apexes.append(next);
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_APEXES,timestamp,source);
}
public int getTemperature() {
return temperature.getValue();
}
public boolean setTemperature(int value, int timestamp, Object source) {
if (temperature.updateValue(value,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_TEMPERATURE,timestamp,source);
return true;
}
return false;
}
public int getImportance() {
return importance.getValue();
}
public boolean setImportance(int i, int timestamp, Object source) {
if (importance.updateValue(i,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BUILDING_IMPORTANCE,timestamp,source);
return true;
}
return false;
}
public boolean isOnFire() {
return getFieryness() > 0 && getFieryness() < 4;
}
public boolean isExtinguished() {
return getFieryness() > 3 && getFieryness() < 7;
}
public boolean isBurntOut() {
return getFieryness() == 7;
}
public boolean isUnburnt() {
return getFieryness() == 0;
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_CAR object
@see RescueConstants#TYPE_CAR
*/
public class Car extends Humanoid {
public Car() {
super();
}
public Car(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury) {
super(pos,extra,dir,history,stam,health,dmg,bury);
}
public int getType() {
return RescueConstants.TYPE_CAR;
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_CIVILIAN object
@see RescueConstants#TYPE_CIVILIAN
*/
public class Civilian extends Humanoid {
public Civilian() {
super();
}
public Civilian(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury) {
super(pos,extra,dir,history,stam,health,dmg,bury);
}
public int getType() {
return RescueConstants.TYPE_CIVILIAN;
}
}
/*
* Last change: $Date: 2004/05/20 23:42:00 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
public abstract class Edge extends MotionlessObject {
protected IntProperty head,tail,length;
protected Edge() {
head = new IntProperty(RescueConstants.PROPERTY_HEAD);
tail = new IntProperty(RescueConstants.PROPERTY_TAIL);
length = new IntProperty(RescueConstants.PROPERTY_LENGTH);
}
protected Edge(int head, int tail, int length) {
this.head = new IntProperty(RescueConstants.PROPERTY_HEAD,head);
this.tail = new IntProperty(RescueConstants.PROPERTY_TAIL,tail);
this.length = new IntProperty(RescueConstants.PROPERTY_LENGTH,length);
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_HEAD:
case RescueConstants.PROPERTY_TAIL:
case RescueConstants.PROPERTY_LENGTH:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_HEAD:
return head;
case RescueConstants.PROPERTY_TAIL:
return tail;
case RescueConstants.PROPERTY_LENGTH:
return length;
}
return super.getProperty(property);
}
public int getHead() {
return head.getValue();
}
public boolean setHead(int h, int timestamp, Object source) {
if (head.updateValue(h,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_HEAD,timestamp,source);
return true;
}
return false;
}
public int getTail() {
return tail.getValue();
}
public boolean setTail(int t, int timestamp, Object source) {
if (tail.updateValue(t,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_TAIL,timestamp,source);
return true;
}
return false;
}
public int getLength() {
return length.getValue();
}
public boolean setLength(int l, int timestamp, Object source) {
if (length.updateValue(l,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_LENGTH,timestamp,source);
return true;
}
return false;
}
}
/*
* Last change: $Date: 2004/05/04 03:40:13 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_FIRE_BRIGADE object
@see RescueConstants#TYPE_FIRE_BRIGADE
*/
public class FireBrigade extends Humanoid {
private IntProperty waterQuantity;//, stretchedLength;
public FireBrigade() {
waterQuantity = new IntProperty(RescueConstants.PROPERTY_WATER_QUANTITY);
// stretchedLength = new IntProperty(RescueConstants.PROPERTY_STRETCHED_LENGTH);
}
public FireBrigade(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury, int water/*, int length*/) {
super(pos,extra,dir,history,stam,health,dmg,bury);
waterQuantity = new IntProperty(RescueConstants.PROPERTY_WATER_QUANTITY,water);
// stretchedLength = new IntProperty(RescueConstants.PROPERTY_STRETCHED_LENGTH,length);
}
public int getType() {
return RescueConstants.TYPE_FIRE_BRIGADE;
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_WATER_QUANTITY:
// case RescueConstants.PROPERTY_STRETCHED_LENGTH:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_WATER_QUANTITY:
return waterQuantity;
// case RescueConstants.PROPERTY_STRETCHED_LENGTH:
// return stretchedLength;
}
return super.getProperty(property);
}
public int getWaterQuantity() {
return waterQuantity.getValue();
}
public boolean setWaterQuantity(int q, int timestamp, Object source) {
if (waterQuantity.updateValue(q,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_WATER_QUANTITY,timestamp,source);
return true;
}
return false;
}
/*
public int getStretchedLength() {
return stretchedLength.getValue();
}
public boolean setStretchedLength(int l, int timestamp, Object source) {
if (stretchedLength.updateValue(l,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_STRETCHED_LENGTH,timestamp,source);
return true;
}
return false;
}
*/
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueConstants;
import rescuecore.RescueObject;
/**
Encapsulation of a TYPE_FIRE_STATION object
@see RescueConstants#TYPE_FIRE_STATION
*/
public class FireStation extends Building {
public FireStation() {
super();
}
public FireStation(int x, int y, int floors, int attributes, boolean ignition, int fieryness, int brokenness, int[] entrances, int code, int ground, int total, int[] apexes, int temperature, int importance) {
super(x,y,floors,attributes,ignition,fieryness,brokenness,entrances,code,ground,total,apexes,temperature,importance);
}
public FireStation(Building other) {
super(other);
}
public int getType() {
return RescueConstants.TYPE_FIRE_STATION;
}
}
/*
* Last change: $Date: 2004/05/04 03:40:13 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Base class for all humanoid objects (civilians, fire brigades, cars etc)
*/
public abstract class Humanoid extends MovingObject {
private IntProperty stamina, hp, damage, buriedness;
public Humanoid() {
stamina = new IntProperty(RescueConstants.PROPERTY_STAMINA);
hp = new IntProperty(RescueConstants.PROPERTY_HP);
damage = new IntProperty(RescueConstants.PROPERTY_DAMAGE);
buriedness = new IntProperty(RescueConstants.PROPERTY_BURIEDNESS);
}
public Humanoid(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury) {
super(pos,extra,dir,history);
stamina = new IntProperty(RescueConstants.PROPERTY_STAMINA,stam);
hp = new IntProperty(RescueConstants.PROPERTY_HP,health);
damage = new IntProperty(RescueConstants.PROPERTY_DAMAGE,dmg);
buriedness = new IntProperty(RescueConstants.PROPERTY_BURIEDNESS,bury);
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_STAMINA:
case RescueConstants.PROPERTY_HP:
case RescueConstants.PROPERTY_DAMAGE:
case RescueConstants.PROPERTY_BURIEDNESS:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_STAMINA:
return stamina;
case RescueConstants.PROPERTY_HP:
return hp;
case RescueConstants.PROPERTY_DAMAGE:
return damage;
case RescueConstants.PROPERTY_BURIEDNESS:
return buriedness;
}
return super.getProperty(property);
}
public int getStamina() {
return stamina.getValue();
}
public boolean setStamina(int s, int timestamp, Object source) {
if (stamina.updateValue(s,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_STAMINA,timestamp,source);
return true;
}
return false;
}
public int getHP() {
return hp.getValue();
}
public boolean setHP(int h, int timestamp, Object source) {
if (hp.updateValue(h,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_HP,timestamp,source);
return true;
}
return false;
}
public int getDamage() {
return damage.getValue();
}
public boolean setDamage(int d, int timestamp, Object source) {
if (damage.updateValue(d,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_DAMAGE,timestamp,source);
return true;
}
return false;
}
public int getBuriedness() {
return buriedness.getValue();
}
public boolean setBuriedness(int b, int timestamp, Object source) {
if (buriedness.updateValue(b,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BURIEDNESS,timestamp,source);
return true;
}
return false;
}
public boolean isHurt() {
return getHP() < 10000;
}
public boolean isAlive() {
return getHP() > 0;
}
public boolean isBuried() {
return getBuriedness() > 0;
}
public boolean isDamaged() {
return getDamage() > 0;
}
}
/*
* Last change: $Date: 2004/05/20 23:42:00 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
public abstract class MotionlessObject extends RealObject {
protected MotionlessObject() {
}
// public boolean propertyExists(int property) {
// return super.propertyExists(property);
// }
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
return super.getProperty(property);
}
}
/*
* Last change: $Date: 2004/05/20 23:42:00 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
public abstract class MovingObject extends RealObject {
protected IntProperty position, positionExtra, direction;
protected ArrayProperty positionHistory;
protected MovingObject() {
position = new IntProperty(RescueConstants.PROPERTY_POSITION);
positionExtra = new IntProperty(RescueConstants.PROPERTY_POSITION_EXTRA);
direction = new IntProperty(RescueConstants.PROPERTY_DIRECTION);
positionHistory = new ArrayProperty(RescueConstants.PROPERTY_POSITION_HISTORY);
}
protected MovingObject(int pos, int extra, int dir, int[] history) {
position = new IntProperty(RescueConstants.PROPERTY_POSITION,pos);
positionExtra = new IntProperty(RescueConstants.PROPERTY_POSITION_EXTRA,extra);
direction = new IntProperty(RescueConstants.PROPERTY_DIRECTION,dir);
positionHistory = new ArrayProperty(RescueConstants.PROPERTY_POSITION_HISTORY,history);
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_POSITION:
case RescueConstants.PROPERTY_POSITION_EXTRA:
case RescueConstants.PROPERTY_DIRECTION:
case RescueConstants.PROPERTY_POSITION_HISTORY:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_POSITION:
return position;
case RescueConstants.PROPERTY_POSITION_EXTRA:
return positionExtra;
case RescueConstants.PROPERTY_DIRECTION:
return direction;
case RescueConstants.PROPERTY_POSITION_HISTORY:
return positionHistory;
}
return super.getProperty(property);
}
public int getPosition() {
return position.getValue();
}
public boolean setPosition(int p, int timestamp, Object source) {
if (position.updateValue(p,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_POSITION,timestamp,source);
return true;
}
return false;
}
public int getPositionExtra() {
return positionExtra.getValue();
}
public boolean setPositionExtra(int e, int timestamp, Object source) {
if (positionExtra.updateValue(e,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_POSITION_EXTRA,timestamp,source);
return true;
}
return false;
}
public int getDirection() {
return direction.getValue();
}
public boolean setDirection(int d, int timestamp, Object source) {
if (direction.updateValue(d,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_DIRECTION,timestamp,source);
return true;
}
return false;
}
public int[] getPositionHistory() {
return positionHistory.getValues();
}
public boolean setPositionHistory(int[] h, int timestamp, Object source) {
if (positionHistory.updateValues(h,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_POSITION_HISTORY,timestamp,source);
return true;
}
return false;
}
public void clearPositionHistory(int timestamp, Object source) {
positionHistory.clear();
firePropertyChanged(RescueConstants.PROPERTY_POSITION_HISTORY,timestamp,source);
}
public void appendPositionHistory(int next, int timestamp, Object source) {
positionHistory.append(next);
firePropertyChanged(RescueConstants.PROPERTY_POSITION_HISTORY,timestamp,source);
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Encapsulation of a TYPE_NODE object
@see RescueConstants#TYPE_NODE
*/
public class Node extends Vertex {
private IntProperty signal;
private ArrayProperty shortcut, pocket, timing;
public Node() {
signal = new IntProperty(RescueConstants.PROPERTY_SIGNAL);
shortcut = new ArrayProperty(RescueConstants.PROPERTY_SHORTCUT_TO_TURN);
pocket = new ArrayProperty(RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS);
timing = new ArrayProperty(RescueConstants.PROPERTY_SIGNAL_TIMING);
}
public Node(int x, int y) {
this(x,y,new int[0],false,new int[0], new int[0], new int[0]);
}
public Node(int x, int y, int[] edges, boolean signal, int[] shortcut, int[] pocket, int[] timing){
super(x,y,edges);
this.signal = new IntProperty(RescueConstants.PROPERTY_SIGNAL,signal);
this.shortcut = new ArrayProperty(RescueConstants.PROPERTY_SHORTCUT_TO_TURN,shortcut);
this.pocket = new ArrayProperty(RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS,pocket);
this.timing = new ArrayProperty(RescueConstants.PROPERTY_SIGNAL_TIMING,timing);
}
public int getType() {
return RescueConstants.TYPE_NODE;
}
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_SIGNAL:
return signal;
case RescueConstants.PROPERTY_SHORTCUT_TO_TURN:
return shortcut;
case RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS:
return pocket;
case RescueConstants.PROPERTY_SIGNAL_TIMING:
return timing;
}
return super.getProperty(property);
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_SIGNAL:
case RescueConstants.PROPERTY_SHORTCUT_TO_TURN:
case RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS:
case RescueConstants.PROPERTY_SIGNAL_TIMING:
return true;
}
return super.propertyExists(property);
}
*/
public boolean hasSignal() {
return signal.getValue()!=0;
}
public boolean setSignal(boolean b, int timestamp, Object source) {
if (signal.updateValue(b?1:0,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_SIGNAL,timestamp,source);
return true;
}
return false;
}
public int[] getShortcutToTurn() {
return shortcut.getValues();
}
public boolean setShortcutToTurn(int[] s, int timestamp, Object source) {
if (shortcut.updateValues(s,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_SHORTCUT_TO_TURN,timestamp,source);
return true;
}
return false;
}
public void clearShortcutToTurn(int timestamp, Object source) {
shortcut.clear();
firePropertyChanged(RescueConstants.PROPERTY_SHORTCUT_TO_TURN,timestamp,source);
}
public void appendShortcutToTurn(int next, int timestamp, Object source) {
shortcut.append(next);
firePropertyChanged(RescueConstants.PROPERTY_SHORTCUT_TO_TURN,timestamp,source);
}
public int[] getPocketToTurnAcross() {
return pocket.getValues();
}
public boolean setPocketToTurnAcross(int[] p, int timestamp, Object source) {
if (pocket.updateValues(p,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS,timestamp,source);
return true;
}
return false;
}
public void clearPocketToTurnAcross(int timestamp, Object source) {
pocket.clear();
firePropertyChanged(RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS,timestamp,source);
}
public void appendPocketToTurnAcross(int next, int timestamp, Object source) {
pocket.append(next);
firePropertyChanged(RescueConstants.PROPERTY_POCKET_TO_TURN_ACROSS,timestamp,source);
}
public int[] getSignalTiming() {
return timing.getValues();
}
public boolean setSignalTiming(int[] t, int timestamp, Object source) {
if (timing.updateValues(t,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_SIGNAL_TIMING,timestamp,source);
return true;
}
return false;
}
public void clearSignalTiming(int timestamp, Object source) {
timing.clear();
firePropertyChanged(RescueConstants.PROPERTY_SIGNAL_TIMING,timestamp,source);
}
public void appendSignalTiming(int next, int timestamp, Object source) {
timing.append(next);
firePropertyChanged(RescueConstants.PROPERTY_SIGNAL_TIMING,timestamp,source);
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_POLICE_FORCE object
@see RescueConstants#TYPE_POLICE_FORCE
*/
public class PoliceForce extends Humanoid {
public PoliceForce() {
super();
}
public PoliceForce(int pos, int extra, int dir, int[] history, int stam, int health, int dmg, int bury) {
super(pos,extra,dir,history,stam,health,dmg,bury);
}
public int getType() {
return RescueConstants.TYPE_POLICE_FORCE;
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_POLICE_OFFICE object
@see RescueConstants#TYPE_POLICE_OFFICE
*/
public class PoliceOffice extends Building {
public PoliceOffice() {
super();
}
public PoliceOffice(int x, int y, int floors, int attributes, boolean ignition, int fieryness, int brokenness, int[] entrances, int code, int ground, int total, int[] apexes, int temperature, int importance) {
super(x,y,floors,attributes,ignition,fieryness,brokenness,entrances,code,ground,total,apexes,temperature,importance);
}
public PoliceOffice(Building other) {
super(other);
}
public int getType() {
return RescueConstants.TYPE_POLICE_OFFICE;
}
}
/*
* Last change: $Date: 2004/05/20 23:42:00 $
* $Revision: 1.7 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
public abstract class RealObject extends RescueObject {
protected RealObject() {
super();
}
// public boolean propertyExists(int property) {
// return super.propertyExists(property);
// }
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
return super.getProperty(property);
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.4 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.RescueObject;
import rescuecore.RescueConstants;
/**
Encapsulation of a TYPE_REFUGE object
@see RescueConstants#TYPE_REFUGE
*/
public class Refuge extends Building {
public Refuge() {
super();
}
public Refuge(Building b) {
super(b);
}
public Refuge(int x, int y, int floors, int attributes, boolean ignition, int fieryness, int brokenness, int[] entrances, int code, int ground, int total, int[] apexes, int temperature, int importance) {
super(x,y,floors,attributes,ignition,fieryness,brokenness,entrances,code,ground,total,apexes,temperature,importance);
}
public int getType() {
return RescueConstants.TYPE_REFUGE;
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.5 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Encapsulation of a TYPE_RIVER object
@see RescueConstants#TYPE_RIVER
*/
public class River extends Edge {
public River() {
}
public River(int head, int tail, int length) {
super(head,tail,length);
}
public int getType() {
return RescueConstants.TYPE_RIVER;
}
/*
public boolean propertyExists(int property) {
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
return super.getProperty(property);
}
}
/*
* Last change: $Date: 2004/05/04 03:09:38 $
* $Revision: 1.5 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Encapsulation of a TYPE_RIVER_NODE object
@see RescueConstants#TYPE_RIVER_NODE
*/
public class RiverNode extends Vertex {
public RiverNode() {
}
public RiverNode(int x, int y, int[] edges) {
super(x,y,edges);
}
public int getType() {
return RescueConstants.TYPE_RIVER_NODE;
}
/*
public boolean propertyExists(int property) {
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
return super.getProperty(property);
}
}
/*
* Last change: $Date: 2005/02/17 02:25:38 $
* $Revision: 1.10 $
*
* Copyright (c) 2004, The Black Sheep, Department of Computer Science, The University of Auckland
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
* Neither the name of The Black Sheep, The Department of Computer Science or The University of Auckland nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package rescuecore.objects;
import rescuecore.*;
/**
Encapsulation of a TYPE_ROAD object
@see RescueConstants#TYPE_ROAD
*/
public class Road extends Edge {
private IntProperty kind, carsToHead, carsToTail, humansToHead, humansToTail, width, block, cost, median, linesToHead, linesToTail, widthForWalkers;
// private boolean hasFreeLines;
// private int previousBlock;
public Road() {
kind = new IntProperty(RescueConstants.PROPERTY_ROAD_KIND);
carsToHead = new IntProperty(RescueConstants.PROPERTY_CARS_PASS_TO_HEAD);
carsToTail = new IntProperty(RescueConstants.PROPERTY_CARS_PASS_TO_TAIL);
humansToHead = new IntProperty(RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD);
humansToTail = new IntProperty(RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL);
width = new IntProperty(RescueConstants.PROPERTY_WIDTH);
block = new IntProperty(RescueConstants.PROPERTY_BLOCK);
cost = new IntProperty(RescueConstants.PROPERTY_REPAIR_COST);
median = new IntProperty(RescueConstants.PROPERTY_MEDIAN_STRIP);
linesToHead = new IntProperty(RescueConstants.PROPERTY_LINES_TO_HEAD);
linesToTail = new IntProperty(RescueConstants.PROPERTY_LINES_TO_TAIL);
widthForWalkers = new IntProperty(RescueConstants.PROPERTY_WIDTH_FOR_WALKERS);
// previousBlock = -1;
}
public Road(int head, int tail, int length, int kind, int cth, int ctt, int hth, int htt, int width, int block, int cost, boolean median, int lth, int ltt, int wfw) {
super(head,tail,length);
this.kind = new IntProperty(RescueConstants.PROPERTY_ROAD_KIND,kind);
this.carsToHead = new IntProperty(RescueConstants.PROPERTY_CARS_PASS_TO_HEAD,cth);
this.carsToTail = new IntProperty(RescueConstants.PROPERTY_CARS_PASS_TO_TAIL,ctt);
this.humansToHead = new IntProperty(RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD,hth);
this.humansToTail = new IntProperty(RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL,htt);
this.width = new IntProperty(RescueConstants.PROPERTY_WIDTH,width);
this.block = new IntProperty(RescueConstants.PROPERTY_BLOCK,block);
this.cost = new IntProperty(RescueConstants.PROPERTY_REPAIR_COST,cost);
this.median = new IntProperty(RescueConstants.PROPERTY_MEDIAN_STRIP,median);
this.linesToHead = new IntProperty(RescueConstants.PROPERTY_LINES_TO_HEAD,lth);
this.linesToTail = new IntProperty(RescueConstants.PROPERTY_LINES_TO_TAIL,ltt);
this.widthForWalkers = new IntProperty(RescueConstants.PROPERTY_WIDTH_FOR_WALKERS,wfw);
// previousBlock = -1;
}
public int getType() {
return RescueConstants.TYPE_ROAD;
}
/*
public boolean propertyExists(int property) {
switch (property) {
case RescueConstants.PROPERTY_ROAD_KIND:
case RescueConstants.PROPERTY_CARS_PASS_TO_HEAD:
case RescueConstants.PROPERTY_CARS_PASS_TO_TAIL:
case RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD:
case RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL:
case RescueConstants.PROPERTY_WIDTH:
case RescueConstants.PROPERTY_BLOCK:
case RescueConstants.PROPERTY_REPAIR_COST:
case RescueConstants.PROPERTY_MEDIAN_STRIP:
case RescueConstants.PROPERTY_LINES_TO_HEAD:
case RescueConstants.PROPERTY_LINES_TO_TAIL:
case RescueConstants.PROPERTY_WIDTH_FOR_WALKERS:
return true;
}
return super.propertyExists(property);
}
*/
public Property getProperty(int property) /*throws UnknownPropertyException*/ {
switch (property) {
case RescueConstants.PROPERTY_ROAD_KIND:
return kind;
case RescueConstants.PROPERTY_CARS_PASS_TO_HEAD:
return carsToHead;
case RescueConstants.PROPERTY_CARS_PASS_TO_TAIL:
return carsToTail;
case RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD:
return humansToHead;
case RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL:
return humansToTail;
case RescueConstants.PROPERTY_WIDTH:
return width;
case RescueConstants.PROPERTY_BLOCK:
return block;
case RescueConstants.PROPERTY_REPAIR_COST:
return cost;
case RescueConstants.PROPERTY_MEDIAN_STRIP:
return median;
case RescueConstants.PROPERTY_LINES_TO_HEAD:
return linesToHead;
case RescueConstants.PROPERTY_LINES_TO_TAIL:
return linesToTail;
case RescueConstants.PROPERTY_WIDTH_FOR_WALKERS:
return widthForWalkers;
}
return super.getProperty(property);
}
public int getRoadKind() {
return kind.getValue();
}
public boolean setRoadKind(int k, int timestamp, Object source) {
if (kind.updateValue(k,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_ROAD_KIND,timestamp,source);
return true;
}
return false;
}
public int getCarsPassToHead() {
return carsToHead.getValue();
}
public boolean setCarsPassToHead(int cars, int timestamp, Object source) {
if (carsToHead.updateValue(cars,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_CARS_PASS_TO_HEAD,timestamp,source);
return true;
}
return false;
}
public int getCarsPassToTail() {
return carsToTail.getValue();
}
public boolean setCarsPassToTail(int cars, int timestamp, Object source) {
if (carsToTail.updateValue(cars,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_CARS_PASS_TO_TAIL,timestamp,source);
return true;
}
return false;
}
public int getHumansPassToHead() {
return humansToHead.getValue();
}
public boolean setHumansPassToHead(int h, int timestamp, Object source) {
if (humansToHead.updateValue(h,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_HUMANS_PASS_TO_HEAD,timestamp,source);
return true;
}
return false;
}
public int getHumansPassToTail() {
return humansToTail.getValue();
}
public boolean setHumansPassToTail(int h, int timestamp, Object source) {
if (humansToTail.updateValue(h,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_HUMANS_PASS_TO_TAIL,timestamp,source);
return true;
}
return false;
}
public int getWidth() {
return width.getValue();
}
public boolean setWidth(int w, int timestamp, Object source) {
if (width.updateValue(w,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_WIDTH,timestamp,source);
return true;
}
return false;
}
public int getBlock() {
return block.getValue();
}
public boolean setBlock(int b, int timestamp, Object source) {
if (block.updateValue(b,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_BLOCK,timestamp,source);
return true;
}
return false;
}
public int getRepairCost() {
return cost.getValue();
}
public boolean setRepairCost(int c, int timestamp, Object source) {
if (cost.updateValue(c,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_REPAIR_COST,timestamp,source);
return true;
}
return false;
}
public boolean hasMedian() {
return median.getValue()!=0;
}
public boolean setMedian(boolean b, int timestamp, Object source) {
if (median.updateValue(b?1:0,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_MEDIAN_STRIP,timestamp,source);
return true;
}
return false;
}
public int getLinesToHead() {
return linesToHead.getValue();
}
public boolean setLinesToHead(int l, int timestamp, Object source) {
if (linesToHead.updateValue(l,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_LINES_TO_HEAD,timestamp,source);
return true;
}
return false;
}
public int getLinesToTail() {
return linesToTail.getValue();
}
public boolean setLinesToTail(int l, int timestamp, Object source) {
if (linesToTail.updateValue(l,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_LINES_TO_TAIL,timestamp,source);
return true;
}
return false;
}
public int getWidthForWalkers() {
return widthForWalkers.getValue();
}
public boolean setWidthForWalkers(int w, int timestamp, Object source) {
if (widthForWalkers.updateValue(w,timestamp,source)) {
firePropertyChanged(RescueConstants.PROPERTY_WIDTH_FOR_WALKERS,timestamp,source);
return true;
}
return false;
}
public boolean isBlocked() {
return getBlock() > 0;
}
public boolean hasBlockedLines() {
return getBlockedLines()>0;
}
public boolean hasFreeLines() {
return getFreeLinesToHead()>0 && getFreeLinesToTail()>0;
}
public int getFreeLinesToHead() {
double lanes = getLinesToHead()+getLinesToTail();
double laneWidth = getWidth()/lanes;
int blockedLanes = (int)Math.floor(getBlock()/laneWidth/2.0 + 0.5);
return getLinesToHead() - blockedLanes;
}
public int getFreeLinesToTail() {
double lanes = getLinesToHead()+getLinesToTail();
double laneWidth = getWidth()/lanes;
int blockedLanes = (int)Math.floor(getBlock()/laneWidth/2.0 + 0.5);
return getLinesToTail() - blockedLanes;
}
public int getBlockedLines() {
double lanes = getLinesToHead()+getLinesToTail();
double laneWidth = getWidth()/lanes;
int blockedLanes = (int)Math.floor(getBlock()/laneWidth/2.0 + 0.5);
return blockedLanes*2;
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment