protected int calculateWalk() { if (!hasEngine()) { return 0; } if (isPrimitive()) { double rating = getEngine().getRating(); rating /= 1.2; if ((rating % 5) != 0) { return (int) (((rating - (rating % 5)) + 5) / (int) weight) + 2; } return (int) (rating / (int) weight) + 2; } return (getEngine().getRating() / (int) weight) + 2; }
@Override protected int calculateWalk() { if(!hasEngine()) { return 0; } if (isPrimitive()) { double rating = getEngine().getRating(); rating /= 1.2; if ((rating % 5) != 0) { return (int) (((rating - (rating % 5)) + 5) / (int) weight); } return (int) (rating / (int) weight); } return (getEngine().getRating() / (int) weight); }
/** * Used to set this Mech's original walk mp * * @return this units calculated walking speed, dependent on engine rating * and weight */ protected int calculateWalk() { if(!hasEngine()) { return 0; } if (isPrimitive()) { double rating = getEngine().getRating(); rating /= 1.2; if ((rating % 5) != 0) { return (int) ((rating - (rating % 5)) + 5) / (int) weight; } return (int) (rating / (int) weight); } return getEngine().getRating() / (int) weight; }
@Override public long getStickerPrice() { return (long)Math.round((getEngine().getBaseCost()/75.0) * getEngine().getRating() * getUnitTonnage()); }
@Override public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); // The engine is a MM object... // And doesn't support XML serialization... // But it's defined by 3 ints. So we'll save those here. pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<engineType>" + engine.getEngineType() + "</engineType>"); pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<engineRating>" + engine.getRating() + "</engineRating>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<engineFlags>" +engine.getFlags() +"</engineFlags>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<forHover>" +forHover +"</forHover>"); writeToXmlEnd(pw1, indent); }
@Override public void writeToXml(PrintWriter pw1, int indent) { writeToXmlBegin(pw1, indent); // The engine is a MM object... // And doesn't support XML serialization... // But it's defined by 3 ints. So we'll save those here. pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<engineType>" + engine.getEngineType() + "</engineType>"); pw1.println(MekHqXmlUtil.indentStr(indent + 1) + "<engineRating>" + engine.getRating() + "</engineRating>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<engineFlags>" +engine.getFlags() +"</engineFlags>"); pw1.println(MekHqXmlUtil.indentStr(indent+1) +"<forHover>" +forHover +"</forHover>"); writeToXmlEnd(pw1, indent); }
public void setUnit(Unit u) { super.setUnit(u); if(null != unit && null != unit.getEntity().getEngine()) { engineRating = unit.getEntity().getEngine().getRating(); } }
public void setUnit(Unit u) { super.setUnit(u); if(null != unit && null != unit.getEntity().getEngine()) { engineRating = unit.getEntity().getEngine().getRating(); } }
public void fixTankFlag(boolean hover) { int flags = engine.getFlags(); if(!engine.hasFlag(Engine.TANK_ENGINE)) { flags |= Engine.TANK_ENGINE; } engine = new Engine(engine.getRating(), engine.getEngineType(), flags); this.name = engine.getEngineName() + " Engine"; this.forHover = hover; }
public void fixClanFlag() { int flags = engine.getFlags(); if(!engine.hasFlag(Engine.CLAN_ENGINE)) { flags |= Engine.CLAN_ENGINE; } engine = new Engine(engine.getRating(), engine.getEngineType(), flags); this.name = engine.getEngineName() + " Engine"; }
private double getEngineTonnage(Engine engine) { double weight = Engine.ENGINE_RATINGS[(int) Math.ceil(engine.getRating() / 5.0)]; switch (engine.getEngineType()) { case Engine.COMBUSTION_ENGINE:
public void fixTankFlag(boolean hover) { int flags = engine.getFlags(); if(!engine.hasFlag(Engine.TANK_ENGINE)) { flags |= Engine.TANK_ENGINE; } engine = new Engine(engine.getRating(), engine.getEngineType(), flags); this.name = engine.getEngineName() + " Engine"; this.forHover = hover; }
public void fixClanFlag() { int flags = engine.getFlags(); if(!engine.hasFlag(Engine.CLAN_ENGINE)) { flags |= Engine.CLAN_ENGINE; } engine = new Engine(engine.getRating(), engine.getEngineType(), flags); this.name = engine.getEngineName() + " Engine"; }
@Override public long getStickerPrice() { double nloc = 7.0; if(null != unit) { nloc = unit.getEntity().locations(); } double totalStructureCost = 2400 * getUnitTonnage(); if(booster) { if(null != unit) { totalStructureCost += Math.round(unit.getEntity().getEngine().getRating() * 1000 * unit.getEntity().getWeight() * 0.025f); } else { //FIXME: uggh different costs by engine rating and weight, use a fake rating totalStructureCost += Math.round(75000 * getUnitTonnage() * 0.025f); } } double cost = totalStructureCost/nloc; if (loc == Protomech.LOC_TORSO) { cost += 575000; } return (long) Math.round(cost); }
public double getWeightGyro() { double retVal = Math.ceil(engine.getRating() / 100.0f); if (mech.getGyroType() == Mech.GYRO_XL) { retVal /= 2; } else if (mech.getGyroType() == Mech.GYRO_COMPACT) { retVal *= 1.5; } else if ((mech.getGyroType() == Mech.GYRO_HEAVY_DUTY) || (mech.getGyroType() == Mech.GYRO_SUPERHEAVY)) { retVal *= 2; } else if (mech.getGyroType() == Mech.GYRO_NONE) { retVal = 0; } retVal = ceil(retVal, getWeightCeilingGyro()); return retVal; }
@Override public boolean isAcceptableReplacement(Part part, boolean refit) { int year = campaign.getCalendar().get(GregorianCalendar.YEAR); if(part instanceof EnginePart) { Engine eng = ((EnginePart)part).getEngine(); if (null != eng) { return getEngine().getEngineType() == eng.getEngineType() && getEngine().getRating() == eng.getRating() && getEngine().getTechType(year) == eng.getTechType(year) && getUnitTonnage() == ((EnginePart)part).getUnitTonnage() && getTonnage() == ((EnginePart)part).getTonnage(); } } return false; }
@Override public MissingPart getMissingPart() { return new MissingEnginePart(getUnitTonnage(), new Engine(engine.getRating(), engine.getEngineType(), engine.getFlags()), campaign, forHover); }
public EnginePart clone() { EnginePart clone = new EnginePart(getUnitTonnage(), new Engine(engine.getRating(), engine.getEngineType(), engine.getFlags()), campaign, forHover); clone.copyBaseData(this); return clone; }
@Override public boolean isSamePartType(Part part) { int year = campaign.getCalendar().get(GregorianCalendar.YEAR); return part instanceof EnginePart && getName().equals(part.getName()) && getEngine().getEngineType() == ((EnginePart) part) .getEngine().getEngineType() && getEngine().getRating() == ((EnginePart) part).getEngine() .getRating() && getEngine().getTechType(year) == ((EnginePart) part).getEngine() .getTechType(year) && getEngine().hasFlag(Engine.TANK_ENGINE) == ((EnginePart) part).getEngine().hasFlag(Engine.TANK_ENGINE) && getUnitTonnage() == ((EnginePart) part).getUnitTonnage() && getTonnage() == ((EnginePart)part).getTonnage(); }
@Override public Part getNewPart() { boolean useHover = null != unit && unit.getEntity().getMovementMode() == EntityMovementMode.HOVER && unit.getEntity() instanceof Tank; int flags = 0; if(engine.hasFlag(Engine.CLAN_ENGINE)) { flags = Engine.CLAN_ENGINE; } if(null != unit && unit.getEntity() instanceof Tank) { flags |= Engine.TANK_ENGINE; } return new EnginePart(getUnitTonnage(), new Engine(engine.getRating(), engine.getEngineType(), flags), campaign, useHover); }