@@ -118,38 +118,43 @@ data class Player(
118
118
}
119
119
}
120
120
121
+ class SettingsMapLoader (private val player : Player ) {
122
+ private val out = LinkedHashMap <String , String >()
123
+
124
+ fun load (): Future <Map <String , String >> {
125
+ val classesFuture = PlayerClassesTable .getByPlayer(player)
126
+ .thenApply { classes -> classes.forEach { out [it.getKey()] = it.toEncoded() } }
127
+ val charactersFuture = PlayerCharactersTable .getByPlayer(player)
128
+ .thenApply { characters -> characters.forEach { out [it.getKey()] = it.toEncoded() } }
129
+ val settingsBase = StringBuilder (" 20;4;" )
130
+ .append(player.credits).append(" ;-1;0;" )
131
+ .append(player.creditsSpent).append(" ;0;" )
132
+ .append(player.gamesPlayed).append(' ;' )
133
+ .append(player.secondsPlayed).append(" ;0;" )
134
+ .append(player.inventory)
135
+ .toString()
136
+ return Future .allOf(classesFuture, charactersFuture)
137
+ .thenApply {
138
+ player.faceCodes?.apply { out [" FaceCodes" ] = this }
139
+ player.newItem?.apply { out [" NewItem" ] = this }
140
+ out [" csreward" ] = player.csReward.toString()
141
+
142
+ player.completion?.apply { out [" Completion" ] = this }
143
+ player.progress?.apply { out [" Progress" ] = this }
144
+ player.cscompletion?.apply { out [" cscompletion" ] = this }
145
+ player.cstimestamps1?.apply { out [" cstimestamps" ] = this }
146
+ player.cstimestamps2?.apply { out [" cstimestamps2" ] = this }
147
+ player.cstimestamps3?.apply { out [" cstimestamps3" ] = this }
148
+ out [" Base" ] = settingsBase
149
+ out
150
+ }
151
+ }
152
+
153
+ }
154
+
121
155
fun createSettingsMap (): Future <Map <String , String >> {
122
- val out = LinkedHashMap <String , String >()
123
- val classesFuture = PlayerClassesTable .getByPlayer(this )
124
- .thenApply { classes ->
125
- classes.forEach { out [it.getKey()] = it.toEncoded() }
126
- }
127
- val charactersFuture = PlayerCharactersTable .getByPlayer(this )
128
- .thenApply { characters ->
129
- characters.forEach { out [it.getKey()] = it.toEncoded() }
130
- }
131
- val settingsBase = StringBuilder (" 20;4;" )
132
- .append(credits).append(" ;-1;0;" )
133
- .append(creditsSpent).append(" ;0;" )
134
- .append(gamesPlayed).append(' ;' )
135
- .append(secondsPlayed).append(" ;0;" )
136
- .append(inventory)
137
- .toString()
138
- return Future .allOf(classesFuture, charactersFuture)
139
- .thenApply {
140
- faceCodes?.apply { out [" FaceCodes" ] = this }
141
- newItem?.apply { out [" NewItem" ] = this }
142
- out [" csreward" ] = csReward.toString()
143
-
144
- completion?.apply { out [" Completion" ] = this }
145
- progress?.apply { out [" Progress" ] = this }
146
- cscompletion?.apply { out [" cscompletion" ] = this }
147
- cstimestamps1?.apply { out [" cstimestamps" ] = this }
148
- cstimestamps2?.apply { out [" cstimestamps2" ] = this }
149
- cstimestamps3?.apply { out [" cstimestamps3" ] = this }
150
- out [" Base" ] = settingsBase
151
- out
152
- }
156
+ val loader = SettingsMapLoader (this )
157
+ return loader.load()
153
158
}
154
159
155
160
fun setPlayerDataBulk (map : Map <String , String >) {
0 commit comments