Skip to content

Commit

Permalink
feat: for the Colossal Candy version
Browse files Browse the repository at this point in the history
  • Loading branch information
z7workbench committed Apr 18, 2022
1 parent 3b1f8a6 commit 798743f
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 21 deletions.
19 changes: 18 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,16 @@ Hit & Blow is inspired by Nintendo Switch's Clubhouse Games: 51 Worldwide Classi
### Description
This is a game of guessing the hidden `n` numbers and positions, with the default `n` being 4. Select `n-2` numbers from 1 to n and place them in the positions, then press "Check" to check for correctness. Each position will be judged as "all correct" (indicated by colored check marks) or "half correct" (indicated by grey check marks), the number of former is the number of correct positions and numbers, the number of latter is the number of correct numbers. If it fails, you can try again until you get it right!

### Leaderboard
Currently Hit & Blow has a leaderboard powered by [Hive Flutter](https://docs.hivedb.dev/). It contains time when finished, playtime and count you tried, sorted by count you tried.

<p align="center">
<img alt="Hit & Blow leaderboard" src="arts/hnb_leaderboard.webp">
</p>

### Further Objects
- Leaderboard
- Minor UI changes
- Bug fixes

## Simple Dice Game
Simple Dice Game inspired by Nintendo Switch's Clubhouse Games: 51 Worldwide Classics' Yacht Dices.
Expand All @@ -38,3 +46,12 @@ It's a game of throwing dices at each other to make permutations and compete for
- Leaderboard
- Versus AI
- More players

# Used Libraries & Materials
- [Flutter](https://flutter.dev)
- [Dart](https://dart.dev)
- [provider](https://pub.dev/packages/provider)
- [shared_preferences](https://pub.dev/packages/shared_preferences)
- [intl](https://pub.dev/packages/intl) & [Localizely extention](https://marketplace.visualstudio.com/items?itemName=localizely.flutter-intl)
- [Hive Flutter](https://docs.hivedb.dev/)
- [flustars](https://pub.dev/packages/flustars) (Not used)
Binary file added arts/hnb_leaderboard.webp
Binary file not shown.
3 changes: 0 additions & 3 deletions lib/games/dices/dice.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import 'dart:async';
import 'dart:math';
import 'package:rxdart/rxdart.dart';
import 'package:flutter/material.dart';

typedef DiceCount = int;
Expand Down
27 changes: 19 additions & 8 deletions lib/games/hnb/hnb_main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,18 @@ class _HitAndBlowState extends State<HitAndBlowHome> {
], title: S.of(context).description),
margin,
DropdownWidget(
children: [content],
children: [
Padding(
child: MaterialButton(
onPressed: () {
hive.hnbLeaderboardBox.clear();
},
child: Text(S.of(context).clean_leaderboard),
),
padding: containerXSPadding,
),
content
],
title: S.of(context).leaderboard,
),
margin,
Expand Down Expand Up @@ -162,7 +173,7 @@ class _HitAndBlowState extends State<HitAndBlowHome> {
Widget get content {
if (hive.hnbLeaderboardBox.isEmpty) {
return Container(
child: Text('Loading'),
child: Text(S.of(context).empty_leaderboard, style: regularTextStyle),
alignment: Alignment.center,
);
}
Expand All @@ -172,7 +183,7 @@ class _HitAndBlowState extends State<HitAndBlowHome> {
builder: (context, Box leaderboard, _) {
if (leaderboard.keys.isEmpty) {
return Container(
child: Text('Empty!'),
child: Text(S.of(context).empty_leaderboard, style: regularTextStyle,),
alignment: Alignment.center,
);
}
Expand All @@ -181,18 +192,18 @@ class _HitAndBlowState extends State<HitAndBlowHome> {
items.sort((a, b) => a.count.compareTo(b.count));
return DataTable(
columns: [
DataColumn(label: Text("When")),
DataColumn(label: Text("Used")),
DataColumn(label: Text("Count"), numeric: true)
DataColumn(label: Text(S.of(context).hnb_when_finished)),
DataColumn(label: Text(S.of(context).hnb_used_time)),
DataColumn(label: Text(S.of(context).hnb_hit), numeric: true)
],
rows: [
for (var item in items)
DataRow(
cells: [
DataCell(Text(DateTime.fromMillisecondsSinceEpoch(item.now)
.toString())),
DataCell(Text(Duration(milliseconds: item.usedTime)
.toString())),
DataCell(
Text(Duration(milliseconds: item.usedTime).toString())),
// DataCell(Text(item.usedTime.toString())),
DataCell(Text(item.count.toString())),
],
Expand Down
8 changes: 8 additions & 0 deletions lib/generated/intl/messages_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"app": MessageLookupByLibrary.simpleMessage("Mini Games"),
"check": MessageLookupByLibrary.simpleMessage("Check"),
"clean_leaderboard":
MessageLookupByLibrary.simpleMessage("Clean Leaderboard"),
"description": MessageLookupByLibrary.simpleMessage("Game info"),
"dice_4_of_kind": MessageLookupByLibrary.simpleMessage("4 of Kind"),
"dice_4_of_kind_desc": MessageLookupByLibrary.simpleMessage(
Expand Down Expand Up @@ -75,10 +77,16 @@ class MessageLookup extends MessageLookupByLibrary {
"dice_yacht_desc":
MessageLookupByLibrary.simpleMessage("Yacht: 5 of the same number"),
"dismiss": MessageLookupByLibrary.simpleMessage("Dismiss"),
"empty_leaderboard":
MessageLookupByLibrary.simpleMessage("Currently no data"),
"hnb_answer": MessageLookupByLibrary.simpleMessage("Correct answer"),
"hnb_desc": MessageLookupByLibrary.simpleMessage(
"This is a game of guessing the hidden n numbers and positions, with the default n being 4. Select n-2 numbers from 1 to n and place them in the positions, then press \"Check\" to check for correctness. Each position will be judged as \"all correct\" (indicated by colored check marks) or \"half correct\" (indicated by grey check marks), the number of former is the number of correct positions and numbers, the number of latter is the number of correct numbers. If it fails, you can try again until you get it right! "),
"hnb_hit": MessageLookupByLibrary.simpleMessage("Count you tried"),
"hnb_title": MessageLookupByLibrary.simpleMessage("Hit and Blow"),
"hnb_used_time": MessageLookupByLibrary.simpleMessage("Playtime"),
"hnb_when_finished":
MessageLookupByLibrary.simpleMessage("When you finished"),
"leaderboard": MessageLookupByLibrary.simpleMessage("Leaderboard"),
"minesweeper_desc": MessageLookupByLibrary.simpleMessage(
"Get ask reduce skin. Child never forget less herself reveal. City example similar service billion store large. Book term although believe. Religious out opportunity upon note."),
Expand Down
5 changes: 5 additions & 0 deletions lib/generated/intl/messages_zh_CN.dart
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class MessageLookup extends MessageLookupByLibrary {
static Map<String, Function> _notInlinedMessages(_) => <String, Function>{
"app": MessageLookupByLibrary.simpleMessage("迷你游戏合集"),
"check": MessageLookupByLibrary.simpleMessage("检查"),
"clean_leaderboard": MessageLookupByLibrary.simpleMessage("清除排行榜"),
"description": MessageLookupByLibrary.simpleMessage("游戏简介"),
"dice_4_of_kind": MessageLookupByLibrary.simpleMessage("四骰同花"),
"dice_4_of_kind_desc":
Expand Down Expand Up @@ -65,10 +66,14 @@ class MessageLookup extends MessageLookupByLibrary {
"dice_yacht": MessageLookupByLibrary.simpleMessage("快艇"),
"dice_yacht_desc": MessageLookupByLibrary.simpleMessage("快艇:5个骰子的点数相同"),
"dismiss": MessageLookupByLibrary.simpleMessage("溜了"),
"empty_leaderboard": MessageLookupByLibrary.simpleMessage("暂无排行榜"),
"hnb_answer": MessageLookupByLibrary.simpleMessage("正确答案"),
"hnb_desc": MessageLookupByLibrary.simpleMessage(
"这是一个猜出隐藏的n个数字和位置的游戏,默认n为4。从1-n中选择n-2个数字放到位置上,按下“检查”即可检查对错。每个位置会被判定为“全对”(用彩色对钩表示)或“半对”(用灰色对钩表示),前者为位置和数字都正确,后者为选取的数字正确。如果判定失败则再来一次,直到判断正确!"),
"hnb_hit": MessageLookupByLibrary.simpleMessage("猜的次数"),
"hnb_title": MessageLookupByLibrary.simpleMessage("猜数字组合"),
"hnb_used_time": MessageLookupByLibrary.simpleMessage("用时"),
"hnb_when_finished": MessageLookupByLibrary.simpleMessage("完成时间"),
"leaderboard": MessageLookupByLibrary.simpleMessage("排行榜"),
"minesweeper_desc": MessageLookupByLibrary.simpleMessage(
"网上或者看到软件查看,新闻我们发生主题包括工具其实,为什您的新闻看到只是都是下载。任何语言这里更多,帮助人民不能工程经济操作。欢迎新闻具有游戏,发布之间其实一个。"),
Expand Down
50 changes: 50 additions & 0 deletions lib/generated/l10n.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions lib/l10n/intl_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"hnb_title": "Hit and Blow",
"hnb_desc": "This is a game of guessing the hidden n numbers and positions, with the default n being 4. Select n-2 numbers from 1 to n and place them in the positions, then press \"Check\" to check for correctness. Each position will be judged as \"all correct\" (indicated by colored check marks) or \"half correct\" (indicated by grey check marks), the number of former is the number of correct positions and numbers, the number of latter is the number of correct numbers. If it fails, you can try again until you get it right! ",
"hnb_answer": "Correct answer",
"hnb_when_finished": "When you finished",
"hnb_used_time": "Playtime",
"hnb_hit": "Count you tried",
"empty_leaderboard": "Currently no data",
"clean_leaderboard": "Clean Leaderboard",
"dice_game_title": "Simple Dice Game",
"dice_game_desc": "It's a game of throwing dices at each other to make permutations and compete for points. If you make a good combination, double tap the corresponding score to confirm the score. The selected permutations cannot be selected again. You can tap on the dice once, save only the good ones and roll them again. The remaining dice can also be changed after a re-roll. Each sheet's cell must be filled in, even if there are no permutations. The one with the highest score wins!",
"dice_reserve": "Reserve",
Expand Down
5 changes: 5 additions & 0 deletions lib/l10n/intl_zh_CN.arb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
"hnb_title": "猜数字组合",
"hnb_desc": "这是一个猜出隐藏的n个数字和位置的游戏,默认n为4。从1-n中选择n-2个数字放到位置上,按下“检查”即可检查对错。每个位置会被判定为“全对”(用彩色对钩表示)或“半对”(用灰色对钩表示),前者为位置和数字都正确,后者为选取的数字正确。如果判定失败则再来一次,直到判断正确!",
"hnb_answer": "正确答案",
"hnb_when_finished": "完成时间",
"hnb_used_time": "用时",
"hnb_hit": "猜的次数",
"empty_leaderboard": "暂无排行榜",
"clean_leaderboard": "清除排行榜",
"dice_game_title": "掷骰子",
"dice_game_desc": "这是一个互相投掷骰子凑出排列组合、竞争总分的游戏。如果凑出不错的组合,就双击对应分数用于确认分数,选过的排列组合不能再次选择。可以单击骰子,只保留点数点数不错的骰子再重新投掷。在重新投掷之后也可以改变保留的骰子。每轮都必须填到表格中,即使没有任何排列组合。最后总分高的人获胜!",
"dice_reserve": "保留区",
Expand Down
7 changes: 0 additions & 7 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -539,13 +539,6 @@ packages:
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "2.1.0"
rxdart:
dependency: "direct main"
description:
name: rxdart
url: "https://mirrors.tuna.tsinghua.edu.cn/dart-pub/"
source: hosted
version: "0.27.3"
shared_preferences:
dependency: "direct main"
description:
Expand Down
3 changes: 1 addition & 2 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 0.2.6+1
version: 0.3.0+1

environment:
sdk: ">=2.16.0 <3.0.0"
Expand All @@ -40,7 +40,6 @@ dependencies:
intl: ^0.17.0
package_info_plus: ^1.3.0
provider: ^6.0.2
rxdart: ^0.27.3
flustars: ^2.0.1
hive: ^2.0.6
hive_flutter: ^1.1.0
Expand Down

0 comments on commit 798743f

Please sign in to comment.