140 lines
4.4 KiB
GDScript
140 lines
4.4 KiB
GDScript
extends Node
|
|
|
|
var Date: int = 0
|
|
var Gold: int
|
|
|
|
var BusyTimeUpgrades: Array = [0, 0, 0, 0, 0, 0]
|
|
|
|
var HelmetOwned: PackedInt64Array = [0]
|
|
var WeaponsOwned: PackedInt64Array = [0, 0]
|
|
var ArmourOwned: PackedInt64Array = [0]
|
|
|
|
# ItemsPath = "user://Items"
|
|
# MoneyPath: String = "user://Money"
|
|
# BusyTimeUpgradesPath: String = "user://BusyTimeUpgrades"
|
|
# DailyPath: String = "user://Daily"
|
|
# DailyDonePath: String = "user://DoneDaily"
|
|
# DatePath: String = "user://Date"
|
|
var ItemsPath: String = "user://Items"
|
|
var StatsPath: String = "user://Stats"
|
|
var CoinRollsPath: String = "user://Rolls"
|
|
|
|
func _ready():
|
|
# Fuck this.
|
|
if !FileAccess.file_exists("user://Money"):
|
|
var file = FileAccess.open("user://Money", FileAccess.WRITE_READ)
|
|
file.close()
|
|
if !FileAccess.file_exists("user://BusyTimeUpgrades"):
|
|
SaveList(BusyTimeUpgrades, "user://BusyTimeUpgrades")
|
|
if !FileAccess.file_exists("user://Daily"):
|
|
var file = FileAccess.open("user://Daily", FileAccess.WRITE_READ)
|
|
file.close()
|
|
if !FileAccess.file_exists("user://DoneDaily"):
|
|
var file = FileAccess.open("user://DoneDaily", FileAccess.WRITE_READ)
|
|
file.close()
|
|
if !FileAccess.file_exists("user://Stats"):
|
|
pass # There isn't any reason
|
|
if !FileAccess.file_exists("user://Rolls"):
|
|
var file = FileAccess.open("user://Rolls", FileAccess.WRITE_READ)
|
|
file.close()
|
|
if !FileAccess.file_exists("user://Date"):
|
|
var file = FileAccess.open("user://Date", FileAccess.WRITE_READ)
|
|
file.close()
|
|
if !FileAccess.file_exists("user://Items"):
|
|
SaveItems()
|
|
# Rolls isn't here because of a weird bug. I don't know how to fix it.
|
|
|
|
# Port some task stuff to here.
|
|
func SaveList(PrimaryList: Array, PrimaryPath: String, SecondaryList: Array = [], SecondaryPath: String = ""):
|
|
var FileList = FileAccess.open(PrimaryPath, FileAccess.WRITE)
|
|
var FileList2 = FileAccess.open(SecondaryPath, FileAccess.WRITE)
|
|
for i in PrimaryList:
|
|
FileList.store_line(str(i))
|
|
if SecondaryPath != "":
|
|
for i in SecondaryList:
|
|
FileList2.store_line(str(i))
|
|
FileList.close()
|
|
if SecondaryPath != "":
|
|
FileList2.close()
|
|
|
|
func LoadList(PrimaryPath: String):
|
|
if !FileAccess.file_exists(PrimaryPath):
|
|
return []
|
|
var FileList = FileAccess.open(PrimaryPath, FileAccess.READ)
|
|
var stringie = FileList.get_line()
|
|
var List: PackedStringArray = []
|
|
while stringie != "":
|
|
List.append(stringie)
|
|
stringie = FileList.get_line()
|
|
return List
|
|
|
|
func SaveSingle(PrimarySingle, PrimaryPath: String):
|
|
var file = FileAccess.open(PrimaryPath, FileAccess.WRITE)
|
|
file.store_line(str(PrimarySingle))
|
|
file.close()
|
|
|
|
func LoadSingle(PrimaryPath: String):
|
|
if !FileAccess.file_exists(PrimaryPath):
|
|
return
|
|
var file = FileAccess.open(PrimaryPath, FileAccess.READ)
|
|
return file.get_line()
|
|
|
|
# Other things go here. These don't fit into the List or Single format.
|
|
func SaveItems():
|
|
var file = FileAccess.open("user://Items", FileAccess.WRITE)
|
|
for i in HelmetOwned:
|
|
file.store_line(str(i))
|
|
for i in WeaponsOwned:
|
|
file.store_line(str(i))
|
|
for i in ArmourOwned:
|
|
file.store_line(str(i))
|
|
file.close()
|
|
|
|
func ChangeMoney(cash: int):
|
|
Gold = Gold + cash
|
|
SaveSingle(Gold, "user://Money")
|
|
|
|
func Reset_Everything():
|
|
Gold = 0
|
|
BusyTimeUpgrades = [0]
|
|
|
|
SaveList(GlobalVars.BusyTimeUpgrades, "user://BusyTimeUpgrades")
|
|
SaveSingle(Gold, "user://Money")
|
|
|
|
func SaveStats(Enemies: Array, Php, Pmaxhp, Pattack, PHeal, Plevel, Ehp, Emaxhp, Eattack, EHeal, Elevel, Exp, Points):
|
|
var File = FileAccess.open(StatsPath, FileAccess.WRITE)
|
|
File.store_line(str(Enemies[0]))
|
|
File.store_line(str(Enemies[1]))
|
|
File.store_line(str(Enemies[2]))
|
|
File.store_line(str(Enemies[3]))
|
|
File.store_line(str(Enemies[4]))
|
|
File.store_line(str(Enemies[5]))
|
|
File.store_line(str(Php))
|
|
File.store_line(str(Pmaxhp))
|
|
File.store_line(str(Pattack))
|
|
File.store_line(str(PHeal))
|
|
File.store_line(str(Plevel))
|
|
File.store_line(str(Ehp))
|
|
File.store_line(str(Emaxhp))
|
|
File.store_line(str(Eattack))
|
|
File.store_line(str(EHeal))
|
|
File.store_line(str(Elevel))
|
|
File.store_line(str(Exp))
|
|
File.store_line(str(Points))
|
|
File.close()
|
|
|
|
func SaveRolls(P: int, N: int, D: int, Q: int, H: int, Do: int, RP: int, RN: int, RD: int, RQ: int, RH: int, RDo: int):
|
|
var File = FileAccess.open(CoinRollsPath, FileAccess.WRITE)
|
|
File.store_line(str(P))
|
|
File.store_line(str(N))
|
|
File.store_line(str(D))
|
|
File.store_line(str(Q))
|
|
File.store_line(str(H))
|
|
File.store_line(str(Do))
|
|
File.store_line(str(RP))
|
|
File.store_line(str(RN))
|
|
File.store_line(str(RD))
|
|
File.store_line(str(RQ))
|
|
File.store_line(str(RH))
|
|
File.store_line(str(RDo))
|
|
File.close()
|