79 lines
1.7 KiB
GDScript3
Raw Normal View History

class_name Data extends Node
enum Element{
NORMAL,
FIRE,
ICE,
POISON,
STONE
}
enum Difficulty{
EASY,
NORMAL,
HARD,
GAMER
}
enum Location{
MAINMENU,
CREDITS,
TAVERN,
ARENA,
DEAD
}
2024-05-20 22:03:50 -04:00
enum Rarity{
COMMON,
RARE,
LEGENDARY,
2024-05-27 13:05:36 -04:00
GODLIKE
2024-05-20 22:03:50 -04:00
}
2024-05-27 19:54:22 -04:00
@onready var musicPlayer: MusicPlayer = $/root/Root/MusicPlayer
@export var spellbook: Spellbook
@export var difficulty: Difficulty = Difficulty.NORMAL
2024-05-03 19:45:30 -04:00
@export var animations: Dictionary = {}
@export var player: Combatant
@export var opponent: Combatant
@export var loc: Location = Location.MAINMENU
@export var playing: bool = false
2024-05-27 13:05:36 -04:00
@export var lockedSpells: Array[Spell]
@export var unlockedSpells: Array[Spell]
@export var commonChance: int = 70
@export var rareChance: int = 24
@export var legendaryChance: int = 5
@export var godlikeChance: int = 1
2024-05-27 19:54:22 -04:00
@export var locations: Dictionary = {
Location.MAINMENU: "res://Scenes/UI/mainMenu.tscn",
Location.CREDITS: "",
Location.TAVERN: "res://Scenes/tavern.tscn",
Location.ARENA: "res://Scenes/arena.tscn"
}
2024-05-27 13:05:36 -04:00
func getNewSpell() -> Spell:
2024-05-27 19:54:22 -04:00
2024-05-27 13:05:36 -04:00
var num: int = randi_range(0, 99)
var rar: Rarity
if (num < commonChance):
rar = Rarity.COMMON
2024-05-27 19:54:22 -04:00
elif (num < rareChance + commonChance):
2024-05-27 13:05:36 -04:00
rar = Rarity.RARE
2024-05-27 19:54:22 -04:00
elif (num < legendaryChance + rareChance + commonChance):
2024-05-27 13:05:36 -04:00
rar = Rarity.LEGENDARY
else:
rar = Rarity.GODLIKE
var options: Array[Spell] = lockedSpells.filter(func(spel): return spel.rarity == rar)
var count: int = 1
while (options.size() == 0):
rar = (int(rar) + 1) as Rarity
if (int(rar) >= 4): rar = 0
count += 1
if (count >= 4): return null
2024-05-27 19:54:22 -04:00
options = lockedSpells.filter(func(spel): return spel.rarity == rar)
2024-05-27 13:05:36 -04:00
var spell: Spell = options[randi_range(0, options.size() - 1)]
lockedSpells.erase(spell)
unlockedSpells.append(spell)
return spell