Skip to content

Commit

Permalink
separate structure class from testentity
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAragua committed Oct 4, 2023
1 parent 0100819 commit 5173c7a
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 80 deletions.
98 changes: 98 additions & 0 deletions megamek/src/megamek/common/verifier/Structure.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* MegaMek - Copyright (C) 2023 - The MegaMek Team
*
* This program is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License as published by the Free Software
* Foundation; either version 2 of the License, or (at your option) any later
* version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*/

package megamek.common.verifier;

import megamek.common.EntityMovementMode;
import megamek.common.EquipmentType;

public class Structure {

private int structureType;
private boolean isSuperHeavy;
private EntityMovementMode movementmode;

public Structure() {
}

public Structure(int structureType, boolean superHeavy,
EntityMovementMode movementMode) {
this.structureType = structureType;
isSuperHeavy = superHeavy;
movementmode = movementMode;
}

public double getWeightStructure(double weight, TestEntity.Ceil roundWeight) {
return Structure.getWeightStructure(structureType, weight, roundWeight,
isSuperHeavy, movementmode);
}

public static double getWeightStructure(int structureType, double weight,
TestEntity.Ceil roundWeight, boolean isSuperHeavy,
EntityMovementMode movementmode) {
double multiplier = 1.0;
if (movementmode == EntityMovementMode.TRIPOD) {
multiplier = 1.1;
}
if (structureType == EquipmentType.T_STRUCTURE_ENDO_STEEL) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 10.0f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
}
} else if (structureType == EquipmentType.T_STRUCTURE_ENDO_PROTOTYPE) {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_REINFORCED) {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_COMPOSITE) {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_INDUSTRIAL) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 2.5f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
}

} else if (structureType == EquipmentType.T_STRUCTURE_ENDO_COMPOSITE) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 10.0f) * 1.5f
* multiplier, roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 10.0f) * 0.75f
* multiplier, roundWeight);
}
}
if (isSuperHeavy
&& ((movementmode != EntityMovementMode.NAVAL)
&& (movementmode != EntityMovementMode.SUBMARINE))) {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 10.0f) * multiplier,
roundWeight);
}
}

public String getShortName() {
return "(" + EquipmentType.getStructureTypeName(structureType) + ")";
}

} // End class Structure
80 changes: 0 additions & 80 deletions megamek/src/megamek/common/verifier/TestEntity.java
Original file line number Diff line number Diff line change
Expand Up @@ -1720,83 +1720,3 @@ public String getShortName() {
}

} // end class Armor

class Structure {

private int structureType;
private boolean isSuperHeavy;
private EntityMovementMode movementmode;

public Structure() {
}

public Structure(int structureType, boolean superHeavy,
EntityMovementMode movementMode) {
this.structureType = structureType;
isSuperHeavy = superHeavy;
movementmode = movementMode;
}

public double getWeightStructure(double weight, TestEntity.Ceil roundWeight) {
return Structure.getWeightStructure(structureType, weight, roundWeight,
isSuperHeavy, movementmode);
}

public static double getWeightStructure(int structureType, double weight,
TestEntity.Ceil roundWeight, boolean isSuperHeavy,
EntityMovementMode movementmode) {
double multiplier = 1.0;
if (movementmode == EntityMovementMode.TRIPOD) {
multiplier = 1.1;
}
if (structureType == EquipmentType.T_STRUCTURE_ENDO_STEEL) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 10.0f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
}
} else if (structureType == EquipmentType.T_STRUCTURE_ENDO_PROTOTYPE) {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_REINFORCED) {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_COMPOSITE) {
return TestEntity.ceilMaxHalf((weight / 20.0f) * multiplier,
roundWeight);
} else if (structureType == EquipmentType.T_STRUCTURE_INDUSTRIAL) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 2.5f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
}

} else if (structureType == EquipmentType.T_STRUCTURE_ENDO_COMPOSITE) {
if (isSuperHeavy) {
return TestEntity.ceilMaxHalf((weight / 10.0f) * 1.5f
* multiplier, roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 10.0f) * 0.75f
* multiplier, roundWeight);
}
}
if (isSuperHeavy
&& ((movementmode != EntityMovementMode.NAVAL)
&& (movementmode != EntityMovementMode.SUBMARINE))) {
return TestEntity.ceilMaxHalf((weight / 5.0f) * multiplier,
roundWeight);
} else {
return TestEntity.ceilMaxHalf((weight / 10.0f) * multiplier,
roundWeight);
}
}

public String getShortName() {
return "(" + EquipmentType.getStructureTypeName(structureType) + ")";
}

} // End class Structure

0 comments on commit 5173c7a

Please sign in to comment.