Skip to content
This repository has been archived by the owner on Jun 22, 2024. It is now read-only.

Commit

Permalink
Party Viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
DrRetro2033 committed Jul 14, 2022
1 parent b731ee5 commit 48988a3
Show file tree
Hide file tree
Showing 12 changed files with 564 additions and 114 deletions.
411 changes: 334 additions & 77 deletions PartyViewer.tscn

Large diffs are not rendered by default.

5 changes: 1 addition & 4 deletions Search.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,6 @@ margin_bottom = -488.0
text = "All"
items = [ "All", null, false, 0, null, "Normal", null, false, 1, null, "Fire", null, false, 2, null, "Water", null, false, 3, null, "Grass", null, false, 4, null, "Electric", null, false, 5, null, "Ice", null, false, 6, null, "Fighting", null, false, 7, null, "Poison", null, false, 8, null, "Ground", null, false, 9, null, "Flying", null, false, 10, null, "Psychic", null, false, 11, null, "Bug", null, false, 12, null, "Rock", null, false, 13, null, "Ghost", null, false, 14, null, "Dark", null, false, 15, null, "Dragon", null, false, 16, null, "Steel", null, false, 17, null, "Fairy", null, false, 18, null ]
selected = 0
__meta__ = {
"_edit_use_anchors_": false
}

