Joszko
Joszko
CC#
Created by Joszko on 12/1/2024 in #help
Timer problem
Yup, that's right
public class Student
{
// Keys
public int Id { get; set; }

// Key fragments

[Required]
public int Money { get; set; } = 0;

[Required]
public int Energy { get; set; } = 100;

// Experience and position in ranking
[Required]
public int LevelPoints { get; set; } = 0;

[Required]
public Ranks Rank { get; set; } = Ranks.Silver_I;

[Required]
public int Level { get; set; } = 1;

[Required]
public int Experience { get; set; } = 0;

// Points used in fights, events etc.
[Required]
public int HealthPoints { get; set; } = 100; // bazowe zdrowie

[Required]
public int AttackPoints { get; set; } = 1; // bazowy atak

[Required]
public int DefensePoints { get; set; } = 1; // zwieksza procentowo hp przy ataku

[Required]
public int LuckPoints { get; set; } = 1; // pomaga przy losowaniu do ataku

[Required]
public int IntelligencePoints { get; set; } = 1;// cappuje zakladanie broni/zbroi aby nie bylo przypadku kiedy osoba na 1lvl moze zalozyc najlepszy przedmiot w grze

// Equipped items
[ForeignKey("Armour")]
[AllowNull]
public int? ArmourId { get; set; }

[ForeignKey("Weapon")]
[AllowNull]
public int? WeaponId { get; set; }

[ForeignKey("Account")]
public int AccountId { get; set; }

// Db relation
public ICollection<Student_Weapon> Student_Weapons { get; set; } = new List<Student_Weapon>();
public ICollection<Student_Armour> Student_Armours { get; set; } = new List<Student_Armour>();
public ICollection<Student_Food> Student_Foods { get; set; } = new List<Student_Food>();
public Stat? Stats{ get; set; }

//child
public Armour Armour { get; set; } = null!;
public Weapon Weapon { get; set; } = null!;
public Account Account { get; set; } = null!;
}

