ai/at
ai/at
1
0
at/scpt/src/ai/syui/game/character.zsh
2025-05-05 08:35:12 +09:00

408 lines
10 KiB
Bash
Executable File

character=(
ai
manny
quinn
chinese
kirin
leviathan
phoenix
wyvern
cerberus
dragon
kitsune
pegasus
)
img=(
bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy
bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy
bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy
bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby
bafkreiegpqedlrfa4ljhssdnkrr5hyd5huy2xhh2zszj5wq2wuuzejggmq
bafkreig6vszkx3c4dcortjwfsz6sa6zwqgj7zpxj4lxfrrkwql4xhiu5ou
bafkreich7fsumke2yvumvixkruonzrcevk3f6g2cntzfwdn4n2c2vox5dm
bafkreiacjvagsekhiiljz3j237b6klrt6pkptxljt7kltprgg5276gv25q
bafkreihpni4lp55jysalcntulzal5rbhidtbseanlucpyucagzxmv6xj24
bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri
bafkreidy74aieb6ie646xhosginox5zbnbnrtd76cnt4pbn73hrxgfnple
bafkreifnbfj27fr6nv7qeqqmwdibf7qrw4lauvzoknw5hexbifmwqt6kmq
)
function download_character_icon(){
t=(
"https://sketchfab.com/3d-models/super-9a80a6d6cf6f4b08906505c7f945d3ce"
)
t=(
"https://sketchfab.com/3d-models/cerberus-quirky-series-4379b571b5a440119d1ebaddb0711142"
"https://sketchfab.com/3d-models/chinese-dragon-quirky-series-a383d3cf5b004978ac620806558b2924"
"https://sketchfab.com/3d-models/dragon-quirky-series-9a0989aae9b84ebdade28e84a0702a71"
"https://sketchfab.com/3d-models/kirin-quirky-series-b280c8bc5b87471eac1068acc91fdce1"
"https://sketchfab.com/3d-models/kitsune-quirky-series-4fc8b2ade43f4d4bb8a8e6e227f00a62"
"https://sketchfab.com/3d-models/leviathan-quirky-series-002200e1db2c461fbcaa8d2fdac2d766"
"https://sketchfab.com/3d-models/pegasus-quirky-series-a4488ae7a2d2405c927a50f5a8b2d6bb"
"https://sketchfab.com/3d-models/phoenix-quirky-series-1f0a01247b78441ab5b9cf8e9711e78e"
"https://sketchfab.com/3d-models/wyvern-quirky-series-7baad217325a45b4877514b3f5924be9"
)
for i in $t; do
name=`echo $i|cut -d / -f 5|cut -d - -f 1`
tt=`curl -sL $i|tr ' ' '\n' |grep .jpeg|cut -d '"' -f 2`
normal=`echo $tt|awk "NR==1"`
min=`echo $tt|awk "NR==2"`
if [ ! -f $name.jpeg ];then
curl -sL $normal -o $name.jpeg
fi
if [ ! -f ${name}-min.jpeg ];then
#curl -sL $min -o ${name}-min.jpeg
fi
array+=(`echo $tt|sed "1,2d"|cut -d ";" -f 2|cut -d '&' -f 1|tr '\n' ' '`)
echo $name
for ((i=1; i<=$#array; i++)); do
echo "Index: $i, Value: ${array[$i]}"
#curl -sL ${array[$i]} -o ${name}-${i}.jpeg
done
done
}
case $OSTYPE in
darwin*)
day=`gdate --iso-8601=seconds`
;;
*)
day=`date --iso-8601=seconds`
;;
esac
function create_game_character() {
t=(
ai
chinese
kirin
leviathan
phoenix
wyvern
cerberus
dragon
kitsune
pegasus
)
for ((i=1; i<=$#t; i++)); do
created=2020-01-01T00:00:00+09:00
col=ai.syui.game.character
req=com.atproto.repo.getRecord
url=https://$host/xrpc/$req
id=$i
name=${t[$i]}
chara=$name
rkey=$chara
repo=$did_yui
json="{\"collection\":\"$col\", \"rkey\":\"$rkey\", \"repo\":\"$repo\"}"
if [ $((RANDOM % 2)) -eq 0 ];then
gender=male
else
gender=female
fi
case $name in
ai)
gender=none
group=origin
season=0
;;
chinese|dragon|cerberus|pegasus|leviathan)
gender=male
group=fantasy
season=1
;;
kitsune|phoenix|kirin|wyvern)
gender=female
group=fantasy
season=1
;;
*)
continue ;;
esac
jj=`curl -sL "$url?repo=$repo&collection=$col&rkey=$rkey"`
link=`echo $jj|jq -r '.value.embed.external.thumb.ref.[]'`
size=`echo $jj|jq -r .value.embed.external.thumb.size`
mtype=`echo $jj|jq -r .value.embed.external.thumb.mimeType`
echo $name
echo $gender
echo https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/$link
## upload img
#if [ -f ./${name}.jpeg ];then
# jj=`ai img-upload ./${name}.jpeg`
#elif [ -f ./${name}.png ];then
# jj=`ai img-upload ./${name}.png`
#fi
#link=`echo $jj|jq -r ".blob.ref.[]"`
#size=`echo $jj|jq -r .blob.size`
#mtype=`echo $jj|jq -r .blob.mimeType`
req=com.atproto.repo.putRecord
url=https://$host/xrpc/$req
nickname=$name
fullname=$name
uri=at://${did_yui}/$col/$chara
json="{
\"repo\": \"$handle_yui\",
\"did\": \"$did_yui\",
\"collection\": \"$col\",
\"rkey\": \"$chara\",
\"record\": {
\"id\": $id,
\"name\": \"$name\",
\"fullname\": \"$fullname\",
\"nickname\": \"$nickname\",
\"gender\": \"$gender\",
\"season\": $season,
\"group\": \"$group\",
\"embed\": {
\"\$type\": \"app.bsky.embed.external\",
\"external\": {
\"uri\": \"$uri\",
\"thumb\": {
\"\$type\": \"blob\",
\"ref\": {
\"\$link\": \"$link\"
},
\"mimeType\": \"$mtype\",
\"size\": $size
} } }, \"createdAt\": \"$created\", \"updatedAt\": \"$day\" } }"
if echo $json|jq . ;then
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token_yui" -d $json $url
fi
done
}
function get_game_user() {
rkey=$did.$pds
pds=bsky.social
if [ "$1" = "syui" ] || [ "$1" = "ai" ];then
rkey=$1
fi
req=com.atproto.repo.getRecord
url="https://$pds/xrpc/$req?rkey=$rkey&repo=$did_yui&collection=ai.syui.game"
curl -sL $url|jq .
}
delete_game_user() {
rkey=$2
if [ -z "$1" ];then
col=ai.syui.game
else
col=$1
fi
req=com.atproto.repo.DeleteRecord
url=https://$pds/xrpc/$req
repo=$did
#repo=did:plc:6qyecktefllvenje24fcxnie
json="{\"collection\":\"$col\", \"rkey\":\"$rkey\", \"repo\":\"$repo\"}"
echo $json
curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url
}
function create_game_user() {
col=ai.syui.game
rkey=$1
handle_yui=$handle
did_yui=$did
pds=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
if [ "$pds" != "syu.is" ];then
pds=bsky.social
fi
version=4
#rkey=syui
#img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg
req=com.atproto.repo.putRecord
url=https://$pds/xrpc/$req
cname=dragon
cid=bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri
if [ "$rkey" = "ai" ];then
cname=$rkey
cid=bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy
gender=none
fi
if [ "$rkey" = "syui" ];then
cname=chinese
did=$did_syui
handle=syui.ai
cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby
gender=male
fi
if [ "$rkey" = "self" ];then
cname=manny
unset did handle gender
pds=bsky.social
plc=plc.directory
fi
imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg
season=1
group=test
lv=1
hp=1
exp=0
rare=0
mode=0
attack=0
attack_post=0
critical=0
critical_d=0
card=0
weapon=0
coin=0
count=0
case $cname in
ai)
group=origin
season=0
mode=2
;;
manny|quinn)
group=test
;;
*)
group=fantasy
;;
esac
json="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"mode\": $mode, \"attack\": $attack, \"critical\": $critical, \"critical_d\": $critical_d, \"card\": $card, \"coin\": $coin, \"weapon\": $weapon, \"count\": $count, \"rare\": $rare}"
#json="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"img\": \"$imguri\", \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"rank\": $rank, \"mode\": $mode, \"attack\": $attack, \"attack_post\": $attack_post, \"critical\": $critical, \"critical_d\": $critical_d }"
v1_json="
{
\"repo\": \"$handle_yui\",
\"did\": \"$did_yui\",
\"collection\": \"$col\",
\"rkey\": \"$rkey\",
\"record\": {
\"did\": \"$did\",
\"limit\": false,
\"login\": false,
\"handle\": \"$handle\",
\"aiten\": 10,
\"gender\": \"$gender\",
\"character\": {
$json
},
\"createdAt\": \"${created}\",
\"updatedAt\": \"${created}\"
}
}"
json_item="
\"coin\": [{\"id\": 0, \"cp\": 0, \"rare\": 0, \"count\": 0}],
\"card\": [{\"id\": 0, \"cp\": 0, \"rare\": 0, \"count\": 0}],
\"weapon\": [{\"id\": 0, \"cp\": 0, \"rare\": 0, \"count\": 0}]
"
json="
{
\"repo\": \"$handle_yui\",
\"did\": \"$did_yui\",
\"collection\": \"$col\",
\"rkey\": \"$rkey\",
\"record\": {
\"version\": $version,
\"did\": \"$did\",
\"handle\": \"$handle\",
\"plc\": \"$plc\",
\"pds\": \"$pds\",
\"player\": {
\"limit\": false,
\"login\": false,
\"ten\": 0,
\"gender\": \"$gender\"
},
\"character\": {
$json
},
\"item\": {
$json_item
},
\"createdAt\": \"${created}\",
\"updatedAt\": \"${created}\"
}
}"
if echo $json|jq . ;then
echo y
read y
if [ "y" = "$y" ];then
t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url`
echo $t|jq .
#f=~/ai/ue/json/v${version}_${rkey}.json
#if [ -f $f ];then
# get_game_user $rkey >! $f
#fi
fi
fi
}
function create_system() {
col=ai.syui.system
rkey=self
did=$did
handle=$handle
pds=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"|cut -d / -f 3`
if [ "$pds" != "syu.is" ];then
pds=bsky.social
fi
version=1
#rkey=syui
#img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg
req=com.atproto.repo.putRecord
url=https://$pds/xrpc/$req
#cid=bafkreia3huw2gdenqatoobx3hcft74chced46bw4znfgepo5aenegobkri
#imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg
imgurl=https://git.syui.ai/ai/ai/raw/branch/main/img/item/card
json_card=" \"id\": $id, \"name\": \"$name\", \"img\": \"${imgurl}/${id}.webp\""
json_card=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/card.json|jq ".[]"`
json_weapon=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/weapon.json|jq ".[]"`
json_system=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/system.json|jq ".[]"`
json_character=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/character.json|jq ".[]"`
json_ability=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/json/ability.json|jq ".[]"`
json="
{
\"repo\": \"$handle\",
\"did\": \"$did\",
\"collection\": \"$col\",
\"rkey\": \"$rkey\",
\"record\": {
\"card\": ${json_card},
\"weapon\": ${json_weapon},
\"system\": ${json_system},
\"character\": ${json_character},
\"ability\": ${json_ability},
\"createdAt\": \"${created}\",
\"updatedAt\": \"${created}\"
}
}"
if echo $json|jq . ;then
echo y
read y
if [ "y" = "$y" ];then
t=`curl -sL -X POST -H "Content-Type: application/json" -H "Authorization: Bearer $token" -d $json $url`
echo $t|jq .
fi
fi
}