mirror of
https://github.com/infinitefusion/infinitefusion-e18.git
synced 2025-12-06 06:01:46 +00:00
Basic online wondertrade system
This commit is contained in:
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -6,7 +6,7 @@
|
||||
module Settings
|
||||
# The version of your game. It has to adhere to the MAJOR.MINOR.PATCH format.
|
||||
GAME_VERSION = '5.0.0'
|
||||
GAME_VERSION_NUMBER = "5.1.0.1"
|
||||
GAME_VERSION_NUMBER = "5.1.0.3"
|
||||
|
||||
POKERADAR_LIGHT_ANIMATION_RED_ID = 17
|
||||
POKERADAR_LIGHT_ANIMATION_GREEN_ID = 18
|
||||
@@ -46,6 +46,9 @@ module Settings
|
||||
ZAPMOLCUNO_NB = 176821
|
||||
MAPS_WITHOUT_SURF_MUSIC = [762]
|
||||
|
||||
WONDERTRADE_BASE_URL = "http://localhost:8080"
|
||||
WONDERTRADE_PUBLIC_KEY = "http://localhost:8080"
|
||||
|
||||
# The generation that the battle system follows. Used throughout the battle
|
||||
# scripts, and also by some other settings which are used in and out of battle
|
||||
# (you can of course change those settings to suit your game).
|
||||
|
||||
8
Data/Scripts/050_AddOns/HttpCalls.rb
Normal file
8
Data/Scripts/050_AddOns/HttpCalls.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
|
||||
def test_http_get
|
||||
url = "http://localhost:8080"
|
||||
response = HTTPLite.get(url)
|
||||
if response[:status] == 200
|
||||
p response[:body]
|
||||
end
|
||||
end
|
||||
@@ -125,7 +125,7 @@ end
|
||||
class GenOneStyle
|
||||
|
||||
def initialize
|
||||
Kernel.pbDisplayText("Controls: F1", 80, 0, 99999)
|
||||
Kernel.pbDisplayText("Keybindings: F1", 80, 0, 99999)
|
||||
Kernel.pbDisplayText("Version " + Settings::GAME_VERSION_NUMBER, 254, 308, 99999)
|
||||
|
||||
@maxPoke = 140 #1st gen, pas de legend la premiere fois, graduellement plus de poke
|
||||
|
||||
65
Data/Scripts/050_AddOns/OnlineWondertrade.rb
Normal file
65
Data/Scripts/050_AddOns/OnlineWondertrade.rb
Normal file
@@ -0,0 +1,65 @@
|
||||
class OnlineWondertrade
|
||||
|
||||
|
||||
|
||||
def pbWonderTrade()
|
||||
givenPokemon = selectPokemonToGive
|
||||
return if givenPokemon == nil
|
||||
queryBody = buildWondertradeQueryJson(givenPokemon)
|
||||
begin
|
||||
response = HTTPLite.post_body(Settings::WONDERTRADE_BASE_URL + "/wondertrade", queryBody, "application/json")
|
||||
if response[:status] == 200
|
||||
body = HTTPLite::JSON.parse(response[:body])
|
||||
doTrade(body)
|
||||
end
|
||||
rescue MKXPError
|
||||
pbMessage("There was an error while sending your Pokémon...")
|
||||
end
|
||||
end
|
||||
|
||||
def doTrade(receivedData)
|
||||
receivedPokemonSpecies = receivedData["pokemon_species"].to_sym
|
||||
receivedPokemonLevel = receivedData["level"].to_i
|
||||
receivedPokemonName = receivedData["nickname"]
|
||||
receivedPokemonOT = receivedData["original_trainer_name"]
|
||||
receivedPokemonTrainerId = receivedData["trainer_id"]
|
||||
receivedPokemonTrainerName = receivedData["trainer_name"]
|
||||
receivedPokemonTrainerGender = receivedData["trainer_gender"].to_i
|
||||
|
||||
newpoke = pbStartTrade(pbGet(1), receivedPokemonSpecies, receivedPokemonName, receivedPokemonTrainerName, receivedPokemonTrainerGender, true) # Starts the trade
|
||||
newpoke.owner=Pokemon::Owner.new(receivedPokemonTrainerId.to_i,receivedPokemonOT,2,2)
|
||||
newpoke.level=receivedPokemonLevel
|
||||
newpoke.calc_stats
|
||||
end
|
||||
|
||||
def selectPokemonToGive
|
||||
pbChoosePokemon(1, 2, # Choose eligable pokemon
|
||||
proc {
|
||||
|poke| !poke.egg? && !(poke.isShadow?)
|
||||
})
|
||||
poke = $Trainer.party[pbGet(1)]
|
||||
|
||||
if pbConfirmMessage(_INTL("Trade {1} away?", poke.name))
|
||||
return poke
|
||||
end
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
# @param [Pokemon] givenPokemon
|
||||
def buildWondertradeQueryJson(givenPokemon)
|
||||
postData = {
|
||||
"trainer_name" => $Trainer.name,
|
||||
"trainer_gender" => $Trainer.gender,
|
||||
"trainer_id" => $Trainer.id.to_s,
|
||||
"nb_badges" => $Trainer.badge_count,
|
||||
"given_pokemon" => givenPokemon.species.to_s,
|
||||
"level" => givenPokemon.level,
|
||||
"nickname" => givenPokemon.name,
|
||||
"original_trainer_name" => givenPokemon.owner.name,
|
||||
"original_trainer_id" => givenPokemon.owner.id.to_s,
|
||||
}
|
||||
return HTTPLite::JSON.stringify(postData)
|
||||
end
|
||||
|
||||
end
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -1,6 +1,7 @@
|
||||
Thank you for downloading Pok<6F>mon Infinite Fusion!
|
||||
|
||||
Use Game.exe to play the game.
|
||||
Use Pokemon Infinite Fusion.exe to play the game.
|
||||
If you are experiencing issues such as long loading times, you can also try the alternate launcher.
|
||||
|
||||
##########################################################################################################################################
|
||||
INFINITE FUSION 5.0
|
||||
|
||||
Reference in New Issue
Block a user