diff --git a/scpt/at.zsh b/scpt/at.zsh index 49ccb63..c53fdba 100755 --- a/scpt/at.zsh +++ b/scpt/at.zsh @@ -49,6 +49,10 @@ case $1 in source $d/src/ai/syui/game/character.zsh create_game_user $2 ;; + create-item) + source $d/src/ai/syui/game/character.zsh + create_item + ;; get-game-user) source $d/src/ai/syui/game/character.zsh get_game_user $2 diff --git a/scpt/src/ai/syui/game/character.zsh b/scpt/src/ai/syui/game/character.zsh index 0d37743..064180e 100755 --- a/scpt/src/ai/syui/game/character.zsh +++ b/scpt/src/ai/syui/game/character.zsh @@ -209,7 +209,7 @@ delete_game_user() { fi req=com.atproto.repo.DeleteRecord url=https://$pds/xrpc/$req - repo=$did_yui + repo=$did 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 @@ -221,7 +221,7 @@ function create_game_user() { did=$did_yui handle=$handle_yui pds=bsky.social - version=2 + version=4 #rkey=syui #img=https://cdn.bsky.app/img/feed_thumbnail/plain/did:plc:4hqjfn7m6n5hno3doamuhgef/bafkreie34pjuc6coenzcdwrgrh4fbacq7bkhsz263g5vpbsqxwaz37kkwy@jpeg req=com.atproto.repo.putRecord @@ -242,18 +242,26 @@ function create_game_user() { cid=bafkreidlealfybajqzwv5eoz4jshnsijc2vnktlhpw4ph47krwj6aigqby gender=male fi + if [ "$rkey" = "self" ];then + cname=manny + unset did handle gender + fi imguri=https://cdn.bsky.app/img/feed_thumbnail/plain/$did_yui/${cid}@jpeg season=1 group=test lv=1 hp=1 exp=0 - rank=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) @@ -268,7 +276,8 @@ function create_game_user() { group=fantasy ;; esac - json="\"$cname\": { \"group\": \"$group\", \"season\": $season, \"lv\": $lv, \"exp\": $exp, \"hp\": $hp, \"rank\": $rank, \"mode\": $mode, \"attack\": $attack, \"critical\": $critical, \"critical_d\": $critical_d }" + + 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=" @@ -293,9 +302,9 @@ function create_game_user() { }" json_item=" -\"coin\": { \"id\": 0, \"count\": 0 }, -\"card\": { \"id\": 0, \"count\": 0, \"cp\": 0, \"rare\": 0 }, -\"weapon\": { \"id\": 0, \"count\": 0, \"attack\": 0, \"type\": 0, \"tp\": 0 } +\"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=" @@ -313,7 +322,7 @@ json_item=" \"player\": { \"limit\": false, \"login\": false, - \"aiten\": 0, + \"ten\": 0, \"gender\": \"$gender\" }, \"character\": { @@ -332,12 +341,52 @@ if echo $json|jq . ;then 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 + #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_item() { + col=ai.syui.item + rkey=self + did=$did_yui + handle=$handle_yui + pds=bsky.social + 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/item/ + json_card=" \"id\": $id, \"name\": \"$name\", \"img\": \"${imgurl}/${id}.webp\"" + json_card=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/item/card.json|jq .` + json_weapon=`curl -sL https://git.syui.ai/ai/ai/raw/branch/main/item/weapon.json|jq .` + json=" + { + \"repo\": \"$handle_yui\", + \"did\": \"$did_yui\", + \"collection\": \"$col\", + \"rkey\": \"$rkey\", + \"record\": { + \"card\": ${json_card}, + \"weapon\": ${json_weapon}, + \"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 +} diff --git a/scpt/src/func.zsh b/scpt/src/func.zsh index 8f60e5a..4d261ac 100644 --- a/scpt/src/func.zsh +++ b/scpt/src/func.zsh @@ -15,7 +15,7 @@ function at-env() { collection=`echo $at_uri|cut -d / -f 4` rkey=`echo $at_uri|cut -d / -f 5` d=${0:a:h} - f=~/.config/.at-zsh.json + f=~/.config/ai/token.json if [ -f $f ];then host=`cat $f|jq -r ".didDoc.service.[].serviceEndpoint"` token=`cat $f|jq -r .accessJwt`