Skip to content

Commit

Permalink
0.1.7; removed String.format, Czech locale
Browse files Browse the repository at this point in the history
  • Loading branch information
trolley813 committed May 25, 2017
1 parent c5aaa72 commit 8979b81
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 32 deletions.
4 changes: 3 additions & 1 deletion android/assets/i18n/OpenFool.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ CardsFrench=French
Language=Language:
LanguageRussian=Russian
LanguageEnglish=English
LanguageCzech=Czech
VictoryHeader=Victory!
VictoryText=
VictoryText=Your team has defeated the opponents!
DefeatHeader=Defeat :(
DefeatText=Your team has lost the game.
PartnerDefeatHeader=Still a defeat...
Expand All @@ -30,3 +31,4 @@ YourTurn=Your turn!
Defend=Defend!
PlayerTakes=I take
PlayerDone=Done
PlayerNames=Player Names
34 changes: 34 additions & 0 deletions android/assets/i18n/OpenFool_cs.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
NewGame=Nová hra
Settings=Nastavení
LoadingAssets=Načítání zdrojů {0}%
Quit=Opustit
ChangeBackgroundColor=Změnit barvu pozadí
SaveSettings=Uložit
Cards=Karty:
CardsRussian=Ruské
CardsInternational=Mezinárodní
CardsFrench=Francouzské
Language=Jazyk:
LanguageRussian=Ruština
LanguageEnglish=Angličtina
LanguageCzech=Čeština
VictoryHeader=Výhra!
DefeatHeader=Prohra :(
PartnerDefeatHeader=To je ještě prohra...
DrawHeader=Remíza.
SortingUnsorted=Bez třídění
SortingSuitAscending=Podle barvy, vzestupně
SortingSuitDescending=Podle barvy, sestupně
SortingRankAscending=Podle hodnoty, vzestupně
SortingRankDescending=Podle hodnoty, sestupně
Background=Pozadí:
YourTurn=Řada je na vás!
Defend=Přebíjejte!
PlayerTakes=Beru
PlayerDone=Bito
PlayerNames=Jména hráčů
VictoryText=Vaš tým porazil protihráčů!
DefeatText=Vaš tým prohrál.
PartnerDefeatText=Jste dosáhli konce hry, ale vaš spoluhráč není.
DrawText=Vaš tým a protihráče dosáhli remízy.
Sorting=Třídění karet:
4 changes: 3 additions & 1 deletion android/assets/i18n/OpenFool_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ SortingRankDescending=By rank, ascending
Background=Background:
YourTurn=Your turn!
Defend=Defend!
PlayerDone=Done
PlayerDone=Done
PlayerNames=Player Names
LanguageCzech=Czech
4 changes: 3 additions & 1 deletion android/assets/i18n/OpenFool_ru.properties
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,6 @@ SortingRankDescending=По рангу (убыв.)
Background=Фон:
YourTurn=Ваш ход!
Defend=Отбивайтесь!
PlayerDone=Бито
PlayerDone=Бито
PlayerNames=Имена игроков
LanguageCzech=Чешский
4 changes: 2 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
buildscript {
ext.kotlinVersion = '1.1.1'
ext.kotlinVersion = '1.1.2-2'

repositories {
mavenLocal()
Expand All @@ -19,7 +19,7 @@ allprojects {
apply plugin: "eclipse"
apply plugin: "idea"

version = '0.1.6'
version = '0.1.7'
ext {
appName = "OpenFool"
gdxVersion = '1.9.6'
Expand Down
3 changes: 1 addition & 2 deletions core/src/ru/hyst329/openfool/Card.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ class Card(internal val suit: Suit, internal val rank: Rank) {
}

override fun toString(): String {
return String.format(Locale.ENGLISH, "%d%c", rank.value,
suit.name.toLowerCase()[0])
return "${rank.value}${suit.name.toLowerCase()[0]}"
}
}
6 changes: 2 additions & 4 deletions core/src/ru/hyst329/openfool/CardActor.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ import com.badlogic.gdx.scenes.scene2d.Actor

internal class CardActor(game: OpenFoolGame, val card: Card, deckStyle: String) : Actor() {
var isFaceUp: Boolean = false
private val face: Sprite
private val back: Sprite
private val face: Sprite = Sprite(game.assetManager.get("decks/$deckStyle/$card.png", Texture::class.java))
private val back: Sprite = Sprite(game.assetManager.get("decks/$deckStyle/back.png", Texture::class.java))

init {
this.face = Sprite(game.assetManager.get(String.format("decks/%s/%s.png", deckStyle, card), Texture::class.java))
this.back = Sprite(game.assetManager.get(String.format("decks/%s/back.png", deckStyle), Texture::class.java))
setSize(face.width, face.height)
face.setOrigin(face.width / 2, face.height / 2)
back.setOrigin(back.width / 2, back.height / 2)
Expand Down
27 changes: 14 additions & 13 deletions core/src/ru/hyst329/openfool/GameScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,15 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
private var oldGameState = FINISHED
private val sortingMode: Player.SortingMode
private var throwLimit = DEAL_LIMIT
private var playerDoneStatuses = Array(PLAYER_COUNT, {i -> false})
private var playerDoneStatuses = Array(PLAYER_COUNT, { i -> false })

init {
// Initialise the stage
Gdx.input.inputProcessor = stage
// Get background color
backgroundColor = Color(game.preferences.getInteger(SettingsScreen.BACKGROUND_COLOR, 0x33cc4dff))
background = game.assetManager.get(String.format(Locale.ENGLISH, "backgrounds/background%d.png",
game.preferences.getInteger(SettingsScreen.BACKGROUND, 1)), Texture::class.java)
val backgroundNo = game.preferences.getInteger(SettingsScreen.BACKGROUND, 1)
background = game.assetManager.get("backgrounds/background$backgroundNo.png", Texture::class.java)
background.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat)
//background.
val deckStyle = game.preferences.getString(SettingsScreen.DECK, "rus")
Expand Down Expand Up @@ -199,7 +199,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
trump?.isFaceUp = true
trump?.moveBy(90 * CARD_SCALE_TABLE, 0f)
trumpSuit = trumpCard!!.suit
println(String.format("Trump suit is %s", trumpSuit.toString()))
println("Trump suit is ${trumpSuit.toString()}")
// Draw cards
for (i in 0..PLAYER_COUNT - 1) {
drawCardsToPlayer(i, DEAL_LIMIT)
Expand Down Expand Up @@ -235,8 +235,9 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
}
}))
}
println(String.format("%s (%s) has the lowest trump %s",
players[firstAttacker].name, players[firstAttacker].index, lowestTrump))
println(players[firstAttacker].name +
" (${players[firstAttacker].index})" +
" has the lowest trump $lowestTrump")
currentAttackerIndex = firstAttacker
currentThrowerIndex = firstAttacker
}
Expand Down Expand Up @@ -320,16 +321,16 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
if (i > 0)
position[0] += ((i - 1) * 640 / (PLAYER_COUNT - 2)).toFloat()
position[1] += 640 * if (i == 0) CARD_SCALE_PLAYER else CARD_SCALE_AI
var playerFormat = String.format("%s: %s ", players[i].name, players[i].hand.size)
var playerFormat = "${players[i].name}: ${players[i].hand.size}"
if (playerDoneStatuses[i]) playerFormat += game.localeBundle["PlayerDone"]
if (isPlayerTaking && currentDefender.index == i)
playerFormat += game.localeBundle["PlayerTakes"]
game.font.draw(game.batch, playerFormat,
position[0], position[1])

}
game.font.draw(game.batch, String.format("%s %s", trumpSuit, cardsRemaining()), 20f, 160f)
var turnString = String.format("%s -> %s", currentAttacker.name, currentDefender.name)
game.font.draw(game.batch, "$trumpSuit ${cardsRemaining()}", 20f, 160f)
var turnString = "${currentAttacker.name} -> ${currentDefender.name}"
if (currentAttacker.index == 0)
turnString += "\n" + game.localeBundle["YourTurn"]
if (currentDefender.index == 0)
Expand Down Expand Up @@ -368,7 +369,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {

private fun endTurn(playerIndex: Int) {
playersSaidDone = 0
playerDoneStatuses = Array(PLAYER_COUNT, {i -> false})
playerDoneStatuses = Array(PLAYER_COUNT, { i -> false })
val tableCards = ArrayList<Card>()
for (i in attackCards.indices) {
if (attackCards[i] != null) {
Expand Down Expand Up @@ -451,7 +452,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
if (event is Player.CardThrownEvent) {
// Handle when card is thrown
playersSaidDone = 0
playerDoneStatuses = Array(PLAYER_COUNT, {i -> false})
playerDoneStatuses = Array(PLAYER_COUNT, { i -> false })
var throwIndex = 0
while (attackCards[throwIndex] != null) throwIndex++
val throwCard = event.card
Expand Down Expand Up @@ -489,7 +490,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
if (event is Player.CardBeatenEvent) {
// Handle when card is beaten
playersSaidDone = 0
playerDoneStatuses = Array(PLAYER_COUNT, {i -> false})
playerDoneStatuses = Array(PLAYER_COUNT, { i -> false })
var beatIndex = 0
while (defenseCards[beatIndex] != null) beatIndex++
val beatCard = event.card
Expand Down Expand Up @@ -527,7 +528,7 @@ class GameScreen(private val game: OpenFoolGame) : Screen, EventListener {
if (event is Player.TakeEvent) {
// Handle when player takes
playersSaidDone = 0
playerDoneStatuses = Array(PLAYER_COUNT, {i -> false})
playerDoneStatuses = Array(PLAYER_COUNT, { i -> false })
isPlayerTaking = true
val player = event.getTarget() as Player
System.out.printf("%s (%s) decides to take\n",
Expand Down
9 changes: 3 additions & 6 deletions core/src/ru/hyst329/openfool/OpenFoolGame.kt
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,13 @@ class OpenFoolGame : Game() {
for (d in decks) {
for (i in 1..13) {
for (s in suits.toCharArray()) {
assetManager.load(String.format(Locale.ENGLISH, "decks/%s/%d%s.png", d, i, s),
Texture::class.java, param)
assetManager.load("decks/$d/$i$s.png", Texture::class.java, param)
}
}
assetManager.load(String.format(Locale.ENGLISH, "decks/%s/back.png", d),
Texture::class.java, param)
assetManager.load("decks/$d/back.png", Texture::class.java, param)
}
for (i in 1..2) {
assetManager.load(String.format(Locale.ENGLISH, "backgrounds/background%d.png", i),
Texture::class.java, param)
assetManager.load("backgrounds/background$i.png", Texture::class.java, param)
}
this.setScreen(MainMenuScreen(this))
}
Expand Down
15 changes: 13 additions & 2 deletions core/src/ru/hyst329/openfool/SettingsScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen {
LANGUAGES = HashMap<String, String>()
LANGUAGES.put(game.localeBundle.get("LanguageRussian"), "ru")
LANGUAGES.put(game.localeBundle.get("LanguageEnglish"), "en")
LANGUAGES.put(game.localeBundle.get("LanguageCzech"), "cs")
// Initialise SORTING_MODES
val SORTING_MODES = ArrayList<String>()
SORTING_MODES.add(game.localeBundle.get("SortingUnsorted"))
Expand All @@ -87,7 +88,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen {
})

val changeColorButton = VisTextButton(game.localeBundle.get("ChangeBackgroundColor"))
changeColorButton.setBounds(40f, 300f, 250f, 80f)
changeColorButton.setBounds(40f, 350f, 250f, 80f)
changeColorButton.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
// super.clicked(event, x, y);
Expand All @@ -97,7 +98,7 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen {
})
stage.addActor(changeColorButton)
val saveButton = VisTextButton(game.localeBundle.get("SaveSettings"))
saveButton.setBounds(40f, 200f, 250f, 80f)
saveButton.setBounds(40f, 250f, 250f, 80f)
saveButton.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
// super.clicked(event, x, y);
Expand All @@ -106,6 +107,16 @@ internal class SettingsScreen(private val game: OpenFoolGame) : Screen {
}
})
stage.addActor(saveButton)
val playerNamesButton = VisTextButton(game.localeBundle.get("PlayerNames"))
playerNamesButton.setBounds(40f, 150f, 250f, 80f)
playerNamesButton.addListener(object : ClickListener() {
override fun clicked(event: InputEvent?, x: Float, y: Float) {
// super.clicked(event, x, y);
// TODO: Add real player name selection

}
})
stage.addActor(playerNamesButton)
val backgroundSelectLabel = VisLabel(game.localeBundle.get("Background"))
backgroundSelectLabel.setBounds(420f, 250f, 60f, 40f)
stage.addActor(backgroundSelectLabel)
Expand Down
Empty file modified gradlew
100644 → 100755
Empty file.

0 comments on commit 8979b81

Please sign in to comment.