parent
b220e961bb
commit
9846c0d0f1
@ -0,0 +1,55 @@ |
||||
package net.pokeranalytics.android.model.utils |
||||
|
||||
import android.content.Context |
||||
import io.realm.Realm |
||||
import io.realm.kotlin.where |
||||
import net.pokeranalytics.android.R |
||||
import net.pokeranalytics.android.model.realm.* |
||||
import net.pokeranalytics.android.model.realm.Currency |
||||
import net.pokeranalytics.android.util.Preferences |
||||
import java.util.* |
||||
|
||||
class Seed(var context:Context, var fake:Boolean = false) : Realm.Transaction { |
||||
|
||||
override fun execute(realm: Realm) { |
||||
this.createDefaultGames(realm) |
||||
this.createDefaultTournamentFeatures(realm) |
||||
this.createDefaultCurrencyAndBankroll(realm) |
||||
} |
||||
|
||||
private fun createDefaultTournamentFeatures(realm: Realm) { |
||||
context.resources.getStringArray(R.array.seed_tournament_features).forEach { |
||||
val tournamentFeature = TournamentFeature() |
||||
tournamentFeature.id = UUID.randomUUID().toString() |
||||
tournamentFeature.name = it |
||||
realm.insertOrUpdate(tournamentFeature) |
||||
} |
||||
} |
||||
|
||||
private fun createDefaultCurrencyAndBankroll(realm: Realm) { |
||||
// Currency |
||||
val localeCurrency = java.util.Currency.getInstance(Locale.getDefault()) |
||||
val defaultCurrency = Currency() |
||||
defaultCurrency.code = localeCurrency.currencyCode |
||||
realm.insertOrUpdate(defaultCurrency) |
||||
|
||||
// Bankroll |
||||
val bankroll = Bankroll() |
||||
bankroll.name = context.resources.getString(R.string.live) |
||||
bankroll.live = true |
||||
bankroll.currency = realm.where<Currency>().equalTo("code", localeCurrency.currencyCode).findFirst() |
||||
realm.insertOrUpdate(bankroll) |
||||
} |
||||
|
||||
private fun createDefaultGames(realm: Realm) { |
||||
val gamesName = context.resources.getStringArray(R.array.seed_games) |
||||
val gamesShortName = context.resources.getStringArray(R.array.seed_games_short_name) |
||||
for ((index, name) in gamesName.withIndex()) { |
||||
val game = Game() |
||||
game.id = UUID.randomUUID().toString() |
||||
game.name = name |
||||
game.shortName = gamesShortName[index] |
||||
realm.insertOrUpdate(game) |
||||
} |
||||
} |
||||
} |
||||
@ -1,17 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string-array name="limit_name"> |
||||
<item>No Limit</item> |
||||
<item>Pot Limit</item> |
||||
<item>Fixed Limit</item> |
||||
<item>Spread Limit</item> |
||||
<item>Mixed Limit</item> |
||||
</string-array> |
||||
<string-array name="limit_short_name"> |
||||
<item>NL</item> |
||||
<item>PL</item> |
||||
<item>FL</item> |
||||
<item>SL</item> |
||||
<item>ML</item> |
||||
</string-array> |
||||
</resources> |
||||
@ -0,0 +1,13 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string-array name="seed_games"> |
||||
<item>Hold\'em</item> |
||||
<item>Omaha</item> |
||||
<item>Omaha Hi-Low</item> |
||||
</string-array> |
||||
<string-array name="seed_games_short_name"> |
||||
<item>HE</item> |
||||
<item>OH</item> |
||||
<item>OH8</item> |
||||
</string-array> |
||||
</resources> |
||||
@ -0,0 +1,8 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string-array name="seed_tournament_features"> |
||||
<item>Knockout</item> |
||||
<item>Shootout</item> |
||||
<item>Turbo</item> |
||||
</string-array> |
||||
</resources> |
||||
@ -1,8 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string-array name="tournament_fake_name"> |
||||
<item>LA FIEVRE</item> |
||||
<item>NITRO</item> |
||||
<item>WCOOP EVENT #1</item> |
||||
</string-array> |
||||
</resources> |
||||
@ -1,21 +0,0 @@ |
||||
<?xml version="1.0" encoding="utf-8"?> |
||||
<resources> |
||||
<string-array name="game_name"> |
||||
<item>Hold\'em</item> |
||||
<item>Omaha</item> |
||||
<item>Omaha Hi-Low</item> |
||||
<item>Seven Card Stud</item> |
||||
<item>Seven Card Stud Hi-Low</item> |
||||
<item>H.O.R.S.E.</item> |
||||
<item>Seven Card Razz</item> |
||||
</string-array> |
||||
<string-array name="game_short_name"> |
||||
<item>HE</item> |
||||
<item>OH</item> |
||||
<item>OH8</item> |
||||
<item>7S</item> |
||||
<item>Stud8</item> |
||||
<item>HORSE</item> |
||||
<item>Razz</item> |
||||
</string-array> |
||||
</resources> |
||||
Loading…
Reference in new issue