Skip to content

Commit

Permalink
+26 i18n, skill editor work, history for skill,...
Browse files Browse the repository at this point in the history
Skill_cooldown_type enum added
BaseSkill >> + cooldown type (milli, sec, or min)
Lot of UI work
linking UI with backend
  • Loading branch information
Ward727a committed Sep 10, 2024
1 parent 62ccadb commit 240ed9e
Show file tree
Hide file tree
Showing 38 changed files with 1,820 additions and 34 deletions.
2 changes: 1 addition & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"godotTools.editorPath.godot4": "c:\\Users\\Malywan\\Desktop\\Godot\\Godot_v4.2.1-stable_mono_win64.exe"
"godotTools.editorPath.godot4": "c:\\Users\\Malywan\\Desktop\\Godot4.2\\Godot_v4.2.1-stable_mono_win64.exe"
}
26 changes: 26 additions & 0 deletions Core/Assets/Translation/main.csv
Original file line number Diff line number Diff line change
Expand Up @@ -82,3 +82,29 @@ HINT_IS_INVINCIBLE,wip,wip
IS_LOOTABLE,Is lootable,Peut-être fouiller
HINT_IS_LOOTABLE,wip,wip
NEW_SKILL,New skill,Nouvelle compétence
ALL,All,Tous
ACTIVE,Active,Actif
PASSIVE,Passive,Passif
REACTIVE,Reactive,Réactif
SPECIAL,Special,Spécial
SKILL_TYPE,Skill type,Type de compétence
SKILL_TARGET,Skill target,Cible de la compétence
SKILL_COOLDOWN,Skill cooldown,Temps de recharge
SKILL_EFFECTS,Skill effects,Effets de compétence
SKILL_CONDITIONS,Skill conditions,Conditions
ADD,Add,Ajouter
CREATE,Create,Nouveau
SKILL,Skill,Compétence
SKILL_NAME,Skill name,Nom de la compétence
SKILL_DESCRIPTION,Skill description,Description de la compétence
OPEN_ADVANCED_EDITOR,Open the advanced text editor,Ouvrir l’éditeur de texte avancé
CHAR_NAME,Name,Prénom
CHAR_SURNAME,Surname,Nom
ALLY,Ally,Allié
ALLIES,Allies,Alliés
ENEMY,Enemy,Ennemi
ENEMIES,Enemies,Ennemis
SELF,Self,Soi
MS,ms,ms
SEC,sec,sec
MIN,min,min
29 changes: 29 additions & 0 deletions Core/Class/engine/history/history_skill.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extends HistoryBase
class_name HistorySkill

var skill_idx: String = ""
var edited_data: Dictionary = {}

func _init(_action: EnumRegister.HistoryAction, _skill_idx: String, _edited_data: Dictionary = {}):
location = EnumRegister.HistoryLocation.DB_SKILL
action = _action
skill_idx = _skill_idx
edited_data = _edited_data

func undo_change() -> void:
print("Undo changement to skill")
var skill: BaseSkill = SkillRegister.get_skill(skill_idx)

for key in edited_data:
skill.set(key, edited_data[key])

SkillRegister.set_skill(skill_idx, skill)

func redo_change() -> void:
print("Redo changement to skill")
var skill: BaseSkill = SkillRegister.get_skill(skill_idx)

for key in edited_data:
skill.set(key, edited_data[key])

SkillRegister.set_skill(skill_idx, skill)
8 changes: 4 additions & 4 deletions Core/Class/entities/Character.gd
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ func is_enemy(_character: Character) -> bool:
return true
return false

func add_skill(_skill_name: String, _skill_lvl) -> void:
var skill = BaseSkill.new()
skill.name = _skill_name
skill.level = _skill_lvl
func add_skill(_skill_name: String) -> void:
var skill = SkillRegister.get_skill(_skill_name)
if skill == null:
return
skills.append(skill)
4 changes: 3 additions & 1 deletion Core/Class/skill.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ class_name BaseSkill

const SkillTypes = EnumRegister.SkillTypes
const SkillTarget = EnumRegister.SkillTarget
const SkillCooldownType = EnumRegister.SkillCooldownType

var id: String = "" # Skill's id
var name: String = "" # Skill's name
var description: String = "" # Skill's description
var level: int = 1 # Skill's level (For now, it's not used - It's different from the character's level!)

var skill_type: SkillTypes = SkillTypes.ACTIVE # Skill's type
var skill_target: SkillTarget = SkillTarget.SELF # Skill's target (self, ally, enemy, all)
Expand All @@ -15,6 +16,7 @@ var skill_cost: Dictionary = {} # Skill's cost (ex: { "hp": 10, "mp": 5})
var skill_conditions: Array[BaseSkillCondition] = [] # Skill's conditions
var skill_caster: Character = null # Skill's caster
var skill_cooldown: int = 0 # Skill's cooldown
var skill_cooldown_type: SkillCooldownType = SkillCooldownType.MS # Skill's cooldown type

# Function to use the skill
# It should return true if the skill was used successfully, and false if it wasn't
Expand Down
3 changes: 2 additions & 1 deletion Core/Enums/gui/history/history_location.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@ enum HistoryLocation {
NONE,
DB_CHARACTERSLIST,
DB_CHARACTER,

DB_SKILLSLIST,
DB_SKILL,
}
6 changes: 6 additions & 0 deletions Core/Enums/skills/skill_cooldown_type.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

enum SkillCooldownType {
MS,
SEC,
MIN,
}
89 changes: 89 additions & 0 deletions Core/Registers/effect_register.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
extends Base
class_name EffectRegister
# This class is used to register all the effects in the game

func _init():
need_register = false # Set it to false to avoid registering this class in the class register

