Skip to content

Commit

Permalink
Merge pull request #15 from mauritssilvis/md_darts_tables_fixes
Browse files Browse the repository at this point in the history
Fix and streamline the Markdown checkout table project
  • Loading branch information
mauritssilvis authored Mar 20, 2023
2 parents 412bff4 + d78794c commit 00775b1
Show file tree
Hide file tree
Showing 22 changed files with 333 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Finally, `darts` can provide output in several formats: easily readable Markdown

Currently, `darts` is available as a Java-based command-line application.
More information about the installation and use of this app can be found in the [Java-based command-line interface](cli/java-darts-cli) readme.
If you are interested in checking out those checkout tables, refer to the [Markdown checkout tables](tables/md).
If you are interested in checking out those checkout tables, refer to the [Markdown checkout tables](tables/md-darts-tables).

## License

Expand Down
15 changes: 15 additions & 0 deletions scripts/md-darts-tables-properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/sh

# Project names
name_prefix="Markdown darts"

names=(
"tables"
)

# Project labels
label_prefix="md-darts"

labels=(
"tables"
)
27 changes: 27 additions & 0 deletions scripts/md-darts-tables-tag
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/sh

# Check version
if [ $# -eq 0 ]; then
echo "Error: No version supplied."
exit
fi

version=${1}

# Check branch
branch=$(git rev-parse --abbrev-ref HEAD)

if [ "${branch}" != "main" ]; then
echo "Error: Not on main branch."
exit
fi

# Get properties
. ./md-darts-tables-properties

# Tag
for i in "${!names[@]}"; do
message="${name_prefix} ${names[i]} ${version}"
tag="${label_prefix}-${labels[i]}-${version}"
git tag -am "${message}" "${tag}"
done
64 changes: 64 additions & 0 deletions scripts/md-darts-tables-zip
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
#!/bin/sh

# Check version
if [ $# -eq 0 ]; then
echo "Error: No version supplied."
exit
fi

version=${1}

# Check branch
branch=$(git rev-parse --abbrev-ref HEAD)

if [ "${branch}" != "main" ]; then
echo "Warning: Not on main branch."
fi

# Get properties
. ./md-darts-tables-properties

# Clone repository
cd ..
git clone . "../darts-${version}" 2>/dev/null
cd "../darts-${version}" || exit

# Clean up
rm -rf .git
rm -rf api
rm -rf cli
rm -rf core
rm -rf scripts
find . -maxdepth 1 -name "*.md" -delete

# Zip
echo -n "" > "zip.log"

for i in "${!labels[@]}"; do
label="${labels[i]}"
project="${label_prefix}-${label}"
path="${label}/${project}"
file="${project}-${version}"

mv "${path}" "${project}" 2>/dev/null
rm -rf "${label}"
rm -rf "${project}/.idea"

# .tar.gz
rm -f "${file}.tar.gz"
7z a "${file}.tar" "./${project}/*" >> "zip.log" 2>> "zip.log"
7z a -mx9 "${file}.tar.gz" "${file}.tar" >> "zip.log" 2>> "zip.log"
rm -f "${file}.tar"

# .zip
rm -f "${file}.zip"
7z a -mx9 "${file}.zip" "./${project}/*" >> "zip.log" 2>> "zip.log"
done

# Check zip
archives=$(grep "Everything is Ok" zip.log -c)

if [ "${archives}" -ne 3 ]; then
echo "Error: Not all archives were created successfully."
exit
fi
4 changes: 2 additions & 2 deletions tables/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# darts > Tables
# Checkout tables

> Darts checkout tables in different formats
Expand All @@ -10,7 +10,7 @@ This part of the [darts](https://github.com/mauritssilvis/darts) project provide

Currently, checkout tables are available in the following formats:

- [Markdown](md)
- [Markdown](md-darts-tables)

## License

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@ All notable changes to the `md-darts-tables` project (see [darts](https://github
The file format is based on [keep a changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [semantic versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.1] - 2023-03-20

### Fixed

- Correct the relative path to the Java darts CLI.
- Ensure existing data do not get lost when generating checkout tables.

## [0.1.0] - 2023-02-23

### Added

- Add checkout table generation scripts.
- Add London dartboard any-in, any-out checkout tables.
- Add London dartboard any-in, master-out checkout tables.
- Add London dartboard any-in, double-out checkout tables.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tables/md/README.md → tables/md-darts-tables/README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# darts > Tables > Markdown
# Markdown checkout tables

> Darts checkout tables in the Markdown format
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,15 @@ other_field_phrases=(
"double or triple"
)

score_ranges=(
"1 60 120 180"
"2 60 120 180"
"2 50 110 170"
"1 80 160 240"
"2 60 140 220"
"2 50 130 210"
)

selected_min_scores=(
" 1 23 61 103 121 101 401 701 1001"
" 1 5 61 103 121 101 401 701 1001"
Expand All @@ -78,15 +87,6 @@ selected_max_scores=(
" 50 50 130 130 210 101 501 901 "
)

commands=(
"checkouts -j any"
"checkouts -j master"
"checkouts"
"checkouts -b quadro -j any"
"checkouts -b quadro -j master"
"checkouts -b quadro"
)

throws=(
"1"
"2"
Expand All @@ -95,6 +95,98 @@ throws=(
"3"
)

anchors=(
"one-dart-checkouts"
"two-dart-checkouts"
"two-dart-checkouts-1"
"three-dart-checkouts"
"three-dart-checkouts-1"
)

tables=(
"| Score | Darts | Checkouts |
|--------------:|------:|--------------:|
| [101](#101) | 2 | 2 |
| 201 | 4 | 772 |
| 301 | 6 | 66,144 |
| [401](#401) | 7 | 392 |
| 501 | 9 | 223,026 |
| 601 | 11 | 24,066,702 |
| [701](#701) | 12 | 3,432 |
| 801 | 14 | 10,666,320 |
| 901 | 16 | 1,821,306,720 |
| [1001](#1001) | 17 | 13,872 |"
"| Score | Darts | Checkouts |
|--------------:|------:|--------------:|
| [101](#101) | 2 | 2 |
| 201 | 4 | 772 |
| 301 | 6 | 65,007 |
| [401](#401) | 7 | 392 |
| 501 | 9 | 223,026 |
| 601 | 11 | 24,032,174 |
| [701](#701) | 12 | 3,432 |
| 801 | 14 | 10,666,320 |
| 901 | 16 | 1,820,922,471 |
| [1001](#1001) | 17 | 13,872 |"
"| Score | Darts | Checkouts |
|--------------:|------:|------------:|
| [101](#101) | 2 | 1 |
| 201 | 4 | 73 |
| 301 | 6 | 15,681 |
| [401](#401) | 7 | 56 |
| [501](#501) | 9 | 3,944 |
| 601 | 11 | 3,658,382 |
| [701](#701) | 12 | 286 |
| 801 | 14 | 38,740 |
| 901 | 16 | 202,772,073 |
| [1001](#1001) | 17 | 816 |"
"| Score | Darts | Checkouts |
|--------------:|------:|-----------:|
| 101 | 2 | 12 |
| [201](#201) | 3 | 21 |
| 301 | 5 | 62,970 |
| 401 | 6 | 56,952 |
| 501 | 7 | 21,301 |
| [601](#601) | 8 | 1,736 |
| 701 | 10 | 67,297,690 |
| 801 | 11 | 15,375,723 |
| 901 | 12 | 1,306,680 |
| [1001](#1001) | 13 | 17,901 |"
"| Score | Darts | Checkouts |
|--------------:|------:|-----------:|
| 101 | 2 | 6 |
| [201](#201) | 3 | 7 |
| 301 | 5 | 21,061 |
| 401 | 6 | 13,631 |
| 501 | 7 | 3,553 |
| [601](#601) | 8 | 217 |
| 701 | 10 | 10,595,757 |
| 801 | 11 | 1,789,517 |
| 901 | 12 | 117,085 |
| [1001](#1001) | 13 | 1,377 |"
"| Score | Darts | Checkouts |
|------------:|------:|------------:|
| [101](#101) | 2 | 1 |
| 201 | 4 | 3,244 |
| 301 | 5 | 3,412 |
| 401 | 6 | 820 |
| [501](#501) | 7 | 6 |
| 601 | 9 | 4,207,648 |
| 701 | 10 | 642,234 |
| 801 | 11 | 21,300 |
| [901](#901) | 12 | 11 |
| 1001 | 14 | 449,392,814 |"
)

other_table_scores=(
""
""
"501"
""
""
""
)

labels=(
"One"
"Two"
Expand All @@ -103,15 +195,16 @@ labels=(
"Three"
)

anchors=(
"one-dart-checkouts"
"two-dart-checkouts"
"two-dart-checkouts-1"
"three-dart-checkouts"
"three-dart-checkouts-1"
commands=(
"checkouts -j any"
"checkouts -j master"
"checkouts"
"checkouts -b quadro -j any"
"checkouts -b quadro -j master"
"checkouts -b quadro"
)

script_path="../../../cli/java/"
script_path="../../../cli/java-darts-cli/bin/"

for i in "${!paths[@]}"; do
path="${paths[i]}"
Expand Down Expand Up @@ -148,12 +241,13 @@ for i in "${!paths[@]}"; do

last_max_score="0"

IFS=' ' read -ra score_range <<< "${score_ranges[i]}"
IFS=' ' read -ra min_scores <<< "${selected_min_scores[i]}"
IFS=' ' read -ra max_scores <<< "${selected_max_scores[i]}"

{
echo -e "In ${out_mode} games with the ${board}, the last dart can score between ${min_scores[0]} and ${max_scores[0]} points."
echo -e "The last two darts can reach ${max_scores[2]} points, and ${max_scores[4]} points can be scored with the last three."
echo -e "In ${out_mode} games with the ${board}, the last dart can score between ${score_range[0]} and ${score_range[1]} points."
echo -e "The last two darts can reach ${score_range[2]} points, and ${score_range[3]} points can be scored with the last three."
echo -e "The following table shows which checkout tables are provided for these scores.\n"

echo -e "| Scores | Darts |"
Expand All @@ -179,6 +273,9 @@ for i in "${!paths[@]}"; do
last_max_score=${max_score}
done

table="${tables[i]}"
other_table_score="${other_table_scores[i]}"

{
echo -e ""

Expand All @@ -187,11 +284,15 @@ for i in "${!paths[@]}"; do
echo -e "The following table shows the required number of darts to reach such scores in ${board} ${mode} games."
echo -e "In addition, the corresponding number of possible checkouts is shown.\n"

echo -e "| Score | Darts | Checkouts |"
echo -e "|--------------:|------:|--------------:|\n"
echo -e "${table}\n"

echo -e "The most exciting games will be those with relatively few possible checkouts."
echo -e "Checkout tables for these scores are given at the end of this document."

if [ "${other_table_score}" != "" ]; then
echo -e "A checkout table for ${other_table_score} points was included as it is a typical score in darts games."
fi

echo -e "Additional tables can be generated using the \`darts\` toolbox of the [darts](https://github.com/mauritssilvis/darts) project.\n"
} >> "${file}"

Expand Down
Loading

0 comments on commit 00775b1

Please sign in to comment.