From 55ba2dfd3ec7f71ed0f785ef60a2375cf097a027 Mon Sep 17 00:00:00 2001
From: "Mr. J" <45538844+Ultraviolet-Ninja@users.noreply.github.com>
Date: Sun, 2 Jan 2022 19:39:06 -0600
Subject: [PATCH] Dev (#40)
* Started on CheapCheckout
* Created CheapCheckoutTest
* Worked on Caesar and created CaesarTest
* Finished CaesarTest
* Down to Java 16
* Wrote instructions for starting the program
---
.github/workflows/codeql-analysis.yml | 68 -----
Progress.md | 12 +-
README.md | 11 +-
build.gradle | 10 +-
src/main/java/bomb/ManualController.java | 247 +++++++++---------
src/main/java/bomb/Widget.java | 132 +++++-----
.../java/bomb/components/hex/HexTile.java | 3 +-
.../microcontroller/EightPinController.java | 3 +-
.../microcontroller/SixPinController.java | 3 +-
.../microcontroller/TenPinController.java | 3 +-
.../bomb/modules/ab/alphabet/Alphabet.java | 3 +-
.../java/bomb/modules/ab/battleship/Ship.java | 11 +-
.../java/bomb/modules/ab/bitwise/Bitwise.java | 3 +-
.../modules/ab/boolean_venn/BooleanVenn.java | 3 +-
.../java/bomb/modules/c/caesar/Caesar.java | 53 ++--
.../c/cheap_checkout/CheapCheckout.java | 165 ++++++++++++
.../c/cheap_checkout/CheckoutItem.java | 94 +++++++
.../c/cheap_checkout/CheckoutItems.java | 31 ---
src/main/java/bomb/modules/c/chess/Chess.java | 3 +-
.../bomb/modules/c/chords/ChordQualities.java | 3 +-
.../c/colored_switches/ColoredSwitches.java | 4 +-
.../java/bomb/modules/dh/emoji/Emoji.java | 16 +-
.../java/bomb/modules/dh/emoji/EmojiMath.java | 13 +-
.../bomb/modules/dh/fast_math/FastMath.java | 5 +-
.../dh/hexamaze_redesign/Hexamaze.java | 3 +-
.../hexalgorithm/maze_finding/MazeSearch.java | 3 +-
.../hexalgorithm/pathfinding/ExitChecker.java | 4 +-
.../hexalgorithm/pathfinding/MazeRunner.java | 3 +-
.../hexalgorithm/storage/HexagonalPlane.java | 4 +-
.../bomb/modules/il/ice_cream/IceCream.java | 4 +-
.../java/bomb/modules/il/laundry/Laundry.java | 3 +-
.../m/microcontroller/MicroController.java | 3 +-
.../m/morsematics/MorsematicsController.java | 10 +
.../java/bomb/modules/m/murder/Murder.java | 5 +-
.../bomb/modules/np/number_pad/NumberPad.java | 4 +-
.../bomb/modules/r/round_keypads/Keypad.java | 2 +
.../modules/r/round_keypads/RoundKeypads.java | 5 +-
.../round_keypads/RoundKeypadsController.java | 3 +-
.../bomb/modules/s/shape_shift/ShapeEnd.java | 4 +-
.../modules/s/shape_shift/ShapeShift.java | 11 +-
.../s/shape_shift/ShapeShiftController.java | 6 +-
.../modules/s/simon/screams/SimonScreams.java | 10 +-
.../bomb/modules/s/simon/screams/Star.java | 12 +-
.../modules/s/simon/states/SimonStates.java | 6 +-
.../bomb/modules/s/square/SquareButton.java | 9 +-
.../s/square/SquareButtonController.java | 10 +
.../java/bomb/modules/t/bulb/TheBulb.java | 5 +-
.../java/bomb/modules/t/two_bit/TwoBit.java | 12 +-
.../modules/wz/word_search/WordFinder.java | 10 +-
.../data/structures/queue/BufferedQueue.java | 6 +-
.../tools/data/structures/ring/ArrayRing.java | 6 +-
.../bomb/tools/data/structures/trie/Trie.java | 12 +-
src/main/java/bomb/tools/filter/Regex.java | 42 +--
.../java/bomb/tools/filter/RegexFilter.java | 4 +-
.../java/bomb/tools/number/MathUtils.java | 32 +++
.../factory/MorseCodeGraphFactory.java | 2 -
.../pattern/factory/TextFormatterFactory.java | 8 +
.../tools/pattern/observer/ObserverHub.java | 15 +-
.../tools/pattern/observer/ResetObserver.java | 5 +-
.../java/bomb/tools/string/StringFormat.java | 19 +-
.../bomb/modules/c/caesar/CaesarTest.java | 69 +++++
.../c/cheap_checkout/CheapCheckoutTest.java | 91 +++++++
.../c/cheap_checkout/CheckoutItemTest.java | 49 ++++
.../modules/dh/fast_math/FastMathTest.java | 2 +-
.../s/simon/screams/SimonScreamsTest.java | 8 -
.../modules/s/square/SquareButtonTest.java | 3 +-
.../wz/word_search/WordFinderTest.java | 12 -
src/test/resources/suites/suiteOne.xml | 3 +
68 files changed, 963 insertions(+), 475 deletions(-)
delete mode 100644 .github/workflows/codeql-analysis.yml
create mode 100644 src/main/java/bomb/modules/c/cheap_checkout/CheckoutItem.java
delete mode 100644 src/main/java/bomb/modules/c/cheap_checkout/CheckoutItems.java
create mode 100644 src/main/java/bomb/modules/m/morsematics/MorsematicsController.java
create mode 100644 src/main/java/bomb/modules/s/square/SquareButtonController.java
create mode 100644 src/test/java/bomb/modules/c/caesar/CaesarTest.java
create mode 100644 src/test/java/bomb/modules/c/cheap_checkout/CheapCheckoutTest.java
create mode 100644 src/test/java/bomb/modules/c/cheap_checkout/CheckoutItemTest.java
diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml
deleted file mode 100644
index e88c72b0..00000000
--- a/.github/workflows/codeql-analysis.yml
+++ /dev/null
@@ -1,68 +0,0 @@
-# For most projects, this workflow file will not need changing; you simply need
-# to commit it to your repository.
-#
-# You may wish to alter this file to override the set of languages analyzed,
-# or to provide custom queries or build logic.
-#
-# ******** NOTE ********
-# We have attempted to detect the languages in your repository. Please check
-# the `language` matrix defined below to confirm you have the correct set of
-# supported CodeQL languages.
-#
-name: "CodeQL"
-
-on:
- pull_request:
- # The branches below must be a subset of the branches above
- branches: [ main ]
- schedule:
- - cron: '16 7 * * 3'
-
-jobs:
- analyze:
- name: Analyze
- runs-on: ubuntu-latest
- permissions:
- actions: read
- contents: read
- security-events: write
-
- strategy:
- fail-fast: false
- matrix:
- language: [ 'java' ]
- # CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
- # Learn more about CodeQL language support at https://git.io/codeql-language-support
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v2
-
- # Initializes the CodeQL tools for scanning.
- - name: Initialize CodeQL
- uses: github/codeql-action/init@v1
- with:
- languages: ${{ matrix.language }}
- # If you wish to specify custom queries, you can do so here or in a config file.
- # By default, queries listed here will override any specified in a config file.
- # Prefix the list here with "+" to use these queries and those in the config file.
- # queries: ./path/to/local/query, your-org/your-repo/queries@main
-
- # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
- # If this step fails, then you should remove it and run the build manually (see below)
- - name: Autobuild
- uses: github/codeql-action/autobuild@v1
-
- # ℹ️ Command-line programs to run using the OS shell.
- # 📚 https://git.io/JvXDl
-
- # ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
- # and modify them (or add more) to build your code if your project
- # uses a compiled language
-
- #- run: |
- # make bootstrap
- # make release
-
- - name: Perform CodeQL Analysis
- uses: github/codeql-action/analyze@v1
diff --git a/Progress.md b/Progress.md
index e5dc85fb..7e5cfb6f 100644
--- a/Progress.md
+++ b/Progress.md
@@ -22,10 +22,12 @@
- The Bulb
- TwoBit
-20/100 + Colored Switches
+21/100
### Incomplete Modules
-- Battleship
+- Battleship
+- Caesar Cipher
+- Cheap Checkout
- Ice Cream
- Morsematics
- Murder
@@ -35,7 +37,7 @@
- Square Button
- Word Search
-9/100
+11/100
### Untouched Modules
- 3D Maze
@@ -45,8 +47,6 @@
- Binary LEDs
- BitMaps
- Broken Button
-- Caesar Cipher
-- Cheap Checkout
- Color Flash
- Color Math
- Color Squares
@@ -109,4 +109,4 @@
- Yahtzee
- Zoo
-72/100
+68/100
diff --git a/README.md b/README.md
index e4d77deb..fb2d933b 100644
--- a/README.md
+++ b/README.md
@@ -3,7 +3,7 @@
[](https://circleci.com/gh/Ultraviolet-Ninja/GradleCenturion/tree/main)
[](https://lgtm.com/projects/g/Ultraviolet-Ninja/GradleCenturion/context:java)
-
+
## Intro
This project is designed to solve all puzzles found on the Centurion Bomb from Keep Talking and Nobody Explodes, which is a combination of many community-made puzzles and some from the base game set in different languages.
@@ -11,7 +11,7 @@ This project is designed to solve all puzzles found on the Centurion Bomb from K
This is a huge project for one man to tackle, but I've [learned a lot](Learned.md) from the challenges I've faced.
## Technologies
-- Java 17
+- Java 16
- Gradle 7.3.3
### Plugins
- Jacoco
@@ -33,6 +33,13 @@ This is a huge project for one man to tackle, but I've [learned a lot](Learned.m
## Status - In progress
See the running list of modules [here](Progress.md)
+## How to run the program
+*Disclaimer:* Make sure you have Java [16](https://www.oracle.com/java/technologies/javase/jdk16-archive-downloads.html) or [17](https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html)
+and the JAVA_HOME is set.
+1. Grab the latest .zip/tar of the GradleCenturion-X.X.X and unzip it
+2. Using the command line, navigate to the unzipped directory
+3. Run the command `./gradlew run`
+
## Inspiration
After my first manual turning out to be successful in solving the main-game bombs, I thought "Why stop there?".
I started creating this project working on the auto-solver for the vanilla game, which was, by comparison, much easier.
diff --git a/build.gradle b/build.gradle
index b41eeb1e..d4479921 100644
--- a/build.gradle
+++ b/build.gradle
@@ -11,7 +11,13 @@ plugins {
}
group 'jasmine.jragon'
-version '0.21.2'
+version '0.21.3'
+
+java {
+ toolchain {
+ languageVersion = JavaLanguageVersion.of(16)
+ }
+}
application {
mainClassName = project.hasProperty('testingArea') ?
@@ -128,7 +134,7 @@ pitest {
}
javafx {
- version = '17'
+ version = '16'
modules = ['javafx.controls', 'javafx.fxml']
}
diff --git a/src/main/java/bomb/ManualController.java b/src/main/java/bomb/ManualController.java
index 6587b356..0f17e857 100644
--- a/src/main/java/bomb/ManualController.java
+++ b/src/main/java/bomb/ManualController.java
@@ -1,5 +1,7 @@
package bomb;
+import bomb.modules.ab.blind_alley.BlindAlleyController;
+import bomb.modules.s.souvenir.SouvenirController;
import bomb.tools.filter.Regex;
import bomb.tools.pattern.facade.FacadeFX;
import bomb.tools.pattern.observer.BlindAlleyPaneObserver;
@@ -11,7 +13,6 @@
import com.jfoenix.controls.JFXRadioButton;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
-import javafx.scene.Node;
import javafx.scene.control.RadioButton;
import javafx.scene.control.TextField;
import javafx.scene.control.Toggle;
@@ -19,28 +20,34 @@
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Region;
import javafx.scene.layout.VBox;
-import org.intellij.lang.annotations.Language;
import java.io.File;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
+import java.nio.file.Path;
import java.nio.file.Paths;
+import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.IdentityHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
-import java.util.regex.Pattern;
+import java.util.stream.IntStream;
-import static bomb.tools.filter.RegexFilter.ALL_CHAR_FILTER;
-import static bomb.tools.filter.RegexFilter.filter;
import static bomb.tools.pattern.facade.FacadeFX.GET_TOGGLE_NAME;
+import static bomb.tools.pattern.factory.TextFormatterFactory.createSearchBarFormatter;
import static bomb.tools.pattern.observer.ObserverHub.ObserverIndex.BLIND_ALLEY_PANE;
+import static bomb.tools.pattern.observer.ObserverHub.ObserverIndex.FORGET_ME_NOT_TOGGLE;
+import static bomb.tools.pattern.observer.ObserverHub.ObserverIndex.RESET;
import static bomb.tools.pattern.observer.ObserverHub.ObserverIndex.SOUVENIR_PANE;
+import static bomb.tools.pattern.observer.ObserverHub.ObserverIndex.SOUVENIR_TOGGLE;
+import static java.util.Arrays.asList;
+import static java.util.concurrent.CompletableFuture.supplyAsync;
import static java.util.function.UnaryOperator.identity;
+import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
@SuppressWarnings("ConstantConditions")
@@ -48,7 +55,7 @@ public class ManualController {
private static final String FXML_DIRECTORY = "fxml";
private Map regionMap;
- private final List allRadioButtons;
+ private final List allRadioButtons;
@FXML
private GridPane base;
@@ -70,149 +77,109 @@ public ManualController() {
}
public void initialize() throws ExecutionException, InterruptedException {
- allRadioButtons.addAll(radioButtonHouse.getChildren());
- ObserverHub.addObserver(new ForgetMeNotToggleObserver(forgetMeNot));
- ObserverHub.addObserver(new SouvenirToggleObserver(souvenir));
- long start = System.nanoTime();
- regionMap = setupRegionMap().get();
- long stop = System.nanoTime();
- System.out.printf("Timer: %,d", stop - start);
- }
-
- @FXML
- public void buttonPress() {
- Toggle selected = options.getSelectedToggle();
- String selectedName = GET_TOGGLE_NAME.apply(selected);
- if (selectedName.equals("Blind Alley")) ObserverHub.updateAtIndex(BLIND_ALLEY_PANE);
- else if (selectedName.equals("Souvenir")) ObserverHub.updateAtIndex(SOUVENIR_PANE);
- paneSwitch(regionMap.get(selected));
- }
-
- private void paneSwitch(final Region pane) {
- if (base.getChildren().size() != 1) base.getChildren().retainAll(menuVBox);
- base.add(pane, 0, 0);
- }
-
- @FXML
- public void search() {
- @Language("regexp")
- String searchTerm = searchBar.getText();
- radioButtonHouse.getChildren().clear();
-
- if (searchTerm.isEmpty()) {
- radioButtonHouse.getChildren().addAll(allRadioButtons);
- return;
- }
-
- Regex searchPattern = new Regex(searchTerm, Pattern.CASE_INSENSITIVE);
-
- radioButtonHouse.getChildren().addAll(
- allRadioButtons.stream()
- .filter(radioButton -> {
- String name = ((RadioButton) radioButton).getText();
- searchPattern.loadText(name);
- return searchPattern.hasMatch();
- }).toList()
+ searchBar.setTextFormatter(createSearchBarFormatter());
+ allRadioButtons.addAll(
+ radioButtonHouse.getChildren().stream()
+ .map(node -> (RadioButton) node)
+ .toList()
);
+ ObserverHub.addObserver(FORGET_ME_NOT_TOGGLE, new ForgetMeNotToggleObserver(forgetMeNot));
+ ObserverHub.addObserver(SOUVENIR_TOGGLE, new SouvenirToggleObserver(souvenir));
+// long start = System.nanoTime();
+ regionMap = setupRegionMap().get();
+// long stop = System.nanoTime();
+// System.out.printf("Timer: %,d%n", stop - start);
}
- private CompletableFuture