Skip to content

Commit

Permalink
Merge pull request #20 from armanaxh/misc-debuging
Browse files Browse the repository at this point in the history
Misc debuging
  • Loading branch information
gnardin authored Sep 7, 2018
2 parents f7acd52 + 6cc029c commit 8be06e8
Show file tree
Hide file tree
Showing 7 changed files with 167 additions and 133 deletions.
13 changes: 13 additions & 0 deletions boot/config/misc.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,16 @@ misc.injury.fire.k: 0.00025
misc.injury.fire.l: 0.03
misc.injury.fire.noise.mean: 0.1
misc.injury.fire.noise.sd: 0.01


# Gas Station Misc config

misc.gas_station.Buriedness.bound: 30
misc.gas_station.Buriedness.min: 0
misc.gas_station.Damage.bound: 50
misc.gas_station.Damage.min: 15





Binary file modified lib/rescuecore.jar
Binary file not shown.
Binary file modified lib/resq-fire.jar
Binary file not shown.
45 changes: 22 additions & 23 deletions modules/misc/src/misc/DamageType.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,45 +8,44 @@
import org.uncommons.maths.number.NumberGenerator;

/**
Container for information about different damage types.
*/
Container for information about different damage types.
*/
public class DamageType {
private String type;
private double k;
private double l;
private Random random;
private NumberGenerator<Double> noise;

private double damage;

/**
Construct a DamageType.
@param type The name of this type.
@param config The system configuration.
Construct a DamageType.
@param type The name of this type.
@param config The system configuration.
@param Random sequence proprietary.
*/
public DamageType(String type, Config config) {
public DamageType(String type, Config config, Random random) {
this.type = type;
k = config.getFloatValue("misc.injury." + type + ".k");
l = config.getFloatValue("misc.injury." + type + ".l");
double mean = config.getFloatValue("misc.injury." + type + ".noise.mean");
double sd = config.getFloatValue("misc.injury." + type + ".noise.sd");
random = config.getRandom();
noise = new GaussianGenerator(mean, sd, random);
damage = 0;
}

/**
Get the type name.
@return The type name.
*/
Get the type name.
@return The type name.
*/
public String getType() {
return type;
}

/**
Compute damage progression for this type.
@return The new damage.
*/
Compute damage progression for this type.
@return The new damage.
*/
public double progress() {
if (damage <= 0) {
return damage;
Expand All @@ -57,25 +56,25 @@ public double progress() {
}

/**
Get the current damage.
@return The current damage.
*/
Get the current damage.
@return The current damage.
*/
public double getDamage() {
return damage;
}

/**
Set the current damage.
@param d The current damage.
*/
Set the current damage.
@param d The current damage.
*/
public void setDamage(double d) {
damage = d;
}

/**
Add some damage.
@param d The amount to add.
*/
Add some damage.
@param d The amount to add.
*/
public void addDamage(double d) {
damage += d;
}
Expand Down
108 changes: 60 additions & 48 deletions modules/misc/src/misc/HumanAttributes.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,137 +5,149 @@

import rescuecore2.standard.entities.Human;

import java.util.Random;

/**
Class for holding information about humans.
*/
Class for holding information about humans.
*/
public class HumanAttributes {
private Human human;
private EntityID id;
private DamageType damageFire;
private DamageType damageCollapse;
private DamageType damageBury;
private Random random;

/**
Construct a HumanAttributes object that wraps a Human.
@param h The Human to wrap.
@param config The system configuration.
*/
Construct a HumanAttributes object that wraps a Human.
@param h The Human to wrap.
@param config The system configuration.
*/
public HumanAttributes(Human h, Config config) {
this.human = h;
this.id = h.getID();
damageFire = new DamageType("fire", config);
damageCollapse = new DamageType("collapse", config);
damageBury = new DamageType("bury", config);
// Generate Random for each Human
this.random = new Random(config.getRandom().nextLong());
damageFire = new DamageType("fire", config, random);
damageCollapse = new DamageType("collapse", config, random);
damageBury = new DamageType("bury", config, random);
}

/**
Get the ID of the wrapped human.
@return The human ID.
*/
Get the ID of the wrapped human.
@return The human ID.
*/
public EntityID getID() {
return id;
}

/**
Get the wrapped human.
@return The wrapped human.
*/
Get the wrapped human.
@return The wrapped human.
*/
public Human getHuman() {
return human;
}

/**
Add some collapse damage.
@param d The amount of damage to add.
*/
Get the random sequence of the wrapped human.
@return The random sequence.
*/
public Random getRandom(){
return random;
}
/**
Add some collapse damage.
@param d The amount of damage to add.
*/
public void addCollapseDamage(double d) {
damageCollapse.addDamage(d);
}

/**
Get the amount of collapse damage this human has.
@return The amount of collapse damage.
*/
Get the amount of collapse damage this human has.
@return The amount of collapse damage.
*/
public double getCollapseDamage() {
return damageCollapse.getDamage();
}

/**
Set the amount of collapse damage this human has.
@param d The new collapse damage.
*/
Set the amount of collapse damage this human has.
@param d The new collapse damage.
*/
public void setCollapseDamage(double d) {
damageCollapse.setDamage(d);
}

/**
Add some buriedness damage.
@param d The amount of damage to add.
*/
Add some buriedness damage.
@param d The amount of damage to add.
*/
public void addBuriednessDamage(double d) {
damageBury.addDamage(d);
}

/**
Get the amount of buriedness damage this human has.
@return The amount of buriedness damage.
*/
Get the amount of buriedness damage this human has.
@return The amount of buriedness damage.
*/
public double getBuriednessDamage() {
return damageBury.getDamage();
}

/**
Set the amount of buriedness damage this human has.
@param d The new buriedness damage.
*/
Set the amount of buriedness damage this human has.
@param d The new buriedness damage.
*/
public void setBuriednessDamage(double d) {
damageBury.setDamage(d);
}

/**
Add some fire damage.
@param d The amount of damage to add.
*/
Add some fire damage.
@param d The amount of damage to add.
*/
public void addFireDamage(double d) {
damageFire.addDamage(d);
}

/**
Get the amount of fire damage this human has.
@return The amount of fire damage.
*/
Get the amount of fire damage this human has.
@return The amount of fire damage.
*/
public double getFireDamage() {
return damageFire.getDamage();
}

/**
Set the amount of fire damage this human has.
@param d The new fire damage.
*/
Set the amount of fire damage this human has.
@param d The new fire damage.
*/
public void setFireDamage(double d) {
damageFire.setDamage(d);
}

/**
Get the total damage of this human, rounded to the nearest integer.
@return The total damage.
Get the total damage of this human, rounded to the nearest integer.
@return The total damage.
*/
public int getTotalDamage() {
return (int)Math.round(damageCollapse.getDamage() + damageFire.getDamage() + damageBury.getDamage());
}

/**
Progress all damage types.
*/
Progress all damage types.
*/
public void progressDamage() {
damageCollapse.progress();
damageFire.progress();
damageBury.progress();
}

/**
Clear all damage.
*/
Clear all damage.
*/
public void clearDamage() {
damageCollapse.setDamage(0);
damageBury.setDamage(0);
Expand Down
Loading

0 comments on commit 8be06e8

Please sign in to comment.