Skip to content

Commit

Permalink
Merge branch 'main' into feat/project-intro
Browse files Browse the repository at this point in the history
  • Loading branch information
upa-r-upa authored Jun 5, 2024
2 parents ee64d7f + 4e42bc3 commit 57201b9
Show file tree
Hide file tree
Showing 154 changed files with 2,516 additions and 2,365 deletions.
34 changes: 25 additions & 9 deletions backend/app/Savor22b/Action/RegisterTradeGoodAction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ namespace Savor22b.Action;
using Libplanet.Assets;
using Libplanet.Headless.Extensions;
using Libplanet.State;
using Savor22b.Action.Exceptions;
using Savor22b.States;
using Savor22b.States.Trade;
using Savor22b.Action.Exceptions;

[ActionType(nameof(RegisterTradeGoodAction))]
public class RegisterTradeGoodAction : SVRAction
Expand Down Expand Up @@ -53,16 +53,23 @@ public RegisterTradeGoodAction(FungibleAssetValue price, int dungeonId)
{
[nameof(Price)] = Price.ToBencodex(),
[nameof(FoodStateId)] = FoodStateId.Serialize(),
[nameof(ItemStateIds)] = ItemStateIds is null ? Null.Value : (List)ItemStateIds.Select(i => i.Serialize()),
[nameof(ItemStateIds)] = ItemStateIds is null
? Null.Value
: (List)ItemStateIds.Select(i => i.Serialize()),
[nameof(DungeonId)] = DungeonId.Serialize(),
}.ToImmutableDictionary();

protected override void LoadPlainValueInternal(IImmutableDictionary<string, IValue> plainValue)
{
Price = plainValue[nameof(Price)].ToFungibleAssetValue();
FoodStateId = plainValue[nameof(FoodStateId)].ToGuid();
ItemStateIds = plainValue[nameof(ItemStateIds)] is Null ? null : ((List)plainValue[nameof(ItemStateIds)]).Select(e => e.ToGuid()).ToImmutableList();
DungeonId = plainValue[nameof(DungeonId)].ToInteger();
ItemStateIds =
plainValue[nameof(ItemStateIds)] is Null
? null
: ((List)plainValue[nameof(ItemStateIds)])
.Select(e => e.ToGuid())
.ToImmutableList();
DungeonId = plainValue[nameof(DungeonId)].ToNullableInteger();
}

public override IAccountStateDelta Execute(IActionContext ctx)
Expand All @@ -77,10 +84,12 @@ public override IAccountStateDelta Execute(IActionContext ctx)
RootState rootState = states.GetState(ctx.Signer) is Dictionary rootStateEncoded
? new RootState(rootStateEncoded)
: new RootState();
TradeInventoryState tradeInventoryState = states.GetState(TradeInventoryState.StateAddress) is Dictionary tradeInventoryStateEncoded
TradeInventoryState tradeInventoryState = states.GetState(TradeInventoryState.StateAddress)
is Dictionary tradeInventoryStateEncoded
? new TradeInventoryState(tradeInventoryStateEncoded)
: new TradeInventoryState();
GlobalDungeonState globalDungeonState = states.GetState(GlobalDungeonState.StateAddress) is Dictionary globalDungeonStateEncoded
GlobalDungeonState globalDungeonState = states.GetState(GlobalDungeonState.StateAddress)
is Dictionary globalDungeonStateEncoded
? new GlobalDungeonState(globalDungeonStateEncoded)
: new GlobalDungeonState();

Expand All @@ -89,7 +98,12 @@ public override IAccountStateDelta Execute(IActionContext ctx)
if (FoodStateId is not null)
{
var foodState = inventoryState.GetRefrigeratorItem(FoodStateId.Value);
var foodGoodState = new FoodGoodState(ctx.Signer, ctx.Random.GenerateRandomGuid(), Price, foodState);
var foodGoodState = new FoodGoodState(
ctx.Signer,
ctx.Random.GenerateRandomGuid(),
Price,
foodState
);
inventoryState = inventoryState.RemoveRefrigeratorItem(FoodStateId.Value);
tradeInventoryState = tradeInventoryState.RegisterGood(foodGoodState);
}
Expand All @@ -106,7 +120,8 @@ public override IAccountStateDelta Execute(IActionContext ctx)
ctx.Signer,
ctx.Random.GenerateRandomGuid(),
Price,
itemStates.ToImmutableList());
itemStates.ToImmutableList()
);

tradeInventoryState = tradeInventoryState.RegisterGood(itemsGoodState);
}
Expand All @@ -116,7 +131,8 @@ public override IAccountStateDelta Execute(IActionContext ctx)
ctx.Signer,
ctx.Random.GenerateRandomGuid(),
Price,
DungeonId.Value);
DungeonId.Value
);

if (!globalDungeonState.IsDungeonConquestAddress(DungeonId.Value, ctx.Signer))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
extends Node

const inventory_scene = preload("res://scenes/inventory/inventory.tscn");
const inventory_scene = preload("res://scenes/inventory/inventory.tscn")

func open_inventory(data: Dictionary):
var inventory_instance := inventory_scene.instantiate()
inventory_instance.data = data;
inventory_instance.data = data

get_tree().root.add_child(inventory_instance)
Original file line number Diff line number Diff line change
@@ -1,42 +1,5 @@
extends Node

#var villages_json_string := """{
#"villages": [
#{
#"id": 1,
#"name": "평범한 도시 1",
#"width": 3,
#"height": 11,
#"worldX": 5,
#"worldY": 1,
#"houses": [
#{
#"x": 1,
#"y": 1,
#"owner": "0x53103C2D7875D2f5f02AeC3075155e268a6e3A94"
#}
#]
#},
#{
#"id": 2,
#"name": "외로운 섬",
#"width": 7,
#"height": 13,
#"worldX": -2,
#"worldY": 7,
#"houses": []
#},
#{
#"id": 3,
#"name": "정글",
#"width": 3,
#"height": 5,
#"worldX": 1,
#"worldY": -3,
#"houses": []
#}
#]
#}"""
var villages: Array
var selected_village_index := 0
var user_state: Dictionary
Expand All @@ -56,7 +19,7 @@ var selected_field_index := 0
var selected_item_index := 0
var selected_item_name : String

var selected_recipe_index := 0
var selected_recipe_index := 1
var selected_ingredients : Array
var selected_tools : Array

Expand All @@ -66,14 +29,6 @@ var installed_tool_info : Array

var block_index : Dictionary

#func _ready():
#var json = JSON.new()
#var error = json.parse(villages_json_string)
#if error != OK:
#print(error)
#else:
#villages = json.data.villages

func set_villages(query_data: Dictionary):
villages = query_data.data.villages

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
extends Node;
extends Node

var signer
var signer_address
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
extends GQLClient

func _ready():
print("client 2 ready")
#set_endpoint(false, "1.230.253.103", 38080, "/graphql")


set_endpoint(false, "localhost", 38080, "/graphql/explorer")


Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
extends GQLClient

func _ready():
print("client ready")
#set_endpoint(false, "1.230.253.103", 38080, "/graphql")

set_endpoint(false, "localhost", 38080, "/graphql")

Expand Down
Loading

0 comments on commit 57201b9

Please sign in to comment.