[node name="Gender" type="OptionButton" parent="Panel"]
anchor_right = 1.0
Expand All @@ -98,7 +95,7 @@ margin_top = 100.0
margin_right = -28.0
margin_bottom = -456.0
text = "All"
items = [ "All", null, false, 1, null, "Male", null, false, 0, null, "Female", null, false, 2, null, "N/A", null, false, 4, null ]
items = [ "All", null, false, 3, null, "Male", null, false, 0, null, "Female", null, false, 1, null, "N/A", null, false, 2, null ]
selected = 0
__meta__ = {
"_edit_use_anchors_": false
Expand Down
38 changes: 10 additions & 28 deletions Types.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,6 @@ script/source = "extends PopupPanel
# Declare member variables here. Examples:
# var a = 2
# var b = \"text\"
const types_def = {
1:{\"fighting\":2,\"ghost\":0},
2:{\"fire\":0.5,\"water\":2,\"grass\":0.5,\"ice\":0.5,\"ground\":2,\"bug\":0.5,\"rock\":2,\"steel\":0.5,\"fairy\":0.5},
3:{\"fire\":0.5,\"water\":0.5,\"electric\":2,\"grass\":2,\"ice\":0.5,\"steel\":0.5},
4:{\"fire\":2,\"water\":0.5,\"electric\":0.5,\"grass\":0.5,\"ice\":2,\"poison\":2,\"ground\":0.5,\"flying\":2,\"bug\":2},
5:{\"electric\":0.5,\"ground\":2,\"flying\":0.5,\"steel\":0.5},
6:{\"fire\":2,\"ice\":0.5,\"fighting\":2,\"rock\":2,\"steel\":2},
7:{\"flying\":2,\"psychic\":2,\"bug\":0.5,\"rock\":0.5,\"dark\":0.5,\"fairy\":2},
8:{\"grass\":0.5,\"fighting\":0.5,\"poison\":0.5,\"ground\":2,\"psychic\":2,\"bug\":0.5,\"fairy\":0.5},
9:{\"water\":2,\"electric\":0,\"grass\":2,\"ice\":2,\"poison\":0.5,\"rock\":0.5},
10:{\"electric\":2,\"grass\":0.5,\"ice\":2,\"fighting\":0.5,\"ground\":0,\"bug\":0.5,\"rock\":2},
11:{\"fighting\":0.5,\"psychic\":0.5,\"bug\":2,\"ghost\":2,\"dark\":2},
12:{\"fire\":2,\"grass\":0.5,\"fighting\":0.5,\"ground\":0.5,\"flying\":2,\"rock\":2},
13:{\"normal\":0.5,\"fire\":0.5,\"water\":2,\"grass\":2,\"fighting\":2,\"poison\":0.5,\"ground\":2,\"flying\":0.5,\"steel\":2},
14:{\"normal\":0,\"fighting\":0,\"poison\":0.5,\"bug\":0.5,\"ghost\":2,\"dark\":2},
15:{\"fighting\":2,\"psychic\":0,\"bug\":2,\"ghost\":0.5,\"dark\":0.5,\"fairy\":2},
16:{\"fire\":0.5,\"water\":0.5,\"electric\":0.5,\"grass\":0.5,\"ice\":2,\"dragon\":2,\"fairy\":2},
17:{\"normal\":0.5,\"fire\":2,\"grass\":0.5,\"ice\":0.5,\"fighting\":2,\"poison\":0,\"ground\":2,\"flying\":0.5,\"psychic\":0.5,\"bug\":0.5,\"rock\":0.5,\"dragon\":0.5,\"steel\":0.5,\"fairy\":0.5},
18:{\"fighting\":0.5,\"poison\":2,\"bug\":0.5,\"dragon\":0,\"dark\":0.5,\"steel\":2}
}

# Called when the node enters the scene tree for the first time.
func _ready():
Expand All @@ -41,14 +21,14 @@ func setChart(type1,type2):
for child in $HBoxContainer/Multipliers.get_children():
child.text = \"1\"
child.visible = false
var type1_interactions = types_def[type1]
var type1_interactions = Pokemon.types_def[type1]
print(type1_interactions.keys())
for key in type1_interactions.keys():
$HBoxContainer/Rows.get_node(key.capitalize()).visible = true
$HBoxContainer/Multipliers.get_node(key.capitalize()).visible = true
$HBoxContainer/Multipliers.get_node(key.capitalize()).text = str(int($HBoxContainer/Multipliers.get_node(key.capitalize()).text)*type1_interactions[key])
if type2 != 0:
var type2_interactions = types_def[type2]
var type2_interactions = Pokemon.types_def[type2]
for key in type2_interactions.keys():
$HBoxContainer/Rows.get_node(key.capitalize()).visible = true
$HBoxContainer/Multipliers.get_node(key.capitalize()).visible = true
Expand Down Expand Up @@ -201,10 +181,10 @@ script = SubResource( 20 )
[node name="HBoxContainer" type="HBoxContainer" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 16.0
margin_top = 16.0
margin_right = -16.0
margin_bottom = -16.0
margin_left = 4.0
margin_top = 4.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
size_flags_vertical = 3

Expand Down Expand Up @@ -848,8 +828,10 @@ align = 1
visible = false
anchor_right = 1.0
anchor_bottom = 1.0
margin_left = 56.0
margin_top = 29.0
margin_left = 4.0
margin_top = 4.0
margin_right = -4.0
margin_bottom = -4.0
size_flags_horizontal = 3
size_flags_vertical = 3
columns = 18
1 change: 1 addition & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ Pokemon="*res://scripts/Pokemon.gd"
Trainer="*res://scripts/Trainer.gd"
PokemonShowdown="*res://scripts/pokemon_showdown.gd"
PM="*res://scripts/PM.gd"
Trading="*res://scripts/Trading.gd"

[display]

Expand Down
15 changes: 11 additions & 4 deletions scenes/Bank.tscn
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[gd_scene load_steps=26 format=2]
[gd_scene load_steps=27 format=2]

[ext_resource path="res://Menu.tscn" type="PackedScene" id=1]
[ext_resource path="res://Panel.tscn" type="PackedScene" id=2]
Expand All @@ -18,6 +18,7 @@
[ext_resource path="res://box.png" type="Texture" id=16]
[ext_resource path="res://Folder_Icon.png" type="Texture" id=17]
[ext_resource path="res://box_top.png" type="Texture" id=18]
[ext_resource path="res://scenes/Trading.tscn" type="PackedScene" id=19]

[sub_resource type="DynamicFont" id=11]
font_data = ExtResource( 7 )
Expand All @@ -30,6 +31,7 @@ var text = {
\"api\":\"Fetching info from the web...\",
\"reading\":\"Reading bank file...\",
\"layout\":\"Organizing the bank...\",
\"welcome\":\"Welcome to Pokémon Manager!\"
}

func _ready():
Expand All @@ -40,6 +42,8 @@ func switch(x):
$Label.text = text[x]

func finised():
$Label.text = text[\"welcome\"]
$ProgressBar.visible = false
$Control/AnimationPlayer.play(\"Finished\")
yield($Control/AnimationPlayer,\"animation_finished\")
$WalkingPokemon.visible = false
Expand Down Expand Up @@ -457,8 +461,8 @@ __meta__ = {
[node name="Control" type="Control" parent="Loading Screen"]
anchor_right = 1.0
anchor_bottom = 1.0
margin_right = 17408.0
margin_bottom = 10200.0
margin_right = 25600.0
margin_bottom = 15000.0
[node name="Sprite" type="Sprite" parent="Loading Screen/Control"]
position = Vector2( 512, 256 )
Expand Down Expand Up @@ -513,7 +517,7 @@ anchor_bottom = 1.0
[node name="PopupMenu" type="PopupMenu" parent="."]
margin_right = 88.0
margin_bottom = 128.0
items = [ "Box", null, 0, false, true, -1, 0, null, "", true, "Add a new box", null, 0, false, false, 0, 0, null, "", false, "Remove this box", null, 0, false, true, 5, 0, null, "", false, "Rename box", null, 0, false, false, 1, 0, null, "", false, "Copy box to clipboard", null, 0, false, false, 2, 0, null, "", false, "Pokémon", null, 0, false, true, -1, 0, null, "", true, "Search for Pokémon", null, 0, false, false, 2, 0, null, "", false, "Manage parties", null, 0, false, false, 3, 0, null, "", false ]
items = [ "Box", null, 0, false, true, -1, 0, null, "", true, "Add a new box", null, 0, false, false, 0, 0, null, "", false, "Remove this box", null, 0, false, true, 5, 0, null, "", false, "Rename box", null, 0, false, false, 1, 0, null, "", false, "Copy box to clipboard", null, 0, false, false, 4, 0, null, "", false, "Pokémon", null, 0, false, true, -1, 0, null, "", true, "Search for Pokémon", null, 0, false, false, 2, 0, null, "", false, "Manage parties", null, 0, false, false, 3, 0, null, "", false, "Trade with someone else", null, 0, false, false, 6, 0, null, "", false ]
script = ExtResource( 10 )
[node name="Rename" type="PopupDialog" parent="."]
Expand Down Expand Up @@ -667,6 +671,9 @@ visible = false
[node name="Panel" parent="." instance=ExtResource( 2 )]
visible = false
[node name="Trade" parent="." instance=ExtResource( 19 )]
visible = false
[node name="Menu" parent="." instance=ExtResource( 1 )]
visible = false
Expand Down
6 changes: 6 additions & 0 deletions scenes/NetworkTrainer.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://scripts/NetworkTrainer.gd" type="Script" id=1]

[node name="NetworkTrainer" type="Node"]
script = ExtResource( 1 )
71 changes: 71 additions & 0 deletions scenes/Trading.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
[gd_scene load_steps=2 format=2]

[ext_resource path="res://scripts/TradeScreen.gd" type="Script" id=1]

[node name="Trade" type="Panel"]
anchor_right = 1.0
anchor_bottom = 1.0
script = ExtResource( 1 )

[node name="Trainer" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0

[node name="RichTextLabel" type="RichTextLabel" parent="Trainer"]
anchor_left = 0.382813
anchor_top = 0.28
anchor_right = 0.617188
anchor_bottom = 0.72
margin_bottom = -3.05176e-05
__meta__ = {
"_edit_use_anchors_": true
}

[node name="Connecting" type="Panel" parent="."]
anchor_right = 1.0
anchor_bottom = 1.0

[node name="Create_Server" type="Button" parent="Connecting"]
anchor_left = 0.382813
anchor_top = 0.48
anchor_right = 0.492188
anchor_bottom = 0.52
text = "Create server"
__meta__ = {
"_edit_use_anchors_": true
}

[node name="Join_Server" type="Button" parent="Connecting"]
anchor_left = 0.507813
anchor_top = 0.48
anchor_right = 0.617188
anchor_bottom = 0.52
text = "Join Server"
__meta__ = {
"_edit_use_anchors_": true
}

[node name="IP_Address" type="LineEdit" parent="Connecting"]
anchor_left = 0.382813
anchor_top = 0.526667
anchor_right = 0.617188
anchor_bottom = 0.566667
align = 1
placeholder_text = "Enter IP Address"
__meta__ = {
"_edit_use_anchors_": true
}

[node name="Label" type="Label" parent="Connecting"]
anchor_left = 0.382813
anchor_top = 0.44
anchor_right = 0.617188
anchor_bottom = 0.473333
__meta__ = {
"_edit_use_anchors_": true
}

[node name="Trainers" type="Node" parent="."]

[connection signal="pressed" from="Connecting/Create_Server" to="." method="_on_Create_Server_pressed"]
[connection signal="pressed" from="Connecting/Join_Server" to="." method="_on_Join_Server_pressed"]
16 changes: 16 additions & 0 deletions scripts/NetworkTrainer.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
extends Node


# Declare member variables here. Examples:
# var a = 2
# var b = "text"
puppet var profile_pic = null
puppet var profile_name = ""

func _ready():
pass # Replace with function body.


# Called every frame. 'delta' is the elapsed time since the previous frame.
#func _process(delta):
# pass
28 changes: 27 additions & 1 deletion scripts/Pokemon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,32 @@ const rates = {
68116
]
}
const types_def = {
1:{"fighting":2,"ghost":0},
2:{"fire":0.5,"water":2,"grass":0.5,"ice":0.5,"ground":2,"bug":0.5,"rock":2,"steel":0.5,"fairy":0.5},
3:{"fire":0.5,"water":0.5,"electric":2,"grass":2,"ice":0.5,"steel":0.5},
4:{"fire":2,"water":0.5,"electric":0.5,"grass":0.5,"ice":2,"poison":2,"ground":0.5,"flying":2,"bug":2},
5:{"electric":0.5,"ground":2,"flying":0.5,"steel":0.5},
6:{"fire":2,"ice":0.5,"fighting":2,"rock":2,"steel":2},
7:{"flying":2,"psychic":2,"bug":0.5,"rock":0.5,"dark":0.5,"fairy":2},
8:{"grass":0.5,"fighting":0.5,"poison":0.5,"ground":2,"psychic":2,"bug":0.5,"fairy":0.5},
9:{"water":2,"electric":0,"grass":2,"ice":2,"poison":0.5,"rock":0.5},
10:{"electric":2,"grass":0.5,"ice":2,"fighting":0.5,"ground":0,"bug":0.5,"rock":2},
11:{"fighting":0.5,"psychic":0.5,"bug":2,"ghost":2,"dark":2},
12:{"fire":2,"grass":0.5,"fighting":0.5,"ground":0.5,"flying":2,"rock":2},
13:{"normal":0.5,"fire":0.5,"water":2,"grass":2,"fighting":2,"poison":0.5,"ground":2,"flying":0.5,"steel":2},
14:{"normal":0,"fighting":0,"poison":0.5,"bug":0.5,"ghost":2,"dark":2},
15:{"fighting":2,"psychic":0,"bug":2,"ghost":0.5,"dark":0.5,"fairy":2},
16:{"fire":0.5,"water":0.5,"electric":0.5,"grass":0.5,"ice":2,"dragon":2,"fairy":2},
17:{"normal":0.5,"fire":2,"grass":0.5,"ice":0.5,"fighting":2,"poison":0,"ground":2,"flying":0.5,"psychic":0.5,"bug":0.5,"rock":0.5,"dragon":0.5,"steel":0.5,"fairy":0.5},
18:{"fighting":0.5,"poison":2,"bug":0.5,"dragon":0,"dark":0.5,"steel":2}
}
const types_atk = {
"normal":[13,14,17],
"fire":[2,3,4,6,12,16],
"water":[2,3,4,9,16],
"grass":[2,3,4]
}
enum {
# Pokémon Sapphire (GBA)
S = 1,
Expand Down Expand Up @@ -700,7 +726,7 @@ func search(search):
if pokemon[x]["type2"] != search["type2"]:
print("Erased "+x+" because of "+str(pokemon[x]["type2"]))
results.erase(x)
if search["gender"] != 1:
if search["gender"] != 3:
var ids = results.duplicate()
for x in ids:
if pokemon[x]["gender"] != search["gender"]:
Expand Down
2 changes: 2 additions & 0 deletions scripts/RightClickMenu.gd
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ func _on_PopupMenu_id_pressed(id):
if tab.isEmpty():
tabs.remove_child(tab)
tab.queue_free()
6:
$"../Trade".visible = true

func _on_PopupMenu_about_to_show():
var tab = tabs.get_tab_control(tabs.current_tab)
Expand Down
53 changes: 53 additions & 0 deletions scripts/TradeScreen.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
extends Panel


# Declare member variables here. Examples:
# var a = 2
# var b = "text"

var new_trainer = load("res://scenes/NetworkTrainer.tscn")
# Called when the node enters the scene tree for the first time.
func _ready():
get_tree().connect("network_peer_connected", self,"_player_connected")
get_tree().connect("network_peer_disconnected", self,"_player_disconnected")
get_tree().connect("connected_to_server", self, "_connected_to_server")
$Connecting/Label.text = Trading.ip_address

func _player_connected(id) -> void:
instance_trainer({"name":Trainer.trainer_name,"pic":Trainer.trainer_picture},id)
print("Player "+str(id)+" has connected")

func _player_disconnected(id) -> void:
print("Player "+str(id)+" has disconnected")

func _connected_to_server() -> void:
instance_trainer({"name":Trainer.trainer_name,"pic":Trainer.trainer_picture},get_tree().get_network_unique_id())

func _on_Create_Server_pressed():
$Connecting.visible = false
Trading.create_server()
instance_trainer({"name":Trainer.trainer_name,"pic":Trainer.trainer_picture},get_tree().get_network_unique_id())


func _on_Join_Server_pressed():
if $Connecting/IP_Address.text != "":
$Connecting.visible = false
Trading.ip_address = $Connecting/IP_Address.text
Trading.join_server()

func instance_trainer(info,id):
var trainer_instance = new_trainer.instance()
print("Player "+str(info["name"])+" has connected")
trainer_instance.profile_name = info["name"]
trainer_instance.profile_pic = info["pic"]
trainer_instance.set_network_master(id)
$Trainers.add_child(trainer_instance)
listTrainers()

func listTrainers():
var text = ""
print(get_tree().get_network_connected_peers())
for trainer in get_tree().get_network_connected_peers():
var node = get_node(str(trainer))
text += node.profile_name+"\n"
$Trainer/RichTextLabel.text = text
32 changes: 32 additions & 0 deletions scripts/Trading.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
extends Node

const DEFAULT_PORT = 28960
const MAX_CLIENTS = 2

var server = null
var client = null

var ip_address = ""
# Called when the node enters the scene tree for the first time.
func _ready():
for ip in IP.get_local_addresses():
if ip.begins_with("192.168."):
ip_address = ip
get_tree().connect("connected_to_server", self, "_connected_to_server")
get_tree().connect("server_disconnected", self, "_server_disconnected")

func create_server() -> void:
server = NetworkedMultiplayerENet.new()
server.create_server(DEFAULT_PORT, MAX_CLIENTS)
get_tree().set_network_peer(server)

func join_server() -> void:
client = NetworkedMultiplayerENet.new()
client.create_client(ip_address, DEFAULT_PORT)
get_tree().set_network_peer(client)

func _connect_to_server() -> void:
print("Successfully connected to the server")

func _server_disconnected() -> void:
print("Disconnected from the server")

0 comments on commit 48988a3

Please sign in to comment.