Skip to content

Adding LEGENDS expansion #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@

{}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm was this giving your issues? .prettierrc can be either yaml OR json so I'm curious why the blank file didn't work for you 🤔

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah this was actually, I'm not sure why. I am using vscode and it wouldn't format unless i had something here. maybe i can take a look at why or remove this once the PR is actually done

Copy link

@sorahn sorahn Mar 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is why.

It also doesn't work with the .yml or .yaml extension if completely empty.

If you have the prettier extension in VSCode (not sure about others) to only run if there is a .prettier config file, there must be at least something to tell it that the config exists.

I work in repositories that are set up with and without prettier, so unfortunately I cannot just tell it always run even though I would much prefer that it does.

44 changes: 43 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "everdell",
"version": "0.1.0",
"engines": {
"node": "12.x"
"node": ">=12.x"
},
"private": true,
"scripts": {
Expand Down Expand Up @@ -32,6 +32,7 @@
"pg": "^8.5.1",
"react": "17.0.1",
"react-dom": "17.0.1",
"react-textfit": "^1.1.1",
"short-uuid": "^4.1.0",
"sqlite3": "^5.0.0"
},
Expand All @@ -44,6 +45,7 @@
"@types/puppeteer": "^5.4.2",
"@types/react": "^17.0.0",
"@types/react-dom": "^17.0.0",
"@types/react-textfit": "^1.1.0",
"@types/sqlite3": "^3.1.6",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
Expand Down
Binary file added public/images/legendary_card.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 46 additions & 23 deletions src/components/Card.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
import * as React from "react";
import { Textfit } from "react-textfit";
import { Card as CardModel } from "../model/card";
import styles from "../styles/card.module.css";
import { ResourceType, CardName, PlayedCardInfo } from "../model/types";
import {
ResourceType,
CardName,
PlayedCardInfo,
ExpansionType,
} from "../model/types";
import { Player } from "../model/player";
import { resourceMapToGameText, toGameText } from "../model/gameText";
import {
Expand All @@ -19,6 +25,7 @@ const colorClassMap = {
PRODUCTION: styles.color_production,
DESTINATION: styles.color_destination,
TRAVELER: styles.color_traveler,
LEGEND: styles.color_legend,
};

function romanize(num: number): string {
Expand Down Expand Up @@ -65,7 +72,12 @@ function romanize(num: number): string {
// determine rarity label, which is unique vs. common and
// critter vs. construction
const getRarityLabel = (card: CardModel) => {
const rarity = card.isUnique ? "Unique" : "Common";
const rarity =
card.expansion === ExpansionType.LEGENDS
? "Legendary"
: card.isUnique
? "Unique"
: "Common";
const category = card.isCritter ? "Critter" : "Construction";
return rarity + " " + category;
};
Expand All @@ -75,14 +87,12 @@ const getAssociatedCard = (card: CardModel) => {
if (card.associatedCard) {
return card.associatedCard;
} else {
if (card.name == CardName.FARM) {
if (card.name == CardName.FARM || card.name == CardName.MCGREGORS_MARKET) {
return "Husband / Wife";
} else if (card.name == CardName.EVERTREE) {
return "Any";
} else {
throw new Error(
"Associated card is null and card is not Farm or Evertree"
);
<>&nbsp;</>;
}
}
};
Expand Down Expand Up @@ -156,6 +166,18 @@ const AssociatedCard = ({
);
};

const UpgradeableCard = ({ card }: { card: CardModel }) => {
if (!card.upgradeableCard) {
return <>&nbsp;</>;
}

return (
<div className={styles.upgradeable_card}>
<span>{card.upgradeableCard}</span>
</div>
);
};

const Card: React.FC<{ name: CardName; usedForCritter?: boolean }> = ({
name,
usedForCritter = false,
Expand All @@ -166,25 +188,29 @@ const Card: React.FC<{ name: CardName; usedForCritter?: boolean }> = ({
return (
<>
<div className={styles.card}>
<div className={styles.card_header_row}>
<div className={[styles.circle, styles.card_header_symbol].join(" ")}>
<div className={[styles.card_header_row, colorClass].join(" ")}>
<div className={[styles.circle].join(" ")}>
<CardTypeSymbol cardType={card.cardType} />
</div>
<div
className={[
styles.circle,
styles.color_victory_point,
styles.card_header_vp,
].join(" ")}
>
<span className={styles.card_header_vp_number}>{card.baseVP}</span>
</div>
<div className={[styles.card_header, colorClass].join(" ")}>
<span>{name}</span>
<div className={styles.card_header}>
<span>
<Textfit min={1} max={12} mode="single">
{name}
</Textfit>
</span>
{card.expansion && (
<span className={styles.expansion}>{card.expansion}</span>
)}
</div>
<div
className={[styles.circle, styles.color_victory_point].join(" ")}
>
<span className={styles.card_header_vp_number}>{card.baseVP}</span>
</div>
</div>
<div className={styles.rarity_label}>
{rarityLabel}
&nbsp;&middot;&nbsp;{romanize(card.numInDeck)}
</div>
<div className={styles.info_row}>
<div className={styles.card_cost}>
Expand Down Expand Up @@ -221,10 +247,7 @@ const Card: React.FC<{ name: CardName; usedForCritter?: boolean }> = ({
</div>
</div>
<div className={styles.card_bottom_row}>
<div className={styles.rarity_label}>
{rarityLabel}
&nbsp;&middot;&nbsp;{romanize(card.numInDeck)}
</div>
<UpgradeableCard card={card} />
<AssociatedCard card={card} usedForCritter={usedForCritter} />
</div>
</div>
Expand Down
48 changes: 45 additions & 3 deletions src/components/CardPayment.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ import { Field, useField } from "formik";

import { Card as CardModel } from "../model/card";
import { Player } from "../model/player";
import { ResourceType, CardName, GameInputPlayCard } from "../model/types";
import {
ResourceType,
CardName,
GameInputPlayCard,
ExpansionType,
} from "../model/types";
import { ResourceTypeIcon, Description } from "./common";

import styles from "../styles/CardPayment.module.css";
Expand Down Expand Up @@ -95,15 +100,17 @@ const OptionToUseAssociatedCard: React.FC<{
const [_field, meta, helpers] = useField(name);
const card = CardModel.fromName(cardName);
const hasUnusedAssociatedCard =
card.expansion !== ExpansionType.LEGENDS &&
card.associatedCard &&
viewingPlayer.hasUnusedByCritterConstruction(card.associatedCard);
const hasUnusedEvertree = viewingPlayer.hasUnusedByCritterConstruction(
CardName.EVERTREE
);
const canUseAssociatedCard =
card.isCritter && (hasUnusedAssociatedCard || hasUnusedEvertree);

if (!canUseAssociatedCard) {
return <></>;
return null;
}

const isChecked = !!meta.value;
Expand Down Expand Up @@ -231,6 +238,32 @@ const CardToDungeonForm: React.FC<{
) : null;
};

const CardToUpgradeForm: React.FC<{
name: string;
cardName: CardName;
viewingPlayer: Player;
}> = ({ name, cardName }) => {
const card = CardModel.fromName(cardName);
if (card.expansion !== ExpansionType.LEGENDS || !card.upgradeableCard) {
return null;
}

return (
<div className={styles.associated_card}>
<label>
<Description
textParts={[
{ type: "text", text: "Upgrade " },
CardModel.fromName(card.upgradeableCard!).getGameTextPart(),
{ type: "text", text: " to play " },
CardModel.fromName(card.name).getGameTextPart(),
]}
/>
</label>
</div>
);
};

const CardPayment: React.FC<{
name: string;
resetPaymentOptions: (state: "DEFAULT" | "COST" | "ZERO") => void;
Expand All @@ -247,7 +280,9 @@ const CardPayment: React.FC<{
resetPaymentOptions={resetPaymentOptions}
/>
)}
<ResourcesForm name={`${name}.resources`} />
{clientOptions.paymentOptions.resources && (
<ResourcesForm name={`${name}.resources`} />
)}
{clientOptions.card && (
<CardToUseForm
name={`${name}.cardToUse`}
Expand All @@ -261,6 +296,13 @@ const CardPayment: React.FC<{
viewingPlayer={viewingPlayer}
resetPaymentOptions={resetPaymentOptions}
/>
{clientOptions.card && (
<CardToUpgradeForm
name={`${name}.cardToUpgrade`}
cardName={clientOptions.card}
viewingPlayer={viewingPlayer}
/>
)}
</div>
);
};
Expand Down
4 changes: 4 additions & 0 deletions src/components/GameBuilder.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ const GameBuilder: React.FC = () => {
<Field type="checkbox" name="pearlbrook" />
{"Pearlbrook"}
</label>
<label className={styles.game_builder_option}>
<Field type="checkbox" name="legends" />
{"Legends"}
</label>
</div>
<div>
<h3>Settings</h3>
Expand Down
Loading