@@ -8,11 +8,11 @@ import (
88type arithmetic uint8
99
1010const (
11- EFFECT_ARITHMETIC_SET arithmetic = iota
12- EFFECT_ARITHMETIC_ADD
13- EFFECT_ARITHMETIC_SUBSTRACT
14- EFFECT_ARITHMETIC_MULTIPLY
15- EFFECT_ARITHMETIC_DIVIDE
11+ SET arithmetic = iota
12+ ADD
13+ SUBSTRACT
14+ MULTIPLY
15+ DIVIDE
1616)
1717
1818type Action struct {
@@ -51,13 +51,13 @@ type EffectInterface interface {
5151
5252type Effect [T Numeric ] struct {
5353 Key StateKey
54- Value T
5554 Operator arithmetic
55+ Value T
5656}
5757
5858func (effect Effect [T ]) check (states states ) bool {
5959 // Other operators than '=' mean the effect will have an impact of the states
60- if effect .Operator != EFFECT_ARITHMETIC_SET {
60+ if effect .Operator != SET {
6161 return false
6262 }
6363
@@ -77,10 +77,10 @@ func (effect Effect[T]) check(states states) bool {
7777func (effect Effect [T ]) apply (data statesData ) error {
7878 k := data .GetIndex (effect .Key )
7979 if k < 0 {
80- if slices .Contains ([]arithmetic {EFFECT_ARITHMETIC_SET , EFFECT_ARITHMETIC_ADD }, effect .Operator ) {
80+ if slices .Contains ([]arithmetic {SET , ADD }, effect .Operator ) {
8181 data = append (data , State [T ]{Value : effect .Value })
8282 return nil
83- } else if slices .Contains ([]arithmetic {EFFECT_ARITHMETIC_SUBSTRACT }, effect .Operator ) {
83+ } else if slices .Contains ([]arithmetic {SUBSTRACT }, effect .Operator ) {
8484 data = append (data , State [T ]{Value : - effect .Value })
8585 return nil
8686 }
@@ -92,15 +92,15 @@ func (effect Effect[T]) apply(data statesData) error {
9292
9393 state := data [k ].(State [T ])
9494 switch effect .Operator {
95- case EFFECT_ARITHMETIC_SET :
95+ case SET :
9696 state .Value = effect .Value
97- case EFFECT_ARITHMETIC_ADD :
97+ case ADD :
9898 state .Value += effect .Value
99- case EFFECT_ARITHMETIC_SUBSTRACT :
99+ case SUBSTRACT :
100100 state .Value -= effect .Value
101- case EFFECT_ARITHMETIC_MULTIPLY :
101+ case MULTIPLY :
102102 state .Value *= effect .Value
103- case EFFECT_ARITHMETIC_DIVIDE :
103+ case DIVIDE :
104104 state .Value /= effect .Value
105105 }
106106
@@ -117,7 +117,7 @@ type EffectBool struct {
117117
118118func (effectBool EffectBool ) check (states states ) bool {
119119 // Other operators than '=' is not allowed
120- if effectBool .Operator != EFFECT_ARITHMETIC_SET {
120+ if effectBool .Operator != SET {
121121 return false
122122 }
123123
@@ -135,7 +135,7 @@ func (effectBool EffectBool) check(states states) bool {
135135}
136136
137137func (effectBool EffectBool ) apply (data statesData ) error {
138- if effectBool .Operator != EFFECT_ARITHMETIC_SET {
138+ if effectBool .Operator != SET {
139139 return fmt .Errorf ("operation %v not allowed on bool type" , effectBool .Operator )
140140 }
141141
@@ -176,7 +176,7 @@ func (effectString EffectString) check(states states) bool {
176176}
177177
178178func (effectString EffectString ) apply (data statesData ) error {
179- if ! slices .Contains ([]arithmetic {EFFECT_ARITHMETIC_SET , EFFECT_ARITHMETIC_ADD }, effectString .Operator ) {
179+ if ! slices .Contains ([]arithmetic {SET , ADD }, effectString .Operator ) {
180180 return fmt .Errorf ("arithmetic operation %v not allowed on string type" , effectString .Operator )
181181 }
182182
@@ -191,9 +191,9 @@ func (effectString EffectString) apply(data statesData) error {
191191
192192 state := data [k ].(State [string ])
193193 switch effectString .Operator {
194- case EFFECT_ARITHMETIC_SET :
194+ case SET :
195195 state .Value = effectString .Value
196- case EFFECT_ARITHMETIC_ADD :
196+ case ADD :
197197 state .Value = fmt .Sprint (state .Value , effectString .Value )
198198 }
199199 data [k ] = state
0 commit comments