Add fish selling, buyer profiles, and player wallet
This commit is contained in:
parent
fb04615600
commit
d2fe367891
25 changed files with 738 additions and 5 deletions
|
|
@ -13,7 +13,7 @@ var _next_catch_sequence: int = 1
|
|||
func add_catch(fish_catch: FishCatchType) -> void:
|
||||
if fish_catch == null or not fish_catch.is_valid():
|
||||
return
|
||||
if get_catch(fish_catch.catch_id) != null:
|
||||
if get_catch_by_id(fish_catch.catch_id) != null:
|
||||
return
|
||||
if fish_catch.catch_sequence <= 0:
|
||||
fish_catch.catch_sequence = _next_catch_sequence
|
||||
|
|
@ -37,7 +37,7 @@ func get_all_catches() -> Array[FishCatchType]:
|
|||
return _catches.duplicate()
|
||||
|
||||
|
||||
func get_catch(catch_id: StringName) -> FishCatchType:
|
||||
func get_catch_by_id(catch_id: StringName) -> FishCatchType:
|
||||
if catch_id.is_empty():
|
||||
return null
|
||||
for fish_catch: FishCatchType in _catches:
|
||||
|
|
@ -46,6 +46,54 @@ func get_catch(catch_id: StringName) -> FishCatchType:
|
|||
return null
|
||||
|
||||
|
||||
func get_catch(catch_id: StringName) -> FishCatchType:
|
||||
return get_catch_by_id(catch_id)
|
||||
|
||||
|
||||
func contains_catch_id(catch_id: StringName) -> bool:
|
||||
return get_catch_by_id(catch_id) != null
|
||||
|
||||
|
||||
func remove_catch_by_id(catch_id: StringName) -> FishCatchType:
|
||||
if catch_id.is_empty():
|
||||
return null
|
||||
for index: int in range(_catches.size()):
|
||||
var fish_catch: FishCatchType = _catches[index]
|
||||
if fish_catch == null or fish_catch.catch_id != catch_id:
|
||||
continue
|
||||
_catches.remove_at(index)
|
||||
contents_changed.emit(
|
||||
fish_catch.fish_id,
|
||||
get_count(fish_catch.fish_id)
|
||||
)
|
||||
catches_changed.emit()
|
||||
return fish_catch
|
||||
return null
|
||||
|
||||
|
||||
func set_catch_favorited(
|
||||
catch_id: StringName,
|
||||
is_favorited: bool,
|
||||
) -> bool:
|
||||
var fish_catch: FishCatchType = get_catch_by_id(catch_id)
|
||||
if fish_catch == null:
|
||||
return false
|
||||
if fish_catch.is_favorited == is_favorited:
|
||||
return true
|
||||
fish_catch.is_favorited = is_favorited
|
||||
catches_changed.emit()
|
||||
return true
|
||||
|
||||
|
||||
func get_total_sale_value() -> int:
|
||||
var total: int = 0
|
||||
for fish_catch: FishCatchType in _catches:
|
||||
if fish_catch == null or fish_catch.sale_value < 0:
|
||||
continue
|
||||
total += fish_catch.sale_value
|
||||
return total
|
||||
|
||||
|
||||
func get_catches_by_fish_id(fish_id: StringName) -> Array[FishCatchType]:
|
||||
var matching: Array[FishCatchType] = []
|
||||
for fish_catch: FishCatchType in _catches:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue