Skip to content
This repository was archived by the owner on Feb 7, 2025. It is now read-only.

Feat/farm #114

Closed
wants to merge 66 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
66 commits
Select commit Hold shift + click to select a range
b958cb3
make initial empty godot project
boscohyun Dec 19, 2023
e66f929
push initial main_scene
boscohyun Dec 19, 2023
424e98a
add several scenes
boscohyun Dec 19, 2023
0e54ce7
remove main_scene and update project settings
boscohyun Dec 19, 2023
21b4001
Merge pull request #91 from not-blond-beard/feat/update-scenes
boscohyun Dec 19, 2023
ff0b490
Migrage use item & planting seed (#92)
Atralupus Dec 19, 2023
fe4f938
implement intro scene
boscohyun Dec 19, 2023
3976ef8
implement select_village scene
boscohyun Dec 19, 2023
3cd32d8
remove useless main scene
boscohyun Dec 19, 2023
98eee57
Merge pull request #93 from not-blond-beard/feat/implement-intro-and-…
boscohyun Dec 19, 2023
224e924
add temporary resource for village background nine patch image
sonohoshi Dec 19, 2023
837e084
add temporary VillageView scene
sonohoshi Dec 19, 2023
570404d
Implement signer
moreal Dec 19, 2023
3dc19e0
Merge pull request #94 from moreal/signer
moreal Dec 19, 2023
94df9dc
오늘 배운거: gdscript는 오버로드가 안된다
sonohoshi Dec 19, 2023
040b8e2
SVR-207 Implement gql client (#95)
Atralupus Dec 20, 2023
c9721e0
Add config (#97)
Atralupus Dec 20, 2023
a4d6866
temporary VillageView implement
sonohoshi Dec 20, 2023
d9f6382
real temp village view using example
sonohoshi Dec 20, 2023
14e2a27
진짜 집들까지 인자로 받게 했음
sonohoshi Dec 20, 2023
bcf6099
Merge pull request #98 from not-blond-beard/feature/village-view
boscohyun Dec 20, 2023
13cf0ab
Implement gql client (re) (#99)
Atralupus Dec 20, 2023
7153bb3
move scripts
boscohyun Dec 20, 2023
ed52c32
autoload scene_context
boscohyun Dec 20, 2023
e90160f
change scene to village_view from select_village
boscohyun Dec 20, 2023
24a5544
Merge pull request #100 from not-blond-beard/feat/load-village-view-t…
boscohyun Dec 20, 2023
455bf4e
add GodotGraphQL as submodule
boscohyun Dec 20, 2023
bfc3434
fix GraphQL endpoint
boscohyun Dec 20, 2023
1afdc52
query villages
boscohyun Dec 20, 2023
329cf9d
Merge pull request #101 from not-blond-beard/feat/bind-villages
boscohyun Dec 20, 2023
1559ca1
add sprites directory
sonohoshi Dec 20, 2023
b4879f3
reflect moved resource path
sonohoshi Dec 20, 2023
bddd3d6
집을 생성해서 설치해보았음
sonohoshi Dec 20, 2023
dc35cbb
마을 사이즈/위치 리셋, 집 위치 설정
sonohoshi Dec 20, 2023
21a3b34
separate select_village_village_button scene
boscohyun Dec 20, 2023
46910c3
bind real villages
boscohyun Dec 20, 2023
37ef65a
Merge pull request #102 from not-blond-beard/feat/bind-villages
boscohyun Dec 20, 2023
c7ba817
하여튼 뭔가 마을을 스크롤 할 수 있게 됐습니다
sonohoshi Dec 20, 2023
46ab8bc
Add LifeStone item, IsSuperFood property, and UseLifeStoneAction
eseiker Dec 20, 2023
a689dd1
Add exception handlings & tests for UseLifeStoneAction
eseiker Dec 20, 2023
3fd2663
Fix UseLifeStoneActionTests
eseiker Dec 20, 2023
2c08f3d
Implement Inventory
moreal Dec 20, 2023
eb66d96
Merge pull request #96 from eseiker/feat/use-lifestone-action
eseiker Dec 20, 2023
8784f73
Add userState grqphql query
eseiker Dec 20, 2023
7968caa
피봇 설정이 잘 안먹혀서 적당히 피봇 맞춰서 잘 집을 설치해주었어요
sonohoshi Dec 20, 2023
dab47c7
Merge pull request #103 from not-blond-beard/feature/village-view-detail
sonohoshi Dec 20, 2023
1b2e45e
Merge pull request #105 from eseiker/query-userstate
eseiker Dec 20, 2023
c4fb52d
Merge pull request #104 from moreal/inventory
moreal Dec 20, 2023
76f3d86
(0, 0) 좌표가 어딘지 모르겠어서 표시용으로 뭐 하나를 추가했습니다...
sonohoshi Dec 20, 2023
8117a49
give seeds and kitchenequips to user for demo purpose
eseiker Dec 21, 2023
5dc5cb1
Merge pull request #106 from eseiker/demo-god-user
eseiker Dec 21, 2023
63c630c
클릭한 곳을 마을 기준 좌표로 어딘지 x, y를 찍게 만들었어요
sonohoshi Dec 21, 2023
195d736
마우스 좌표를 bg 오브젝트 기준으로 변경
sonohoshi Dec 21, 2023
24ec657
이번엔 진짜로 좌표 설정 똑바로 됩니다 스크롤해도 됨
sonohoshi Dec 21, 2023
59a2488
커맨드나 컨트롤 키를 같이 눌러야 로그가 찍히게 해놨습니다 제대로 된 인풋 조건 필터링이 어렵네요...
sonohoshi Dec 21, 2023
8d16958
Merge pull request #107 from not-blond-beard/feature/build-house
sonohoshi Dec 21, 2023
54054c4
implement farm #1
boscohyun Dec 21, 2023
e9cee0a
add Signer.signer_address
boscohyun Dec 21, 2023
bc0ea49
query userState
boscohyun Dec 21, 2023
d969775
Merge pull request #108 from not-blond-beard/feat/farm
boscohyun Dec 21, 2023
9576f5a
place house gql(real) (#109)
sonohoshi Dec 21, 2023
a28efc6
Fix initial seeding in PlaceUserHouseAction (#110)
eseiker Dec 21, 2023
8e12c32
query villageState with userState
boscohyun Dec 21, 2023
1ca9349
remove useless
boscohyun Dec 21, 2023
47651b3
wip
boscohyun Dec 21, 2023
2b80b6b
Merge branch 'main' into feat/farm
Atralupus Jan 14, 2024
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
25 changes: 25 additions & 0 deletions backend/app/Savor22b.Tests/Action/PlaceUserHouseActionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ namespace Savor22b.Tests.Action;
using Savor22b.Constants;
using Libplanet.Assets;
using Savor22b.Action.Exceptions;
using System.Collections.Immutable;

public class PlaceUserHouseActionTests : ActionTests
{
Expand Down Expand Up @@ -54,6 +55,30 @@ is Bencodex.Types.Dictionary stateEncoded
SignerAddress(),
globalUserHouseState.UserHouse[$"{villageId},{targetX},{targetY}"]
);

Assert.Equal(100, rootState.InventoryState.SeedStateList.Count);
Assert.All(
rootState.InventoryState.SeedStateList,
(seed) => Assert.True(seed.SeedID >= 1 && seed.SeedID <= 13)
);
Assert.Equal(
Enumerable.Repeat(10, 6).ToImmutableList(),
rootState.InventoryState.KitchenEquipmentStateList.Aggregate(
new Dictionary<int, int>(),
(dict, curr) =>
{
if (!dict.ContainsKey(curr.KitchenEquipmentID))
{
dict.Add(curr.KitchenEquipmentID, 1);
}
else
{
dict[curr.KitchenEquipmentID]++;
}
return dict;
}
).Values.ToImmutableList()
);
}

private IAccountStateDelta createStateForRelocationHouse()
Expand Down
26 changes: 26 additions & 0 deletions backend/app/Savor22b/Action/PlaceUserHouseAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,32 @@ is Dictionary stateEncoded
if (isInitialPlaceHouse)
{
PlaceInitialUserHouse(rootState);

var inventoryState = rootState.InventoryState;

for (int i = 0; i < 100; i++)
{
inventoryState = inventoryState.AddSeed(
new SeedState(ctx.Random.GenerateRandomGuid(), ctx.Random.Next() % 13 + 1)
);
}

var kitchenEquipments = CsvDataHelper.GetKitchenEquipmentCSVData();
foreach (var k in kitchenEquipments)
{
for (int i = 0; i < 10; i++)
{
inventoryState = inventoryState.AddKitchenEquipmentItem(
new KitchenEquipmentState(
ctx.Random.GenerateRandomGuid(),
k.ID,
k.KitchenEquipmentCategoryID
)
);
}
}

rootState.SetInventoryState(inventoryState);
}
else
{
Expand Down
21 changes: 21 additions & 0 deletions backend/app/Savor22b/GraphTypes/Query/Query.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,27 @@ public Query(BlockChain blockChain, Swarm? swarm = null)
}
);

Field<UserStateType>(
"userState",
description: "The specified address's user state",
arguments: new QueryArguments(
new QueryArgument<NonNullGraphType<StringGraphType>>
{
Name = "address",
Description = "The account holder's 40-hex address",
}
),
resolve: context =>
{
var accountAddress = new Address(context.GetArgument<string>("address"));
var rootStateEncoded = blockChain.GetState(accountAddress);
RootState rootState = rootStateEncoded is Bencodex.Types.Dictionary bdict
? new RootState(bdict)
: new RootState();
return rootState;
}
);

// TODO: Move to Libplanet.Explorer or Node API.
Field<StringGraphType>(
"peerString",
Expand Down
102 changes: 102 additions & 0 deletions frontend/Saver-22b-godot/scripts/scenes/intro.gd
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,108 @@ func _query_user_state():
var query = GQLQuery.new("userState").set_args({
"signer_address": "address",
}).set_props([
GQLQuery.new("villageState").set_props([
GQLQuery.new("houseFieldStates").set_props([
"installedSeedGuid",
"seedID",
"installedBlock",
"totalBlock",
"lastWeedBlock",
"weedRemovalCount",
"seedName",
"isHarvested",
"weedRemovalAble",
]),
GQLQuery.new("houseState").set_props([
"villageId",
"positionX",
"positionY",
GQLQuery.new("kitchenState").set_props([
GQLQuery.new("firstApplianceSpace").set_props([
"spaceNumber",
GQLQuery.new("installedKitchenEquipment").set_props([
"stateId",
"equipmentId",
"equipmentName",
"blockTimeReductionPercent",
"equipmentCategoryId",
"equipmentCategoryName",
"equipmentCategoryType",
"isCooking",
"cookingEndBlockIndex",
GQLQuery.new("cookingFood").set_props([
"stateId",
"ingredientId",
"foodID",
"name",
"grade",
"hp",
"attack",
"defense",
"speed",
"isSuperFood",
"isAvailable",
]),
]),
]),
GQLQuery.new("secondApplianceSpace").set_props([
"spaceNumber",
GQLQuery.new("installedKitchenEquipment").set_props([
"stateId",
"equipmentId",
"equipmentName",
"blockTimeReductionPercent",
"equipmentCategoryId",
"equipmentCategoryName",
"equipmentCategoryType",
"isCooking",
"cookingEndBlockIndex",
GQLQuery.new("cookingFood").set_props([
"stateId",
"ingredientId",
"foodID",
"name",
"grade",
"hp",
"attack",
"defense",
"speed",
"isSuperFood",
"isAvailable",
]),
]),
]),
GQLQuery.new("thirdApplianceSpace").set_props([
"spaceNumber",
GQLQuery.new("installedKitchenEquipment").set_props([
"stateId",
"equipmentId",
"equipmentName",
"blockTimeReductionPercent",
"equipmentCategoryId",
"equipmentCategoryName",
"equipmentCategoryType",
"isCooking",
"cookingEndBlockIndex",
GQLQuery.new("cookingFood").set_props([
"stateId",
"ingredientId",
"foodID",
"name",
"grade",
"hp",
"attack",
"defense",
"speed",
"isSuperFood",
"isAvailable",
]),
]),
]),
]),
"villageName",
])
]),
GQLQuery.new("inventoryState").set_props([
GQLQuery.new("seedStateList").set_props([
"stateId",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,3 @@ func _on_village_button_button_down(village_index):
func _on_start_button_button_down():
print("start button down: %s" % SceneContext.selected_village_index)
get_tree().change_scene_to_file("res://village_view/VillageView.tscn")
#get_tree().change_scene_to_file("res://scenes/farm.tscn")
7 changes: 0 additions & 7 deletions frontend/Saver-22b-godot/village_view/TemporaryView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,5 @@ func _ready():
var village = SceneContext.get_selected_village()
var village_view_instance = village_view_node.instantiate()
village_view_instance.set_name("view")
#village_view_instance.initialize(
#1000,
#500,
#0,
#0,
#[Vector2(0,0),Vector2(1,0),Vector2(0,1),Vector2(1,1)])

add_child(village_view_instance)
village_view_instance.initialize_by_village(village)
23 changes: 14 additions & 9 deletions frontend/Saver-22b-godot/village_view/VillageView.gd
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,14 @@ func _input(event):
var mouse_event = event as InputEventMouseButton
if mouse_event != null and mouse_event.is_released() and mouse_event.button_index == MOUSE_BUTTON_LEFT and mouse_event.is_command_or_control_pressed():
print("Mouse Click/Unclick at: ", event.position)
build_house()
print("root pos: ", root_local_position)
var pos = bg.get_local_mouse_position()
print("mouse pos: ", pos)
var relative_pos = pos - root_local_position
relative_pos /= Coordinate_weight
relative_pos.x = roundi(relative_pos.x)
relative_pos.y = roundi(relative_pos.y)
build_house(relative_pos)

func initialize_by_village(village: Dictionary):
initialize(
Expand Down Expand Up @@ -61,16 +68,14 @@ func instantiate_house(pos: Vector2):
bg.add_child(house)
house.set_size(Vector2(Coordinate_weight, Coordinate_weight))
house.set_global_position(pos * Coordinate_weight + root_position - Vector2(Coordinate_weight / 2, Coordinate_weight / 2))
house.button_down.connect(func(house_pos):
#var village = SceneContext.get_selected_village()
#village.houses.
get_tree().change_scene_to_file("res://scenes/farm.tscn")
)

func build_house():
var pos = bg.get_local_mouse_position()
var relative_pos = pos - root_local_position
relative_pos /= Coordinate_weight
relative_pos.x = roundi(relative_pos.x)
relative_pos.y = roundi(relative_pos.y)
func build_house(relative_pos: Vector2):
print("build house pos: ", relative_pos)
print("root pos: ", root_local_position)
print("mouse pos: ", pos)
print("public key: ", GlobalSigner.signer.GetPublicKey())
var gql_query = Gql_query.new()
var query_string = gql_query.place_house_query_format.format([
Expand Down
7 changes: 7 additions & 0 deletions frontend/Saver-22b-godot/village_view/house_texture_rect.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
extends TextureRect

signal button_down(position: Vector2)

func _on_button_button_down():
print(position)
button_down.emit(position)
19 changes: 18 additions & 1 deletion frontend/Saver-22b-godot/village_view/house_texture_rect.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[gd_scene load_steps=2 format=3 uid="uid://cjvcx7fit5avb"]
[gd_scene load_steps=3 format=3 uid="uid://ccrlf3kfcisji"]

[ext_resource type="Texture2D" uid="uid://dajunmx26gvr5" path="res://sprites/house.png" id="1_4yb37"]
[ext_resource type="Script" path="res://village_view/house_texture_rect.gd" id="2_hemgv"]

[node name="House_TextureRect" type="TextureRect"]
anchors_preset = 8
Expand All @@ -17,3 +18,19 @@ grow_vertical = 2
size_flags_horizontal = 4
size_flags_vertical = 4
texture = ExtResource("1_4yb37")
script = ExtResource("2_hemgv")

[node name="Button" type="Button" parent="."]
layout_mode = 1
anchors_preset = 12
anchor_top = 1.0
anchor_right = 1.0
anchor_bottom = 1.0
offset_top = -6.0
offset_bottom = 16.0
grow_horizontal = 2
grow_vertical = 0
theme_override_font_sizes/font_size = 10
text = "Enter"

[connection signal="button_down" from="Button" to="." method="_on_button_button_down"]