Skip to content

Commit

Permalink
fix: Armor adding problems #43
Browse files Browse the repository at this point in the history
  • Loading branch information
KrystianKempski committed Nov 20, 2024
1 parent 773b69c commit 2ed1193
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 26 deletions.
49 changes: 42 additions & 7 deletions DagoniteEmpire/Pages/Components/BattleStatsComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
}
</div>
</div>
@if (Armor is not null && ArmorBattleProperties is not null)
@if (Armor is not null && ArmorBattleProperties is not null && AllParams?.SpecialSkills is not null)
{
<div class="d-flex w-100 p-0 my-1">
<div class="d-flex flex-column border w-100">
Expand All @@ -208,7 +208,7 @@
<label>Armor defence bonus: </label>
</div>
<div class="weapon-prop-value">
@ArmorBattleProperties.FirstOrDefault(p => p.Name == SD.WeaponQuality.ArmorDefenceBonus).GearBonus
@ArmorDefenceBonus
</div>
</div>
</div>
Expand All @@ -218,15 +218,15 @@
<label>Armor damage reduction: </label>
</div>
<div class="weapon-prop-value">
@ArmorBattleProperties.FirstOrDefault(p => p.Name == SD.WeaponQuality.Armor).GearBonus
@ArmorValue
</div>
</div>
<div class="d-flex">
<div class="flex-grow-1 weapon-prop-label">
<label>Armor penalty: </label>
</div>
<div class="weapon-prop-value">
@ArmorBattleProperties.FirstOrDefault(p => p.Name == SD.WeaponQuality.ArmorPenalty).GearBonus
@ArmorPenalty
</div>
</div>
</div>
Expand Down Expand Up @@ -342,9 +342,13 @@
public Dictionary<EquippedItems, EquipItemComponent> EquipItemComp { get; set; } = new Dictionary<EquippedItems, EquipItemComponent>();
public Dictionary<EquippedItems, IEnumerable<BattlePropertyDTO>?> WeaponBattleProperties { get; set; } = new Dictionary<EquippedItems, IEnumerable<BattlePropertyDTO>?>();
public Dictionary<EquippedItems, EquipmentDTO?> Weapons { get; set; } = new Dictionary<EquippedItems, EquipmentDTO?>();
public EquipmentDTO? Armor { get; set; }
public IEnumerable<BattlePropertyDTO>? ArmorBattleProperties { get; set; }

public EquipmentDTO? Armor { get; set; }
public IEnumerable<BattlePropertyDTO>? ArmorBattleProperties { get; set; } = null;
public int ArmorDefenceBonus { get; set; } = 0;
public int ArmorValue { get; set; } = 0;
public int ArmorPenalty {get;set;} = 0;
public int a;

protected override async Task OnInitializedAsync()
{
for (EquippedItems i = EquippedItems.WeaponMain1; i <= EquippedItems.WeaponOff2; i++)
Expand Down Expand Up @@ -377,7 +381,38 @@
{
Armor = AllParams.EquipmentSlots?.FirstOrDefault(s => s.SlotType == SD.SlotType.Body)?.Equipment;
if (Armor is not null)
{

ArmorBattleProperties = AllParams.BattleProperties.GetWeaponQualityListFromItem(Armor);
BattlePropertyDTO? prop = ArmorBattleProperties?.FirstOrDefault(p => p.Name == SD.WeaponQuality.ArmorDefenceBonus);
if(prop is null)
{
ArmorDefenceBonus = 0;
}
else
{
ArmorDefenceBonus = prop.GearBonus;
}
var arm = ArmorBattleProperties?.FirstOrDefault(p => p.Name == SD.WeaponQuality.Armor);
if (prop is null)
{
ArmorValue = 0;
}
else
{
ArmorValue = prop.GearBonus;
}
var def = ArmorBattleProperties?.FirstOrDefault(p => p.Name == SD.WeaponQuality.ArmorPenalty);
if (prop is null)
{
ArmorPenalty = 0;
}
else
{
ArmorPenalty = prop.GearBonus;
}

}
else
ArmorBattleProperties = null;
}
Expand Down
34 changes: 17 additions & 17 deletions DagoniteEmpire/Pages/Components/TraitsComponent.razor
Original file line number Diff line number Diff line change
Expand Up @@ -149,17 +149,17 @@
private async Task AddWeaponQualities()
{
NewTrait = CreateNewTrait();
var weaponPropertyTrait = Traits.FirstOrDefault(t => t.Name == SD.WeaponParametersDescr);
bool editMode = false;
if (weaponPropertyTrait is not null)
{
editMode = true;
NewTrait = new TraitEquipmentDTO(weaponPropertyTrait,null);
}
else
{
// var weaponPropertyTrait = Traits.FirstOrDefault(t => t.Name == SD.WeaponParametersDescr);
// bool editMode = false;
// if (weaponPropertyTrait is not null)
// {
// editMode = true;
// NewTrait = new TraitEquipmentDTO(weaponPropertyTrait,null);
// }
// else
// {
NewTrait = new TraitEquipmentDTO();
}
//}
var parameters = new DialogParameters<CreateTraitDialog> { { x => x.NewTrait, NewTrait },
{ x => x.IsWeaponQualityMode, true },
{ x => x.AllParams, AllParams } };
Expand All @@ -170,14 +170,14 @@
if (!result.Canceled)
{
NewTrait = (TraitDTO)result.Data;
if (editMode)
{
weaponPropertyTrait = NewTrait;
}
else
{
// if (editMode)
// {
// weaponPropertyTrait = NewTrait;
// }
// else
// {
Traits.Add(NewTrait);
}
// }
await UpdateTraits();
}
}
Expand Down
16 changes: 14 additions & 2 deletions DagoniteEmpire/Pages/Dialogs/CreateEquipmentSlotDialog.razor
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

@using System.Globalization;
@using System.Text;
@using DA_Models
@inject ISnackbar Snackbar
@inject IUserService _userService
@inject ISpecialSkillRepository _specialSkillRepository
Expand Down Expand Up @@ -294,8 +295,19 @@
Traits = NewSlot.Equipment.Traits.Cast<TraitDTO>().ToList();
}
userInfo = await _userService.GetUserInfo();
MeleeSkills = await (_specialSkillRepository.GetAllFromGroup(userInfo.SelectedCharacter.Id , SD.BaseSkills.Melee));
ShootingSkills = await (_specialSkillRepository.GetAllFromGroup(userInfo.SelectedCharacter.Id, SD.BaseSkills.Shooting));


if(userInfo?.SelectedCharacter is not null && userInfo.SelectedCharacter.Id != 0)
{

MeleeSkills = await (_specialSkillRepository.GetAllFromGroup(userInfo.SelectedCharacter.Id , SD.BaseSkills.Melee));
ShootingSkills = await (_specialSkillRepository.GetAllFromGroup(userInfo.SelectedCharacter.Id, SD.BaseSkills.Shooting));
}
else
{
MeleeSkills = CharacterSeeder.GetSpecialSkills().Where(u => u.RelatedBaseSkillName == SD.BaseSkills.Melee);
ShootingSkills = CharacterSeeder.GetSpecialSkills().Where(u => u.RelatedBaseSkillName == SD.BaseSkills.Shooting);
}
HeaderName = IsEditMode ? "Edit" : "Add";
HeaderName += " item";
if (NewSlot.Equipment is not null && NewSlot.Equipment.IsApproved)
Expand Down
Binary file not shown.

0 comments on commit 2ed1193

Please sign in to comment.