set_custom_name("EffectRegister")

static var data: Dictionary = {}

static func set_effects(effects: Dictionary) -> void:
# Set the effects data
data = effects

static func set_effect(effect_id: String, effect: BaseEffect) -> void:
# Set a effect data
data[effect_id] = effect

static func get_effect(effect_id: String) -> BaseEffect:
# Get a effect data
return data[effect_id]

static func get_all_effects() -> Dictionary:
# Get all effects data
return data

static func get_all_effects_names() -> Array:
# Get all effects names
var names = []
for effect in data.values():
names.append(effect.name)
return names

static func get_all_effects_ids() -> Array:
# Get all effects ids
return data.keys()

static func get_all_effects_name_by_ids() -> Array:
# Get all effects names by ids
var names = []
for effect_id in data.keys():
names.append({"name": data[effect_id].name, "value": effect_id})
return names

static func remove_effect(effect_id: String) -> bool:
# Remove a effect data
return data.erase(effect_id)

static func add_effect(effect: BaseEffect) -> String:
# Add a effect data

# Check if the effect has an id, if not, generate one
if effect.id == "":
effect.id = IdGenerator.new().generate_id()

var effect_id = effect.id
data[effect_id] = effect
return effect_id

static func new_effect() -> BaseEffect:
# Create a new effect

var id = IdGenerator.new().generate_id()

var effect = BaseEffect.new()

effect.id = id
effect.name = "New Effect"
effect.set_custom_name("Effect")

add_effect(effect)

return effect

static func get_effect_by_name(name: String) -> BaseEffect:
# Get a effect by name
for effect in data.values():
if effect.name == name:
return effect
return null

static func effects_to_string() -> String:
# Convert the skills data to a string
return var_to_str(data)

static func has_effect(effect_id: String) -> bool:
# Check if the effect exists
return data.has(effect_id)
1 change: 1 addition & 0 deletions Core/Registers/enum_register.gd
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ const EffectTarget = preload("res://Core/Enums/effects/effect_target.gd").Effect
## Skills
const SkillTypes = preload("res://Core/Enums/skills/skill_types.gd").SkillTypes
const SkillTarget = preload("res://Core/Enums/skills/skill_target.gd").SkillTarget
const SkillCooldownType = preload("res://Core/Enums/skills/skill_cooldown_type.gd").SkillCooldownType
## Objects
const ObjectType = preload("res://Core/Enums/objects/object_type.gd").ObjectType
## Items
Expand Down
82 changes: 82 additions & 0 deletions Core/Registers/skill_register.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
extends Base
class_name SkillRegister
# This class is used to register all the skills in the game

func _init():
need_register = false # Set it to false to avoid registering this class in the class register

set_custom_name("SkillRegister")

static var data: Dictionary = {}

static func set_skills(skills: Dictionary) -> void:
# Set the skills data
data = skills

static func set_skill(skill_id: String, skill: BaseSkill) -> void:
# Set a skill data
data[skill_id] = skill

static func get_skill(skill_id: String) -> BaseSkill:
# Get a skill data
return data[skill_id]

static func get_all_skills() -> Dictionary:
# Get all skills data
return data

static func get_all_skills_names() -> Array:
# Get all skills names
var names = []
for skill in data.values():
names.append(skill.name)
return names

static func get_all_skills_ids() -> Array:
# Get all skills ids
return data.keys()

static func get_all_skills_name_by_ids() -> Array:
# Get all skills names by ids
var names = []
for skill_id in data.keys():
names.append({"name": data[skill_id].name, "value": skill_id})
return names

static func remove_skill(skill_id: String) -> bool:
# Remove a skill data
return data.erase(skill_id)

static func add_skill(skill: BaseSkill) -> String:
# Add a skill data

# Check if the skill has an id, if not, generate one
if skill.id == "":
skill.id = IdGenerator.new().generate_id()

var skill_id = skill.id
data[skill_id] = skill
return skill_id

static func new_skill() -> BaseSkill:
# Create a new skill

var id: String = IdGenerator.new().generate_id()

var skill = BaseSkill.new()

skill.id = id
skill.name = "Skill"
skill.set_custom_name(id)

add_skill(skill)

return skill

static func skills_to_string() -> String:
# Convert the skills data to a string
return var_to_str(data)

static func has_skill(skill_id: String) -> bool:
# Check if a skill exists
return data.has(skill_id)
18 changes: 18 additions & 0 deletions Core/Scenes/Tests/list_template_test.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
extends CustomListTemplateBase

var idx: String
var label: Label


func load(): # This function will be called first when the list is created.
label = get_node("Panel/MarginContainer/HBoxContainer/Label")
pass

func set_data(_data: Dictionary): # This function will be called at third when the list is created.

print(_data)

label.text = _data["val"]

func set_idx(_idx: String): # This function will be called at second when the list is created. The IDX is the unique id of the item.
idx = _idx
27 changes: 27 additions & 0 deletions Core/Scenes/Utils/custom_list_v2.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
extends VBoxContainer
class_name CustomListV2Base

@onready var create_button: Button = get_node("MarginContainer2/menu/create")
@onready var add_button: Button = get_node("MarginContainer2/menu/add")
@onready var title_label: Label = get_node("TitleContainer/Title")
@onready var title_container: HBoxContainer = get_node("TitleContainer")


@export var show_create_button: bool = true
@export var show_add_button: bool = true
@export var show_title: bool = true

@export var title: String = "Title"

func _ready():

if !show_create_button:
create_button.hide()

if !show_add_button:
add_button.hide()

if !show_title:
title_container.hide()

title_label.text = tr(title)
Loading

0 comments on commit 240ed9e

Please sign in to comment.