Skip to content

Commit

Permalink
Merge pull request #6 from TopDownSurvival-Dev-Team/main
Browse files Browse the repository at this point in the history
0.6-beta build
  • Loading branch information
MysteryCoder456 authored Nov 8, 2021
2 parents 950b34f + a3d3e0d commit c07727e
Show file tree
Hide file tree
Showing 31 changed files with 1,043 additions and 1,043 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/release-beta.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: "Release Beta"

env:
GODOT_VERSION: 3.3.4
GODOT_VERSION: 3.4
CLIENT_PATH: "Top Down Survival"
SERVER_PATH: "Top Down Survival Server"

Expand All @@ -20,7 +20,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: barichello/godot-ci:3.3.4
image: barichello/godot-ci:3.4

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: barichello/godot-ci:3.3.4
image: barichello/godot-ci:3.4

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
Expand All @@ -109,7 +109,7 @@ jobs:
run: |
mkdir -v -p "${SERVER_PATH}/exports"
cd "${SERVER_PATH}"
godot -v --export "MacOS" exports/MacOS.dmg
godot -v --export "MacOS" exports/MacOS.zip
- name: Windows Build
run: |
Expand All @@ -132,7 +132,7 @@ jobs:
CHANNEL: "macos-server-beta"
ITCH_GAME: "top-down-survival"
ITCH_USER: "mysterycoder456"
PACKAGE: "Top Down Survival Server/exports/MacOS.dmg"
PACKAGE: "Top Down Survival Server/exports/MacOS.zip"
VERSION_FILE: "version.txt"

- name: Publish Windows Build
Expand Down
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Client",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}/Top Down Survival",
"port": 6009,
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false
},
{
"name": "Debug Server",
"type": "godot",
"request": "launch",
"project": "${workspaceFolder}/Top Down Survival Server",
"port": 6010,
"address": "127.0.0.1",
"launch_game_instance": true,
"launch_scene": false
}
]
}
16 changes: 11 additions & 5 deletions Top Down Survival Server/export_presets.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ script_encryption_key=""
custom_template/debug=""
custom_template/release=""
application/name="Top Down Survival Server"
application/info="0.5-beta"
application/info="0.6-beta"
application/icon="res://icon.png"
application/identifier="com.mysterycoder456.top-down-survival-server"
application/signature=""
application/short_version="0.5"
application/version="0.5-beta"
application/app_category="Games"
application/short_version="0.6"
application/version="0.6-beta"
application/copyright=""
display/high_res=false
privacy/camera_usage_description=""
Expand All @@ -43,6 +44,7 @@ codesign/entitlements/address_book=false
codesign/entitlements/calendars=false
codesign/entitlements/photos_library=false
codesign/entitlements/apple_events=false
codesign/entitlements/debugging=false
codesign/entitlements/app_sandbox/enabled=false
codesign/entitlements/app_sandbox/network_server=false
codesign/entitlements/app_sandbox/network_client=false
Expand All @@ -53,6 +55,10 @@ codesign/entitlements/app_sandbox/files_pictures=0
codesign/entitlements/app_sandbox/files_music=0
codesign/entitlements/app_sandbox/files_movies=0
codesign/custom_options=PoolStringArray( )
notarization/enable=false
notarization/apple_id_name=""
notarization/apple_id_password=""
notarization/apple_team_id=""
texture_format/s3tc=true
texture_format/etc=false
texture_format/etc2=false
Expand Down Expand Up @@ -90,8 +96,8 @@ codesign/digest_algorithm=1
codesign/description=""
codesign/custom_options=PoolStringArray( )
application/icon="res://icon.png"
application/file_version="0.5-beta"
application/product_version="0.5-beta"
application/file_version="0.6-beta"
application/product_version="0.6-beta"
application/company_name="MysteryCoder456"
application/product_name="Top Down Survival Server"
application/file_description="Multiplayer Survival Game"
Expand Down
16 changes: 0 additions & 16 deletions Top Down Survival Server/publish-beta.sh

This file was deleted.

12 changes: 3 additions & 9 deletions Top Down Survival Server/src/scenes/World.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,15 @@
[ext_resource path="res://src/scripts/ChatBox.gd" type="Script" id=2]
[ext_resource path="res://src/scripts/Inventory.gd" type="Script" id=3]

[node name="World" type="Node2D" groups=[
"World",
]]
[node name="World" type="Node2D" groups=["World"]]
script = ExtResource( 1 )

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

[node name="ChatBox" type="Node" parent="HUD" groups=[
"Chat Box",
]]
[node name="ChatBox" type="Node" parent="HUD" groups=["Chat Box"]]
script = ExtResource( 2 )

[node name="Inventory" type="Node" parent="HUD" groups=[
"Inventory",
]]
[node name="Inventory" type="Node" parent="HUD" groups=["Inventory"]]
script = ExtResource( 3 )

[node name="Players" type="Node" parent="."]
Expand Down
40 changes: 20 additions & 20 deletions Top Down Survival Server/src/scripts/ChatBox.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ extends Node


func _ready():
Network.connect("player_joined_game", self, "send_join_message")
Network.connect("player_left_game", self, "send_leave_message")
Network.connect("player_joined_game", self, "send_join_message")
Network.connect("player_left_game", self, "send_leave_message")


remote func send_message_s(message_text: String):
var sender_id = get_tree().get_rpc_sender_id()
var sender = Network.players[sender_id]["username"]
var message_text_formatted = message_text.strip_edges()
if not message_text_formatted.empty():
rpc("add_message", message_text_formatted, sender, "FFFFFF")
var sender_id = get_tree().get_rpc_sender_id()
var sender = Network.players[sender_id]["username"]
var message_text_formatted = message_text.strip_edges()

