I do not know what changed.
too long ago
This commit is contained in:
@@ -1463,13 +1463,10 @@ func GetAvailableSkillsNewSystem(c *gin.Context) {
|
||||
// getCharacterClassCode converts a character class name to its code using the database
|
||||
func getCharacterClassCode(className string) (string, error) {
|
||||
var characterClass models.CharacterClass
|
||||
err := characterClass.FirstByName(className)
|
||||
if err != nil {
|
||||
err := characterClass.FirstByCode(className)
|
||||
err := characterClass.FirstByNameOrCode(className)
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("character class '%s' not found: %w", className, err)
|
||||
}
|
||||
}
|
||||
return characterClass.Code, nil
|
||||
}
|
||||
|
||||
|
||||
@@ -128,8 +128,8 @@ func TestImproveSkillHandler(t *testing.T) {
|
||||
"from_level": float64(9),
|
||||
"gold_cost": float64(20),
|
||||
"message": "Fertigkeit erfolgreich verbessert",
|
||||
"remaining_ep": float64(316),
|
||||
"remaining_gold": float64(370),
|
||||
"remaining_ep": float64(250),
|
||||
"remaining_gold": float64(290),
|
||||
"skill_name": "Athletik",
|
||||
"to_level": float64(10),
|
||||
}
|
||||
@@ -151,10 +151,10 @@ func TestImproveSkillHandler(t *testing.T) {
|
||||
assert.NoError(t, err)
|
||||
|
||||
// Check that EP was deducted correctly
|
||||
assert.Equal(t, 316, updatedChar.Erfahrungsschatz.EP, "Character should have 316 EP remaining")
|
||||
assert.Equal(t, 250, updatedChar.Erfahrungsschatz.EP, "Character should have 316 EP remaining")
|
||||
|
||||
// Check that Gold was deducted correctly
|
||||
assert.Equal(t, 370, updatedChar.Vermoegen.Goldstücke, "Character should have 370 Gold remaining")
|
||||
assert.Equal(t, 290, updatedChar.Vermoegen.Goldstücke, "Character should have 370 Gold remaining")
|
||||
|
||||
t.Logf("Test completed successfully!")
|
||||
t.Logf("EP: %d -> %d (cost: %.0f)", 326, updatedChar.Erfahrungsschatz.EP, response["ep_cost"])
|
||||
|
||||
@@ -230,6 +230,9 @@ func (cc *CharacterClass) FirstByCode(code string) error {
|
||||
func (cc *CharacterClass) FirstByName(code string) error {
|
||||
return database.DB.Where("name = ?", code).First(cc).Error
|
||||
}
|
||||
func (cc *CharacterClass) FirstByNameOrCode(value string) error {
|
||||
return database.DB.Where("name = ? OR code = ?", value, value).First(cc).Error
|
||||
}
|
||||
|
||||
func (sc *SkillCategory) Create() error {
|
||||
return database.DB.Create(sc).Error
|
||||
|
||||
Reference in New Issue
Block a user