Skip to content

Commit

Permalink
various bug fixes
Browse files Browse the repository at this point in the history
Red symbols blend with coloured background - resolves #72
Highlight leading/winning player in a round - resolves #77
  • Loading branch information
mytja committed Sep 7, 2024
1 parent bae6f03 commit 57ecb39
Show file tree
Hide file tree
Showing 8 changed files with 241 additions and 70 deletions.
18 changes: 9 additions & 9 deletions stockskis/lib/src/stockskis_base.dart
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ class StockSkis {
for (int i = 0; i < stihi.length; i++) {
if (stihi[i].isEmpty) continue;
Card prvaKarta = stihi[i].first;
StihAnalysis? s = analyzeStih(stihi[i]);
StihAnalysis? s = analyzeStih(stihi[i], gamemode);
if (s != null &&
!allPlaying.contains(s.cardPicks.user) &&
stihi[i].length >= users.length) {
Expand Down Expand Up @@ -683,7 +683,7 @@ class StockSkis {
}
} else {
String cardType = stih.first.card.asset.split("/")[1];
StihAnalysis analysis = analyzeStih(stih)!;
StihAnalysis analysis = analyzeStih(stih, gamemode)!;
bool hasColor = false;
bool hasTarocks = false;
for (int n = 0; n < user.cards.length; n++) {
Expand Down Expand Up @@ -953,7 +953,7 @@ class StockSkis {

// ali bot šenka punte pravi osebi?
List<Card> currentStih = [...stih, card];
StihAnalysis newAnalysis = analyzeStih(currentStih)!;
StihAnalysis newAnalysis = analyzeStih(currentStih, gamemode)!;
debugPrint(
"Analysis ${newAnalysis.cardPicks.user} ${newAnalysis.cardPicks.card.asset} for player $userId, whereas stih consists of ${currentStih.map((e) => e.card.asset).join(" ")}",
);
Expand Down Expand Up @@ -1053,7 +1053,7 @@ class StockSkis {
}
*/

StihAnalysis? analyzeStih(List<Card> stih) {
static StihAnalysis? analyzeStih(List<Card> stih, int gamemode) {
if (stih.isEmpty) return null;

Card first = stih.first;
Expand Down Expand Up @@ -2071,7 +2071,7 @@ class StockSkis {

String stihPickedUpBy(List<Card> stih) {
if (stih.isEmpty) throw Exception("stih's length is 0");
StihAnalysis analysis = analyzeStih(stih)!;
StihAnalysis analysis = analyzeStih(stih, gamemode)!;
return analysis.cardPicks.user;
}

Expand Down Expand Up @@ -2806,7 +2806,7 @@ class StockSkis {
// pagata ni not v štihu
if (!pagatInside) return 0;

StihAnalysis analysis = analyzeStih(stih)!;
StihAnalysis analysis = analyzeStih(stih, gamemode)!;

// pagat ni pobral
if (analysis.cardPicks.card.asset != "/taroki/pagat") {
Expand Down Expand Up @@ -2917,7 +2917,7 @@ class StockSkis {
for (int i = 0; i < stihi.length; i++) {
List<Card> stih = stihi[i];
if (stih.isEmpty) continue;
StihAnalysis analysis = analyzeStih(stih)!;
StihAnalysis analysis = analyzeStih(stih, gamemode)!;
if (analysis.cardPicks.card.asset == selectedKing &&
analysis.cardPicks.user == actuallyPlayingUser.id) {
// zaruf, prištejemo talon
Expand All @@ -2943,7 +2943,7 @@ class StockSkis {
//debugPrint(i);
//debugPrint(stih.map((e) => e.card.asset));
//debugPrint(stih.length);
StihAnalysis analysis = analyzeStih(stih)!;
StihAnalysis analysis = analyzeStih(stih, gamemode)!;

stihiMessage.add(
MessagesStih(
Expand Down Expand Up @@ -3648,7 +3648,7 @@ class StockSkis {
List<Card> notPlayingPickedUpCards = [...talon];
for (int i = 0; i < stihi.length; i++) {
if (stihi[i].isEmpty) continue;
StihAnalysis by = analyzeStih(stihi[i])!;
StihAnalysis by = analyzeStih(stihi[i], gamemode)!;
for (int n = 0; n < stihi[i].length; n++) {
if (playing.contains(by.cardPicks.user)) {
playingPickedUpCards.add(stihi[i][n]);
Expand Down
2 changes: 1 addition & 1 deletion tarok/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ I made use of [Twemoji](https://github.com/twitter/twemoji), which is licensed u
These cards are licensed under [CC0](https://creativecommons.org/publicdomain/zero/1.0/legalcode).

### Other pictures
- F-Droid logo. (c) Andrew Nayenko. CC-BY-SA 3.0, available [here](https://gitlab.com/fdroid/artwork/-/blob/master/fdroid-logo-2015/fdroid-logo.svg).
- F-Droid logo. (c) Andrew Nayenko. CC-BY-SA 3.0, available [here](https://gitlab.com/fdroid/artwork/-/blob/master/fdroid-logo-2015/fdroid-logo.svg).
10 changes: 8 additions & 2 deletions tarok/lib/constants.dart
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ bool RED_FILTER = true;
bool COUNTERCLOCKWISE_GAME = false;
bool POINTS_TOOLTIP = false;
bool SHOW_EVALUATION = true;
bool SHOW_MOST_POWERFUL_CARD = false;
String THEME = "";
Locale LOCALE = Get.deviceLocale ?? const Locale("sl", "SI");

Expand Down Expand Up @@ -83,12 +84,17 @@ void parseBackendUrls() {
}

class CardWidget {
const CardWidget(
{required this.position, required this.widget, required this.angle});
const CardWidget({
required this.position,
required this.widget,
required this.angle,
required this.asset,
});

final int position;
final Widget widget;
final double angle;
final String asset;
}

const GAME_DESC = [
Expand Down
51 changes: 31 additions & 20 deletions tarok/lib/game/game.dart
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class Game extends StatelessWidget {
// REZULTATI
// KLEPET
// CHAT
// LEADERBOARD
Container(
alignment: Alignment.topRight,
child: Card(
Expand Down Expand Up @@ -700,6 +701,7 @@ class Game extends StatelessWidget {
),

// ŠTIHI
// CARDS
if (controller.playing == 3 &&
!(controller.bots && SLEPI_TAROK))
...controller.stihi3(
Expand Down Expand Up @@ -1073,26 +1075,35 @@ class Game extends StatelessWidget {
),
DataColumn(
label: Expanded(
child: Text(
"points_prediction".trParams(
{
"points": (stockskis
.GAMES[controller
.currentPredictions
.value!
.gamemode +
1]
.worth *
pow(
2,
controller
.currentPredictions
.value!
.igraKontra))
.toString(),
},
),
),
child: stockskis
.GAMES[controller
.currentPredictions
.value!
.gamemode +
1]
.worth !=
0
? Text(
"points_prediction".trParams(
{
"points": (stockskis
.GAMES[controller
.currentPredictions
.value!
.gamemode +
1]
.worth *
pow(
2,
controller
.currentPredictions
.value!
.igraKontra))
.toString(),
},
),
)
: const Text("-"),
),
),
],
Expand Down
Loading

0 comments on commit 57ecb39

Please sign in to comment.