Skip to content

Commit

Permalink
v.1.13.2 Small buttons visibility fixes. Docs updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
yvolk committed Aug 6, 2023
1 parent ee3e670 commit 5d82e40
Show file tree
Hide file tree
Showing 10 changed files with 45 additions and 36 deletions.
34 changes: 21 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ see [User experience](doc/User-Experience.md).
* Turn on AI (Artificial Intelligence) mode and let the AI play for you.
Increase or decrease AI player speed. Stop it and continue playing yourself.
Choose one of several AI algorithms, see how they play and compare them.
* Select board size from 3x3 up to 8x8, and not 4x4 default classic size only.
* Bookmarks at the interesting game positions. Return to a bookmark and play again from that place.
* Move number and game duration shown. The time starts when you make a move.
* Move number and game duration are shown. The time starts when you make a move.
It stops when you tap Undo or Pause button.
* "Watch" mode. Auto replay current game forward and backwards at any speed,
stop at any position.
Expand All @@ -57,13 +58,13 @@ see [User experience](doc/User-Experience.md).
* The app is multilingual. Please add new translations [2048 Open Fun Game at Crowdin](https://crowdin.com/project/2048-open-fun-game)

<p>
<img title="Main screen of Game2048 app. Play mode. You see Bookmark and Pause buttons" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/1.png" height="400" />
<img title="Main screen of Game2048 app. Play mode ('Game pad' button in the top left corner). You see Bookmark and Pause buttons" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/1.png" height="400" />
<img src="doc/images/5x5.png" width="5" />
<img title="Dark Theme. Play mode in Landscape orientation. You see Bookmark button. Game2048 app" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/2.png" width="400" />
<img src="doc/images/5x5.png" width="5" />
<img title="Dark Theme. Watch mode. Now watching the game movements backwards. To the left: 'Game pad' button to switch to Play mode. Game2048 app" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/3.png" height="400" />
<img title="6x6 board. Light theme. Watch mode ('Movie' button in the top left corner). Now watching the game movements backwards. Press the 'Movie' button to switch to Play mode. Game2048 app" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/3.png" height="400" />
<img src="doc/images/5x5.png" width="5" />
<img title="Game actions menu of Game2048 app" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/4.png" height="400" />
<img title="Game actions menu of Game2048 app. 'Delete game' option is shown when AI is turned off (and its 'Select AI algorithm' menu item frees a space)" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/4.png" height="400" />
<img src="doc/images/5x5.png" width="5" />
<img title="Open recent game, then watch or play it. Game2048 app" src="game2048-android/src/main/play/listings/en-US/graphics/phone-screenshots/5.png" height="400" />
<img src="doc/images/5x5.png" width="5" />
Expand Down Expand Up @@ -104,6 +105,10 @@ in order to ease understanding of implementation logic.

## Changelog

### 2023-08-06 v.1.13.2 (37) Different board sizes.
* Previously we had only 4x4 classic game board. Now "Select board size" menu item
added allowing to select boards from 3x3 to 8x8. [#9](https://github.com/andstatus/game2048/issues/9)

### 2022-03-20 v.1.12.0 (34) Share and Load huge game histories.
* Now we can Share and Load huge game histories. Successfully tested with
a game having 120 thousand moves.
Expand Down Expand Up @@ -148,10 +153,14 @@ Below are the compiling and running instructions taken from the template.

You can open this project in IntelliJ IDEA by opening the folder or the build.gradle.kts file.

You can find this template at GitHub: <https://github.com/korlibs/korge-hello-world>

For Windows, change all the `./gradlew` for `gradlew.bat`.

You should use Gradle 5.5 or greater and Java 8 or greater.

Tasks related to specific targets, might not be available if the target is not enabled, make sure that the required targets are enabled/not commented out in the `korge {}` section inside `build.gradle.kts`.

## Compiling for the JVM (Desktop)

Inside IntelliJ you can go to the `src/commonMain/kotlin/main.kt` file and press the green ▶️ icon
Expand Down Expand Up @@ -271,8 +280,8 @@ won't include Swift's runtime.

```bash
./gradlew iosBuildSimulatorDebug # Creates an APP file
./gradlew iosInstallSimulatorDebug # Installs an APP file in the simulator
./gradlew iosRunSimulatorDebug # Runs the APP in the simulator
./gradlew installIosSimulatorDebug # Installs an APP file in the simulator
./gradlew runIosSimulatorDebug # Runs the APP in the simulator

```

Expand All @@ -282,10 +291,9 @@ with XCode and do additional tasks there.
It uses [XCodeGen](https://github.com/yonaskolb/XcodeGen) for the project generation
and [ios-deploy](https://github.com/ios-control/ios-deploy) for deploying to real devices.

### Apache Cordova (JS)

```bash
./gradlew compileCordovaIos # Just compiles cordova from iOS
./gradlew runCordovaIos # Runs the application (dce'd, minimized and webpacked) in an iOS device
./gradlew runCordovaIosNoMinimized # Runs the application in iOS without minimizing (so you can use Safari on macOS to debug the application easier)
```
## JS-game deployment to GitHub Pages
- Go to [settings page](../../settings) and enable GitHub Pages
- Choose branch `github-pages` and select folder `/ (root)`
- After that you can use link:
[link to JS-game](../../deployments/activity_log?environment=github-pages), click "View Deployment"
- When you push to main or master branch, - deployment process will start again with GitHub Actions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ korge {
androidCompileSdk = 30
androidTargetSdk = 31

versionCode = 36
version = "1.13.1"
versionCode = 37
version = "1.13.2"

targetJvm()
targetJs()
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
v.1.12.0. * Now we can Share and load huge game histories.
* Keep the game screen on during inactivity.
* "Exit app" button added to the "Game actions" menu.
* Fixed "How to play" screen overlays with main screen or "Game actions" opens after closing the "How to play" screen.
v.1.13.2. * Select board size from 3x3 up to 8x8, and not 4x4 default classic size only.
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
v.1.12.0. * Теперь можно Поделиться и Загрузить игру с огромной историей.
* Эран игры не выключается при бездействии.
* Добавлена кнопка "Выйти из приложения" в меню "Действия с игрой".
* Исправлена ошибка с наложением текста окна "Как играть" на основное окно игры.
v.1.13.2. * Можно выбрать размер поля от 3х3 до 8х8, а не только обычный 4х4.
18 changes: 13 additions & 5 deletions src/commonMain/kotlin/org/andstatus/game2048/model/History.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package org.andstatus.game2048.model

import korlibs.time.DateTimeTz
import korlibs.time.weeks
import korlibs.io.concurrent.atomic.KorAtomicRef
import korlibs.io.concurrent.atomic.korAtomic
import korlibs.time.DateTimeTz
import korlibs.time.weeks
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.async
import kotlinx.coroutines.coroutineScope
Expand Down Expand Up @@ -32,7 +32,7 @@ class History(
val currentGame: GameRecord get() = currentGameRef.value

// 1. Info on previous games
var bestScore: Int = settings.storage.getOrNull(keyBest)?.toInt() ?: 0
var bestScore: Int = settings.storage.getInt(keyBest, 0)

// 2. This game, see for the inspiration https://en.wikipedia.org/wiki/Portable_Game_Notation
/** 0 means that the pointer is turned off */
Expand Down Expand Up @@ -93,6 +93,7 @@ class History(
}
currentGameRef.value = it
settings.storage[keyCurrentGameId] = it.id
updateBestScore()
gameMode.modeEnum = if (it.isEmpty) GameModeEnum.PLAY else GameModeEnum.STOP
}
?: run {
Expand Down Expand Up @@ -122,7 +123,7 @@ class History(
(currentGame.score).let { score ->
if (bestScore < score) {
bestScore = score
settings.storage[keyBest] = score.toString()
settings.storage[keyBest] = score
}
}
}
Expand Down Expand Up @@ -183,9 +184,11 @@ class History(
redoPlyPointer < 1 -> {
game.shortRecord.bookmarks
}

redoPlyPointer == 1 -> {
emptyList()
}

else -> {
game.shortRecord.bookmarks.filterNot { it.plyNumber >= redoPlyPointer }
}
Expand All @@ -194,15 +197,20 @@ class History(
redoPlyPointer < 1 -> {
game.gamePlies
}

redoPlyPointer == 1 -> {
GamePlies(game.shortRecord, emptySequenceLineReader)
}

else -> {
game.gamePlies.take(redoPlyPointer - 1)
}
} + position.ply
with(game.shortRecord) {
GameRecord(ShortRecord(settings, board, note, id, start, position.position, bookmarksNew), gamePliesNew)
GameRecord(
ShortRecord(settings, board, note, id, start, position.position, bookmarksNew),
gamePliesNew
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ class Presenter(val view: ViewData, history: History) {
fun onGameMenuClick() = afterStop {
logClick("GameMenu")
hideMainView()
view.showGameMenu(model.gameMode.aiEnabled, model.history.recentGames.size)
view.showGameMenu(model.gameMode, model.history.recentGames.size)
pauseGame()
}

Expand Down Expand Up @@ -579,7 +579,7 @@ class Presenter(val view: ViewData, history: History) {
myLogInTest { "showMainView started" }
if (!view.closed) {
view.mainView.show(buttonsToShow(), gameMode.speed)
if (gameMode.aiEnabled && gameMode.speed == 0) {
if (gameMode.isPlaying && gameMode.aiEnabled && gameMode.speed == 0) {
multithreadedScope.showAiTip(this@Presenter)
myLog("After AI Launch")
}
Expand Down Expand Up @@ -635,9 +635,6 @@ class Presenter(val view: ViewData, history: History) {

else -> {
list.add(AppBarButtonsEnum.WATCH)
list.add(
if (gameMode.aiEnabled) AppBarButtonsEnum.AI_ON else AppBarButtonsEnum.AI_OFF
)
if (model.moveNumber > 1 && model.isBookmarked) {
list.add(AppBarButtonsEnum.BOOKMARKED)
} else {
Expand Down
8 changes: 5 additions & 3 deletions src/commonMain/kotlin/org/andstatus/game2048/view/GameMenu.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ package org.andstatus.game2048.view

import korlibs.korge.view.addTo
import korlibs.korge.view.position
import org.andstatus.game2048.model.GameMode

fun ViewData.showGameMenu(aiEnabled: Boolean, numberOfRecentGames: Int) = myWindow("game_actions") {
fun ViewData.showGameMenu(gameMode: GameMode, numberOfRecentGames: Int) = myWindow("game_actions") {
var xInd = 0
var yInd = 0

Expand All @@ -29,14 +30,15 @@ fun ViewData.showGameMenu(aiEnabled: Boolean, numberOfRecentGames: Int) = myWind
}
}

if (aiEnabled) {
val aiShown = gameMode.isPlaying && gameMode.aiEnabled
if (aiShown) {
button(GameMenuButtonsEnum.SELECT_AI_ALGORITHM) { selectAiAlgorithm(settings) }
}
button(GameMenuButtonsEnum.BOOKMARKS, presenter::onBookmarksClick)
button(GameMenuButtonsEnum.RECENT, presenter::onRecentClick)
button(GameMenuButtonsEnum.TRY_AGAIN, presenter::onTryAgainClick)
button(GameMenuButtonsEnum.SHARE, presenter::onShareClick)
if (!aiEnabled || isPortrait) {
if (!aiShown || isPortrait) {
button(GameMenuButtonsEnum.LOAD, presenter::onLoadClick)
}
button(GameMenuButtonsEnum.SELECT_THEME) { selectTheme(settings) }
Expand Down

0 comments on commit 5d82e40

Please sign in to comment.