otherworldly_simulation/autoload/database/database.gd
2024-11-01 23:23:07 +08:00

123 lines
2.4 KiB
GDScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

extends Node
#不同族群单位之间的初始好感度
#下面意思为测试族群1对2具有初始负面好感
#相反2对1具有正面好感
var init_favour:Dictionary={
#测试族群1
"test_1":{
#对测试族群2的初始好感度为-10
"test_1":-100,
"test_2":-100,
"player":-100,
},
"test_2":{
"test_2":-100,
"test_1":-100,
"player":-100,
},
"default":{
"default":-60
}
}
#获取初始好感度
func get_init_favour(self_type:String,other_type:String):
if not init_favour.has(self_type):
return 0
var favour_dic=init_favour[self_type]
if not favour_dic.has(other_type):
return 0
else:
return favour_dic[other_type]
pass
static func pre_proces_data(dic:Dictionary):
var new_dic=dic.duplicate(true)
for i in new_dic.keys():
new_dic[i]["id"]=i
for j in other_unit_data.keys():
new_dic[i][j]=other_unit_data[j]
return new_dic
static var other_unit_data={
"hungry":0,
"fatigue":0,
"rage":0,
"tensity":0,
"panic":0,
#压力
"pressure":0,
"hp_max":100,
"hp":100,
"atk":10,
"position":[0,0],
"bag":[]
}
#角色数据
@onready var character_data:Dictionary=pre_proces_data(preload("res://json/character.json").data)
func get_unit_data(id:String,as_unit_id:String="default"):
if character_data.has(id):
var res=character_data[id].duplicate(true)
res["unit_id"]=as_unit_id
return res
else:
return null
func get_all_unit_type()->Array:
return character_data.keys()
#地图数据
@export var map_data:Dictionary=preload("res://json/map.json").data
func get_map_data(id:String):
if map_data.has(id):
return map_data[id]
else:
return null
#获取预先添加的物品默认数据
static var pre_item_add_data:Dictionary={"num":1}:
get():
return pre_item_add_data.duplicate(true)
#预处理物品数据
static func pre_process_item_data(origin_data:Dictionary):
var new_res=origin_data
var pre_item_data=pre_item_add_data
#如数据中没有默认数据则填入默认数据
for i in new_res.keys():
for j in pre_item_data.keys():
if not new_res[i].has(j):
new_res[i][j]=new_res[j]
return new_res
#物品数据
@export var item_data:Dictionary=preload("res://json/item.json").data
#获取- 新 -的物品单例默认数量为1
func get_item(id:String,num:int=1)->BagItem:
if item_data.has(id):
var itd=item_data[id]
itd["num"]=num
return BagItem.new(itd)
else:
return BagItem.new({})