added rps module, fixed minor bugs, removed the redundant test.sh

This commit is contained in:
Dimitar Dimitrov
2013-07-18 17:40:25 +01:00
parent 2b8141c224
commit 19181cdfa9
5 changed files with 35 additions and 4 deletions

1
modules/args.sh Executable file
View File

@ -0,0 +1 @@
echo "PRIVMSG $2 :$1: $@"

View File

@ -1,3 +1,3 @@
echo "PRIVMSG $2 :$1: The available modules I have are:"
output=$(ls modules/ | sed "s/.sh//")
output=$(find modules/ -maxdepth 1 -type f -not -name ".*" -printf "%f\n" | sed "s/.sh//")
echo "PRIVMSG $2 :$1: "$output

32
modules/rps.sh Executable file
View File

@ -0,0 +1,32 @@
#!/bin/bash
# 0 - rock
# 1 - paper
# 2 - scissor
m_choice=$(($RANDOM%3))
o_choice=$(echo $4 | sed -r "s/^[rR].*/0/" | sed -r "s/^[pP].*/1/" | sed -r "s/^[sS].*/2/")
#convert my random to either r/p/s
case "$m_choice" in
0)
mr_choice="rock"
;;
1)
mr_choice="paper"
;;
2)
mr_choice="scissor"
;;
esac
if [ "$m_choice" == "$o_choice" ]
then
outcome="tie"
elif [ "$((($m_choice+1)%3))" == "$o_choice" ]
then
outcome="lose"
else
outcome="win"
fi
echo "PRIVMSG $2 :$1: $4 VS $mr_choice | I $outcome!"

View File

@ -1 +0,0 @@
echo "PRIVMSG $2 :$1: The test was successful"