Added tools to browse the database, and make new times in the acceptable format, created from apr to late may of 2023

This commit is contained in:
Rebekah 2024-06-18 15:45:10 -04:00
parent e776c27136
commit d8f5c79ed9
Signed by: oneechanhax
GPG Key ID: 0074BF373B812798
11 changed files with 319 additions and 0 deletions

57
convert-time.js Normal file
View File

@ -0,0 +1,57 @@
const input_time = process.argv[2];
//console.log("input_time")
//console.log(input_time)
/*function convertToSeconds(time) {
var parts = time.split(":");
var seconds = 0;
for (var i = 0; i < parts.length; i++) {
var value = parseFloat(parts[i]);
console.log(`Parsing ${i}: ${value}`)
if (i === 0) {
console.log("as day");
seconds += value * 86400;
} else if (i === 1) {
console.log("as hour");
seconds += value * 3600;
} else if (i === 2) {
console.log("as minutes");
seconds += value * 60;
} else if (i === 3) {
console.log("as seconds");
seconds += value;
}
}
console.log(seconds);
return seconds;
}*/
function convertToSeconds(time) {
var parts = time.split(":");
var seconds = 0;
if(parts.length==1) {
var secs = parseFloat(parts[0]);
seconds += secs;
}
else if(parts.length==2) {
var minutes = parseFloat(parts[0]);
var secs = parseFloat(parts[1]);
seconds += minutes * 60 + secs;
}
else if(parts.length==3) {
var hours = parseFloat(parts[0]);
var minutes = parseFloat(parts[1]);
var secs = parseFloat(parts[2]);
seconds += hours * 3600 + minutes * 60 + secs;
}
else if(parts.length==4) {
var days = parseFloat(parts[0]);
var hours = parseFloat(parts[1]);
var minutes = parseFloat(parts[2]);
var secs = parseFloat(parts[3]);
seconds += days * 86400 + hours * 3600 + minutes * 60 + secs;
}
return seconds;
}
console.log(convertToSeconds(input_time));

6
get-curtime.js Normal file
View File

@ -0,0 +1,6 @@
var currentTime = Date.now() / 1000;
console.log(currentTime);
// to reverse
/*var seconds = 1673721347.942;
var date = new Date(seconds * 1000);
console.log(date.toLocaleDateString()); console.log(date.toLocaleTimeString());*/

66
get-time.sh Executable file
View File

@ -0,0 +1,66 @@
#!/bin/bash -e
usage() {
echo "usage $0 <MAP_NAME> <SOLDIER/DEMOMAN(s/d)>"
}
# Check that a map name was provided
if [ -z "$1" ]; then
echo "Error: No map name provided"
exit 1
fi
WANTED_MAP="$1"
WANTED_CLASS="$2"
case "$WANTED_CLASS" in
s*)
WANTED_CLASS="soldier"
;;
S*)
WANTED_CLASS="soldier"
;;
d*)
WANTED_CLASS="demoman"
;;
D*)
WANTED_CLASS="demoman"
;;
*)
echo "Error: Invalid class. Must be either SOLDIER or DEMOMAN"
usage
exit
;;
esac
FILE_LOC="personal/completed.$WANTED_CLASS/"
files="$(ls "$FILE_LOC/$WANTED_MAP"*.json | sed 's/.json//' | sed 's/.*\///')"
count="$(echo "$files" | wc -l)"
if [ "$count" -gt 1 ]; then
if [ -e "$FILE_LOC/$WANTED_MAP.json" ]; then
files="$WANTED_MAP"
else
if [ "$(echo "$files" | head -l)" ]; then
echo "There are too many maps that match your request: \"$WANTED_MAP\""
if [ "$count" -lt 5 ]; then
echo "The following maps match your request."
echo "$files"
fi
exit
fi
fi
fi
# Get the duration for the map
duration=$(jq '.duration' $FILE_LOC/$files.json)
# Convert the duration to a human-readable format
human_readable=$(awk -v t=$duration 'BEGIN{
h=int(t/3600);
t-=h*3600;
m=int(t/60);
t-=m*60;
s=t
printf "%dh %dm %ds\n",h,m,s
}')
echo "Run time for $files: $human_readable"

42
list-completed-tiers.sh Executable file
View File

@ -0,0 +1,42 @@
#!/bin/bash
# Check that a class was provided
if [ -z "$1" ]; then
echo "Error: No class provided"
exit 1
fi
# Normalize the class argument to uppercase
class=$(echo $1 | tr '[:lower:]' '[:upper:]')
# Check that the class is either SOLDIER or DEMOMAN
case "$class" in
s*)
class="SOLDIER"
;;
S*)
class="SOLDIER"
;;
d*)
class="DEMOMAN"
;;
D*)
class="DEMOMAN"
;;
*)
echo "Error: Invalid class. Must be either SOLDIER or DEMOMAN"
exit 1
;;
esac
# Get a list of maps
maps=$(ls personal/completed.soldier/)
# Iterate over the list of maps
for map in $maps; do
# Strip the .json extension from the map name
map_name=$(echo $map | sed 's/.json//')
# Call the list-tier.sh script with the map name and class as arguments
./list-tier.sh $map_name $class
done

