From d1a16995f263b4985668a26da311fda77d5a92ab Mon Sep 17 00:00:00 2001
From: Marvin Borner
Date: Mon, 6 Apr 2020 15:13:13 +0200
Subject: More stats in leaderboard, basic cheat detection
---
qml/harbour-binaryfun.qml | 2 +-
qml/pages/Game.qml | 2 +-
qml/pages/LeaderBoard.qml | 49 +++++++++++++++++++++++++-----------
rpm/harbour-binaryfun.spec | 2 +-
rpm/harbour-binaryfun.yaml | 2 +-
translations/harbour-binaryfun-de.ts | 36 ++++++++++++++++++++------
translations/harbour-binaryfun.ts | 30 ++++++++++++++++++----
7 files changed, 92 insertions(+), 31 deletions(-)
diff --git a/qml/harbour-binaryfun.qml b/qml/harbour-binaryfun.qml
index 9378223..599a3ea 100644
--- a/qml/harbour-binaryfun.qml
+++ b/qml/harbour-binaryfun.qml
@@ -6,5 +6,5 @@ ApplicationWindow
{
initialPage: Component { Menu { } }
cover: Qt.resolvedUrl("cover/CoverPage.qml")
- allowedOrientations: defaultAllowedOrientations
+ allowedOrientations: Orientation.Portrait
}
diff --git a/qml/pages/Game.qml b/qml/pages/Game.qml
index c99c8a3..cc13b84 100644
--- a/qml/pages/Game.qml
+++ b/qml/pages/Game.qml
@@ -132,7 +132,7 @@ Page {
Button {
id: new_game
- text: qsTr("Play again!")
+ text: qsTr("Play again")
visible: false
anchors.horizontalCenter: parent.horizontalCenter
onClicked: pageStack.replace(Qt.resolvedUrl("Game.qml"), {bits: root.bits})
diff --git a/qml/pages/LeaderBoard.qml b/qml/pages/LeaderBoard.qml
index f80c969..75f8c64 100644
--- a/qml/pages/LeaderBoard.qml
+++ b/qml/pages/LeaderBoard.qml
@@ -15,9 +15,9 @@ Page {
}
TextField {
- placeholderText: "Enter username (default: anon)"
+ placeholderText: qsTr("Enter username (default: anon)")
text: username.value
- label: "Username"
+ label: qsTr("Username")
width: page.width
EnterKey.enabled: text.length > 0 && text.length <= 16
EnterKey.iconSource: "image://theme/icon-m-enter-close"
@@ -29,20 +29,22 @@ Page {
ComboBox {
id: selector
- label: "Difficulty"
+ label: qsTr("Difficulty")
function select(diff) {
var xhr = new XMLHttpRequest()
xhr.open("GET",
"https://marvinborner.de/lead/binaryfun1/list?sort=time&order=asc&count=1000&filter=difficulty,"+diff,
- false)
- xhr.send()
- if (xhr.status !== 0) {
- list.model = JSON.parse(xhr.responseText);
- internet.visible = false;
- } else {
- internet.visible = true;
+ true)
+ xhr.onreadystatechange = function() {
+ if (xhr.readyState === 4 && xhr.status === 200) {
+ list.model = JSON.parse(xhr.responseText);
+ internet.visible = false;
+ } else {
+ internet.visible = true;
+ }
}
+ xhr.send()
}
menu: ContextMenu {
@@ -79,7 +81,7 @@ Page {
Label {
id: internet
- text: qsTr("No internet connection!")
+ text: qsTr("Please try again later.")
visible: false
}
@@ -90,7 +92,8 @@ Page {
height: page.height - y
model: []
delegate: ListItem {
- contentHeight: Theme.itemSizeMedium
+ id: score
+ contentHeight: Theme.itemSizeLarge
Label {
id: name
@@ -98,9 +101,27 @@ Page {
}
Label {
+ id: level
anchors.top: name.bottom
- text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + "s - Help: " + modelData.cheats
- font.pixelSize: Theme.fontSizeSmall
+ text: {
+ var numbers = modelData.level.split(",").slice(
+ modelData.difficulty).filter(function (_, i) {
+ return i % (modelData.difficulty + 1) === 0.
+ }).slice(1);
+ if (numbers.length !== modelData.difficulty && modelData.difficulty !== 10) {
+ console.log("Tempered: " + numbers.length + " " + modelData.difficulty);
+ score.visible = false;
+ }
+
+ return qsTr("Numbers: ") + numbers.join(", ");
+ }
+ font.pixelSize: Theme.fontSizeExtraSmall
+ }
+
+ Label {
+ anchors.top: level.bottom
+ text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + qsTr("s - Help: ") + modelData.cheats
+ font.pixelSize: Theme.fontSizeExtraSmall
}
}
}
diff --git a/rpm/harbour-binaryfun.spec b/rpm/harbour-binaryfun.spec
index 4ad17dc..ab41aaa 100644
--- a/rpm/harbour-binaryfun.spec
+++ b/rpm/harbour-binaryfun.spec
@@ -13,7 +13,7 @@ Name: harbour-binaryfun
%{!?qtc_make:%define qtc_make make}
%{?qtc_builddir:%define _builddir %qtc_builddir}
Summary: An awesome binary game
-Version: 1.0
+Version: 1.1
Release: 1
Group: Qt/Qt
License: MIT
diff --git a/rpm/harbour-binaryfun.yaml b/rpm/harbour-binaryfun.yaml
index 1d45899..0b8357c 100644
--- a/rpm/harbour-binaryfun.yaml
+++ b/rpm/harbour-binaryfun.yaml
@@ -1,6 +1,6 @@
Name: harbour-binaryfun
Summary: An awesome binary game
-Version: 1.0
+Version: 1.1
Release: 1
# The contents of the Group field should be one of the groups listed here:
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS
diff --git a/translations/harbour-binaryfun-de.ts b/translations/harbour-binaryfun-de.ts
index efb8610..8c0aa0d 100644
--- a/translations/harbour-binaryfun-de.ts
+++ b/translations/harbour-binaryfun-de.ts
@@ -14,10 +14,6 @@
Binary Fun
Binär-Spaß
-
- Play again!
- Nochmal!
-
Not bad!
Nicht schlecht!
@@ -26,6 +22,10 @@
Leaderboard
Bestenliste
+
+ Play again
+ Nochmal spielen
+
LeaderBoard
@@ -33,6 +33,10 @@
Leaderboard
Bestenliste
+
+ Please select
+ Bitte auswählen
+
Very easy (2 Bit)
Sehr einfach (2 Bit)
@@ -54,12 +58,28 @@
Krass (10 Bit)
- Please select
- Bitte auswählen
+ Enter username (default: anon)
+ Nutzername eingeben (Standard: anon)
+
+
+ Username
+ Nutzername
+
+
+ Difficulty
+ Schwierigkeit
+
+
+ Numbers:
+ Zahlen:
+
+
+ s - Help:
+ s - Hilfe:
- No internet connection!
- Keine Internetverbindung!
+ Please try again later.
+ Bitte probiere es später nochmal.
diff --git a/translations/harbour-binaryfun.ts b/translations/harbour-binaryfun.ts
index 3902a1f..2d4e464 100644
--- a/translations/harbour-binaryfun.ts
+++ b/translations/harbour-binaryfun.ts
@@ -15,15 +15,15 @@
- Play again!
+ Not bad!
- Not bad!
+ Leaderboard
- Leaderboard
+ Play again
@@ -33,6 +33,10 @@
Leaderboard
+
+ Please select
+
+
Very easy (2 Bit)
@@ -54,11 +58,27 @@
- Please select
+ Enter username (default: anon)
+
+
+
+ Username
+
+
+
+ Difficulty
+
+
+
+ Numbers:
+
+
+
+ s - Help:
- No internet connection!
+ Please try again later.
--
cgit v1.2.3