update 6.7

This commit is contained in:
chardub
2025-09-28 15:53:01 -04:00
parent ef5e023ae0
commit 318ff90d8d
696 changed files with 111759 additions and 198230 deletions

View File

@@ -0,0 +1,50 @@
#todo: limit of 10 at once
#todo: append new friends at the end of the list instead of overwriting everything
#todo: if the friend's id is already in there, update (overwrite) it
#
class SecretBaseFetcher
SECRETBASE_DOWNLOAD_URL = "https://secretbase-download.pkmninfinitefusion.workers.dev"
def import_friend_base(friend_player_id)
base_json = fetch_base(friend_player_id)
if base_json
save_friend_base(base_json)
else
pbMessage(_INTL("The game couldn't find your friend's base. Make sure that they published it and that you wrote their trainer ID correctly."))
raise "Secret Base does not exist"
end
end
# Fetch a secret base by playerID
def fetch_base(player_id)
url = "#{SECRETBASE_DOWNLOAD_URL}/get-base?playerID=#{player_id}"
begin
response = HTTPLite.get(url)
if response[:status] == 200
echoln "[SecretBase] Downloaded base for #{player_id}"
base_json = JSON.parse(response[:body])
return base_json
else
echoln "[SecretBase] Failed with status #{response[:status]} for #{player_id}"
return nil
end
rescue MKXPError => e
echoln "[SecretBase] MKXPError: #{e.message}"
return nil
rescue Exception => e
echoln "[SecretBase] Error: #{e.message}"
return nil
end
end
def save_friend_base(new_base)
exporter = SecretBaseExporter.new
exporter.write_base_json_to_file(new_base,SecretBaseImporter::FRIEND_BASES_FILE,true)
end
end

View File

@@ -0,0 +1,54 @@
class SecretBasePublisher
def initialize()
@player_id = $Trainer.id
end
def register
if $Trainer.secretBase_uuid
echoln "Already registered!"
else
begin
payload = { playerID: @player_id }
url = "#{Settings::SECRETBASE_UPLOAD_URL}/register"
response = pbPostToString(url,payload)
echoln response
json = JSON.parse(response) rescue {}
secret_uuid = json[:secretUUID]
echoln json
$Trainer.secretBase_uuid = secret_uuid
echoln $Trainer.secretBase_uuid
Game.save
rescue Exception => e
echoln e
end
end
return $Trainer.secretBase_uuid
end
#Trainer needs to be registered before this is called
def upload_base(base_json)
secret_uuid = $Trainer.secretBase_uuid
echoln secret_uuid
unless $Trainer.secretBase_uuid
echoln "Trainer not registered!"
pbMessage(_INTL("The base could not be uploaded"))
end
payload = {
playerID: @player_id,
secretUUID: secret_uuid,
baseJSON: base_json
}
url = "#{Settings::SECRETBASE_UPLOAD_URL}/upload-base"
response = pbPostToString(url,payload)
echoln response
json = JSON.parse(response) rescue {}
json["success"] == true
end
private
end