-
Notifications
You must be signed in to change notification settings - Fork 291
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
separate structure class from testentity
- Loading branch information
1 parent
0100819
commit 5173c7a
Showing
2 changed files
with
98 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters