Skip to content

Commit

Permalink
Add 'preferred team' feature (#307)
Browse files Browse the repository at this point in the history
Implements:

- /quest/get_quest_clear_party
- /quest/get_quest_clear_party_multi
- /quest/set_quest_clear_party
- /quest/set_quest_clear_party_multi

Includes a new database table for saved clear units, and also logic to
detect when entities from saved parties are missing.

Saved clear parties are exempted from the save import deletion process,
as they are not contained in a save, so wiping them on every import
seemed harsh. As a result, they may contain entities which the user no
longer owns.

Fortunately, the game provides a mechanism to handle this in the form of
"lost_unit_list", which shows a pop-up indicating what entities cannot
be retrieved from the clear party.
This is probably intended for entities which can normally be lost, like
dragons or portrait prints, but seems to work sort of okay with weapons
and wyrmprints:

<img
src="https://github.com/SapiensAnatis/Dawnshard/assets/5047192/f769492b-ced9-4fe5-81a0-651f8f161267"
width="30%" height="30%"/>

There is however no entity type for missing shared skills, and missing
characters will cause the button to be disabled entirely.
  • Loading branch information
SapiensAnatis authored Jul 16, 2023
1 parent 153c1de commit 61176d8
Show file tree
Hide file tree
Showing 36 changed files with 5,119 additions and 318 deletions.
2 changes: 2 additions & 0 deletions DragaliaAPI.Database/ApiContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,4 +155,6 @@ but EF Core doesn't like this and the client probably stops you anyway?
public DbSet<DbPlayerShopPurchase> PlayerPurchases { get; set; }

public DbSet<DbPlayerTrade> PlayerTrades { get; set; }

public DbSet<DbQuestClearPartyUnit> QuestClearPartyUnits { get; set; }
}
17 changes: 17 additions & 0 deletions DragaliaAPI.Database/Entities/Abstract/DbPartyUnitBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using DragaliaAPI.Shared.Definitions.Enums;

namespace DragaliaAPI.Database.Entities.Abstract;

/// <summary>
/// Base class for party units with edit skills / weapon skins equipped.
/// </summary>
public abstract class DbPartyUnitBase : DbUnitBase
{
public int EquipWeaponSkinId { get; set; }

public Charas EditSkill1CharaId { get; set; }

public Charas EditSkill2CharaId { get; set; }

public required int UnitNo { get; set; }
}
31 changes: 31 additions & 0 deletions DragaliaAPI.Database/Entities/Abstract/DbUnitBase.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using DragaliaAPI.Shared.Definitions.Enums;

namespace DragaliaAPI.Database.Entities.Abstract;

/// <summary>
/// Base class for party units and unit equipment set entries.
/// </summary>
public abstract class DbUnitBase
{
public Charas CharaId { get; set; }

public long EquipDragonKeyId { get; set; }

public WeaponBodies EquipWeaponBodyId { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId2 { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId3 { get; set; }

public AbilityCrests EquipCrestSlotType2CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType2CrestId2 { get; set; }

public AbilityCrests EquipCrestSlotType3CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType3CrestId2 { get; set; }

public long EquipTalismanKeyId { get; set; }
}
33 changes: 2 additions & 31 deletions DragaliaAPI.Database/Entities/DbPartyUnit.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using DragaliaAPI.Database.Entities.Abstract;
using DragaliaAPI.Shared.Definitions.Enums;
using Microsoft.EntityFrameworkCore;

namespace DragaliaAPI.Database.Entities;

[Index(nameof(DeviceAccountId))]
public class DbPartyUnit
public class DbPartyUnit : DbPartyUnitBase
{
// In theory, a composite primary key of [Party, UnitNo] would work great.
// However, EF Core doesn't like navigation properties being used as keys.
Expand All @@ -19,34 +20,4 @@ public class DbPartyUnit
public string DeviceAccountId { get; set; } = string.Empty;

public int PartyNo { get; set; }

public required int UnitNo { get; set; }

public required Charas CharaId { get; set; }

public long EquipDragonKeyId { get; set; } = 0;

public WeaponBodies EquipWeaponBodyId { get; set; }

public int EquipWeaponSkinId { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId2 { get; set; }

public AbilityCrests EquipCrestSlotType1CrestId3 { get; set; }

public AbilityCrests EquipCrestSlotType2CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType2CrestId2 { get; set; }

public AbilityCrests EquipCrestSlotType3CrestId1 { get; set; }

public AbilityCrests EquipCrestSlotType3CrestId2 { get; set; }

public long EquipTalismanKeyId { get; set; }

public Charas EditSkill1CharaId { get; set; }

public Charas EditSkill2CharaId { get; set; }
}
53 changes: 53 additions & 0 deletions DragaliaAPI.Database/Entities/DbQuestClearPartyUnit.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using DragaliaAPI.Database.Entities.Abstract;
using DragaliaAPI.Shared.Definitions.Enums;
using Microsoft.EntityFrameworkCore;

namespace DragaliaAPI.Database.Entities;

[PrimaryKey(nameof(DeviceAccountId), nameof(QuestId), nameof(IsMulti), nameof(UnitNo))]
public class DbQuestClearPartyUnit : DbPartyUnitBase, IDbHasAccountId
{
public virtual DbPlayer? Owner { get; set; }

[ForeignKey(nameof(Owner))]
public required string DeviceAccountId { get; set; }

public required int QuestId { get; set; }

public required bool IsMulti { get; set; }

public Dragons EquippedDragonEntityId { get; set; }

public Talismans EquippedTalismanEntityId { get; set; }

/// <summary>
/// Reset this entity back to a state representing an empty slot.
/// </summary>
public void Clear()
{
this.CharaId = Charas.Empty;

this.EquipWeaponBodyId = WeaponBodies.Empty;
this.EquipWeaponSkinId = 0;

this.EquipDragonKeyId = 0;
this.EquipTalismanKeyId = 0;
this.EquippedDragonEntityId = Dragons.Empty;
this.EquippedTalismanEntityId = Talismans.Empty;

this.EquipCrestSlotType1CrestId1 = AbilityCrests.Empty;
this.EquipCrestSlotType1CrestId2 = AbilityCrests.Empty;
this.EquipCrestSlotType1CrestId3 = AbilityCrests.Empty;

this.EquipCrestSlotType2CrestId1 = AbilityCrests.Empty;
this.EquipCrestSlotType2CrestId2 = AbilityCrests.Empty;

this.EquipCrestSlotType3CrestId1 = AbilityCrests.Empty;
this.EquipCrestSlotType3CrestId2 = AbilityCrests.Empty;

this.EditSkill1CharaId = Charas.Empty;
this.EditSkill2CharaId = Charas.Empty;
}
}
28 changes: 2 additions & 26 deletions DragaliaAPI.Database/Entities/DbSetUnit.cs
Original file line number Diff line number Diff line change
@@ -1,47 +1,23 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using DragaliaAPI.Database.Entities.Abstract;
using DragaliaAPI.Shared.Definitions.Enums;
using Microsoft.EntityFrameworkCore;

namespace DragaliaAPI.Database.Entities;

//TODO: This and PartyUnit share a lot of properties, maybe extract those and make these into subclasses which inherit them
[Table("PlayerSetUnit")]
[Index(nameof(DeviceAccountId))]
public class DbSetUnit : IDbHasAccountId
public class DbSetUnit : DbUnitBase, IDbHasAccountId
{
/// <inheritdoc />
public virtual DbPlayer? Owner { get; set; }

/// <inheritdoc />
[ForeignKey(nameof(Owner))]
public required string DeviceAccountId { get; set; }

[Required]
public Charas CharaId { get; set; }

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

public required string UnitSetName { get; set; }

public long EquipDragonKeyId { get; set; }

public int EquipWeaponBodyId { get; set; }

public int EquipCrestSlotType1CrestId1 { get; set; }

public int EquipCrestSlotType1CrestId2 { get; set; }

public int EquipCrestSlotType1CrestId3 { get; set; }

public int EquipCrestSlotType2CrestId1 { get; set; }

public int EquipCrestSlotType2CrestId2 { get; set; }

public int EquipCrestSlotType3CrestId1 { get; set; }

public int EquipCrestSlotType3CrestId2 { get; set; }

public long EquipTalismanKeyId { get; set; }
}
6 changes: 4 additions & 2 deletions DragaliaAPI.Database/Entities/Scaffold/DbDetailedPartyUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ public class DbDetailedPartyUnit
{
public required string DeviceAccountId { get; set; }

public int PartyNo { get; set; }

public int Position { get; set; }

public required DbPlayerCharaData CharaData { get; set; }
Expand All @@ -21,10 +23,10 @@ public class DbDetailedPartyUnit
public IEnumerable<DbAbilityCrest> CrestSlotType1CrestList { get; set; } =
Enumerable.Empty<DbAbilityCrest>();

public IEnumerable<DbAbilityCrest> CrestSlotType2CrestList { get; set; } =
public IEnumerable<DbAbilityCrest?> CrestSlotType2CrestList { get; set; } =
Enumerable.Empty<DbAbilityCrest>();

public IEnumerable<DbAbilityCrest> CrestSlotType3CrestList { get; set; } =
public IEnumerable<DbAbilityCrest?> CrestSlotType3CrestList { get; set; } =
Enumerable.Empty<DbAbilityCrest>();

public DbWeaponSkin? WeaponSkinData { get; set; } = null;
Expand Down
Loading

0 comments on commit 61176d8

Please sign in to comment.