-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrentAHero_Save.sh
106 lines (104 loc) · 2.72 KB
/
rentAHero_Save.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#! /bin/bash
# This Program creates a hero
select Hero in Name Strength Dexterity Intelligence Finish
do
case $Hero in
Name)
echo "Please insert the name of your hero."
read hname
if [ ! -e heroes ]; then
mkdir heroes
cd heroes
echo $hname > "${hname}.txt"
echo "Level 1" >> "${hname}.txt"
echo "Your hero will be Level 1 and henceforth be called ${hname}."
else
cd heroes
echo $hname > "${hname}.txt"
echo "Level 1" >> "${hname}.txt"
echo "Your hero will be Level 1 and henceforth be called ${hname}."
fi
;;
Strength)
for (( c=0; c <= 4; c++ ))
do
echo "Rolling dice ... "
sleep 1
StrValue=$(($RANDOM%10-0))
echo "Your Strength value is $StrValue ."
let c++
echo "Re-Roll your Strength [y/n]?"
read q
if [[ $q == "n" ]]; then
let c=4
fi
done
echo "Your heros Strength value of $StrValue was be saved."
echo "Strength: ${StrValue}" >> Values.txt
;;
Dexterity)
for (( c=0; c <= 4; c++ ))
do
echo "Rolling dice ... "
sleep 1
DexValue=$(($RANDOM%10-0))
echo "Your Dexterity value is $DexValue ."
let c++
echo "Re-Roll your Dexterity [y/n]?"
read q
if [[ $q == "n" ]]; then
let c=4
fi
done
echo "Your heros Dexterity value of $DexValue was be saved."
echo "Dexterity: ${DexValue}" >> Values.txt
;;
Intelligence)
for (( c=0; c <= 4; c++ ))
do
echo "Rolling dice ... "
sleep 1
IntValue=$(($RANDOM%10-0))
echo "Your Intelligence value is $IntValue ."
let c++
echo "Re-Roll your Intelligence [y/n]?"
read q
if [[ $q == "n" ]]; then
let c=4
fi
done
echo "Your heros Intelligence value of $IntValue was be saved."
echo "Intelligence: ${IntValue}" >> Values.txt
;;
Finish)
if [ ! -e heroes ]; then
mkdir heroes
cd heroes
else
if [ -e "${hname}.txt" ]; then
"Level 1" >> "${name}.txt"
cat Values.txt >> "${hname}.txt"
echo "Your hero has the following attributes: "
cat "${hname}.txt"
sleep 4
echo "Your hero was saved to ${hname}.txt"
#rm Values.txt
cd ..
break
else
echo "Your hero still needs a name. Please insert one now."
read hname
echo $hname > "${hname}.txt"
cat Values.txt >> "${hname}.txt"
echo "Your hero has the following attributes: "
cat "${hname}.txt"
sleep 4
echo "Your hero was saved to ${hname}.txt."
#rm Values.txt
cd ..
break
fi
fi
;;
esac
done