38 lines
1.2 KiB
Python
38 lines
1.2 KiB
Python
import dataclasses
|
|
import fractions
|
|
|
|
materials = {
|
|
"raw": {
|
|
"Raw Material Category 1": ["Carbon", "Vanadium", "Niobium", "Yttrium"],
|
|
"Raw Material Category 2": [
|
|
"Phosphorus",
|
|
"Chromium",
|
|
"Molybdenum",
|
|
"Technetium",
|
|
],
|
|
"Raw Material Category 3": ["Sulphur", "Manganese", "Cadmium", "Ruthenium"],
|
|
"Raw Material Category 4": ["Iron", "Zinc", "Tin", "Selenium"],
|
|
"Raw Material Category 5": ["Nickel", "Germanium", "Tungsten", "Tellurium"],
|
|
"Raw Material Category 6": ["Rhenium", "Arsenic", "Mercury", "Polonium"],
|
|
"Raw Material Category 7": ["Lead", "Zirconium", "Boron", "Antimony"],
|
|
}
|
|
}
|
|
|
|
|
|
@dataclasses.dataclass
|
|
class Material:
|
|
name: str
|
|
category: str
|
|
grade: int
|
|
|
|
def trade_ratio(self, other: "Material") -> fractions.Fraction:
|
|
grade_base = 3 if self.grade <= other.grade else 6
|
|
grade_ratio = fractions.Fraction(
|
|
grade_base ** self.grade, grade_base ** other.grade
|
|
)
|
|
category_ratio = (
|
|
fractions.Fraction(1, 1)
|
|
if self.category == other.category
|
|
else fractions.Fraction(6, 1)
|
|
)
|
|
return grade_ratio * category_ratio
|