添加小游戏面板

This commit is contained in:
2025-08-28 10:23:13 +08:00
parent 633c1cac44
commit ca5685df52
24 changed files with 4569 additions and 1250 deletions

View File

@@ -389,10 +389,23 @@ func _apply_filter_and_sort():
# 自定义排序函数
func _sort_crop_items(a, b):
# 安全地获取排序值,并进行类型转换
var value_a = a["data"].get(current_sort_key, 0)
var value_b = b["data"].get(current_sort_key, 0)
# 如果是数值类型的字段,确保转换为数值进行比较
if current_sort_key in ["花费", "生长时间", "收益", "等级", "经验", "耐候性"]:
# 转换为数值如果转换失败则使用0
if typeof(value_a) == TYPE_STRING:
value_a = int(value_a) if value_a.is_valid_int() else 0
if typeof(value_b) == TYPE_STRING:
value_b = int(value_b) if value_b.is_valid_int() else 0
# 执行排序比较
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
return value_a < value_b
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
return value_a > value_b
# 更新金钱显示
func _update_money_display():

View File

@@ -210,11 +210,23 @@ func _sort_crop_items(a, b):
print("警告: 排序键 ", current_sort_key, " 在某些成熟物数据中不存在")
return false
# 执行排序
# 安全地获取排序值,并进行类型转换
var value_a = a["data"].get(current_sort_key, 0)
var value_b = b["data"].get(current_sort_key, 0)
# 如果是数值类型的字段,确保转换为数值进行比较
if current_sort_key in ["花费", "生长时间", "收益", "等级", "经验", "耐候性"]:
# 转换为数值如果转换失败则使用0
if typeof(value_a) == TYPE_STRING:
value_a = int(value_a) if value_a.is_valid_int() else 0
if typeof(value_b) == TYPE_STRING:
value_b = int(value_b) if value_b.is_valid_int() else 0
# 执行排序比较
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
return value_a < value_b
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
return value_a > value_b
# 按品质过滤成熟物
func _filter_by_quality(quality: String):

View File

@@ -1 +1,27 @@
extends Panel
var _2048_GAME = preload('res://Scene/SmallGame/2048Game.tscn').instantiate()
var PUSH_BOX = preload('res://Scene/SmallGame/PushBox.tscn').instantiate()
var SNAKE_GAME = preload('res://Scene/SmallGame/SnakeGame.tscn').instantiate()
var TETRIS = preload('res://Scene/SmallGame/Tetris.tscn').instantiate()
func _on_game_button_pressed() -> void:
self.add_child(_2048_GAME)
pass # Replace with function body.
func _on_push_box_button_pressed() -> void:
self.add_child(PUSH_BOX)
pass # Replace with function body.
func _on_snake_game_button_pressed() -> void:
self.add_child(SNAKE_GAME)
pass # Replace with function body.
func _on_tetris_button_pressed() -> void:
self.add_child(TETRIS)
pass # Replace with function body.

View File

@@ -165,11 +165,23 @@ func _sort_seed_items(a, b):
print("警告: 排序键 ", current_sort_key, " 在某些种子数据中不存在")
return false
# 执行排序
# 安全地获取排序值,并进行类型转换
var value_a = a["data"].get(current_sort_key, 0)
var value_b = b["data"].get(current_sort_key, 0)
# 如果是数值类型的字段,确保转换为数值进行比较
if current_sort_key in ["花费", "生长时间", "收益", "等级", "经验", "耐候性"]:
# 转换为数值如果转换失败则使用0
if typeof(value_a) == TYPE_STRING:
value_a = int(value_a) if value_a.is_valid_int() else 0
if typeof(value_b) == TYPE_STRING:
value_b = int(value_b) if value_b.is_valid_int() else 0
# 执行排序比较
if current_sort_ascending:
return a["data"][current_sort_key] < b["data"][current_sort_key]
return value_a < value_b
else:
return a["data"][current_sort_key] > b["data"][current_sort_key]
return value_a > value_b
# 按品质过滤种子
func _filter_by_quality(quality: String):