if not message_text_formatted.empty():
rpc("add_message", message_text_formatted, sender, "FFFFFF")


func send_join_message(player_id: int):
var player_name = Network.players[player_id]["username"]
var message_text = player_name + " has joined the game!"
rpc("add_message", message_text, "Server", "F7E65E")
var player_name = Network.players[player_id]["username"]
var message_text = player_name + " has joined the game!"
rpc("add_message", message_text, "Server", "F7E65E")


func send_leave_message(player_id: int):
var player_name = Network.players[player_id]["username"]
var message_text = player_name + " disconnected from the game!"
rpc("add_message", message_text, "Server", "F7E65E")
var player_name = Network.players[player_id]["username"]
var message_text = player_name + " disconnected from the game!"
rpc("add_message", message_text, "Server", "F7E65E")
166 changes: 83 additions & 83 deletions Top Down Survival Server/src/scripts/Database.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,94 +7,94 @@ var db = SQLite.new()


func _ready():
init_db()
create_tables()
init_db()
create_tables()


func init_db():
db.path = DB_PATH
db.open_db()
db.path = DB_PATH
db.open_db()


func create_tables():
# Inventory Table
db.query("""
CREATE TABLE IF NOT EXISTS inventories (
player_uid TEXT NOT NULL,
item_id TEXT NOT NULL,
quantity INTEGER NOT NULL DEFAULT 1
)
""")
db.query("""
CREATE TABLE IF NOT EXISTS world (
entity_type TEXT NOT NULL,
x_position INTEGER NOT NULL,
y_position INTEGER NOT NULL,
entity_info TEXT NOT NULL DEFAULT "{}"
)
""")
# Inventory Table
db.query("""
CREATE TABLE IF NOT EXISTS inventories (
player_uid TEXT NOT NULL,
item_id TEXT NOT NULL,
quantity INTEGER NOT NULL DEFAULT 1
)
""")

db.query("""
CREATE TABLE IF NOT EXISTS world (
entity_type TEXT NOT NULL,
x_position INTEGER NOT NULL,
y_position INTEGER NOT NULL,
entity_info TEXT NOT NULL DEFAULT "{}"
)
""")


func get_world_data() -> Array:
var world_data = []
db.query("SELECT * FROM world")
for entity_data in db.query_result:
var data = {
"entity_type": entity_data["entity_type"],
"position": Vector2(entity_data["x_position"], entity_data["y_position"]),
"entity_info": parse_json(entity_data["entity_info"])
}
world_data.append(data)
return world_data
var world_data = []
db.query("SELECT * FROM world")

for entity_data in db.query_result:
var data = {
"entity_type": entity_data["entity_type"],
"position": Vector2(entity_data["x_position"], entity_data["y_position"]),
"entity_info": parse_json(entity_data["entity_info"])
}
world_data.append(data)

return world_data


func save_world_data(world_data: Array):
db.query("DELETE FROM world")
for entity_data in world_data:
var entity_type = entity_data["entity_type"]
var position = entity_data["position"]
var entity_info = to_json(entity_data["entity_info"])
db.query("""
INSERT INTO world VALUES ('%s', %s, %s, '%s')
""" % [entity_type, position.x, position.y, entity_info])
db.query("DELETE FROM world")

for entity_data in world_data:
var entity_type = entity_data["entity_type"]
var position = entity_data["position"]
var entity_info = to_json(entity_data["entity_info"])

db.query("""
INSERT INTO world VALUES ('%s', %s, %s, '%s')
""" % [entity_type, position.x, position.y, entity_info])


func get_inventory(player_uid: String) -> Array:
db.query("""
SELECT item_id, quantity
FROM inventories
WHERE player_uid = \"%s\"
""" % player_uid)
return db.query_result
db.query("""
SELECT item_id, quantity
FROM inventories
WHERE player_uid = \"%s\"
""" % player_uid)
return db.query_result


func create_new_item(player_uid: String, item_id: String, quantity: int):
db.query("""
INSERT INTO inventories (player_uid, item_id, quantity)
VALUES (\"%s\", \"%s\", %s)
""" % [player_uid, item_id, quantity])
db.query("""
INSERT INTO inventories (player_uid, item_id, quantity)
VALUES (\"%s\", \"%s\", %s)
""" % [player_uid, item_id, quantity])


func get_item_quantity(player_uid: String, item_id: String): # int or null
db.query("""
SELECT quantity
FROM inventories
WHERE player_uid = \"%s\" AND item_id = \"%s\"
""" % [player_uid, item_id])
if db.query_result:
return db.query_result[0]["quantity"]
return null
db.query("""
SELECT quantity
FROM inventories
WHERE player_uid = \"%s\" AND item_id = \"%s\"
""" % [player_uid, item_id])

if db.query_result:
return db.query_result[0]["quantity"]
return null


func set_item_quantity(player_uid: String, item_id: String, quantity: int):
db.query("""
UPDATE inventories
SET quantity = %s
WHERE player_uid = \"%s\" AND item_id = \"%s\"
""" % [quantity, player_uid, item_id])
db.query("""
UPDATE inventories
SET quantity = %s
WHERE player_uid = \"%s\" AND item_id = \"%s\"
""" % [quantity, player_uid, item_id])
Loading

0 comments on commit c07727e

Please sign in to comment.