Skip to content

Commit

Permalink
Scum and Villainy support
Browse files Browse the repository at this point in the history
Fix #19
  • Loading branch information
mclemente committed Jan 6, 2022
1 parent a7bba84 commit 9ddcc6c
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 1 deletion.
74 changes: 74 additions & 0 deletions module/SystemProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,80 @@ export class pf2eProvider extends SystemProvider {
}
}

export class scumAndVillainyProvider extends SystemProvider {
get tabs() {
return {
ship: { id: "ship", visible: true, localization: "BITD.ship" },
};
}

get template() {
return "/modules/party-overview/templates/scum-and-villainy.hbs";
}

getHarm(data) {
const light = game.i18n.localize("BITD.LessEffect");
const medium = "-1D";
const heavy = game.i18n.localize("BITD.NeedHelp");
if (data.harm.heavy.one) return `${light}, ${medium}, ${heavy}`;
if (data.harm.medium.one || data.harm.medium.two) return `${light}, ${medium}`;
if (data.harm.light.one || data.harm.light.two) return `${light}`;
return "";
}

getActorDetails(actor) {
const data = actor.data.data;
const base = {
id: actor.id,
name: actor.name,
type: actor.type,
coins: data.coins,
};
if (actor.type == "character") {
return {
...base,
stress: data.stress || { value: "-", max: "-" },
harm: this.getHarm(data),
};
} else if (actor.type == "ship") {
return {
...base,
crew: data.systems.crew,
gambits: data.gambits,
};
}
}

getUpdate(actors) {
let characters = actors
.filter((actor) => {
if (actor.type == "character") return true;
return false;
})
.map((actor) => {
return {
...actor,
};
});
let ships = actors
.filter((actor) => {
if (actor.type == "ship") return true;
return false;
})
.map((actor) => {
return {
...actor,
};
});
return [
characters,
{
ships,
},
];
}
}

export class sfrpgProvider extends SystemProvider {
get loadTemplates() {
return ["modules/party-overview/templates/parts/PF2e-Lore.html"];
Expand Down
7 changes: 6 additions & 1 deletion module/api.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { SystemProvider, dccProvider, dnd5eProvider, pf1Provider, pf2eProvider, sfrpgProvider, swadeProvider, tormenta20Provider, wfrp4eProvider } from "./SystemProvider.js";
// prettier-ignore
import { SystemProvider, dccProvider, dnd5eProvider, pf1Provider, pf2eProvider, scumAndVillainyProvider, sfrpgProvider, swadeProvider,tormenta20Provider,
wfrp4eProvider, } from "./SystemProvider.js";

export const availableSystemProviders = {};
export let currentSystemProvider = undefined;
Expand Down Expand Up @@ -53,6 +55,9 @@ export function initApi() {
case "pf2e":
systemProviders.push(new pf2eProvider("native.pf2e"));
break;
case "scum-and-villainy":
systemProviders.push(new scumAndVillainyProvider("native.scum-and-villainy"));
break;
case "sfrpg":
systemProviders.push(new sfrpgProvider("native.swade"));
break;
Expand Down
54 changes: 54 additions & 0 deletions templates/scum-and-villainy.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<div>
{{> "modules/party-overview/templates/parts/Tabs.html"}}
<section class="content">
<div class="tab" data-tab="general" data-group="party">
<div class="table-row header">
{{> "modules/party-overview/templates/parts/FilterButton.html"}}
<div class="text">{{localize "party-overview.NAME"}}</div>
<div class="text icon">{{localize "BITD.Stress"}}</i></div>
<div class="text icon">{{localize "BITD.Coins"}}</i></div>
<div class="text icon">{{localize "BITD.Harm"}}</i></div>
</div>

{{#each actors as | actor | }}
<div class="table-row">
<div class="button">
<button class="btn-toggle-visibility" data-actor="{{actor.id }}">
{{#if actor.isHidden }}<i class="value fas fa-eye-slash"></i>{{else}}<i
class="value fas fa-eye"></i>{{/if}}
</button>
</div>
<div class="text">{{ actor.shortestName }}</div>
<div class="text icon">{{ actor.stress.value }}/{{ actor.stress.max }}</div>
<div class="text icon">{{ actor.coins }}</div>
<div class="text icon">{{ actor.harm }}</div>
</div>
{{/each}}
</div>

<div class="tab" data-tab="ship" data-group="party">
<div class="table-row header">
{{> "modules/party-overview/templates/parts/FilterButton.html"}}
<div class="text">{{localize "party-overview.NAME"}}</div>
<div class="text icon">{{localize "BITD.Gambits"}}</i></div>
<div class="text icon">{{localize "BITD.Coins"}}</i></div>
<div class="text icon">{{localize "BITD.SystemsCrew"}}</i></div>
</div>

{{#each ships as | actor | }}
<div class="table-row">
<div class="button">
<button class="btn-toggle-visibility" data-actor="{{actor.id }}">
{{#if actor.isHidden }}<i class="value fas fa-eye-slash"></i>{{else}}<i
class="value fas fa-eye"></i>{{/if}}
</button>
</div>
<div class="text">{{ actor.shortestName }}</div>
<div class="text icon">{{ actor.gambits.value }}/{{ actor.gambits.max }}</div>
<div class="text icon">{{ actor.coins }}</div>
<div class="text icon">{{ actor.crew.value }}/{{ actor.crew.max }}</div>
</div>
{{/each}}
</div>
</section>
</div>

0 comments on commit 9ddcc6c

Please sign in to comment.