I guess I should update this
This commit is contained in:
parent
a7e9d92d82
commit
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.0.2
|
||||
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 swat_* codegen.sh ${pkgdir}/opt/swat-codegen
|
||||
ln -s /opt/swat-codegen/codegen.sh /${pkgdir}/usr/bin/rcpd
|
||||
}
|
105
swat-codegen/codegen.sh
Executable file
105
swat-codegen/codegen.sh
Executable file
|
@ -0,0 +1,105 @@
|
|||
#!/bin/bash
|
||||
|
||||
loc=$(dirname $(readlink -f "$0"))
|
||||
|
||||
# TOKEN MANAGEMENT
|
||||
function migrate
|
||||
{
|
||||
curl "https://swataftermath.com:8443/account/$1/activate-migrated" --json '{"currentPassword":"'"$3"'","emailAddress":"'"$2"'","newPassword":"'"$3"'"}'
|
||||
curl "https://swataftermath.com:8443/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 https://swataftermath.com:8443/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" https://swataftermath.com:9443/account/$1
|
||||
}
|
||||
|
||||
function post
|
||||
{
|
||||
TOKE=`get_token`
|
||||
curl -H "Authorization:Bearer $TOKE" https://swataftermath.com:9443/account/$1 --json "$2"
|
||||
}
|
||||
|
||||
function delete_code
|
||||
{
|
||||
TOKE=`get_token`
|
||||
curl -H "Authorization:Bearer $TOKE" https://swataftermath.com:9443/account/rank-code/$1 -X DELETE
|
||||
}
|
||||
|
||||
# UTILS
|
||||
function lookup
|
||||
{
|
||||
w=
|
||||
matches=`grep -ic "${*:2}" $loc/swat_$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/swat_$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/swat_$1`"
|
||||
}
|
||||
|
||||
# USER-FACING COMMANDS
|
||||
function builds
|
||||
{
|
||||
if [ -n "$1" ]; then filter='.[] | select(.buildName=="'"$*"'")'; fi
|
||||
get saved-builds | jq $filter
|
||||
}
|
||||
|
||||
function save
|
||||
{
|
||||
if [ -n "$2" ]; then name=',"buildName":"'"${*:2}"'"'; fi
|
||||
post rank-code '{"rankCode":"'$1'"'$name'}' | jq
|
||||
if [ -z "$2" ]; then delete_code $1; fi # Don't bother storing any build that doesn't have a name. 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:2}" = "wm" ]; then gun=${class%wm}; class=wm
|
||||
elif [ "${class:1}" = "mav" ] || [ "${class:2}" = "mav" ]; 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
1931
swat-codegen/openapi.yaml
Normal file
1931
swat-codegen/openapi.yaml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
swat-codegen/swat-codegen-1.0.2-1-any.pkg.tar.zst
Normal file
BIN
swat-codegen/swat-codegen-1.0.2-1-any.pkg.tar.zst
Normal file
Binary file not shown.
4
swat-codegen/swat_armour
Normal file
4
swat-codegen/swat_armour
Normal file
|
@ -0,0 +1,4 @@
|
|||
Light
|
||||
Medium m
|
||||
Heavy h
|
||||
Advanced Cyborg Watchman
|
12
swat-codegen/swat_class
Normal file
12
swat-codegen/swat_class
Normal file
|
@ -0,0 +1,12 @@
|
|||
Sniper gs ss
|
||||
Medic
|
||||
Tactician
|
||||
Psychologist
|
||||
Maverick
|
||||
HeavyOrdnance ho
|
||||
Demolitions
|
||||
Cyborg
|
||||
Pyrotechnician
|
||||
Watchman wm
|
||||
TechOps techies
|
||||
UmbrellaClone gal alice
|
8
swat-codegen/swat_gun
Normal file
8
swat-codegen/swat_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
|
9
swat-codegen/swat_spec
Normal file
9
swat-codegen/swat_spec
Normal file
|
@ -0,0 +1,9 @@
|
|||
Weaponry
|
||||
PowerArmor pa
|
||||
EnergyCells
|
||||
Cybernetics
|
||||
Triage
|
||||
Chemistry
|
||||
Leadership
|
||||
Robotics
|
||||
Espionage
|
7
swat-codegen/swat_talent
Normal file
7
swat-codegen/swat_talent
Normal file
|
@ -0,0 +1,7 @@
|
|||
Courage crg
|
||||
Wiring
|
||||
Running
|
||||
Spotting
|
||||
Toughness
|
||||
Tinkering
|
||||
Hacking
|
16
swat-codegen/swat_trait
Normal file
16
swat-codegen/swat_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
|
Loading…
Reference in New Issue
Block a user