2
list-random-midtier.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
sh list-tiers.sh s | grep -E '(T3|T4)' | shuf | head -n 6

2
list-random.sh Normal file
View File

@ -0,0 +1,2 @@
#!/bin/sh
sh list-tiers.sh s | grep -vE '(T5|T6|T0|Tnull)' | shuf | head -n6

58
list-tier.sh Executable file
View File

@ -0,0 +1,58 @@
#!/bin/sh -e
usage() {
echo "usage list-tier <MAP_NAME> <SOLDIER/DEMOMAN(s/d)>"
}
if [ $# -lt 2 ]; then
echo "Error: At least two arguments is required"
usage
exit 1
fi
WANTED_MAP="$1"
WANTED_CLASS="$2"
case "$WANTED_CLASS" in
s*)
WANTED_CLASS="soldier"
;;
S*)
WANTED_CLASS="soldier"
;;
d*)
WANTED_CLASS="demoman"
;;
D*)
WANTED_CLASS="demoman"
;;
*)
echo "Error: Invalid class. Must be either SOLDIER or DEMOMAN"
usage
exit
;;
esac
FILE_LOC="database/map_info/"
files="$(ls $FILE_LOC/$WANTED_MAP*.json | sed 's/.json//' | sed 's/.*\///')"
count="$(echo "$files" | wc -l)"
if [ "$count" -gt 1 ]; then
if [ -e "$FILE_LOC/$WANTED_MAP.json" ]; then
files="$WANTED_MAP"
else
if [ "$(echo "$files" | head -l)" ]; then
echo "There are too many maps that match your request: \"$WANTED_MAP\""
if [ "$count" -lt 5 ]; then
echo "The following maps match your request."
echo "$files"
fi
exit
fi
fi
fi
JSON_FILEPATH="$FILE_LOC/$files.json"
FOUND_MAP_TIER="$(jq .tiers."$WANTED_CLASS" "$JSON_FILEPATH")"
FOUND_MAP_NAME="$(jq .name "$JSON_FILEPATH" | tr -d '"')"
echo "$FOUND_MAP_NAME: T$FOUND_MAP_TIER"

41
list-tiers.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/sh -e
usage() {
echo "usage list-tiers <SOLDIER/DEMOMAN(s/d)>"
}
if [ $# -lt 1 ]; then
echo "Error: At least one argument is required"
usage
exit 1
fi
WANTED_CLASS="$1"
case "$WANTED_CLASS" in
s*)
WANTED_CLASS="soldier"
;;
S*)
WANTED_CLASS="soldier"
;;
d*)
WANTED_CLASS="demoman"
;;
D*)
WANTED_CLASS="demoman"
;;
*)
echo "Unknown class: $1"
usage
exit
;;
esac
for i in database/map_info/*.json; do
# Strip the .json extension from the map name
map_name=$(echo $i | sed 's/.json//' | sed 's/.*\///')
# Call the list-tier.sh script with the map name and class as arguments
./list-tier.sh $map_name $WANTED_CLASS
done

View File

@ -0,0 +1,2 @@
#!/bin/sh
sh list-uncompleted-tiers.sh s | grep -E '(T3|T4)' | shuf | head

View File

@ -0,0 +1,2 @@
#!/bin/sh
sh list-uncompleted-tiers.sh s | grep -vE '(T4|T5|T6|T0|Tnull)' | shuf | head

41
list-uncompleted-tiers.sh Executable file
View File

@ -0,0 +1,41 @@
#!/bin/bash
# Check that a class was provided
if [ -z "$1" ]; then
echo "Error: No class provided"
exit 1
fi
# Normalize the class argument to uppercase
class=$(echo $1 | tr '[:lower:]' '[:upper:]')
# Check that the class is either SOLDIER or DEMOMAN
case "$class" in
s*)
class="soldier"
;;
S*)
class="soldier"
;;
d*)
class="demoman"
;;
D*)
class="demoman"
;;
*)
echo "Error: Invalid class. Must be either SOLDIER or DEMOMAN"
exit 1
;;
esac
# Get a list of maps
completed_maps=$(ls personal/completed.$class/ | sed 's/.json//')
for i in database/map_info/*.json; do
# Strip the .json extension from the map name
map_name=$(echo $i | sed 's/.json//' | sed 's/.*\///')
# Call the list-tier.sh script with the map name and class as arguments
[ "$(echo "$map_name" | grep -v "$completed_maps")" == "$mapname" ] || ./list-tier.sh $map_name $class
done