From 3cf07e5d8f5579893a43a4300d44d4dbab90ba81 Mon Sep 17 00:00:00 2001 From: Andinus Date: Thu, 29 Apr 2021 20:46:30 +0530 Subject: Initial implementation --- META6.json | 22 +++++++++++ README | 105 +++++++++++++++++++++++++++++++++++++++++++++++++ README.org | 68 ++++++++++++++++++++++++++++++++ bin/antlia | 3 ++ lib/Antlia/CLI.rakumod | 52 ++++++++++++++++++++++++ resources/paper/1 | 7 ++++ resources/paper/2 | 6 +++ resources/rock/1 | 6 +++ resources/rock/2 | 6 +++ resources/scissor/1 | 6 +++ resources/scissor/2 | 8 ++++ 11 files changed, 289 insertions(+) create mode 100644 META6.json create mode 100644 README create mode 100644 README.org create mode 100644 bin/antlia create mode 100644 lib/Antlia/CLI.rakumod create mode 100644 resources/paper/1 create mode 100644 resources/paper/2 create mode 100644 resources/rock/1 create mode 100644 resources/rock/2 create mode 100644 resources/scissor/1 create mode 100644 resources/scissor/2 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 " ], + "license" : "ISC", + "perl" : "6.d", + "provides" : { + "Antlia::CLI" : "lib/Antlia/CLI.rakumod", + }, + "depends" : [ + "Terminal::Table:auth" + ], + "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 + Source + GitHub (mirror) +━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ + + +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: + • + • + 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] + + + +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.slurp, + paper => %?RESOURCES.slurp, + scissor => %?RESOURCES.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; } 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 @@ + .-. _ + | | / ) + | |/ / + _|__ /_ + / __)-' ) + \ `(.-') + > ._>-' + / \/ -- cgit 1.4.1-2-gfad0