-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobj_getattr.sh
59 lines (54 loc) · 1.27 KB
/
obj_getattr.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
#!/bin/bash
# "$1" must be a "$x,$y" pair.
# "$2" is an attr to get.
if [[ -z "$2" || "$3" ]]; then
echo "obj_getattr(): wrong number of arguments."
echo "Usage: <int:x>,<int:y> <string:attrtype>."
source shutdown.sh error
elif [[ -z ${GAME_BASH_STRATEGY+x} ]]; then
echo "obj_getattr(): game not launched."
source shutdown.sh error
fi
# Convert argument type string to lowercase:
declare -l ATTR="$2"
case "$2" in
"symb"*)
echo "${CLASSPROPS[${OBJECTS[$1]}:symb]}"
;;
"maxhp"|"maxhealth")
echo "${CLASSPROPS[${OBJECTS[$1]}:maxhp]}"
;;
"cost"|"price")
echo "${CLASSPROPS[${OBJECTS[$1]}:cost]}"
;;
"range"|"speed")
echo "${CLASSPROPS[${OBJECTS[$1]}:range]}"
;;
"attack"|"atk"|"damage")
echo "${CLASSPROPS[${OBJECTS[$1]}:atk]}"
;;
"backfire"|"batk")
echo "${CLASSPROPS[${OBJECTS[$1]}:batk]}"
;;
"team")
echo "${PLAYERTEAMS[${OBJECTSCOLOR[$1]}]}"
;;
"possibleteams"|"teams")
for (( i_getattr = 1; i_getattr < $MAXPLAYERS; i_getattr++ )); do
[[ "${TEAMCLASSES[$i_getattr]}" == *"${OBJECTS[$1]}"* ]] && echo "$i_getattr" && break
done
;;
"attr"*)
echo "${CLASSATTRS[${OBJECTS[$1]}]}"
;;
"hp"|"health")
echo "${OBJECTSHP[$1]}"
;;
"color")
echo "${OBJECTSCOLOR[$1]}"
;;
*)
echo "Warning: unknown property \"$2\"."
;;
esac
unset ATTR