Skip to content

Commit ac87f3e

Browse files
committed
refactor(attribute): remove Operand enum and related logic
1 parent d819e68 commit ac87f3e

File tree

3 files changed

+7
-51
lines changed

3 files changed

+7
-51
lines changed

endstone/attribute/__init__.pyi

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,7 @@ class AttributeModifier:
3333
"""
3434
Represents an attribute modifier.
3535
"""
36-
def __init__(self, name: str, amount: float, operation: Operation, operand: Operand = Operand.VALUE) -> None: ...
37-
class Operand(enum.Enum):
38-
"""
39-
Value on which operation to be applied.
40-
"""
41-
42-
VALUE = 0
43-
MAX_VALUE = 1
44-
MIN_VALUE = 2
45-
46-
VALUE = Operand.VALUE
47-
MAX_VALUE = Operand.MAX_VALUE
48-
MIN_VALUE = Operand.MIN_VALUE
36+
def __init__(self, name: str, amount: float, operation: Operation) -> None: ...
4937
class Operation(enum.Enum):
5038
"""
5139
Operation to be applied.
@@ -86,12 +74,6 @@ class AttributeModifier:
8674
"""
8775
...
8876
@property
89-
def operand(self) -> Operand:
90-
"""
91-
Get the operand this modifier will apply.
92-
"""
93-
...
94-
@property
9577
def operation(self) -> Operation:
9678
"""
9779
Get the operation this modifier will apply.

include/endstone/attribute/attribute_modifier.h

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,6 @@ namespace endstone {
2323
*/
2424
class AttributeModifier {
2525
public:
26-
/**
27-
* @brief Value on which operation to be applied.
28-
*/
29-
enum class Operand {
30-
Value,
31-
MaxValue,
32-
MinValue,
33-
};
34-
3526
/**
3627
* @brief Operation to be applied.
3728
*/
@@ -55,13 +46,13 @@ class AttributeModifier {
5546
Multiply
5647
};
5748

58-
AttributeModifier(std::string name, float amount, Operation operation, Operand operand = Operand::Value)
59-
: name_(std::move(name)), amount_(amount), operand_(operand), operation_(operation)
49+
AttributeModifier(std::string name, float amount, Operation operation)
50+
: name_(std::move(name)), amount_(amount), operation_(operation)
6051
{
6152
}
6253

63-
AttributeModifier(std::string name, UUID uuid, float amount, Operation operation, Operand operand = Operand::Value)
64-
: name_(std::move(name)), uuid_(uuid), amount_(amount), operand_(operand), operation_(operation)
54+
AttributeModifier(std::string name, UUID uuid, float amount, Operation operation)
55+
: name_(std::move(name)), uuid_(uuid), amount_(amount), operation_(operation)
6556
{
6657
}
6758

@@ -86,13 +77,6 @@ class AttributeModifier {
8677
*/
8778
[[nodiscard]] float getAmount() const { return amount_; }
8879

89-
/**
90-
* @brief Get the operand this modifier will apply.
91-
*
92-
* @return operand
93-
*/
94-
[[nodiscard]] Operand getOperand() const { return operand_; }
95-
9680
/**
9781
* @brief Get the operation this modifier will apply.
9882
*
@@ -104,7 +88,6 @@ class AttributeModifier {
10488
std::string name_;
10589
UUID uuid_;
10690
float amount_;
107-
Operand operand_;
10891
Operation operation_;
10992
};
11093
} // namespace endstone

src/endstone/python/attribute.cpp

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,6 @@ void init_attribute(py::module_ &m)
6565

6666
auto modifier = py::class_<AttributeModifier>(m, "AttributeModifier", "Represents an attribute modifier.");
6767

68-
py::native_enum<AttributeModifier::Operand>(modifier, "Operand", "enum.Enum",
69-
"Value on which operation to be applied.")
70-
.value("VALUE", AttributeModifier::Operand::Value)
71-
.value("MAX_VALUE", AttributeModifier::Operand::MaxValue)
72-
.value("MIN_VALUE", AttributeModifier::Operand::MinValue)
73-
.export_values()
74-
.finalize();
75-
7668
py::native_enum<AttributeModifier::Operation>(modifier, "Operation", "enum.Enum", "Operation to be applied.")
7769
.value("ADD", AttributeModifier::Operation::Add, "Adds (or subtracts) the specified amount to the base value.")
7870
.value("MULTIPLY_BASE", AttributeModifier::Operation::MultiplyBase,
@@ -85,13 +77,12 @@ void init_attribute(py::module_ &m)
8577
.finalize();
8678

8779
modifier
88-
.def(py::init<std::string, float, AttributeModifier::Operation, AttributeModifier::Operand>(), py::arg("name"),
89-
py::arg("amount"), py::arg("operation"), py::arg("operand") = AttributeModifier::Operand::Value)
80+
.def(py::init<std::string, float, AttributeModifier::Operation>(), py::arg("name"), py::arg("amount"),
81+
py::arg("operation"))
9082
.def_property_readonly("unique_id", &AttributeModifier::getUniqueId, "Get the unique ID for this modifier.")
9183
.def_property_readonly("name", &AttributeModifier::getName, "Get the name of this modifier.")
9284
.def_property_readonly("amount", &AttributeModifier::getAmount,
9385
"Get the amount by which this modifier will apply the operation.")
94-
.def_property_readonly("operand", &AttributeModifier::getOperand, "Get the operand this modifier will apply.")
9586
.def_property_readonly("operation", &AttributeModifier::getOperation,
9687
"Get the operation this modifier will apply.");
9788

0 commit comments

Comments
 (0)