Add Sweetlogger
This commit is contained in:
+25
-25
@@ -9,9 +9,9 @@ func set_money(value):
|
||||
if multiplayer.is_server():
|
||||
money = max(0,value)
|
||||
client_sync_money.rpc(money)
|
||||
print("GameManager: set_money money set to ", money)
|
||||
SweetLogger.info("set_money money set to {0}", [money], "GameManager.gd", "set_money")
|
||||
else:
|
||||
print("GameManager: set_money client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set money directly, sending request to server")
|
||||
SweetLogger.info("set_money client/(peer_id={0}) attempted to set money directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_money")
|
||||
server_set_money.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable") # CLIENT -> SERVER: Request a change
|
||||
@@ -29,9 +29,9 @@ func set_day_number(value: int) -> void:
|
||||
if multiplayer.is_server():
|
||||
day_number = value
|
||||
client_sync_day_number.rpc(day_number)
|
||||
print("GameManager: set_day_number day_number set to ", day_number)
|
||||
SweetLogger.info("set_day_number day_number set to {0}", [day_number], "GameManager.gd", "set_day_number")
|
||||
else:
|
||||
print("GameManager: set_day_number client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set day_number directly, sending request to server")
|
||||
SweetLogger.info("set_day_number client/(peer_id={0}) attempted to set day_number directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_day_number")
|
||||
server_set_day_number.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -51,9 +51,9 @@ func set_meals_in_play(value: Array[String]) -> void:
|
||||
if multiplayer.is_server():
|
||||
meals_in_play = value
|
||||
client_sync_meals_in_play.rpc(meals_in_play)
|
||||
print("GameManager: set_meals_in_play meals_in_play set to ", meals_in_play)
|
||||
SweetLogger.info("set_meals_in_play meals_in_play set to {0}", [meals_in_play], "GameManager.gd", "set_meals_in_play")
|
||||
else:
|
||||
print("GameManager: set_meals_in_play client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set meals_in_play directly, sending request to server")
|
||||
SweetLogger.info("set_meals_in_play client/(peer_id={0}) attempted to set meals_in_play directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_meals_in_play")
|
||||
server_set_meals_in_play.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -73,9 +73,9 @@ func set_sides_in_play(value: Array[String]) -> void:
|
||||
if multiplayer.is_server():
|
||||
sides_in_play = value
|
||||
client_sync_sides_in_play.rpc(sides_in_play)
|
||||
print("GameManager: set_sides_in_play sides_in_play set to ", sides_in_play)
|
||||
SweetLogger.info("set_sides_in_play sides_in_play set to {0}", [sides_in_play], "GameManager.gd", "set_sides_in_play")
|
||||
else:
|
||||
print("GameManager: set_sides_in_play client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set sides_in_play directly, sending request to server")
|
||||
SweetLogger.info("set_sides_in_play client/(peer_id={0}) attempted to set sides_in_play directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_sides_in_play")
|
||||
server_set_sides_in_play.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -96,9 +96,9 @@ func set_day_length_seconds(value: float) -> void:
|
||||
if multiplayer.is_server():
|
||||
day_length_seconds = value
|
||||
client_sync_day_length_seconds.rpc(day_length_seconds)
|
||||
print("GameManager: set_day_length_seconds day_length_seconds set to ", day_length_seconds)
|
||||
SweetLogger.info("set_day_length_seconds day_length_seconds set to {0}", [day_length_seconds], "GameManager.gd", "set_day_length_seconds")
|
||||
else:
|
||||
print("GameManager: set_day_length_seconds client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set day_length_seconds directly, sending request to server")
|
||||
SweetLogger.info("set_day_length_seconds client/(peer_id={0}) attempted to set day_length_seconds directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_day_length_seconds")
|
||||
server_set_day_length_seconds.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -118,9 +118,9 @@ func set_customers_per_day(value: float) -> void:
|
||||
if multiplayer.is_server():
|
||||
customers_per_day = value
|
||||
client_sync_customers_per_day.rpc(customers_per_day)
|
||||
print("GameManager: set_customers_per_day customers_per_day set to ", customers_per_day)
|
||||
SweetLogger.info("set_customers_per_day customers_per_day set to {0}", [customers_per_day], "GameManager.gd", "set_customers_per_day")
|
||||
else:
|
||||
print("GameManager: set_customers_per_day client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set customers_per_day directly, sending request to server")
|
||||
SweetLogger.info("set_customers_per_day client/(peer_id={0}) attempted to set customers_per_day directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_customers_per_day")
|
||||
server_set_customers_per_day.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -140,9 +140,9 @@ func set_customers_count_increase_per_day(value: float) -> void:
|
||||
if multiplayer.is_server():
|
||||
customers_count_increase_per_day = value
|
||||
client_sync_customers_count_increase_per_day.rpc(customers_count_increase_per_day)
|
||||
print("GameManager: set_customers_count_increase_per_day customers_count_increase_per_day set to ", customers_count_increase_per_day)
|
||||
SweetLogger.info("set_customers_count_increase_per_day customers_count_increase_per_day set to {0}", [customers_count_increase_per_day], "GameManager.gd", "set_customers_count_increase_per_day")
|
||||
else:
|
||||
print("GameManager: set_customers_count_increase_per_day client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set customers_count_increase_per_day directly, sending request to server")
|
||||
SweetLogger.info("set_customers_count_increase_per_day client/(peer_id={0}) attempted to set customers_count_increase_per_day directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_customers_count_increase_per_day")
|
||||
server_set_customers_count_increase_per_day.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -162,9 +162,9 @@ func set_group_min_size(value: int) -> void:
|
||||
if multiplayer.is_server():
|
||||
group_min_size = value
|
||||
client_sync_group_min_size.rpc(group_min_size)
|
||||
print("GameManager: set_group_min_size group_min_size set to ", group_min_size)
|
||||
SweetLogger.info("set_group_min_size group_min_size set to {0}", [group_min_size], "GameManager.gd", "set_group_min_size")
|
||||
else:
|
||||
print("GameManager: set_group_min_size client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set group_min_size directly, sending request to server")
|
||||
SweetLogger.info("set_group_min_size client/(peer_id={0}) attempted to set group_min_size directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_group_min_size")
|
||||
server_set_group_min_size.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -184,9 +184,9 @@ func set_group_max_size(value: int) -> void:
|
||||
if multiplayer.is_server():
|
||||
group_max_size = value
|
||||
client_sync_group_max_size.rpc(group_max_size)
|
||||
print("GameManager: set_group_max_size group_max_size set to ", group_max_size)
|
||||
SweetLogger.info("set_group_max_size group_max_size set to {0}", [group_max_size], "GameManager.gd", "set_group_max_size")
|
||||
else:
|
||||
print("GameManager: set_group_max_size client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set group_max_size directly, sending request to server")
|
||||
SweetLogger.info("set_group_max_size client/(peer_id={0}) attempted to set group_max_size directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_group_max_size")
|
||||
server_set_group_max_size.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -213,9 +213,9 @@ func set_game_state(value: GameState) -> void:
|
||||
game_state = value
|
||||
client_sync_game_state.rpc(game_state)
|
||||
Signals.game_state_changed.emit(game_state)
|
||||
print("GameManager: set_game_state game_state set to ", game_state)
|
||||
SweetLogger.info("set_game_state game_state set to {0}", [game_state], "GameManager.gd", "set_game_state")
|
||||
else:
|
||||
print("GameManager: set_game_state client/(peer_id=", multiplayer.get_unique_id(), ") attempted to set game_state directly, sending request to server")
|
||||
SweetLogger.info("set_game_state client/(peer_id={0}) attempted to set game_state directly, sending request to server", [multiplayer.get_unique_id()], "GameManager.gd", "set_game_state")
|
||||
server_set_game_state.rpc_id(1, value)
|
||||
|
||||
@rpc("any_peer", "call_remote", "reliable")
|
||||
@@ -233,26 +233,26 @@ func get_random_meal() -> String:
|
||||
push_error("GameManager: get_random_meal() called but meals_in_play is empty")
|
||||
return ""
|
||||
var rand_index = randi() % meals_in_play.size()
|
||||
print("GameManager: get_random_meal() returning ", meals_in_play[rand_index])
|
||||
SweetLogger.debug("get_random_meal() returning {0}", [meals_in_play[rand_index]], "GameManager.gd", "get_random_meal")
|
||||
return meals_in_play[rand_index]
|
||||
|
||||
|
||||
func get_random_side() -> String:
|
||||
print("GameManager: get_random_side() ")
|
||||
SweetLogger.debug("get_random_side()", [], "GameManager.gd", "get_random_side")
|
||||
if sides_in_play.size() == 0:
|
||||
push_error("GameManager: get_random_side() called but sides_in_play is empty")
|
||||
return ""
|
||||
var rand_index = randi() % sides_in_play.size()
|
||||
print("GameManager: get_random_side() list=%s returning %s" % [sides_in_play, sides_in_play[rand_index]])
|
||||
SweetLogger.debug("get_random_side() list={0} returning {1}", [sides_in_play, sides_in_play[rand_index]], "GameManager.gd", "get_random_side")
|
||||
return sides_in_play[rand_index]
|
||||
|
||||
|
||||
func _restart():
|
||||
print("restart Game")
|
||||
SweetLogger.info("restart Game", [], "GameManager.gd", "_restart")
|
||||
game_state = GameState.RUNNING
|
||||
|
||||
|
||||
func game_over():
|
||||
print("Game Over")
|
||||
SweetLogger.info("Game Over", [], "GameManager.gd", "game_over")
|
||||
game_state = GameState.GAME_OVER
|
||||
Signals.game_over.emit()
|
||||
|
||||
+14
-14
@@ -111,22 +111,22 @@ static func get_item_scene(item_id: StringName) -> PackedScene:
|
||||
static func print_all_recipes() -> void:
|
||||
load_recipes()
|
||||
if not _loaded:
|
||||
print("RecipeManager: could not load recipes.yaml; no recipes printed.")
|
||||
SweetLogger.warning("could not load recipes.yaml; no recipes printed.", [], "RecipeManager.gd", "print_all_recipes")
|
||||
return
|
||||
|
||||
if _combining_map.is_empty():
|
||||
print("RecipeManager: no combining recipes found")
|
||||
SweetLogger.warning("no combining recipes found", [], "RecipeManager.gd", "print_all_recipes")
|
||||
return
|
||||
|
||||
print("#### RecipeManager: Loaded recipes ####")
|
||||
SweetLogger.info("#### RecipeManager: Loaded recipes ####", [], "RecipeManager.gd", "print_all_recipes")
|
||||
_print_combining_recipes()
|
||||
print("")
|
||||
SweetLogger.info("", [], "RecipeManager.gd", "print_all_recipes")
|
||||
_print_cooking_recipes()
|
||||
print("")
|
||||
SweetLogger.info("", [], "RecipeManager.gd", "print_all_recipes")
|
||||
_print_chopping_recipes()
|
||||
print("")
|
||||
SweetLogger.info("", [], "RecipeManager.gd", "print_all_recipes")
|
||||
_print_rolling_recipes()
|
||||
print("")
|
||||
SweetLogger.info("", [], "RecipeManager.gd", "print_all_recipes")
|
||||
_print_augmenting_recipes()
|
||||
|
||||
static func _print_combining_recipes() -> void:
|
||||
@@ -135,12 +135,12 @@ static func _print_combining_recipes() -> void:
|
||||
var key_str = str(pair_key)
|
||||
var separator_index = key_str.find("|")
|
||||
if separator_index == -1:
|
||||
print("RecipeManager: invalid combining map key '%s'" % key_str)
|
||||
SweetLogger.warning("invalid combining map key '{0}'", [key_str], "RecipeManager.gd", "_print_combining_recipes")
|
||||
continue
|
||||
|
||||
var first = key_str.substr(0, separator_index)
|
||||
var second = key_str.substr(separator_index + 1, key_str.length() - separator_index - 1)
|
||||
print(" %s <-combine-- %s + %s" % [result_id, first, second])
|
||||
SweetLogger.info(" {0} <-combine-- {1} + {2}", [result_id, first, second], "RecipeManager.gd", "_print_combining_recipes")
|
||||
|
||||
|
||||
static func _print_cooking_recipes() -> void:
|
||||
@@ -148,22 +148,22 @@ static func _print_cooking_recipes() -> void:
|
||||
var cook_defs = _cooking_map[cooked_id]
|
||||
if typeof(cook_defs) == TYPE_ARRAY:
|
||||
for cook_def in cook_defs:
|
||||
print(" %s <-cook-- %s - time: %.1f" % [cooked_id, cook_def["ingredient"], cook_def["time"]])
|
||||
SweetLogger.info(" {0} <-cook-- {1} - time: {2}", [cooked_id, cook_def["ingredient"], cook_def["time"]], "RecipeManager.gd", "_print_cooking_recipes")
|
||||
else:
|
||||
var cook_def = cook_defs
|
||||
print(" %s <-cook-- %s - time: %.1f" % [cooked_id, cook_def["ingredient"], cook_def["time"]])
|
||||
SweetLogger.info(" {0} <-cook-- {1} - time: {2}", [cooked_id, cook_def["ingredient"], cook_def["time"]], "RecipeManager.gd", "_print_cooking_recipes")
|
||||
|
||||
|
||||
static func _print_chopping_recipes() -> void:
|
||||
for chopped_id in _chopping_map.keys():
|
||||
var chop_def = _chopping_map[chopped_id]
|
||||
print(" %s <-chop-- %s - work: %.1f" % [chopped_id, chop_def["ingredient"], chop_def["work"]])
|
||||
SweetLogger.info(" {0} <-chop-- {1} - work: {2}", [chopped_id, chop_def["ingredient"], chop_def["work"]], "RecipeManager.gd", "_print_chopping_recipes")
|
||||
|
||||
|
||||
static func _print_rolling_recipes() -> void:
|
||||
for rolled_id in _rolling_map.keys():
|
||||
var roll_def = _rolling_map[rolled_id]
|
||||
print(" %s <-roll-- %s - work: %.1f" % [rolled_id, roll_def["ingredient"], roll_def["work"]])
|
||||
SweetLogger.info(" {0} <-roll-- {1} - work: {2}", [rolled_id, roll_def["ingredient"], roll_def["work"]], "RecipeManager.gd", "_print_rolling_recipes")
|
||||
|
||||
|
||||
static func _print_augmenting_recipes() -> void:
|
||||
@@ -171,7 +171,7 @@ static func _print_augmenting_recipes() -> void:
|
||||
var augment_def = _augmenting_map[target_id]
|
||||
for ingredient_id in augment_def.keys():
|
||||
var attr_key = augment_def[ingredient_id]
|
||||
print(" %s <-augment-- %s adds attribute '%s'" % [target_id, ingredient_id, attr_key])
|
||||
SweetLogger.info(" {0} <-augment-- {1} adds attribute '{2}'", [target_id, ingredient_id, attr_key], "RecipeManager.gd", "_print_augmenting_recipes")
|
||||
|
||||
|
||||
static func _build_scene_paths() -> void:
|
||||
|
||||
@@ -28,14 +28,14 @@ func satisfy_table_orders() -> void:
|
||||
|
||||
|
||||
func set_buidling_mode():
|
||||
print("Global key event: Setting building mode")
|
||||
SweetLogger.info("Setting building mode", [], "global_key_events.gd", "set_buidling_mode")
|
||||
GameManager.set_game_state(GameManager.GameState.BUILDING)
|
||||
|
||||
|
||||
func set_running_mode():
|
||||
print("Global key event: Setting running mode")
|
||||
SweetLogger.info("Setting running mode", [], "global_key_events.gd", "set_running_mode")
|
||||
GameManager.set_game_state(GameManager.GameState.RUNNING)
|
||||
|
||||
func set_game_over():
|
||||
print("Global key event: Setting game over")
|
||||
SweetLogger.info("Setting game over", [], "global_key_events.gd", "set_game_over")
|
||||
GameManager.set_game_state(GameManager.GameState.GAME_OVER)
|
||||
|
||||
+3
-3
@@ -25,15 +25,15 @@ static func find_first_child_of_type(node: Node, type: Variant) -> Node:
|
||||
# Returns true if decendant is a decendant node of root, false otherwise. Returns false if either node is null.
|
||||
static func is_node_decendant_of(decendant: Node, root: Node) -> bool:
|
||||
if not decendant or not root:
|
||||
print("Helper.is_node_decendant_of: decendant or root is null")
|
||||
SweetLogger.debug("is_node_decendant_of: decendant or root is null", [], "helper.gd", "is_node_decendant_of")
|
||||
return false
|
||||
var current: Node = decendant
|
||||
while current:
|
||||
if current == root:
|
||||
print("Helper.is_node_decendant_of: decendant %s is a descendant of root %s" % [decendant.name, root.name])
|
||||
SweetLogger.debug("is_node_decendant_of: decendant {0} is a descendant of root {1}", [decendant.name, root.name], "helper.gd", "is_node_decendant_of")
|
||||
return true
|
||||
current = current.get_parent()
|
||||
print("Helper.is_node_decendant_of: decendant %s is NOT a descendant of root %s" % [decendant.name, root.name])
|
||||
SweetLogger.debug("is_node_decendant_of: decendant {0} is NOT a descendant of root {1}", [decendant.name, root.name], "helper.gd", "is_node_decendant_of")
|
||||
return false
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user