aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndinus <andinus@nand.sh>2021-04-29 20:46:30 +0530
committerAndinus <andinus@nand.sh>2021-04-29 20:46:30 +0530
commit3cf07e5d8f5579893a43a4300d44d4dbab90ba81 (patch)
tree736fefaf3d286f6fe37e332aacf4ec09e27d3899
parent7a5a05f5af12731bc714234726ab4049e68461f3 (diff)
downloadantlia-3cf07e5d8f5579893a43a4300d44d4dbab90ba81.tar.gz
Initial implementation
-rw-r--r--META6.json22
-rw-r--r--README105
-rw-r--r--README.org68
-rw-r--r--bin/antlia3
-rw-r--r--lib/Antlia/CLI.rakumod52
-rw-r--r--resources/paper/17
-rw-r--r--resources/paper/26
-rw-r--r--resources/rock/16
-rw-r--r--resources/rock/26
-rw-r--r--resources/scissor/16
-rw-r--r--resources/scissor/28
11 files changed, 289 insertions, 0 deletions
diff --git a/META6.json b/META6.json
new file mode 100644
index 0000000..1deb828
--- /dev/null
+++ b/META6.json
@@ -0,0 +1,22 @@
+{
+ "name" : "antlia",
+ "auth" : "zef:andinus",
+ "version" : "0.1.0",
+ "description" : "Antlia is a text based Rock paper scissors game",
+ "authors" : [ "Andinus <andinus@nand.sh>" ],
+ "license" : "ISC",
+ "perl" : "6.d",
+ "provides" : {
+ "Antlia::CLI" : "lib/Antlia/CLI.rakumod",
+ },
+ "depends" : [
+ "Terminal::Table:auth<github:araraloren>"
+ ],
+ "resources" : [
+ "rock/1", "rock/2", "paper/1", "paper/2", "scissor/1", "scissor/2"
+ ],
+ "tags": [
+ "Antlia", "roshambo", "ro-sham-bo", "Rock paper scissors"
+ ],
+ "source-url" : "https://git.tilde.institute/andinus/antlia"
+}
diff --git a/README b/README
new file mode 100644
index 0000000..2499d14
--- /dev/null
+++ b/README
@@ -0,0 +1,105 @@
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ ANTLIA
+ Antlia is a text based Rock paper scissors game
+
+ Andinus
+ ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+
+Table of Contents
+─────────────────
+
+Installation
+Documentation
+News
+
+
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+ Website <https://andinus.nand.sh/antlia>
+ Source <https://git.tilde.institute/andinus/antlia>
+ GitHub (mirror) <https://github.com/andinus/antlia>
+━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
+
+
+Installation
+════════════
+
+ Antlia is released to CPAN, you can get it from there or install it
+ from source. In any case, `zef' is required to install the
+ distribution.
+
+ You can run Antlia without `zef'. Just run `raku -Ilib bin/antlia'
+ from within the source directory.
+
+
+Release
+───────
+
+ 1. Run `zef install antlia'.
+
+ Antlia should be installed, try running `antlia --version' to confirm.
+
+
+From Source
+───────────
+
+ You can either download the release archive generated by cgit/GitHub
+ or clone the project if you have `git' installed.
+
+
+Without `git'
+╌╌╌╌╌╌╌╌╌╌╌╌╌
+
+ 1. Download the release:
+ • <https://git.tilde.institute/andinus/antlia>
+ • <https://github.com/andinus/antlia/releases>
+ 2. Extract the file.
+ 3. Run `zef install .' in source directory.
+
+
+With `git'
+╌╌╌╌╌╌╌╌╌╌
+
+ All commits will be signed by my [PGP Key].
+
+ ┌────
+ │ # Clone the project.
+ │ git clone https://git.tilde.institute/andinus/antlia
+ │ cd antlia
+ │
+ │ # Install octans.
+ │ zef install .
+ └────
+
+
+[PGP Key]
+<https://andinus.nand.sh/static/D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD.asc>
+
+
+Documentation
+═════════════
+
+Implementation
+──────────────
+
+ Just enter the player names & it'll print each throw along with
+ scores. Press enter to play another round.
+
+
+Options
+───────
+
+players
+╌╌╌╌╌╌╌
+
+ Number of players. Default is 2, should be an integer equal to 2.
+ Support for more than 2 players will be added later.
+
+
+News
+════
+
+v0.1.0 - 2021-04-29
+───────────────────
+
+ Initial Implementation
diff --git a/README.org b/README.org
new file mode 100644
index 0000000..d6b3cec
--- /dev/null
+++ b/README.org
@@ -0,0 +1,68 @@
+#+title: Antlia
+#+subtitle: Antlia is a text based Rock paper scissors game
+#+export_file_name: index
+#+setupfile: ~/.emacs.d/org-templates/projects.org
+
+| Website | https://andinus.nand.sh/antlia |
+| Source | https://git.tilde.institute/andinus/antlia |
+| GitHub (mirror) | https://github.com/andinus/antlia |
+
+* Installation
+
+Antlia is released to CPAN, you can get it from there or install it from
+source. In any case, ~zef~ is required to install the distribution.
+
+You can run Antlia without ~zef~. Just run ~raku -Ilib bin/antlia~ from
+within the source directory.
+
+** Release
+
+1. Run ~zef install antlia~.
+
+Antlia should be installed, try running ~antlia --version~ to confirm.
+
+** From Source
+
+You can either download the release archive generated by cgit/GitHub or
+clone the project if you have ~git~ installed.
+
+*** Without ~git~
+
+1. Download the release:
+ - https://git.tilde.institute/andinus/antlia
+ - https://github.com/andinus/antlia/releases
+2. Extract the file.
+3. Run ~zef install .~ in source directory.
+
+*** With ~git~
+
+All commits will be signed by my [[https://andinus.nand.sh/static/D9AE4AEEE1F1B3598E81D9DFB67D55D482A799FD.asc][PGP Key]].
+
+#+begin_src sh
+# Clone the project.
+git clone https://git.tilde.institute/andinus/antlia
+cd antlia
+
+# Install octans.
+zef install .
+#+end_src
+
+* Documentation
+
+** Implementation
+
+Just enter the player names & it'll print each throw along with scores.
+Press enter to play another round.
+
+** Options
+
+*** players
+
+Number of players. Default is 2, should be an integer equal to 2.
+Support for more than 2 players will be added later.
+
+* News
+
+** v0.1.0 - 2021-04-29
+
+Initial Implementation
diff --git a/bin/antlia b/bin/antlia
new file mode 100644
index 0000000..0be6d64
--- /dev/null
+++ b/bin/antlia
@@ -0,0 +1,3 @@
+#!/usr/bin/env raku
+
+use Antlia::CLI;
diff --git a/lib/Antlia/CLI.rakumod b/lib/Antlia/CLI.rakumod
new file mode 100644
index 0000000..581bfe8
--- /dev/null
+++ b/lib/Antlia/CLI.rakumod
@@ -0,0 +1,52 @@
+use Terminal::Boxer;
+
+class Player is export {
+ has Str $.name;
+ has $.throw is rw;
+ has $.score is rw = 0;
+}
+
+#| text based Rock paper scissors game
+multi sub MAIN(
+ Int :$players where * == 2 = 2, #= Number of players (default: 2)
+) is export {
+ say "Antlia - text based Rock paper scissors game";
+ say "--------------------------------------------\n";
+
+ my Player $player1 = Player.new(name => prompt("[Player 1] Name: ").trim);
+ my Player $player2 = Player.new(name => prompt("[Player 2] Name: ").trim);
+
+ my %ascii-art = (
+ rock => %?RESOURCES<rock/2>.slurp,
+ paper => %?RESOURCES<paper/2>.slurp,
+ scissor => %?RESOURCES<scissor/2>.slurp,
+ );
+
+ my %score-against = (
+ rock => "scissor",
+ paper => "rock",
+ scissor => "paper"
+ );
+
+ loop {
+ print "\n";
+ say "- " x 40;
+
+ $player1.throw = %ascii-art.pick[0].key;
+ $player2.throw = %ascii-art.pick[0].key;
+
+ $player1.score += 1 if $player2.throw eq %score-against{$player1.throw};
+ $player2.score += 1 if $player1.throw eq %score-against{$player2.throw};
+
+ say ss-box(:40cw, %ascii-art{$player1.throw},
+ %ascii-art{$player2.throw});
+ say ss-box(:40cw, "{$player1.name} ({$player1.score})",
+ "{$player2.name} ({$player2.score})");
+
+ sink prompt "";
+ }
+}
+
+multi sub MAIN(
+ Bool :$version #= print version
+) is export { say "Antlia v" ~ $?DISTRIBUTION.meta<version>; }
diff --git a/resources/paper/1 b/resources/paper/1
new file mode 100644
index 0000000..823bf0b
--- /dev/null
+++ b/resources/paper/1
@@ -0,0 +1,7 @@
+ ___..__
+____..--'''' ._ __.'
+ "-..__
+ '"--..__";
+____ '--...__"";
+ `-..__ '"---..._;"
+ ''''----
diff --git a/resources/paper/2 b/resources/paper/2
new file mode 100644
index 0000000..9328cb5
--- /dev/null
+++ b/resources/paper/2
@@ -0,0 +1,6 @@
+ _______
+---' ____)____
+ ______)
+ _______)
+ _______)
+---.__________)
diff --git a/resources/rock/1 b/resources/rock/1
new file mode 100644
index 0000000..5e425b5
--- /dev/null
+++ b/resources/rock/1
@@ -0,0 +1,6 @@
+ _______
+---' ____)
+ (_____)
+ (_____)
+ (____)
+---.__(___)
diff --git a/resources/rock/2 b/resources/rock/2
new file mode 100644
index 0000000..658350e
--- /dev/null
+++ b/resources/rock/2
@@ -0,0 +1,6 @@
+ ,--.--._
+------" _, \___)
+ / _/____)
+ \//(____)
+------\ (__)
+ `-----"
diff --git a/resources/scissor/1 b/resources/scissor/1
new file mode 100644
index 0000000..5b1efd9
--- /dev/null
+++ b/resources/scissor/1
@@ -0,0 +1,6 @@
+ _______
+---' ____)____
+ ______)
+ __________)
+ (____)
+---.__(___)
diff --git a/resources/scissor/2 b/resources/scissor/2
new file mode 100644
index 0000000..8512e95
--- /dev/null
+++ b/resources/scissor/2
@@ -0,0 +1,8 @@
+ .-. _
+ | | / )
+ | |/ /
+ _|__ /_
+ / __)-' )
+ \ `(.-')
+ > ._>-'
+ / \/