dvorak321 / gbfr-parser

6 stars 3 forks source link

How to see damage done to target? #2

Closed brunolm closed 8 months ago

brunolm commented 8 months ago

When comparing DPS it's a bit unfair when certain characters do overkill damage to crystals and other irrelevant things. To get a closer comparison without unfairness the total damage dealt to the boss helps.

brunolm commented 8 months ago

In the main repo:

image

T-kON99 commented 8 months ago

I have a WIP PR which will have this feature (including detailed breakdown of each action to targets), but still have some minor issues, please wait a bit

brunolm commented 8 months ago

  const headersTarget: { key?: any; text: string }[] = [
    { key: "target", text: "Target" },
    { key: "dmg", text: "Damage" }
  ];

  let sortByTarget = "dmg";
  let descendingTarget = true;

    $: {
    actor.targets = (actor.targets as any)?.sort((a: any, b: any) => {
      if (descendingTarget) {
        return Number(a[sortByTarget]) > Number(b[sortByTarget]) ? -1 : 1;
      }
      return Number(a[sortByTarget]) < Number(b[sortByTarget]) ? -1 : 1;
    });
  }

  const getTargetName = (characterId: string) => {
    const $_ = get(_);

    if (characterId === "26a4848a") {
      characterId = "9498420d";
    }

    let v = $_(`actors.${characterId}`);
    return v ?? characterId;
  };

<table>
  <thead>
    <tr>
      {#each headersTarget as header}
        <th
          scope="col"
          class={header.key ? "sortable" : undefined}
          data-active={sortByTarget === header.key || undefined}
          on:click={header.key
            ? () => {
                if (header.key) sortByTarget = header.key;
                descending = !descending;
              }
            : undefined}
        >
          {#if sortByTarget === header.key}
            <svelte:component this={descending ? SortDescending : SortAscending} size="2.1rem" />
          {/if}
          {header.text}
        </th>
      {/each}
    </tr>
  </thead>
  <tbody>
    {#if actor.targets?.length}
      {#each actor.targets || [] as target}
        <tr>
          <td>{getTargetName(target.character_id)}</td>
          <td>{target.dmg}</td>
        </tr>
      {/each}
    {/if}
  </tbody>
</table>

image

T-kON99 commented 8 months ago

You can try this PR https://github.com/dvorak321/gbfr-parser/pull/7

Any feedback is appreciated, thanks

image