Skip to content

Commit b5e3734

Browse files
committed
feat: added PropertyMap divide Double and Int
1 parent 0220377 commit b5e3734

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

fxgl-core/src/main/kotlin/com/almasb/fxgl/core/collection/PropertyMap.kt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,14 @@ class PropertyMap {
165165
doubleProperty(propertyName).value *= value
166166
}
167167

168+
fun divide(propertyName: String, value: Int) {
169+
intProperty(propertyName).value /= value
170+
}
171+
172+
fun divide(propertyName: String, value: Double) {
173+
doubleProperty(propertyName).value /= value
174+
}
175+
168176
fun getBoolean(propertyName: String) = booleanProperty(propertyName).value
169177

170178
fun getInt(propertyName: String) = intProperty(propertyName).value

fxgl-core/src/test/kotlin/com/almasb/fxgl/core/collection/PropertyMapTest.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,18 @@ class PropertyMapTest {
129129
assertThat(map.getDouble("key3"), `is`(-90000.0))
130130
}
131131

132+
@Test
133+
fun `Divide Double and Int`() {
134+
map.setValue("key2", -55)
135+
map.setValue("key3", 900.0)
136+
137+
map.divide("key2", 5)
138+
assertThat(map.getInt("key2"), `is`(-11))
139+
140+
map.divide("key3", -100.0)
141+
assertThat(map.getDouble("key3"), `is`(-9.0))
142+
}
143+
132144
@Test
133145
fun `Listeners`() {
134146
var count = 0

0 commit comments

Comments
 (0)