@@ -43,17 +43,17 @@ public interface LevelSystem {
4343 */
4444 public var totalExp: Double
4545 get() {
46- val levelExp = this . converter.levelToExp(this . level)
47- return levelExp + this . exp
46+ val levelExp = converter.levelToExp(level)
47+ return levelExp + exp
4848 }
4949 set(value) {
5050 val allowedTotalExperience = value.coerceAtLeast(0.0 )
5151
52- val level = this . converter.expToFullLevel(allowedTotalExperience)
53- val levelExp = this . converter.levelToExp(level )
52+ val fullLevels = converter.expToFullLevel(allowedTotalExperience)
53+ val levelExp = converter.levelToExp(fullLevels )
5454
55- this . level = level
56- this . exp = allowedTotalExperience - levelExp
55+ level = fullLevels
56+ exp = allowedTotalExperience - levelExp
5757 }
5858
5959 /* *
@@ -65,16 +65,16 @@ public interface LevelSystem {
6565 public var fractionalExp: Double
6666 get() {
6767 val expToNextLevel = totalExpToNextLevel
68- val exp = this . exp.coerceAtMost(expToNextLevel - 1 )
68+ val exp = exp.coerceAtMost(expToNextLevel - 1 )
6969 return if (exp <= 0.0 ) 0.0 else exp / expToNextLevel
7070 }
7171 set(value) {
7272 val allowedExp = value.coerceAtLeast(0.0 )
73- if (value < 1.0 ) {
74- this .exp = converter.getExpToReachNextLevel(this . level) * allowedExp
73+ exp = if (value < 1.0 ) {
74+ converter.getExpToReachNextLevel(level) * allowedExp
7575 } else {
76- this . giveLevels(1 )
77- this .exp = 0.0
76+ giveLevels(1 )
77+ 0.0
7878 }
7979 }
8080
@@ -126,8 +126,8 @@ public interface LevelSystem {
126126 * @throws IllegalStateException If player-related object not exists
127127 */
128128 public fun takeLevels (lvlAmount : Int ) {
129- val currentLevel = this . level
130- this . level = currentLevel - lvlAmount.coerceAtMost(currentLevel)
129+ val currentLevel = level
130+ level = currentLevel - lvlAmount.coerceAtMost(currentLevel)
131131 }
132132
133133 /* *
@@ -139,7 +139,7 @@ public interface LevelSystem {
139139 * @throws IllegalStateException If player-related object not exists
140140 */
141141 public fun giveLevels (lvlAmount : Int ) {
142- this . level + = lvlAmount
142+ level + = lvlAmount
143143 }
144144
145145 /* *
@@ -148,7 +148,7 @@ public interface LevelSystem {
148148 * @param requiredLevel Required experience level. Negative value will be interpreted as 0.
149149 * @return true if player player did reach required level
150150 */
151- public fun didReachLevel (requiredLevel : Int ): Boolean = requiredLevel.coerceAtLeast(0 ) <= this . level
151+ public fun didReachLevel (requiredLevel : Int ): Boolean = requiredLevel.coerceAtLeast(0 ) <= level
152152
153153 /* *
154154 * Takes away player the amount of experience specified.
@@ -162,8 +162,8 @@ public interface LevelSystem {
162162 * @see giveExp
163163 */
164164 public fun takeExp (expAmount : Double ) {
165- val currentTotalExp = this . totalExp
166- this . totalExp = currentTotalExp - expAmount.coerceAtMost(currentTotalExp)
165+ val currentTotalExp = totalExp
166+ totalExp = currentTotalExp - expAmount.coerceAtMost(currentTotalExp)
167167 }
168168
169169 /* *
@@ -188,13 +188,13 @@ public interface LevelSystem {
188188 * @return true if player player has required experience
189189 * @throws IllegalStateException If player-related object not exists
190190 */
191- public fun hasExp (requiredExp : Double ): Boolean = requiredExp.coerceAtLeast(0.0 ) <= this . exp
191+ public fun hasExp (requiredExp : Double ): Boolean = requiredExp.coerceAtLeast(0.0 ) <= exp
192192
193193 /* *
194194 * Checks player has required total experience.
195195 * @param requiredExp Required total experience amount. Negative value will be interpreted as 0.
196196 * @return true if player player has required total experience
197197 * @throws IllegalStateException If player-related object not exists
198198 */
199- public fun hasExpTotal (requiredExp : Double ): Boolean = requiredExp.coerceAtLeast(0.0 ) <= this . totalExp
199+ public fun hasExpTotal (requiredExp : Double ): Boolean = requiredExp.coerceAtLeast(0.0 ) <= totalExp
200200}
0 commit comments