1515"""
1616
1717
18- class ConstantExpression (Rollable ):
18+ class ConstantOperand (Rollable ):
1919 """
2020 Expression for a constant value.
2121
@@ -26,30 +26,30 @@ class ConstantExpression(Rollable):
2626 """
2727
2828 def __init__ (self , constant ):
29- super (ConstantExpression , self ).__init__ ()
29+ super (ConstantOperand , self ).__init__ ()
3030 self ._constant = constant
3131 # If it received a constant node this is unwrapped
3232 # TODO: Maybe this problem should be fixed somewhere else
33- while isinstance (self ._constant , ConstantExpression ):
33+ while isinstance (self ._constant , ConstantOperand ):
3434 self ._constant = constant .constant
3535
3636 def __add__ (self , other ):
37- return ConstantExpression (other + self .constant )
37+ return ConstantOperand (other + self .constant )
3838
3939 def __sub__ (self , other ):
40- return ConstantExpression (self .constant - other )
40+ return ConstantOperand (self .constant - other )
4141
4242 def __radd__ (self , other ):
43- return ConstantExpression (self .constant + other )
43+ return ConstantOperand (self .constant + other )
4444
4545 def __rsub__ (self , other ):
46- return ConstantExpression (other - self .constant )
46+ return ConstantOperand (other - self .constant )
4747
4848 def __lt__ (self , other ):
4949 return self .constant < other
5050
5151 def __le__ (self , other ):
52- if isinstance (other , ConstantExpression ):
52+ if isinstance (other , ConstantOperand ):
5353 return self .constant <= other .constant
5454 elif isinstance (other , (int , float )):
5555 return self .constant <= other
@@ -66,7 +66,7 @@ def __gt__(self, other):
6666 return self .constant > other
6767
6868 def __ge__ (self , other ):
69- if isinstance (other , ConstantExpression ):
69+ if isinstance (other , ConstantOperand ):
7070 return self .constant >= other .constant
7171 elif isinstance (other , (int , float )):
7272 return self .constant >= other
@@ -102,27 +102,27 @@ def roll(self):
102102 return self .constant
103103
104104
105- class DiceExpression (RollableDice ):
105+ class DiceOperand (RollableDice ):
106106 """
107107 Expression for a dice.
108108
109109 It is mostly just its parent class, only adding comparison methods.
110110 """
111111
112112 def __init__ (self , quantity , sides ):
113- super (DiceExpression , self ).__init__ (quantity = quantity , sides = sides )
113+ super (DiceOperand , self ).__init__ (quantity = quantity , sides = sides )
114114
115115 def __add__ (self , other ):
116- return ConstantExpression (other + self .roll ())
116+ return ConstantOperand (other + self .roll ())
117117
118118 def __sub__ (self , other ):
119- return ConstantExpression (self .roll () - other )
119+ return ConstantOperand (self .roll () - other )
120120
121121 def __radd__ (self , other ):
122- return ConstantExpression (self .roll () + other )
122+ return ConstantOperand (self .roll () + other )
123123
124124 def __rsub__ (self , other ):
125- return ConstantExpression (other - self .roll ())
125+ return ConstantOperand (other - self .roll ())
126126
127127 def __str__ (self ):
128128 return '%sd%s' % (self .quantity , self .sides )
@@ -132,15 +132,15 @@ def __repr__(self):
132132 (self .__class__ .__name__ , self .quantity , self .sides )
133133
134134
135- class BinaryOperationExpression (Rollable ):
135+ class BinaryOperation (Rollable ):
136136 """
137137 Exprssion for a binary operation.
138138
139139 Acquiring its value will execute a function with two parameters.
140140 """
141141
142142 def __init__ (self , function , left , right ):
143- super (BinaryOperationExpression , self ).__init__ ()
143+ super (BinaryOperation , self ).__init__ ()
144144 self ._logger = logging .getLogger (self .__class__ .__name__ )
145145 self ._function = function
146146 self ._left = left
@@ -149,28 +149,28 @@ def __init__(self, function, left, right):
149149 def __add__ (self , other ):
150150 value = self .operate ()
151151 self ._logger .debug ("%s + %s" , value , other )
152- return ConstantExpression (other + value )
152+ return ConstantOperand (other + value )
153153
154154 def __sub__ (self , other ):
155155 value = self .operate ()
156156 self ._logger .debug ("%s - %s" , other , value )
157- return ConstantExpression (value - other )
157+ return ConstantOperand (value - other )
158158
159159 def __radd__ (self , other ):
160160 value = self .operate ()
161161 self ._logger .debug ("(rear) %s + %s" , value , other )
162- return ConstantExpression (value + other )
162+ return ConstantOperand (value + other )
163163
164164 def __rsub__ (self , other ):
165165 value = self .operate ()
166166 self ._logger .debug ("(rear) %s - %s" , other , value )
167- return ConstantExpression (other - value )
167+ return ConstantOperand (other - value )
168168
169169 def __lt__ (self , other ):
170170 return self .operate () < other
171171
172172 def __le__ (self , other ):
173- if isinstance (other , ConstantExpression ):
173+ if isinstance (other , ConstantOperand ):
174174 return self .operate () <= other .constant
175175 elif isinstance (other , (int , float )):
176176 return self .operate () <= other
@@ -187,7 +187,7 @@ def __gt__(self, other):
187187 return self .operate () > other
188188
189189 def __ge__ (self , other ):
190- if isinstance (other , ConstantExpression ):
190+ if isinstance (other , ConstantOperand ):
191191 return self .operate () >= other .constant
192192 elif isinstance (other , (int , float )):
193193 return self .operate () >= other
0 commit comments