Compare commits
10 Commits
a7e9d92d82
...
master
Author | SHA1 | Date | |
---|---|---|---|
bc68c03f34 | |||
0126ec1204 | |||
27b824f152 | |||
7c75f6ccd6 | |||
d77499c011 | |||
e82d65061e | |||
f585c85a44 | |||
1cdf83968f | |||
8ab582e450 | |||
19141954e9 |
21
swat-codegen/PKGBUILD
Normal file
21
swat-codegen/PKGBUILD
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Maintainer: Zergling_man, from fedora.email
|
||||||
|
|
||||||
|
pkgname=swat-codegen
|
||||||
|
pkgver=1.1.1
|
||||||
|
pkgrel=1
|
||||||
|
pkgdesc="A simple CLI interface to RCPDv3, the rank code management service for the game SWAT: Aftermath"
|
||||||
|
arch=('any')
|
||||||
|
url=http://rakka.au/contact
|
||||||
|
license=('WTFPL+nigger')
|
||||||
|
depends=('jq' 'curl' 'coreutils' 'grep')
|
||||||
|
source=()
|
||||||
|
sha256sums=('SKIP') #Don't know how to use this on a repo.
|
||||||
|
|
||||||
|
package() {
|
||||||
|
cd ${pkgdir}
|
||||||
|
install -d usr/bin opt/swat-codegen
|
||||||
|
cd ${srcdir}/${pkgname}
|
||||||
|
chmod a+x codegen.sh
|
||||||
|
cp class gun armour trait spec talent codegen.sh ${pkgdir}/opt/swat-codegen
|
||||||
|
ln -s /opt/swat-codegen/codegen.sh /${pkgdir}/usr/bin/rcpd
|
||||||
|
}
|
4
swat-codegen/armour
Normal file
4
swat-codegen/armour
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
Light
|
||||||
|
Medium m
|
||||||
|
Heavy h
|
||||||
|
Advanced Cyborg Watchman a
|
12
swat-codegen/class
Normal file
12
swat-codegen/class
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
Sniper gs ss
|
||||||
|
Medic
|
||||||
|
Tactician
|
||||||
|
Psychologist
|
||||||
|
Maverick
|
||||||
|
HeavyOrdnance ho
|
||||||
|
Demolitions
|
||||||
|
Cyborg
|
||||||
|
Pyrotechnician
|
||||||
|
Watchman wm
|
||||||
|
TechOps techies tech
|
||||||
|
UmbrellaClone gal alice
|
112
swat-codegen/codegen.sh
Executable file
112
swat-codegen/codegen.sh
Executable file
@@ -0,0 +1,112 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
loc=$(dirname $(readlink -f "$0"))
|
||||||
|
|
||||||
|
account_server_root_url=https://swataftermath.com:8443
|
||||||
|
code_server_root_url=https://swataftermath.com:9443/account
|
||||||
|
|
||||||
|
# TOKEN MANAGEMENT
|
||||||
|
function migrate
|
||||||
|
{
|
||||||
|
curl "$account_server_root_url/account/$1/activate-migrated" --json '{"currentPassword":"'"$3"'","emailAddress":"'"$2"'","newPassword":"'"$3"'"}'
|
||||||
|
curl "$account_server_root_url/account/$1/verify-email" --json '{"verificationCode":"'"$(cat)"'"}'
|
||||||
|
login "$1" "$3"
|
||||||
|
}
|
||||||
|
|
||||||
|
function login
|
||||||
|
{
|
||||||
|
[ -n "$2" ] || { echo "Please provide a username and password, in that order, when calling this"; exit; }
|
||||||
|
curl $account_server_root_url/login --json '{"username":"'"$1"'","password":"'"$2"'"}' > ~/.config/rcpd.cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_token
|
||||||
|
{
|
||||||
|
cat ~/.config/rcpd.cfg 2>/dev/null || { echo "Please login first" >&2; exit; }
|
||||||
|
}
|
||||||
|
|
||||||
|
# CORE API CALLS
|
||||||
|
function get
|
||||||
|
{
|
||||||
|
TOKE=`get_token`
|
||||||
|
curl -H "Authorization:Bearer $TOKE" $code_server_root_url/$1
|
||||||
|
}
|
||||||
|
|
||||||
|
function post
|
||||||
|
{
|
||||||
|
TOKE=`get_token`
|
||||||
|
curl -$3H "Authorization:Bearer $TOKE" $code_server_root_url/$1 --json "$2"
|
||||||
|
}
|
||||||
|
|
||||||
|
function delete_code
|
||||||
|
{
|
||||||
|
TOKE=`get_token`
|
||||||
|
curl -H "Authorization:Bearer $TOKE" $code_server_root_url/rank-code/$1 -X DELETE
|
||||||
|
}
|
||||||
|
|
||||||
|
# UTILS
|
||||||
|
function lookup
|
||||||
|
{
|
||||||
|
w=
|
||||||
|
matches=`grep -ic "${*:2}" $loc/$1`
|
||||||
|
if [ "$matches" -ne 1 ]; then
|
||||||
|
echo "$1 '${*:2}' is ambiguous (got $matches matches), trying whole-word match" >&2
|
||||||
|
# Attempt whole-word match and see if we get exactly one result (and then remember it has happened!!!)
|
||||||
|
w=w
|
||||||
|
word_matches=`grep -ic$w "${*:2}" $loc/$1`
|
||||||
|
if [ "$word_matches" -ne 1 ]; then echo "still ambiguous (got $word_matches matches)" >&2; return 1; fi
|
||||||
|
fi
|
||||||
|
read $1 garbage <<< "`grep -i$w "${*:2}" $loc/$1`"
|
||||||
|
}
|
||||||
|
|
||||||
|
# USER-FACING COMMANDS
|
||||||
|
function builds
|
||||||
|
{
|
||||||
|
filter='.[] | .rankCode+" "+.buildName'
|
||||||
|
if [ -n "$1" ]; then filter='.[] | select(.buildName=="'"$*"'")'; fi
|
||||||
|
get saved-builds | jq "$filter"
|
||||||
|
}
|
||||||
|
|
||||||
|
function save
|
||||||
|
{
|
||||||
|
if [ -n "$2" ]; then name=',"buildName":"'"${*:2}"'"'; fi
|
||||||
|
res=`post rank-code '{"rankCode":"'$1'"'"$name"'}' i`
|
||||||
|
created=`head -n 1 <<< "$res" | cut -d' ' -f2`
|
||||||
|
res=`tr -d '\r' <<< "$res" | awk -F '\r\n' 'BEGIN { a=1 } a==0 { print } $0=="" { a=0 }'`
|
||||||
|
jq <<< "$res"
|
||||||
|
if [ $created = 201 -a -z "$2" ]; then delete_code $1; fi # Don't bother storing any build that doesn't have a name if it didn't already exist. Assume it's just logging the results of a game.
|
||||||
|
}
|
||||||
|
|
||||||
|
function generate
|
||||||
|
{
|
||||||
|
# mfw I actually have to do work
|
||||||
|
IFS=/ read -a hero <<< "$*"
|
||||||
|
length=${#hero[*]}
|
||||||
|
if [ $length -eq 6 ]; then IFS=/ read class gun armour trait spec talent <<< "$*"
|
||||||
|
elif [ $length -eq 5 ]; then IFS=/ read class armour trait spec talent <<< "$*"
|
||||||
|
elif [ $length -eq 4 ]; then IFS=/ read class trait spec talent <<< "$*"; fi # Probably a borg or a wm.
|
||||||
|
if [ -z "$gun" ]; then
|
||||||
|
if [ "${class%wm}" != "$class" ]; then gun=${class%wm}; class=wm
|
||||||
|
elif [ "${class%mav}" != "$class" ]; then gun=${class%mav}; class=mav; fi
|
||||||
|
fi
|
||||||
|
res=0
|
||||||
|
lookup class "$class"
|
||||||
|
res=$((res+$?))
|
||||||
|
if [ -z "$gun" ]; then gun=$class; fi # Do this after qualifying class so I don't have to nest the full class table in the gun table.
|
||||||
|
lookup gun "$gun"
|
||||||
|
res=$((res+$?))
|
||||||
|
if [ -z "$armour" ]; then armour=$class; fi
|
||||||
|
lookup armour "$armour"
|
||||||
|
res=$((res+$?))
|
||||||
|
lookup trait "$trait"
|
||||||
|
res=$((res+$?))
|
||||||
|
lookup spec "$spec"
|
||||||
|
res=$((res+$?))
|
||||||
|
lookup talent "$talent"
|
||||||
|
res=$((res+$?))
|
||||||
|
if [ $res -gt 0 ]; then echo "Please correct above errors and try again"; exit; fi
|
||||||
|
echo $class $gun $armour $trait $spec $talent
|
||||||
|
post generate '{"swatClass":"'$class'","gun":"'$gun'","armor":"'$armour'","trait":"'$trait'","specialization":"'$spec'","talent":"'$talent'"}' | jq '.rankCode//.'
|
||||||
|
}
|
||||||
|
|
||||||
|
# DO SHIT
|
||||||
|
"$@"
|
1251
swat-codegen/documentation.yaml
Normal file
1251
swat-codegen/documentation.yaml
Normal file
File diff suppressed because it is too large
Load Diff
8
swat-codegen/gun
Normal file
8
swat-codegen/gun
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
AssaultRifle a ar Medic Tactician Psychologist
|
||||||
|
SniperRifle s sr TechOps
|
||||||
|
Chaingun c cg HeavyOrdnance Cyborg
|
||||||
|
RocketLauncher r rl Demolitions
|
||||||
|
Flamethrower f ft Pyrotechnician
|
||||||
|
LaserRifle lr
|
||||||
|
GatlingLaser gl
|
||||||
|
Pistols fists UmbrellaClone
|
2206
swat-codegen/openapi.yaml
Normal file
2206
swat-codegen/openapi.yaml
Normal file
File diff suppressed because it is too large
Load Diff
9
swat-codegen/spec
Normal file
9
swat-codegen/spec
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
Weaponry
|
||||||
|
PowerArmor pa
|
||||||
|
EnergyCells
|
||||||
|
Cybernetics
|
||||||
|
Triage
|
||||||
|
Chemistry
|
||||||
|
Leadership
|
||||||
|
Robotics
|
||||||
|
Espionage
|
7
swat-codegen/talent
Normal file
7
swat-codegen/talent
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
Courage crg
|
||||||
|
Wiring wire
|
||||||
|
Running
|
||||||
|
Spotting
|
||||||
|
Toughness
|
||||||
|
Tinkering
|
||||||
|
Hacking
|
16
swat-codegen/trait
Normal file
16
swat-codegen/trait
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
Skilled
|
||||||
|
Gifted
|
||||||
|
Survivalist
|
||||||
|
Dragoon
|
||||||
|
Acrobat
|
||||||
|
SwiftLearner sl
|
||||||
|
Healer
|
||||||
|
FlowerChild fc
|
||||||
|
ChemReliant cr
|
||||||
|
RadResistant rr
|
||||||
|
Gadgeteer
|
||||||
|
Prowler
|
||||||
|
Energizer energiser
|
||||||
|
PackRat pr
|
||||||
|
Engineer
|
||||||
|
Reckless
|
Reference in New Issue
Block a user