Add starter RV progression and fishing feedback
This commit is contained in:
parent
eed361681a
commit
d8bf59bca0
47 changed files with 2268 additions and 467 deletions
|
|
@ -27,6 +27,8 @@ var _manifests_by_fingerprint: Dictionary[String, Dictionary] = {}
|
|||
var _fingerprint_by_peer: Dictionary[int, String] = {}
|
||||
var _authorized_owned_counts: Dictionary[int, Dictionary] = {}
|
||||
var _authorization_result_owner: Dictionary[String, int] = {}
|
||||
var _authorized_home_tiers: Dictionary[int, int] = {}
|
||||
var _home_upgrade_result_owner: Dictionary[String, int] = {}
|
||||
var _interior_slots_by_space: Dictionary[StringName, Dictionary] = {}
|
||||
var _next_interior_index: int = 0
|
||||
var _suppress_local_submission: bool = false
|
||||
|
|
@ -103,6 +105,17 @@ func get_authoritative_owned_count(
|
|||
return int(owned.get(String(decor_id), 0))
|
||||
|
||||
|
||||
func get_authoritative_home_tier(peer_id: int) -> int:
|
||||
if _authorized_home_tiers.has(peer_id):
|
||||
return int(_authorized_home_tiers[peer_id])
|
||||
var fingerprint: String = _fingerprint_for_peer(peer_id)
|
||||
var manifest: Dictionary = _manifests_by_fingerprint.get(fingerprint, {})
|
||||
if manifest.is_empty():
|
||||
return -1
|
||||
var home: Dictionary = manifest.get("home", {})
|
||||
return int(home.get("tier", -1))
|
||||
|
||||
|
||||
func place_local_decor(
|
||||
decor_id: StringName,
|
||||
position: Vector3,
|
||||
|
|
@ -337,6 +350,35 @@ func finalize_decor_purchase(
|
|||
_authorized_owned_counts.erase(peer_id)
|
||||
|
||||
|
||||
func authorize_home_upgrade(
|
||||
peer_id: int,
|
||||
resulting_tier: int,
|
||||
result_id: String,
|
||||
) -> void:
|
||||
if (
|
||||
not _session.is_host()
|
||||
or peer_id <= 0
|
||||
or result_id.is_empty()
|
||||
or resulting_tier < PlayerHomeStateType.STARTER_TIER
|
||||
or resulting_tier > PlayerHomeStateType.MAX_TIER
|
||||
):
|
||||
return
|
||||
_authorized_home_tiers[peer_id] = resulting_tier
|
||||
_home_upgrade_result_owner[result_id] = peer_id
|
||||
|
||||
|
||||
func finalize_home_upgrade(
|
||||
peer_id: int,
|
||||
result_id: String,
|
||||
applied: bool,
|
||||
) -> void:
|
||||
if _home_upgrade_result_owner.get(result_id, 0) != peer_id:
|
||||
return
|
||||
_home_upgrade_result_owner.erase(result_id)
|
||||
if not applied:
|
||||
_authorized_home_tiers.erase(peer_id)
|
||||
|
||||
|
||||
func refresh_world_presentations() -> void:
|
||||
if _world_service == null:
|
||||
return
|
||||
|
|
@ -442,7 +484,7 @@ func _process_manifest_request(peer_id: int, data: Dictionary) -> void:
|
|||
not NetworkHomeProtocolType.validate_manifest_request(data)
|
||||
or str(data["session_id"]) != _session.get_session_id()
|
||||
):
|
||||
_reject_manifest(peer_id, "The RV update was invalid.")
|
||||
_reject_manifest(peer_id, "The home update was invalid.")
|
||||
return
|
||||
var record := _session.get_peer_record(peer_id)
|
||||
var fingerprint: String = str(data["owner_fingerprint"])
|
||||
|
|
@ -456,7 +498,7 @@ func _process_manifest_request(peer_id: int, data: Dictionary) -> void:
|
|||
data["sender_signature"],
|
||||
)
|
||||
):
|
||||
_reject_manifest(peer_id, "The RV owner could not be verified.")
|
||||
_reject_manifest(peer_id, "The home owner could not be verified.")
|
||||
return
|
||||
var home_data: Dictionary = PlayerHomeStateType.sanitize_save_data(
|
||||
data["home"]
|
||||
|
|
@ -464,7 +506,7 @@ func _process_manifest_request(peer_id: int, data: Dictionary) -> void:
|
|||
var prior: Dictionary = _manifests_by_fingerprint.get(fingerprint, {})
|
||||
var is_first_manifest: bool = prior.is_empty()
|
||||
if not _valid_manifest_revision(peer_id, prior, home_data):
|
||||
_reject_manifest(peer_id, "The RV update was rejected by the host.")
|
||||
_reject_manifest(peer_id, "The home update was rejected by the host.")
|
||||
return
|
||||
if not _moved_decor_clear_of_players(fingerprint, prior, home_data):
|
||||
_reject_manifest(peer_id, "A player is in the way of that decor.")
|
||||
|
|
@ -472,7 +514,7 @@ func _process_manifest_request(peer_id: int, data: Dictionary) -> void:
|
|||
var manifest: Dictionary
|
||||
if prior.is_empty():
|
||||
if _manifests_by_fingerprint.size() >= MAX_MANIFESTS:
|
||||
_reject_manifest(peer_id, "This room cannot place another RV.")
|
||||
_reject_manifest(peer_id, "This room cannot place another home.")
|
||||
return
|
||||
var reserved: Array[Transform3D] = []
|
||||
for existing: Dictionary in _manifests_by_fingerprint.values():
|
||||
|
|
@ -523,10 +565,17 @@ func _valid_manifest_revision(
|
|||
# no prior room ledger with which to compare its first manifest.
|
||||
return true
|
||||
var prior_home: Dictionary = prior_manifest["home"]
|
||||
var prior_tier: int = int(prior_home["tier"])
|
||||
var next_tier: int = int(home_data["tier"])
|
||||
var tier_is_authorized: bool = (
|
||||
next_tier != prior_tier
|
||||
and int(_authorized_home_tiers.get(peer_id, -1)) == next_tier
|
||||
)
|
||||
if (
|
||||
int(home_data["revision"]) <= int(prior_home["revision"])
|
||||
or int(home_data["tier"]) != int(prior_home["tier"])
|
||||
or str(home_data["exterior_id"]) != str(prior_home["exterior_id"])
|
||||
or (next_tier != prior_tier and not tier_is_authorized)
|
||||
or str(home_data["exterior_id"])
|
||||
!= str(PlayerHomeStateType.exterior_id_for_tier(next_tier))
|
||||
):
|
||||
return false
|
||||
var prior_owned: Dictionary = prior_home["owned_decor"]
|
||||
|
|
@ -619,6 +668,11 @@ static func _placement_position(placement: Dictionary) -> Vector3:
|
|||
|
||||
|
||||
func _consume_owned_authorizations(peer_id: int, home_data: Dictionary) -> void:
|
||||
if (
|
||||
_authorized_home_tiers.has(peer_id)
|
||||
and int(home_data["tier"]) == int(_authorized_home_tiers[peer_id])
|
||||
):
|
||||
_authorized_home_tiers.erase(peer_id)
|
||||
var authorized: Dictionary = _authorized_owned_counts.get(peer_id, {})
|
||||
if authorized.is_empty():
|
||||
return
|
||||
|
|
@ -1027,7 +1081,7 @@ func _process_transition_request(peer_id: int, data: Dictionary) -> void:
|
|||
data["sender_signature"],
|
||||
)
|
||||
):
|
||||
_send_transition_rejection(peer_id, "The RV transition was invalid.")
|
||||
_send_transition_rejection(peer_id, "The home transition was invalid.")
|
||||
return
|
||||
var owner_fingerprint: String = str(data["owner_fingerprint"])
|
||||
var action: int = int(data["action"])
|
||||
|
|
@ -1036,7 +1090,7 @@ func _process_transition_request(peer_id: int, data: Dictionary) -> void:
|
|||
owner_fingerprint, {}
|
||||
)
|
||||
if avatar == null or manifest.is_empty():
|
||||
_send_transition_rejection(peer_id, "That RV is unavailable.")
|
||||
_send_transition_rejection(peer_id, "That home is unavailable.")
|
||||
return
|
||||
if action == NetworkHomeProtocolType.TransitionAction.ENTER:
|
||||
var record := _session.get_peer_record(peer_id)
|
||||
|
|
@ -1052,7 +1106,7 @@ func _process_transition_request(peer_id: int, data: Dictionary) -> void:
|
|||
avatar, owner_fingerprint
|
||||
)
|
||||
):
|
||||
_send_transition_rejection(peer_id, "You cannot enter that RV.")
|
||||
_send_transition_rejection(peer_id, "You cannot enter that home.")
|
||||
return
|
||||
var interior_space: StringName = (
|
||||
NetworkHomeProtocolType.make_space_id(owner_fingerprint)
|
||||
|
|
@ -1076,7 +1130,7 @@ func _process_transition_request(peer_id: int, data: Dictionary) -> void:
|
|||
avatar, owner_fingerprint
|
||||
)
|
||||
):
|
||||
_send_transition_rejection(peer_id, "Move closer to the RV door.")
|
||||
_send_transition_rejection(peer_id, "Move closer to the home door.")
|
||||
return
|
||||
_apply_host_transition(
|
||||
peer_id,
|
||||
|
|
@ -1282,6 +1336,10 @@ func _on_peer_removed(peer_id: int) -> void:
|
|||
var fingerprint: String = _fingerprint_by_peer.get(peer_id, "")
|
||||
_fingerprint_by_peer.erase(peer_id)
|
||||
_authorized_owned_counts.erase(peer_id)
|
||||
_authorized_home_tiers.erase(peer_id)
|
||||
for result_id: String in _home_upgrade_result_owner.keys():
|
||||
if int(_home_upgrade_result_owner[result_id]) == peer_id:
|
||||
_home_upgrade_result_owner.erase(result_id)
|
||||
if fingerprint.is_empty():
|
||||
return
|
||||
if _session.is_host():
|
||||
|
|
@ -1336,6 +1394,8 @@ func _on_session_state_changed(state: NetworkSession.State) -> void:
|
|||
_fingerprint_by_peer.clear()
|
||||
_authorized_owned_counts.clear()
|
||||
_authorization_result_owner.clear()
|
||||
_authorized_home_tiers.clear()
|
||||
_home_upgrade_result_owner.clear()
|
||||
_publish_queued = false
|
||||
_last_submitted_local_home_revision = -1
|
||||
_pending_local_decor_transactions.clear()
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ const FRIENDS_CAPABILITY: String = "friends_v1"
|
|||
const MOVEMENT_RECONCILIATION_CAPABILITY: String = "movement_reconciliation_v2"
|
||||
const FISHING_REPLICATION_CAPABILITY: String = "fishing_replication_v2"
|
||||
const HOME_CAPABILITY: String = "portable_home_v1"
|
||||
const HOME_UPGRADE_CAPABILITY: String = "home_upgrade_v1"
|
||||
const DEFAULT_WORLD_SEED: int = 13001
|
||||
const MAX_WORLD_SEED: int = 2147483646
|
||||
|
||||
|
|
@ -205,6 +206,7 @@ static func make_client_hello(
|
|||
MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
FISHING_REPLICATION_CAPABILITY,
|
||||
HOME_CAPABILITY,
|
||||
HOME_UPGRADE_CAPABILITY,
|
||||
]),
|
||||
"cosmetic_snapshot": cosmetic_snapshot,
|
||||
"identity_fingerprint": identity_fingerprint,
|
||||
|
|
@ -346,6 +348,7 @@ static func make_server_hello(
|
|||
MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
FISHING_REPLICATION_CAPABILITY,
|
||||
HOME_CAPABILITY,
|
||||
HOME_UPGRADE_CAPABILITY,
|
||||
"chat_v1",
|
||||
"mail_v1",
|
||||
"profile_v1",
|
||||
|
|
|
|||
|
|
@ -340,6 +340,7 @@ func _register_player_host() -> void:
|
|||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
NetworkProtocol.HOME_UPGRADE_CAPABILITY,
|
||||
]),
|
||||
)
|
||||
_registry.update_appearance(1, _local_appearance_snapshot)
|
||||
|
|
@ -668,6 +669,7 @@ func supports_server_capability(capability: StringName) -> bool:
|
|||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
NetworkProtocol.HOME_UPGRADE_CAPABILITY,
|
||||
"chat_v1",
|
||||
"mail_v1",
|
||||
"profile_v1",
|
||||
|
|
@ -1638,6 +1640,7 @@ func receive_server_hello(data: Dictionary) -> void:
|
|||
NetworkProtocol.MOVEMENT_RECONCILIATION_CAPABILITY,
|
||||
NetworkProtocol.FISHING_REPLICATION_CAPABILITY,
|
||||
NetworkProtocol.HOME_CAPABILITY,
|
||||
NetworkProtocol.HOME_UPGRADE_CAPABILITY,
|
||||
]),
|
||||
)
|
||||
_registry.update_appearance(local_peer_id, _local_appearance_snapshot)
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ const CAPABILITY: StringName = &"shop_v1"
|
|||
const ART_CAPABILITY: StringName = &"art_shop_v1"
|
||||
const BACKPACK_CAPABILITY: StringName = &"backpack_shop_v1"
|
||||
const DECOR_CAPABILITY: StringName = &"portable_home_v1"
|
||||
const HOME_UPGRADE_CAPABILITY: StringName = &"home_upgrade_v1"
|
||||
const RELIABLE_CHANNEL: int = NetworkProtocol.SHOP_RELIABLE_CHANNEL
|
||||
const MAX_ID_LENGTH: int = 96
|
||||
const MAX_MESSAGE_LENGTH: int = 160
|
||||
|
|
@ -15,7 +16,7 @@ enum ProductCategory {
|
|||
ROD,
|
||||
REEL_SPEED_UPGRADE,
|
||||
BARRIER_POWER_UPGRADE,
|
||||
COOLER_CAPACITY_UPGRADE,
|
||||
HOME_UPGRADE,
|
||||
ART_KIT,
|
||||
ART_UPGRADE,
|
||||
BACKPACK_CAPACITY_UPGRADE,
|
||||
|
|
|
|||
|
|
@ -12,9 +12,10 @@ const DecorCatalogType = preload("res://homes/decor_catalog.gd")
|
|||
|
||||
const FISHING_SHOP_ID: StringName = &"main_fishing_shop"
|
||||
const DECOR_SHOP_ID: StringName = &"rv_decor_shop"
|
||||
const RV_UPGRADE_SHOP_ID: StringName = &"rv_upgrade_shop"
|
||||
const REEL_PRODUCT_ID: StringName = &"reel_speed_upgrade"
|
||||
const BARRIER_PRODUCT_ID: StringName = &"barrier_power_upgrade"
|
||||
const COOLER_PRODUCT_ID: StringName = &"cooler_capacity_upgrade"
|
||||
const HOME_UPGRADE_PRODUCT_ID: StringName = &"starter_rv_upgrade"
|
||||
const BACKPACK_PRODUCT_ID: StringName = &"backpack_capacity_upgrade"
|
||||
const MAX_LEDGER_ENTRIES_PER_PEER: int = 64
|
||||
|
||||
|
|
@ -34,6 +35,7 @@ var _spawn_service: PlayerSpawnService
|
|||
var _network_fishing: NetworkFishingService
|
||||
var _interaction: FishingShopInteraction
|
||||
var _decor_interaction: DecorShopInteraction
|
||||
var _rv_upgrade_interaction: FishingShopInteraction
|
||||
var _wallet: PlayerWallet
|
||||
var _bag: PlayerBag
|
||||
var _item_catalog: ItemCatalog
|
||||
|
|
@ -71,6 +73,7 @@ func setup(
|
|||
home_state: PlayerHomeState = null,
|
||||
network_home: NetworkHomeService = null,
|
||||
decor_interaction: DecorShopInteraction = null,
|
||||
rv_upgrade_interaction: FishingShopInteraction = null,
|
||||
) -> void:
|
||||
_session = session
|
||||
_spawn_service = spawn_service
|
||||
|
|
@ -88,6 +91,7 @@ func setup(
|
|||
_home_state = home_state
|
||||
_network_home = network_home
|
||||
_decor_interaction = decor_interaction
|
||||
_rv_upgrade_interaction = rv_upgrade_interaction
|
||||
if not _session.peer_removed.is_connected(_on_peer_removed):
|
||||
_session.peer_removed.connect(_on_peer_removed)
|
||||
if not _session.state_changed.is_connected(_on_session_state_changed):
|
||||
|
|
@ -104,6 +108,12 @@ func set_decor_shop_interaction(
|
|||
_decor_interaction = interaction
|
||||
|
||||
|
||||
func set_rv_upgrade_shop_interaction(
|
||||
interaction: FishingShopInteraction,
|
||||
) -> void:
|
||||
_rv_upgrade_interaction = interaction
|
||||
|
||||
|
||||
func can_request_purchase() -> bool:
|
||||
return (
|
||||
_session != null
|
||||
|
|
@ -154,6 +164,19 @@ func can_request_decor_purchase() -> bool:
|
|||
)
|
||||
|
||||
|
||||
func can_request_home_upgrade() -> bool:
|
||||
return (
|
||||
can_request_purchase()
|
||||
and _home_state != null
|
||||
and (
|
||||
_session.is_host()
|
||||
or _session.supports_server_capability(
|
||||
NetworkShopProtocol.HOME_UPGRADE_CAPABILITY
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
func is_local_purchase_pending() -> bool:
|
||||
return not _pending_local_request.is_empty()
|
||||
|
||||
|
|
@ -204,12 +227,12 @@ func request_barrier_power_upgrade() -> String:
|
|||
)
|
||||
|
||||
|
||||
func request_cooler_capacity_upgrade() -> String:
|
||||
func request_home_upgrade() -> String:
|
||||
return _request_purchase(
|
||||
COOLER_PRODUCT_ID,
|
||||
NetworkShopProtocol.ProductCategory.COOLER_CAPACITY_UPGRADE,
|
||||
HOME_UPGRADE_PRODUCT_ID,
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE,
|
||||
1,
|
||||
_cooler_capacity.get_level() if _cooler_capacity != null else 0
|
||||
_home_state.get_tier() if _home_state != null else 0
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -308,6 +331,15 @@ func _request_purchase(
|
|||
product_id, category, 0, 0,
|
||||
)
|
||||
return ""
|
||||
if (
|
||||
category == NetworkShopProtocol.ProductCategory.HOME_UPGRADE
|
||||
and not can_request_home_upgrade()
|
||||
):
|
||||
local_purchase_finished.emit(
|
||||
"", false, "RV upgrades require a newer server.",
|
||||
product_id, category, 0, 0,
|
||||
)
|
||||
return ""
|
||||
if (
|
||||
category == NetworkShopProtocol.ProductCategory.DECOR
|
||||
and not can_request_decor_purchase()
|
||||
|
|
@ -318,11 +350,7 @@ func _request_purchase(
|
|||
)
|
||||
return ""
|
||||
var request_id: String = _new_id("shop")
|
||||
var shop_id: StringName = (
|
||||
DECOR_SHOP_ID
|
||||
if category == NetworkShopProtocol.ProductCategory.DECOR
|
||||
else FISHING_SHOP_ID
|
||||
)
|
||||
var shop_id: StringName = _shop_id_for_category(category)
|
||||
var request: Dictionary = {
|
||||
"request_id": request_id,
|
||||
"session_id": _session.get_session_id(),
|
||||
|
|
@ -402,9 +430,7 @@ func _handle_purchase_request(peer_id: int, data: Dictionary) -> void:
|
|||
if not _is_shop_available_for_peer(peer_id, requested_shop_id):
|
||||
var avatar: Player = _spawn_service.get_avatar(peer_id)
|
||||
var requested_interaction: FishingShopInteraction = (
|
||||
_decor_interaction
|
||||
if requested_shop_id == DECOR_SHOP_ID
|
||||
else _interaction
|
||||
_interaction_for_shop(requested_shop_id)
|
||||
)
|
||||
var message: String = (
|
||||
"The shop is unavailable."
|
||||
|
|
@ -416,16 +442,22 @@ func _handle_purchase_request(peer_id: int, data: Dictionary) -> void:
|
|||
var result: Dictionary = _build_authoritative_result(peer_id, data)
|
||||
if (
|
||||
bool(result.get("accepted", false))
|
||||
and int(result.get("category", -1))
|
||||
== NetworkShopProtocol.ProductCategory.DECOR
|
||||
and _network_home != null
|
||||
):
|
||||
_network_home.authorize_decor_purchase(
|
||||
peer_id,
|
||||
StringName(str(result["product_id"])),
|
||||
int(result["resulting_state"]),
|
||||
str(result["result_id"]),
|
||||
)
|
||||
match int(result.get("category", -1)):
|
||||
NetworkShopProtocol.ProductCategory.DECOR:
|
||||
_network_home.authorize_decor_purchase(
|
||||
peer_id,
|
||||
StringName(str(result["product_id"])),
|
||||
int(result["resulting_state"]),
|
||||
str(result["result_id"]),
|
||||
)
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE:
|
||||
_network_home.authorize_home_upgrade(
|
||||
peer_id,
|
||||
int(result["resulting_state"]),
|
||||
str(result["result_id"]),
|
||||
)
|
||||
_pending_by_peer[peer_id] = request_id
|
||||
_record_and_send(peer_id, result)
|
||||
|
||||
|
|
@ -448,14 +480,19 @@ func _build_authoritative_result(
|
|||
)
|
||||
if authoritative_count >= 0:
|
||||
current_state = authoritative_count
|
||||
elif (
|
||||
category == NetworkShopProtocol.ProductCategory.HOME_UPGRADE
|
||||
and _network_home != null
|
||||
):
|
||||
var authoritative_tier: int = (
|
||||
_network_home.get_authoritative_home_tier(peer_id)
|
||||
)
|
||||
if authoritative_tier >= 0:
|
||||
current_state = authoritative_tier
|
||||
var cost: int = -1
|
||||
var resulting_state: int = current_state
|
||||
var rejection: String = ""
|
||||
var expected_shop_id: StringName = (
|
||||
DECOR_SHOP_ID
|
||||
if category == NetworkShopProtocol.ProductCategory.DECOR
|
||||
else FISHING_SHOP_ID
|
||||
)
|
||||
var expected_shop_id: StringName = _shop_id_for_category(category)
|
||||
if StringName(str(request["shop_id"])) != expected_shop_id:
|
||||
rejection = "The shop is unavailable."
|
||||
elif quantity < 1:
|
||||
|
|
@ -569,18 +606,14 @@ func _build_authoritative_result(
|
|||
]
|
||||
)
|
||||
resulting_state = current_state + 1
|
||||
NetworkShopProtocol.ProductCategory.COOLER_CAPACITY_UPGRADE:
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE:
|
||||
if (
|
||||
product_id != COOLER_PRODUCT_ID
|
||||
or current_state >= PlayerCoolerCapacity.MAX_LEVEL
|
||||
product_id != HOME_UPGRADE_PRODUCT_ID
|
||||
or current_state >= PlayerHomeState.MAX_TIER
|
||||
):
|
||||
rejection = "Upgrade is already at maximum."
|
||||
else:
|
||||
cost = (
|
||||
PlayerCoolerCapacity.EXPANSION_COSTS[
|
||||
current_state
|
||||
]
|
||||
)
|
||||
cost = PlayerHomeState.HOME_UPGRADE_COSTS[current_state]
|
||||
resulting_state = current_state + 1
|
||||
NetworkShopProtocol.ProductCategory.BACKPACK_CAPACITY_UPGRADE:
|
||||
if (
|
||||
|
|
@ -874,10 +907,12 @@ func _validate_local_result(data: Dictionary) -> String:
|
|||
return "Purchase could not be completed."
|
||||
if _upgrades.get_next_barrier_power_cost() != cost:
|
||||
return "Purchase could not be completed."
|
||||
NetworkShopProtocol.ProductCategory.COOLER_CAPACITY_UPGRADE:
|
||||
if _cooler_capacity.get_level() != expected_state:
|
||||
return "Purchase could not be completed."
|
||||
if _cooler_capacity.get_next_cost() != cost:
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE:
|
||||
if (
|
||||
product_id != HOME_UPGRADE_PRODUCT_ID
|
||||
or _home_state.get_tier() != expected_state
|
||||
or _home_state.get_next_upgrade_cost() != cost
|
||||
):
|
||||
return "Purchase could not be completed."
|
||||
NetworkShopProtocol.ProductCategory.BACKPACK_CAPACITY_UPGRADE:
|
||||
if (
|
||||
|
|
@ -947,8 +982,11 @@ func _apply_local_product(data: Dictionary) -> bool:
|
|||
return _upgrades.purchase_reel_speed(_wallet)
|
||||
NetworkShopProtocol.ProductCategory.BARRIER_POWER_UPGRADE:
|
||||
return _upgrades.purchase_barrier_power(_wallet)
|
||||
NetworkShopProtocol.ProductCategory.COOLER_CAPACITY_UPGRADE:
|
||||
return _cooler_capacity.purchase(_wallet)
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE:
|
||||
return (
|
||||
_wallet.debit(int(data["total_cost"]))
|
||||
and _home_state.upgrade_to_next_tier()
|
||||
)
|
||||
NetworkShopProtocol.ProductCategory.BACKPACK_CAPACITY_UPGRADE:
|
||||
return (
|
||||
_inventory_layout != null
|
||||
|
|
@ -1061,6 +1099,9 @@ func _handle_acknowledgement(
|
|||
_network_home.finalize_decor_purchase(
|
||||
peer_id, result_id, applied
|
||||
)
|
||||
_network_home.finalize_home_upgrade(
|
||||
peer_id, result_id, applied
|
||||
)
|
||||
_acknowledged_results[result_id] = true
|
||||
_bound_dictionary(_acknowledged_results)
|
||||
if _pending_by_peer.get(peer_id, "") == request_id:
|
||||
|
|
@ -1071,11 +1112,7 @@ func _is_shop_available_for_peer(
|
|||
peer_id: int,
|
||||
shop_id: StringName,
|
||||
) -> bool:
|
||||
var interaction: FishingShopInteraction = (
|
||||
_decor_interaction
|
||||
if shop_id == DECOR_SHOP_ID
|
||||
else _interaction
|
||||
)
|
||||
var interaction: FishingShopInteraction = _interaction_for_shop(shop_id)
|
||||
if (
|
||||
_session == null
|
||||
or not _session.is_host()
|
||||
|
|
@ -1097,6 +1134,24 @@ func _is_shop_available_for_peer(
|
|||
)
|
||||
|
||||
|
||||
func _shop_id_for_category(category: int) -> StringName:
|
||||
match category:
|
||||
NetworkShopProtocol.ProductCategory.DECOR:
|
||||
return DECOR_SHOP_ID
|
||||
NetworkShopProtocol.ProductCategory.HOME_UPGRADE:
|
||||
return RV_UPGRADE_SHOP_ID
|
||||
return FISHING_SHOP_ID
|
||||
|
||||
|
||||
func _interaction_for_shop(shop_id: StringName) -> FishingShopInteraction:
|
||||
match shop_id:
|
||||
DECOR_SHOP_ID:
|
||||
return _decor_interaction
|
||||
RV_UPGRADE_SHOP_ID:
|
||||
return _rv_upgrade_interaction
|
||||
return _interaction
|
||||
|
||||
|
||||
func _on_peer_removed(peer_id: int) -> void:
|
||||
_request_ledgers.erase(peer_id)
|
||||
_pending_by_peer.erase(peer_id)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue