renamed models.SkillImprovementCost2 to models.SkillImprovementCost
This commit is contained in:
@@ -1254,7 +1254,7 @@ func ImportSpellLevelLECosts(inputDir string) error {
|
|||||||
|
|
||||||
// ExportSkillImprovementCosts exports all skill improvement costs to a JSON file
|
// ExportSkillImprovementCosts exports all skill improvement costs to a JSON file
|
||||||
func ExportSkillImprovementCosts(outputDir string) error {
|
func ExportSkillImprovementCosts(outputDir string) error {
|
||||||
var costs []models.SkillImprovementCost2
|
var costs []models.SkillImprovementCost
|
||||||
if err := database.DB.Find(&costs).Error; err != nil {
|
if err := database.DB.Find(&costs).Error; err != nil {
|
||||||
return fmt.Errorf("failed to fetch skill improvement costs: %w", err)
|
return fmt.Errorf("failed to fetch skill improvement costs: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1332,13 +1332,13 @@ func ImportSkillImprovementCosts(inputDir string) error {
|
|||||||
exp.SkillName, exp.CategoryName, exp.DifficultyName, err)
|
exp.SkillName, exp.CategoryName, exp.DifficultyName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find or create SkillImprovementCost2 using category/difficulty IDs
|
// Find or create SkillImprovementCost using category/difficulty IDs
|
||||||
var cost models.SkillImprovementCost2
|
var cost models.SkillImprovementCost
|
||||||
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
||||||
categoryID, difficultyID, exp.CurrentLevel).First(&cost)
|
categoryID, difficultyID, exp.CurrentLevel).First(&cost)
|
||||||
|
|
||||||
if result.Error == gorm.ErrRecordNotFound {
|
if result.Error == gorm.ErrRecordNotFound {
|
||||||
cost = models.SkillImprovementCost2{
|
cost = models.SkillImprovementCost{
|
||||||
CategoryID: categoryID,
|
CategoryID: categoryID,
|
||||||
DifficultyID: difficultyID,
|
DifficultyID: difficultyID,
|
||||||
CurrentLevel: exp.CurrentLevel,
|
CurrentLevel: exp.CurrentLevel,
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import (
|
|||||||
|
|
||||||
// ExportSkillImprovementCosts exports all skill improvement costs to a JSON file
|
// ExportSkillImprovementCosts exports all skill improvement costs to a JSON file
|
||||||
func ExportSkillImprovementCosts(outputDir string) error {
|
func ExportSkillImprovementCosts(outputDir string) error {
|
||||||
var costs []models.SkillImprovementCost2
|
var costs []models.SkillImprovementCost
|
||||||
if err := database.DB.Find(&costs).Error; err != nil {
|
if err := database.DB.Find(&costs).Error; err != nil {
|
||||||
return fmt.Errorf("failed to fetch skill improvement costs: %w", err)
|
return fmt.Errorf("failed to fetch skill improvement costs: %w", err)
|
||||||
}
|
}
|
||||||
@@ -93,13 +93,13 @@ func ImportSkillImprovementCosts(inputDir string) error {
|
|||||||
exp.SkillName, exp.CategoryName, exp.DifficultyName, err)
|
exp.SkillName, exp.CategoryName, exp.DifficultyName, err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find or create SkillImprovementCost2 using category/difficulty IDs
|
// Find or create SkillImprovementCost using category/difficulty IDs
|
||||||
var cost models.SkillImprovementCost2
|
var cost models.SkillImprovementCost
|
||||||
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
||||||
categoryID, difficultyID, exp.CurrentLevel).First(&cost)
|
categoryID, difficultyID, exp.CurrentLevel).First(&cost)
|
||||||
|
|
||||||
if result.Error == gorm.ErrRecordNotFound {
|
if result.Error == gorm.ErrRecordNotFound {
|
||||||
cost = models.SkillImprovementCost2{
|
cost = models.SkillImprovementCost{
|
||||||
CategoryID: categoryID,
|
CategoryID: categoryID,
|
||||||
DifficultyID: difficultyID,
|
DifficultyID: difficultyID,
|
||||||
CurrentLevel: exp.CurrentLevel,
|
CurrentLevel: exp.CurrentLevel,
|
||||||
|
|||||||
@@ -893,8 +893,8 @@ func TestExportImportSkillImprovementCosts(t *testing.T) {
|
|||||||
t.Fatalf("Failed to query SkillCategoryDifficulty: %v", err)
|
t.Fatalf("Failed to query SkillCategoryDifficulty: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create SkillImprovementCost2 (new model)
|
// Create SkillImprovementCost (new model)
|
||||||
improvementCost := models.SkillImprovementCost2{
|
improvementCost := models.SkillImprovementCost{
|
||||||
CategoryID: category.ID,
|
CategoryID: category.ID,
|
||||||
DifficultyID: difficulty.ID,
|
DifficultyID: difficulty.ID,
|
||||||
CurrentLevel: 15, // Use unique level to avoid conflicts
|
CurrentLevel: 15, // Use unique level to avoid conflicts
|
||||||
@@ -924,10 +924,10 @@ func TestExportImportSkillImprovementCosts(t *testing.T) {
|
|||||||
t.Fatalf("ImportSkillImprovementCosts failed: %v", err)
|
t.Fatalf("ImportSkillImprovementCosts failed: %v", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
var imported models.SkillImprovementCost2
|
var imported models.SkillImprovementCost
|
||||||
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?", category.ID, difficulty.ID, 15).First(&imported)
|
result := database.DB.Where("skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?", category.ID, difficulty.ID, 15).First(&imported)
|
||||||
if result.Error != nil {
|
if result.Error != nil {
|
||||||
t.Fatalf("SkillImprovementCost2 not found after import: %v", result.Error)
|
t.Fatalf("SkillImprovementCost not found after import: %v", result.Error)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should be restored to original value from export
|
// Should be restored to original value from export
|
||||||
|
|||||||
@@ -291,7 +291,7 @@ func CreateLearningCostsTables() error {
|
|||||||
&models.ClassSpellSchoolEPCost{},
|
&models.ClassSpellSchoolEPCost{},
|
||||||
&models.SpellLevelLECost{},
|
&models.SpellLevelLECost{},
|
||||||
&models.SkillCategoryDifficulty{},
|
&models.SkillCategoryDifficulty{},
|
||||||
&models.SkillImprovementCost2{},
|
&models.SkillImprovementCost{},
|
||||||
}
|
}
|
||||||
|
|
||||||
// Erstelle oder migriere alle Tabellen
|
// Erstelle oder migriere alle Tabellen
|
||||||
|
|||||||
@@ -475,14 +475,14 @@ func migrateSkillImprovementCosts() error {
|
|||||||
|
|
||||||
// Für jeden Level in TrainCosts
|
// Für jeden Level in TrainCosts
|
||||||
for level, teCost := range data.TrainCosts {
|
for level, teCost := range data.TrainCosts {
|
||||||
var improvementCost models.SkillImprovementCost2
|
var improvementCost models.SkillImprovementCost
|
||||||
err := database.DB.Where(
|
err := database.DB.Where(
|
||||||
"skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
"skill_category_id = ? AND skill_difficulty_id = ? AND current_level = ?",
|
||||||
skillCategory.ID, skillDifficulty.ID, level,
|
skillCategory.ID, skillDifficulty.ID, level,
|
||||||
).First(&improvementCost).Error
|
).First(&improvementCost).Error
|
||||||
|
|
||||||
if err == gorm.ErrRecordNotFound {
|
if err == gorm.ErrRecordNotFound {
|
||||||
improvementCost = models.SkillImprovementCost2{
|
improvementCost = models.SkillImprovementCost{
|
||||||
CategoryID: skillCategory.ID,
|
CategoryID: skillCategory.ID,
|
||||||
DifficultyID: skillDifficulty.ID,
|
DifficultyID: skillDifficulty.ID,
|
||||||
CurrentLevel: level,
|
CurrentLevel: level,
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ func copyMariaDBToSQLite(mariaDB, sqliteDB *gorm.DB) error {
|
|||||||
&models.SpellLevelLECost{},
|
&models.SpellLevelLECost{},
|
||||||
&models.SkillCategoryDifficulty{},
|
&models.SkillCategoryDifficulty{},
|
||||||
&models.WeaponSkillCategoryDifficulty{},
|
&models.WeaponSkillCategoryDifficulty{},
|
||||||
&models.SkillImprovementCost2{},
|
&models.SkillImprovementCost{},
|
||||||
&models.ClassCategoryLearningPoints{},
|
&models.ClassCategoryLearningPoints{},
|
||||||
&models.ClassSpellPoints{},
|
&models.ClassSpellPoints{},
|
||||||
&models.ClassTypicalSkill{},
|
&models.ClassTypicalSkill{},
|
||||||
@@ -771,7 +771,7 @@ func copySQLiteToMariaDB(sqliteDB, mariaDB *gorm.DB) error {
|
|||||||
&models.SpellLevelLECost{},
|
&models.SpellLevelLECost{},
|
||||||
&models.SkillCategoryDifficulty{}, // Jetzt nach Skills
|
&models.SkillCategoryDifficulty{}, // Jetzt nach Skills
|
||||||
&models.WeaponSkillCategoryDifficulty{},
|
&models.WeaponSkillCategoryDifficulty{},
|
||||||
&models.SkillImprovementCost2{},
|
&models.SkillImprovementCost{},
|
||||||
&models.ClassCategoryLearningPoints{},
|
&models.ClassCategoryLearningPoints{},
|
||||||
&models.ClassSpellPoints{},
|
&models.ClassSpellPoints{},
|
||||||
&models.ClassTypicalSkill{},
|
&models.ClassTypicalSkill{},
|
||||||
@@ -924,8 +924,8 @@ func copyTableDataReverse(sourceDB, targetDB *gorm.DB, model interface{}) error
|
|||||||
return fmt.Errorf("failed to read batch from source: %w", err)
|
return fmt.Errorf("failed to read batch from source: %w", err)
|
||||||
}
|
}
|
||||||
records = batch
|
records = batch
|
||||||
case *models.SkillImprovementCost2:
|
case *models.SkillImprovementCost:
|
||||||
var batch []models.SkillImprovementCost2
|
var batch []models.SkillImprovementCost
|
||||||
if err := sourceDB.Limit(batchSize).Offset(offset).Find(&batch).Error; err != nil {
|
if err := sourceDB.Limit(batchSize).Offset(offset).Find(&batch).Error; err != nil {
|
||||||
return fmt.Errorf("failed to read batch from source: %w", err)
|
return fmt.Errorf("failed to read batch from source: %w", err)
|
||||||
}
|
}
|
||||||
@@ -1163,7 +1163,7 @@ func clearMariaDBData(db *gorm.DB) error {
|
|||||||
&models.Char{},
|
&models.Char{},
|
||||||
|
|
||||||
// Learning Costs System - Abhängige Tabellen (vor Skills/Spells löschen)
|
// Learning Costs System - Abhängige Tabellen (vor Skills/Spells löschen)
|
||||||
&models.SkillImprovementCost2{},
|
&models.SkillImprovementCost{},
|
||||||
&models.WeaponSkillCategoryDifficulty{},
|
&models.WeaponSkillCategoryDifficulty{},
|
||||||
&models.SkillCategoryDifficulty{},
|
&models.SkillCategoryDifficulty{},
|
||||||
&models.SpellLevelLECost{},
|
&models.SpellLevelLECost{},
|
||||||
|
|||||||
@@ -32,7 +32,7 @@ func TestTableListCompleteness(t *testing.T) {
|
|||||||
"*models.SpellLevelLECost": true,
|
"*models.SpellLevelLECost": true,
|
||||||
"*models.SkillCategoryDifficulty": true,
|
"*models.SkillCategoryDifficulty": true,
|
||||||
"*models.WeaponSkillCategoryDifficulty": true,
|
"*models.WeaponSkillCategoryDifficulty": true,
|
||||||
"*models.SkillImprovementCost2": true,
|
"*models.SkillImprovementCost": true,
|
||||||
|
|
||||||
// GSMaster Base Data
|
// GSMaster Base Data
|
||||||
"*models.Skill": true,
|
"*models.Skill": true,
|
||||||
@@ -88,7 +88,7 @@ func TestTableListCompleteness(t *testing.T) {
|
|||||||
&models.SpellLevelLECost{},
|
&models.SpellLevelLECost{},
|
||||||
&models.SkillCategoryDifficulty{},
|
&models.SkillCategoryDifficulty{},
|
||||||
&models.WeaponSkillCategoryDifficulty{},
|
&models.WeaponSkillCategoryDifficulty{},
|
||||||
&models.SkillImprovementCost2{},
|
&models.SkillImprovementCost{},
|
||||||
&models.Skill{},
|
&models.Skill{},
|
||||||
&models.WeaponSkill{},
|
&models.WeaponSkill{},
|
||||||
&models.Spell{},
|
&models.Spell{},
|
||||||
@@ -301,8 +301,8 @@ func getModelTypeName(model interface{}) string {
|
|||||||
return "*models.SkillCategoryDifficulty"
|
return "*models.SkillCategoryDifficulty"
|
||||||
case *models.WeaponSkillCategoryDifficulty:
|
case *models.WeaponSkillCategoryDifficulty:
|
||||||
return "*models.WeaponSkillCategoryDifficulty"
|
return "*models.WeaponSkillCategoryDifficulty"
|
||||||
case *models.SkillImprovementCost2:
|
case *models.SkillImprovementCost:
|
||||||
return "*models.SkillImprovementCost2"
|
return "*models.SkillImprovementCost"
|
||||||
case *models.Skill:
|
case *models.Skill:
|
||||||
return "*models.Skill"
|
return "*models.Skill"
|
||||||
case *models.WeaponSkill:
|
case *models.WeaponSkill:
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ func learningMigrateStructure(db ...*gorm.DB) error {
|
|||||||
&ClassTypicalSkill{},
|
&ClassTypicalSkill{},
|
||||||
&ClassTypicalSpell{},
|
&ClassTypicalSpell{},
|
||||||
&AuditLogEntry{},
|
&AuditLogEntry{},
|
||||||
&SkillImprovementCost2{},
|
&SkillImprovementCost{},
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
@@ -306,7 +306,7 @@ func TestLearningMigrateStructure_VerifyStructures(t *testing.T) {
|
|||||||
&ClassSpellSchoolEPCost{},
|
&ClassSpellSchoolEPCost{},
|
||||||
&SpellLevelLECost{},
|
&SpellLevelLECost{},
|
||||||
&SkillCategoryDifficulty{},
|
&SkillCategoryDifficulty{},
|
||||||
&SkillImprovementCost2{},
|
&SkillImprovementCost{},
|
||||||
&AuditLogEntry{},
|
&AuditLogEntry{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -132,20 +132,8 @@ type WeaponSkillCategoryDifficulty struct {
|
|||||||
SCategory string `gorm:"column:skill_category;size:25;not null;index;default:Waffen" json:"skillCategory"`
|
SCategory string `gorm:"column:skill_category;size:25;not null;index;default:Waffen" json:"skillCategory"`
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
// SkillImprovementCost definiert TE-Kosten für Verbesserungen basierend auf Kategorie, Schwierigkeit und aktuellem Wert
|
// SkillImprovementCost definiert TE-Kosten für Verbesserungen basierend auf Kategorie, Schwierigkeit und aktuellem Wert
|
||||||
type SkillImprovementCost struct {
|
type SkillImprovementCost struct {
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
|
||||||
SkillCategoryDifficultyID uint `gorm:"not null;index" json:"skill_category_difficulty_id"`
|
|
||||||
CurrentLevel int `gorm:"not null;index" json:"current_level"` // Aktueller Fertigkeitswert
|
|
||||||
TERequired int `gorm:"not null" json:"te_required"` // Benötigte Trainingseinheiten
|
|
||||||
SkillCategoryDifficulty SkillCategoryDifficulty `gorm:"foreignKey:SkillCategoryDifficultyID;constraint:OnUpdate:CASCADE,OnDelete:CASCADE" json:"skill_category_difficulty"`
|
|
||||||
CategoryID uint `gorm:"column:skill_category_id;not null;index;default:1" json:"skillCategoryId"` // SkillCategoryID
|
|
||||||
DifficultyID uint `gorm:"column:skill_difficulty_id;not null;index;default:1" json:"skillDifficultyId"` // SkillDifficultyID
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
// SkillImprovementCost definiert TE-Kosten für Verbesserungen basierend auf Kategorie, Schwierigkeit und aktuellem Wert
|
|
||||||
type SkillImprovementCost2 struct {
|
|
||||||
ID uint `gorm:"primaryKey" json:"id"`
|
ID uint `gorm:"primaryKey" json:"id"`
|
||||||
CurrentLevel int `gorm:"not null;index" json:"current_level"` // Aktueller Fertigkeitswert
|
CurrentLevel int `gorm:"not null;index" json:"current_level"` // Aktueller Fertigkeitswert
|
||||||
TERequired int `gorm:"not null" json:"te_required"` // Benötigte Trainingseinheiten
|
TERequired int `gorm:"not null" json:"te_required"` // Benötigte Trainingseinheiten
|
||||||
@@ -251,7 +239,7 @@ func (SkillImprovementCost) TableName() string {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (SkillImprovementCost2) TableName() string {
|
func (SkillImprovementCost) TableName() string {
|
||||||
return "skill_improvement_cost2"
|
return "skill_improvement_cost2"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -500,7 +488,7 @@ func (sic *SkillImprovementCost) Create() error {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func (sic *SkillImprovementCost2) Create() error {
|
func (sic *SkillImprovementCost) Create() error {
|
||||||
return database.DB.Create(sic).Error
|
return database.DB.Create(sic).Error
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -654,7 +642,7 @@ func GetSpellLearningInfoNewSystem(spellName string, classCode string) (*SpellLe
|
|||||||
|
|
||||||
// GetImprovementCost holt die Verbesserungskosten für eine Fertigkeit
|
// GetImprovementCost holt die Verbesserungskosten für eine Fertigkeit
|
||||||
func GetImprovementCost(skillName string, categoryName string, difficultyName string, currentLevel int) (int, error) {
|
func GetImprovementCost(skillName string, categoryName string, difficultyName string, currentLevel int) (int, error) {
|
||||||
var result SkillImprovementCost2
|
var result SkillImprovementCost
|
||||||
|
|
||||||
err := database.DB.Raw(`
|
err := database.DB.Raw(`
|
||||||
SELECT sic.te_required
|
SELECT sic.te_required
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ type DatabaseExport struct {
|
|||||||
ClassSpellSchoolEPCosts []models.ClassSpellSchoolEPCost `json:"learning_class_spell_school_ep_costs"`
|
ClassSpellSchoolEPCosts []models.ClassSpellSchoolEPCost `json:"learning_class_spell_school_ep_costs"`
|
||||||
SpellLevelLECosts []models.SpellLevelLECost `json:"learning_spell_level_le_costs"`
|
SpellLevelLECosts []models.SpellLevelLECost `json:"learning_spell_level_le_costs"`
|
||||||
SkillCategoryDifficulties []models.SkillCategoryDifficulty `json:"learning_skill_category_difficulties"`
|
SkillCategoryDifficulties []models.SkillCategoryDifficulty `json:"learning_skill_category_difficulties"`
|
||||||
SkillImprovementCosts []models.SkillImprovementCost2 `json:"learning_skill_improvement_costs"`
|
SkillImprovementCosts []models.SkillImprovementCost `json:"learning_skill_improvement_costs"`
|
||||||
AuditLogEntries []models.AuditLogEntry `json:"audit_log_entries"`
|
AuditLogEntries []models.AuditLogEntry `json:"audit_log_entries"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ type LearningDataExport struct {
|
|||||||
ClassSpellSchoolEPCosts []models.ClassSpellSchoolEPCost `json:"class_spell_school_ep_costs"`
|
ClassSpellSchoolEPCosts []models.ClassSpellSchoolEPCost `json:"class_spell_school_ep_costs"`
|
||||||
SpellLevelLECosts []models.SpellLevelLECost `json:"spell_level_le_costs"`
|
SpellLevelLECosts []models.SpellLevelLECost `json:"spell_level_le_costs"`
|
||||||
SkillCategoryDifficulties []models.SkillCategoryDifficulty `json:"skill_category_difficulties"`
|
SkillCategoryDifficulties []models.SkillCategoryDifficulty `json:"skill_category_difficulties"`
|
||||||
SkillImprovementCosts []models.SkillImprovementCost2 `json:"skill_improvement_costs"`
|
SkillImprovementCosts []models.SkillImprovementCost `json:"skill_improvement_costs"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ExportCharacter exports a complete character with all related data
|
// ExportCharacter exports a complete character with all related data
|
||||||
@@ -177,7 +177,7 @@ func ExportCharacter(characterID uint) (*CharacterExport, error) {
|
|||||||
ClassSpellSchoolEPCosts: make([]models.ClassSpellSchoolEPCost, 0),
|
ClassSpellSchoolEPCosts: make([]models.ClassSpellSchoolEPCost, 0),
|
||||||
SpellLevelLECosts: make([]models.SpellLevelLECost, 0),
|
SpellLevelLECosts: make([]models.SpellLevelLECost, 0),
|
||||||
SkillCategoryDifficulties: make([]models.SkillCategoryDifficulty, 0),
|
SkillCategoryDifficulties: make([]models.SkillCategoryDifficulty, 0),
|
||||||
SkillImprovementCosts: make([]models.SkillImprovementCost2, 0),
|
SkillImprovementCosts: make([]models.SkillImprovementCost, 0),
|
||||||
}
|
}
|
||||||
|
|
||||||
database.DB.Find(&export.LearningData.Sources)
|
database.DB.Find(&export.LearningData.Sources)
|
||||||
|
|||||||
Reference in New Issue
Block a user