Skip to content
This repository was archived by the owner on May 24, 2023. It is now read-only.

Commit d1a1699

Browse files
committed
More stats in leaderboard, basic cheat detection
1 parent bf800f3 commit d1a1699

7 files changed

Lines changed: 92 additions & 31 deletions

File tree

qml/harbour-binaryfun.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ ApplicationWindow
66
{
77
initialPage: Component { Menu { } }
88
cover: Qt.resolvedUrl("cover/CoverPage.qml")
9-
allowedOrientations: defaultAllowedOrientations
9+
allowedOrientations: Orientation.Portrait
1010
}

qml/pages/Game.qml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ Page {
132132

133133
Button {
134134
id: new_game
135-
text: qsTr("Play again!")
135+
text: qsTr("Play again")
136136
visible: false
137137
anchors.horizontalCenter: parent.horizontalCenter
138138
onClicked: pageStack.replace(Qt.resolvedUrl("Game.qml"), {bits: root.bits})

qml/pages/LeaderBoard.qml

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ Page {
1515
}
1616

1717
TextField {
18-
placeholderText: "Enter username (default: anon)"
18+
placeholderText: qsTr("Enter username (default: anon)")
1919
text: username.value
20-
label: "Username"
20+
label: qsTr("Username")
2121
width: page.width
2222
EnterKey.enabled: text.length > 0 && text.length <= 16
2323
EnterKey.iconSource: "image://theme/icon-m-enter-close"
@@ -29,20 +29,22 @@ Page {
2929

3030
ComboBox {
3131
id: selector
32-
label: "Difficulty"
32+
label: qsTr("Difficulty")
3333

3434
function select(diff) {
3535
var xhr = new XMLHttpRequest()
3636
xhr.open("GET",
3737
"https://marvinborner.de/lead/binaryfun1/list?sort=time&order=asc&count=1000&filter=difficulty,"+diff,
38-
false)
39-
xhr.send()
40-
if (xhr.status !== 0) {
41-
list.model = JSON.parse(xhr.responseText);
42-
internet.visible = false;
43-
} else {
44-
internet.visible = true;
38+
true)
39+
xhr.onreadystatechange = function() {
40+
if (xhr.readyState === 4 && xhr.status === 200) {
41+
list.model = JSON.parse(xhr.responseText);
42+
internet.visible = false;
43+
} else {
44+
internet.visible = true;
45+
}
4546
}
47+
xhr.send()
4648
}
4749

4850
menu: ContextMenu {
@@ -79,7 +81,7 @@ Page {
7981

8082
Label {
8183
id: internet
82-
text: qsTr("No internet connection!")
84+
text: qsTr("Please try again later.")
8385
visible: false
8486
}
8587

@@ -90,17 +92,36 @@ Page {
9092
height: page.height - y
9193
model: []
9294
delegate: ListItem {
93-
contentHeight: Theme.itemSizeMedium
95+
id: score
96+
contentHeight: Theme.itemSizeLarge
9497

9598
Label {
9699
id: name
97100
text: index + 1 + ". " + modelData.name
98101
}
99102

100103
Label {
104+
id: level
101105
anchors.top: name.bottom
102-
text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + "s - Help: " + modelData.cheats
103-
font.pixelSize: Theme.fontSizeSmall
106+
text: {
107+
var numbers = modelData.level.split(",").slice(
108+
modelData.difficulty).filter(function (_, i) {
109+
return i % (modelData.difficulty + 1) === 0.
110+
}).slice(1);
111+
if (numbers.length !== modelData.difficulty && modelData.difficulty !== 10) {
112+
console.log("Tempered: " + numbers.length + " " + modelData.difficulty);
113+
score.visible = false;
114+
}
115+
116+
return qsTr("Numbers: ") + numbers.join(", ");
117+
}
118+
font.pixelSize: Theme.fontSizeExtraSmall
119+
}
120+
121+
Label {
122+
anchors.top: level.bottom
123+
text: ((modelData.end_time[1] - modelData.start_time[1]) / 1000) + qsTr("s - Help: ") + modelData.cheats
124+
font.pixelSize: Theme.fontSizeExtraSmall
104125
}
105126
}
106127
}

rpm/harbour-binaryfun.spec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Name: harbour-binaryfun
1313
%{!?qtc_make:%define qtc_make make}
1414
%{?qtc_builddir:%define _builddir %qtc_builddir}
1515
Summary: An awesome binary game
16-
Version: 1.0
16+
Version: 1.1
1717
Release: 1
1818
Group: Qt/Qt
1919
License: MIT

rpm/harbour-binaryfun.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Name: harbour-binaryfun
22
Summary: An awesome binary game
3-
Version: 1.0
3+
Version: 1.1
44
Release: 1
55
# The contents of the Group field should be one of the groups listed here:
66
# https://github.com/mer-tools/spectacle/blob/master/data/GROUPS

translations/harbour-binaryfun-de.ts

Lines changed: 28 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
<source>Binary Fun</source>
1515
<translation>Binär-Spaß</translation>
1616
</message>
17-
<message>
18-
<source>Play again!</source>
19-
<translation>Nochmal!</translation>
20-
</message>
2117
<message>
2218
<source>Not bad!</source>
2319
<translation>Nicht schlecht!</translation>
@@ -26,13 +22,21 @@
2622
<source>Leaderboard</source>
2723
<translation>Bestenliste</translation>
2824
</message>
25+
<message>
26+
<source>Play again</source>
27+
<translation>Nochmal spielen</translation>
28+
</message>
2929
</context>
3030
<context>
3131
<name>LeaderBoard</name>
3232
<message>
3333
<source>Leaderboard</source>
3434
<translation>Bestenliste</translation>
3535
</message>
36+
<message>
37+
<source>Please select</source>
38+
<translation>Bitte auswählen</translation>
39+
</message>
3640
<message>
3741
<source>Very easy (2 Bit)</source>
3842
<translation>Sehr einfach (2 Bit)</translation>
@@ -54,12 +58,28 @@
5458
<translation>Krass (10 Bit)</translation>
5559
</message>
5660
<message>
57-
<source>Please select</source>
58-
<translation>Bitte auswählen</translation>
61+
<source>Enter username (default: anon)</source>
62+
<translation>Nutzername eingeben (Standard: anon)</translation>
63+
</message>
64+
<message>
65+
<source>Username</source>
66+
<translation>Nutzername</translation>
67+
</message>
68+
<message>
69+
<source>Difficulty</source>
70+
<translation>Schwierigkeit</translation>
71+
</message>
72+
<message>
73+
<source>Numbers: </source>
74+
<translation>Zahlen: </translation>
75+
</message>
76+
<message>
77+
<source>s - Help: </source>
78+
<translation>s - Hilfe:</translation>
5979
</message>
6080
<message>
61-
<source>No internet connection!</source>
62-
<translation>Keine Internetverbindung!</translation>
81+
<source>Please try again later.</source>
82+
<translation>Bitte probiere es später nochmal.</translation>
6383
</message>
6484
</context>
6585
<context>

translations/harbour-binaryfun.ts

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@
1515
<translation type="unfinished"></translation>
1616
</message>
1717
<message>
18-
<source>Play again!</source>
18+
<source>Not bad!</source>
1919
<translation type="unfinished"></translation>
2020
</message>
2121
<message>
22-
<source>Not bad!</source>
22+
<source>Leaderboard</source>
2323
<translation type="unfinished"></translation>
2424
</message>
2525
<message>
26-
<source>Leaderboard</source>
26+
<source>Play again</source>
2727
<translation type="unfinished"></translation>
2828
</message>
2929
</context>
@@ -33,6 +33,10 @@
3333
<source>Leaderboard</source>
3434
<translation type="unfinished"></translation>
3535
</message>
36+
<message>
37+
<source>Please select</source>
38+
<translation type="unfinished"></translation>
39+
</message>
3640
<message>
3741
<source>Very easy (2 Bit)</source>
3842
<translation type="unfinished"></translation>
@@ -54,11 +58,27 @@
5458
<translation type="unfinished"></translation>
5559
</message>
5660
<message>
57-
<source>Please select</source>
61+
<source>Enter username (default: anon)</source>
62+
<translation type="unfinished"></translation>
63+
</message>
64+
<message>
65+
<source>Username</source>
66+
<translation type="unfinished"></translation>
67+
</message>
68+
<message>
69+
<source>Difficulty</source>
70+
<translation type="unfinished"></translation>
71+
</message>
72+
<message>
73+
<source>Numbers: </source>
74+
<translation type="unfinished"></translation>
75+
</message>
76+
<message>
77+
<source>s - Help: </source>
5878
<translation type="unfinished"></translation>
5979
</message>
6080
<message>
61-
<source>No internet connection!</source>
81+
<source>Please try again later.</source>
6282
<translation type="unfinished"></translation>
6383
</message>
6484
</context>

0 commit comments

Comments
 (0)