enabled enforced static typing
This commit is contained in:
@ -1,22 +1,21 @@
|
||||
extends Node
|
||||
class_name Inventory
|
||||
class_name Inventory extends Node
|
||||
|
||||
signal item_added(item)
|
||||
signal item_removed(item)
|
||||
signal item_added(item: Item)
|
||||
signal item_removed(item: Item)
|
||||
|
||||
@export var max_size := 0
|
||||
var contents = {}
|
||||
var size : int :
|
||||
@export var max_size: int = 0
|
||||
var contents: Dictionary = {}
|
||||
var size: int :
|
||||
get:
|
||||
var x = 0
|
||||
for key in contents:
|
||||
var x: int = 0
|
||||
for key: Item in contents:
|
||||
x += contents[key]
|
||||
return x
|
||||
set(_value):
|
||||
return
|
||||
|
||||
|
||||
func add(item : Item) -> bool:
|
||||
func add(item: Item) -> bool:
|
||||
if item != null and max_size == 0 or size < max_size:
|
||||
if contents.has(item):
|
||||
contents[item] += 1
|
||||
@ -28,8 +27,8 @@ func add(item : Item) -> bool:
|
||||
return false
|
||||
|
||||
|
||||
func remove_at(index : int) -> Item:
|
||||
var item = contents.keys()[index]
|
||||
func remove_at(index: int) -> Item:
|
||||
var item: Item = contents.keys()[index]
|
||||
contents[item] -= 1
|
||||
if contents[item] == 0:
|
||||
contents.erase(item)
|
||||
@ -39,8 +38,8 @@ func remove_at(index : int) -> Item:
|
||||
|
||||
|
||||
@rpc("reliable", "any_peer")
|
||||
func networked_add(value):
|
||||
var item = Data.cards[value]
|
||||
func networked_add(value: int) -> void:
|
||||
var item: Item = Data.cards[value]
|
||||
if contents.has(item):
|
||||
contents[item] += 1
|
||||
else:
|
||||
@ -49,8 +48,8 @@ func networked_add(value):
|
||||
|
||||
|
||||
@rpc("reliable", "any_peer")
|
||||
func networked_remove_at(value):
|
||||
var item = contents.keys[value]
|
||||
func networked_remove_at(value: int) -> void:
|
||||
var item: Item = contents.keys[value]
|
||||
contents[item] -= 1
|
||||
if contents[item] == 0:
|
||||
contents.erase(item)
|
||||
|
Reference in New Issue
Block a user