public class Food
{
public int Id { get; set; }

[Required]
public string Name { get; set; } = string.Empty;

[Required]
public int BoostAmount { get; set; }

[Required]
public Boost BoostType { get; set; }

[Required]
public int Duration { get; set; }

[Required]
public int Cost { get; set; }

[Required]
public Rarity Rarity{ get; set; }

// Db relation
public ICollection<Student_Food> Student_Foods { get; set; } = new List<Student_Food>();
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Boost
{
HealthBoost = 1,
AttackBoost = 2,
DefenseBoost = 3,
LuckBoost = 4
}
public class Student
{
// Keys
public int Id { get; set; }

// Key fragments

[Required]
public int Money { get; set; } = 0;

[Required]
public int Energy { get; set; } = 100;

// Experience and position in ranking
[Required]
public int LevelPoints { get; set; } = 0;

[Required]
public Ranks Rank { get; set; } = Ranks.Silver_I;

[Required]
public int Level { get; set; } = 1;

[Required]
public int Experience { get; set; } = 0;

// Points used in fights, events etc.
[Required]
public int HealthPoints { get; set; } = 100; // bazowe zdrowie

[Required]
public int AttackPoints { get; set; } = 1; // bazowy atak

[Required]
public int DefensePoints { get; set; } = 1; // zwieksza procentowo hp przy ataku

[Required]
public int LuckPoints { get; set; } = 1; // pomaga przy losowaniu do ataku

[Required]
public int IntelligencePoints { get; set; } = 1;// cappuje zakladanie broni/zbroi aby nie bylo przypadku kiedy osoba na 1lvl moze zalozyc najlepszy przedmiot w grze

// Equipped items
[ForeignKey("Armour")]
[AllowNull]
public int? ArmourId { get; set; }

[ForeignKey("Weapon")]
[AllowNull]
public int? WeaponId { get; set; }

[ForeignKey("Account")]
public int AccountId { get; set; }

// Db relation
public ICollection<Student_Weapon> Student_Weapons { get; set; } = new List<Student_Weapon>();
public ICollection<Student_Armour> Student_Armours { get; set; } = new List<Student_Armour>();
public ICollection<Student_Food> Student_Foods { get; set; } = new List<Student_Food>();
public Stat? Stats{ get; set; }

//child
public Armour Armour { get; set; } = null!;
public Weapon Weapon { get; set; } = null!;
public Account Account { get; set; } = null!;
}

public class Food
{
public int Id { get; set; }

[Required]
public string Name { get; set; } = string.Empty;

[Required]
public int BoostAmount { get; set; }

[Required]
public Boost BoostType { get; set; }

[Required]
public int Duration { get; set; }

[Required]
public int Cost { get; set; }

[Required]
public Rarity Rarity{ get; set; }

// Db relation
public ICollection<Student_Food> Student_Foods { get; set; } = new List<Student_Food>();
}

[JsonConverter(typeof(JsonStringEnumConverter))]
public enum Boost
{
HealthBoost = 1,
AttackBoost = 2,
DefenseBoost = 3,
LuckBoost = 4
}
Here are these classes
4 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
Ok, found the issue, axios.get is getting the wrong thing because of param
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
that's why i don't like frontend ;.;
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
and thats profile
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
profile: { nickname: 'none', money: 0, energy: 0, rank: 'none', level: 0, experience: 0, levelPoints: 0, healthPoints: 0, attackPoints: 0, defensePoints: 0, luckPoints: 0, intelligencePoints: 0 } };
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
call looks like that
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
async fetchProfile() { try { const response = await axios.get('http://localhost:5033/api/Student/GetStudentProfile', { params: { StudentId: 1 // tutaj ustalamy jakiego uzytkownika id chcemy } }); if (response.data.value.success) { this.profile = response.data.value.data; console.log("Profil:", this.profile); } else { console.error("Failed to fetch profile: ", response.data.value.message); } } catch (error) { console.error("Error fetching profile: ", error); } }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
hmmm, weird cause im using the GetStudentProfile
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
public class GetStudentProfileDTO { public string Nickname { get; set;} = string.Empty; public int Money { get; set; } = 0; public int Energy { get; set; } = 100; public Ranks Rank { get; set; } = Ranks.Silver_I; public int Level { get; set; } = 1; public int Experience { get; set; } = 0; public int LevelPoints { get; set; } = 0; public int HealthPoints { get; set; } = 100; public int AttackPoints { get; set; } = 1; public int DefensePoints { get; set; } = 1; public int LuckPoints { get; set; } = 1; public int IntelligencePoints { get; set; } = 1; }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
i mean, i even showed you output from swagger xD
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
and Dto in swagger looks like it should but idk why it is showing this odd things when consol.logging it in browser
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
it's service call which later im passing to controller: [HttpGet("GetStudentProfile{StudentId}")] public async Task<IActionResult> GetStudentProfile(int StudentId) { return Ok(new JsonResult(await _studentService.GetStudentProfile(StudentId))); }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
public async Task<ServiceResponse<GetStudentProfileDTO>> GetStudentProfile(int StudentId) { var serviceResponse = new ServiceResponse<GetStudentProfileDTO>(); try { var student = await _context.Students .Include(c => c.Account) .FirstOrDefaultAsync(x => x.Id == StudentId); if (student is not null) { GetStudentProfileDTO response = student.Adapt<GetStudentProfileDTO>(); response.Nickname = student.Account.Nickname; serviceResponse.Data = response; } else{ serviceResponse.Success = false; serviceResponse.Message = $"Brak studenta o {StudentId} id"; } } catch (Exception ex) { serviceResponse.Success = false; serviceResponse.Message = $"Error: {ex.Message}"; return serviceResponse; } return serviceResponse; }
22 replies
CC#
Created by Joszko on 11/6/2024 in #help
✅ [SOLVED] Weird DTO response
i mean, why account, id or even weapon is showing if it is not in the DTO data
22 replies