Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add draft of resources in Client and Server #85

Merged
merged 31 commits into from
Mar 25, 2025
Merged
Changes from 1 commit
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
97ebc2c
Add draft of resources in Client and Server
EduardoLR10 Dec 10, 2024
c08f3f7
Make resources into objects
z-silver Dec 17, 2024
d4c1fbb
Make client compile
z-silver Jan 7, 2025
84c8beb
Merge branch 'master' of github.com:Dr-Nekoma/lyceum into issue-60
z-silver Jan 7, 2025
d81ed1c
Fix position type expected in the client
z-silver Jan 7, 2025
8cfda8e
Remove wrong check
z-silver Jan 7, 2025
bba1b4d
Add conversion for kinds when sending resources to client
EduardoLR10 Jan 25, 2025
ef18b24
Update resources query in Server
EduardoLR10 Jan 26, 2025
4ce2876
Introduce resource proximity + rock asset (resource)
EduardoLR10 Jan 26, 2025
cdbdee5
Merge branch 'master' of github.com:Dr-Nekoma/lyceum into issue-60
z-silver Feb 3, 2025
d064f35
Update README to note requirement on nix run command
z-silver Feb 4, 2025
6a8f700
Add new state for resource collection
z-silver Feb 4, 2025
ef589e0
Add resource collection controls and HUD on client
z-silver Feb 4, 2025
a40b6dd
Add resource management and inventory management in the BE
EduardoLR10 Feb 11, 2025
685ca3d
60: fix dialyzer
schonfinkel Feb 11, 2025
56ac0c5
Add update_inventory function to the DB
z-silver Feb 20, 2025
7a8e711
Update update_character to use update_inventory
z-silver Feb 20, 2025
48f55a5
WIP: Add map.harvest_resource procedure
z-silver Feb 20, 2025
f6ff35a
Replace faulty trigger with a procedure
z-silver Mar 3, 2025
3da99dc
WIP: start implementing the handler for resource harvesting
z-silver Mar 3, 2025
6138f3f
Finish server changes to retrieve resources and inventory
EduardoLR10 Mar 11, 2025
9faa436
Reorganize server types in client using namespaces
EduardoLR10 Mar 11, 2025
dcf1162
Add post processing into harvest query results from DB in server
EduardoLR10 Mar 11, 2025
4513e97
Add message dispatch from client to server when harvesting
EduardoLR10 Mar 11, 2025
9f454fa
Make the rock easier to mine
z-silver Mar 18, 2025
2aee089
Fix resource exhaustion
z-silver Mar 18, 2025
172112b
Fix server breakage when a resource is exhausted
z-silver Mar 18, 2025
1bde09b
Add resource harvesting to the client
z-silver Mar 18, 2025
3aaf2b4
Simplify upsert procedure as suggested in comment
z-silver Mar 25, 2025
89f289b
Remove old comment
z-silver Mar 25, 2025
6cb3330
Use less Doofenschmirtzy nomenclature
z-silver Mar 25, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
WIP: Add map.harvest_resource procedure
z-silver committed Feb 20, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
commit 48f55a5bd61316485b3629571b0457fb37151d9b
1 change: 1 addition & 0 deletions server/database/main.input.sql
Original file line number Diff line number Diff line change
@@ -15,6 +15,7 @@ VALUES ('Dolomite', 'In this world, dolomite is used as a valuable currency by t
('Great Bardook Branch', 'A tree that has been planted by the goddess Caithee.', 5),
('Sussman''s Lispy Fez', 'The magical headgear from a once great wizard.', 1);

-- Should insert into map.resource_view instead, but that's currently broken.
INSERT INTO map.object_is_resource (kind, capacity, base_extraction_amount, base_extraction_time, name, description, item_pk)
VALUES ('ROCK'::map.OBJECT_TYPE, 50, 1, 1600, 'Fluorite', 'It is blue and pretty.', 'Dolomite'),
('TREE'::map.OBJECT_TYPE, 50, 1, 1600, 'Willow', 'Likes water.', 'Great Bardook Branch');
27 changes: 26 additions & 1 deletion server/database/migrations/000005_resource.sql
Original file line number Diff line number Diff line change
@@ -31,7 +31,7 @@ NATURAL JOIN map.object_is_resource
NATURAL JOIN map.object;

CREATE OR REPLACE FUNCTION map.resource_management_view() RETURNS trigger LANGUAGE plpgsql AS $$
BEGIN
BEGIN -- FIXME
IF NEW.quantity = 0
THEN
DELETE FROM map.resource
@@ -67,3 +67,28 @@ CREATE CONSTRAINT TRIGGER object_is_resource_trigger
DEFERRABLE INITIALLY IMMEDIATE
FOR EACH ROW
EXECUTE PROCEDURE object_is_resource();


CREATE OR REPLACE PROCEDURE map.harvest_resource
(target_map_name TEXT, target_kind map.OBJECT_TYPE, target_x_position REAL, target_y_position REAL, player_name TEXT, player_e_mail TEXT, player_username TEXT)
LANGUAGE plpgsql AS
$$
DECLARE resource map.resource_view%rowtype;
delta INTEGER;
BEGIN
SELECT * INTO resource
FROM map.resource_view
WHERE map.resource_view.map_name = target_map_name
AND map.resource_view.kind = target_kind
AND map.resource_view.x_position = target_x_position
AND map.resource_view.y_position = target_y_position;
SELECT min(x) INTO delta FROM (values(resource.quantity),(resource.base_extraction_amount)) AS t(x);
UPDATE map.resource_view
SET quantity = resource.quantity - delta
WHERE map_name = target_map_name
AND kind = target_kind
AND x_position = target_x_position
AND y_position = target_y_position;
CALL character.update_inventory(player_name, player_e_mail, player_username, resource.item_pk, delta);
END;
$$;

Unchanged files with check annotations Beta

access-tokens = github.com=${{ github.token }}
- name: Install Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 41 in .github/workflows/client_build.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 41 in .github/workflows/client_build.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- name: "[Client] Build"
run: |
access-tokens = github.com=${{ github.token }}
- name: Install Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 63 in .github/workflows/server_build.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 63 in .github/workflows/server_build.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- name: "[Server] Build"
run: |
access-tokens = github.com=${{ github.token }}
- name: Install Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 31 in .github/workflows/server_deploy.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 31 in .github/workflows/server_deploy.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- name: "[Deploy] Build the new release"
run: |
access-tokens = github.com=${{ github.token }}
- name: Install Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main

Check warning on line 41 in .github/workflows/server_dialyzer.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol

Check warning on line 41 in .github/workflows/server_dialyzer.yml

GitHub Actions / Build and Test

Magic Nix Cache is deprecated

Magic Nix Cache has been deprecated due to a change in the underlying GitHub APIs and will stop working on 1 February 2025. To continue caching Nix builds in GitHub Actions, use FlakeHub Cache instead. Replace... uses: DeterminateSystems/magic-nix-cache-action@main ...with... uses: DeterminateSystems/flakehub-cache-action@main For more details: https://dtr.mn/magic-nix-cache-eol
- name: "[Server] Check Dialyzer"
run: |