✨ (viewer) Add burned tokens to chart (#40)

This commit is contained in:
Gregor Zeitlinger 2021-03-27 15:00:23 +01:00 • committed by GitHub
commit 310614ec27
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 4 deletions

View file

@ -8,7 +8,7 @@
<rect v-else-if="kind == 'o'" class="ore" width="14" height="14" x="-7" y="-7" />
<rect v-else-if="kind == 'c'" class="credit" width="16" height="16" ry="8" rx="8" x="-8" y="-8" />
<rect
v-else-if="['pw', 'pay-pw', 't', 'bowl-t', 'tg', 'brainstone'].includes(kind)"
v-else-if="['pw', 'pay-pw', 't', 'bowl-t', 'burn-t', 'tg', 'brainstone'].includes(kind)"
:class="kind === 'tg' ? 'gaia' : 'power'"
width="15"
height="15"
@ -116,11 +116,12 @@
x="0"
y="0"
v-if="
(count >= 0 && ['o', 'c', 'k', 'pw', 'pay-pw', 't', 'bowl-t', 'tg', 'vp', 'q', 'gf'].includes(kind)) ||
(count >= 0 &&
['o', 'c', 'k', 'pw', 'pay-pw', 't', 'bowl-t', 'burn-t', 'tg', 'vp', 'q', 'gf'].includes(kind)) ||
count === '+'
"
:class="{ plus: count === '+' }"
>{{ kind === "t" ? "+" : "" }}{{ count }}</text
>{{ kind === "t" ? "+" : "" }}{{ kind === "burn-t" ? "-" : "" }}{{ count }}</text
>
<text x="0" y="0" v-if="kind == 'brainstone'">B</text>
</g>

View file

@ -83,7 +83,7 @@ export type SimpleSourceFactory<Source extends SimpleSource<any>> = {
extractLog?: (cmd: CommandObject, source: Source, data: Engine, player: Player) => number;
};
export type ResourceKind = Resource | "pay-pw";
export type ResourceKind = Resource | "pay-pw" | "burn-t";
const researchNames = {
[ResearchField.Terraforming]: "Terraforming",
@ -143,6 +143,12 @@ const factories = [
((resource == source.type && change > 0) || (resource == source.inverseOf && change < 0))
? Math.abs(change)
: 0,
extractLog: (cmd, source) => {
if (source.type == "burn-t" && cmd.command == Command.BurnPower) {
return Number(cmd.args[0]);
}
return 0;
},
sources: [
{
type: Resource.Credit,
@ -194,6 +200,13 @@ const factories = [
color: () => "--recent",
weight: 0,
},
{
type: "burn-t",
label: "Burned Tokens",
plural: "Burned Tokens",
color: () => "--current-round",
weight: 0,
},
],
} as SimpleSourceFactory<SimpleSource<ResourceKind> & { inverseOf?: Resource }>,
{