Skip to content

Commit 21d379d

Browse files
authored
Merge pull request #5 from TheCodeRaccoons/te-taking-project
Te taking project
2 parents dbed1a4 + 9b28e29 commit 21d379d

84 files changed

Lines changed: 815 additions & 574 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.eslintrc.json

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
{
2+
"extends": [
3+
"react-app",
4+
"react-app/jest"
5+
],
6+
"rules": {
7+
"max-len": [
8+
"error",
9+
{
10+
"code": 100,
11+
"tabWidth": 4,
12+
"ignoreUrls": true,
13+
"ignoreStrings": true,
14+
"ignoreTemplateLiterals": true,
15+
"ignoreRegExpLiterals": true,
16+
"ignoreComments": false
17+
}
18+
],
19+
"object-curly-newline": [
20+
"error",
21+
{
22+
"ObjectExpression": {
23+
"multiline": true,
24+
"minProperties": 3,
25+
"consistent": true
26+
},
27+
"ObjectPattern": {
28+
"multiline": true,
29+
"minProperties": 3,
30+
"consistent": true
31+
},
32+
"ImportDeclaration": {
33+
"multiline": true,
34+
"minProperties": 4,
35+
"consistent": true
36+
},
37+
"ExportDeclaration": {
38+
"multiline": true,
39+
"minProperties": 3,
40+
"consistent": true
41+
}
42+
}
43+
],
44+
"object-property-newline": [
45+
"error",
46+
{
47+
"allowAllPropertiesOnSameLine": false,
48+
"allowMultiplePropertiesPerLine": false
49+
}
50+
],
51+
"array-element-newline": [
52+
"error",
53+
{
54+
"ArrayExpression": "consistent",
55+
"ArrayPattern": "consistent"
56+
}
57+
],
58+
"function-paren-newline": ["error", "multiline-arguments"],
59+
"function-call-argument-newline": ["error", "consistent"],
60+
"indent": [
61+
"error",
62+
4,
63+
{
64+
"SwitchCase": 1,
65+
"VariableDeclarator": 1,
66+
"outerIIFEBody": 1,
67+
"MemberExpression": 1,
68+
"FunctionDeclaration": {
69+
"parameters": 1,
70+
"body": 1
71+
},
72+
"FunctionExpression": {
73+
"parameters": 1,
74+
"body": 1
75+
},
76+
"CallExpression": {
77+
"arguments": 1
78+
},
79+
"ArrayExpression": 1,
80+
"ObjectExpression": 1,
81+
"ImportDeclaration": 1,
82+
"flatTernaryExpressions": false,
83+
"ignoreComments": false
84+
}
85+
]
86+
},
87+
"overrides": [
88+
{
89+
"files": ["*.ts", "*.tsx"],
90+
"rules": {
91+
"@typescript-eslint/max-len": [
92+
"error",
93+
{
94+
"code": 100,
95+
"tabWidth": 4,
96+
"ignoreUrls": true,
97+
"ignoreStrings": true,
98+
"ignoreTemplateLiterals": true,
99+
"ignoreRegExpLiterals": true,
100+
"ignoreComments": false
101+
}
102+
]
103+
}
104+
}
105+
]
106+
}

.prettierrc

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"printWidth": 100,
3+
"tabWidth": 4,
4+
"useTabs": false,
5+
"semi": true,
6+
"singleQuote": true,
7+
"quoteProps": "as-needed",
8+
"jsxSingleQuote": false,
9+
"trailingComma": "es5",
10+
"bracketSpacing": true,
11+
"bracketSameLine": false,
12+
"arrowParens": "avoid",
13+
"endOfLine": "lf"
14+
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,8 @@
2222
"build": "vite build",
2323
"preview": "vite preview",
2424
"predeploy": "npm run build",
25-
"deploy": "npm run build && gh-pages -d build"
26-
},
27-
"eslintConfig": {
28-
"extends": "react-app"
25+
"deploy": "npm run build && gh-pages -d build",
26+
"lint": "eslint src --ext .js,.jsx,.ts,.tsx --fix"
2927
},
3028
"browserslist": {
3129
"production": [

src/App.css

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -339,42 +339,6 @@ section.sv-container{
339339
justify-content: center;
340340
}
341341

342-
.skill-container{
343-
position: relative;
344-
width: 28%;
345-
height: 42%;
346-
margin: 1%;
347-
padding: 1%;
348-
background: url('./Media/Windows/Window7.png') no-repeat center center;
349-
-webkit-background-size: cover;
350-
-moz-background-size: cover;
351-
-o-background-size: cover;
352-
background-size: 100% 100%;
353-
}
354-
.skill-container h1{
355-
font-size: 1.5em;
356-
text-align: center;
357-
}
358-
359-
.skill-container img{
360-
position: absolute;
361-
bottom: 15px;
362-
left: 20px;
363-
width: 40px;
364-
height: 40px;
365-
cursor: help;
366-
}
367-
368-
.skill-container span{
369-
display: flex;
370-
justify-content: center;
371-
padding-top: 1rem;
372-
font-size: 1.25em;
373-
width: 100%;
374-
height: 80%;
375-
line-height: 1.5em;
376-
377-
}
378342
.a-title{
379343
width: 100%;
380344
align-items: center;
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import { useState, useEffect } from 'react'
2+
import type { generalFormatedItemType } from 'types/savefile';
3+
4+
interface dishesCookedType {
5+
recipesCooked: generalFormatedItemType[];
6+
}
7+
8+
const Food = ( recipesCooked : dishesCookedType) => {
9+
const [dishesCooked, setDishesCooked] = useState(0);
10+
if(!recipesCooked) return <div>No cooking data available.</div>;
11+
12+
const canMap = (recipesCooked.recipesCooked && recipesCooked.recipesCooked.length > 0);
13+
useEffect(() => {
14+
const cookedCount = canMap ? recipesCooked.recipesCooked.map((num) => (num.times !== undefined && num.times > 0) ? 1 : 0).reduce((n: number, next: number) => n + next, 0) : 0;
15+
setDishesCooked(cookedCount);
16+
}, [recipesCooked]);
17+
const cookedCount = canMap ? recipesCooked.recipesCooked.map((num) => (num.times !== undefined && num.times > 0) ? 1 : 0).reduce((n: number, next: number) => n + next, 0) : 0;
18+
const knownCount = canMap ? recipesCooked.recipesCooked.map((num) => (num.times !== undefined && num.times >= 0) ? 1 : 0).reduce((n: number, next: number) => n + next, 0) : 0;
19+
20+
return (
21+
<div className="progress-container">
22+
<span className="a-title"><h1>You have cooked {cookedCount}, knowing {knownCount} out of {recipesCooked.recipesCooked.length} recipes</h1></span>
23+
<br />
24+
<h2>Cooking Achievements</h2>
25+
<ul className="a-List">
26+
<li>Cook: {(dishesCooked >= 10) ? <span className="completed">You have this achievement</span> : <span className="pending">You need to cook {10 - dishesCooked} more dishes to get this</span> } </li>
27+
<li>Sous Chef: {(dishesCooked >= 25) ? <span className="completed">You have this achievement</span> : <span className="pending"> You need to cook {25 - dishesCooked} more dishes to get this</span> }</li>
28+
<li>Gourmet Chef: {(dishesCooked >= 74) ? <span className="completed">You have this achievement</span> : <span className="pending">You need to cook {74 - dishesCooked} more dishes to get this</span> }</li>
29+
</ul>
30+
<br />
31+
{ canMap ?
32+
recipesCooked.recipesCooked.map((d, i) => <a href={`https://stardewvalleywiki.com/${d.link}`} target="blank" key={i}><img src={`https://stardew-tracker.s3.amazonaws.com/Cooking/${d.image}.png`} alt={d.name} className={ (d.times !== undefined) ? ((d.times > 0) ? "done" : "known" ): "" } title={(d.times !== undefined) ? (d.times > 0) ? `Cooked ${d.name} ${d.times} times` : `You haven't cooked ${d.name}` : `You don't know how to cook ${d.name}`} ></img></a>)
33+
: null
34+
}
35+
</div>
36+
);
37+
};
38+
39+
export default Food;

src/Components/AchieveTabs/Crops.tsx

Lines changed: 18 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,28 @@
11
import React, { useState, useEffect } from 'react'
2+
import type { cropsShippedType } from 'types/savefile';
23

3-
interface CropShipped {
4-
shipped?: {
5-
times: string;
6-
};
7-
name: string;
8-
image: string;
4+
interface CropsShippedWrapperType {
5+
cropsShipped: cropsShippedType;
96
}
107

11-
interface CropsShippedData {
12-
poly_crops: CropShipped[];
13-
mono_extras: CropShipped[];
14-
}
15-
16-
interface CropsProps {
17-
cropsShipped: CropsShippedData;
18-
}
19-
20-
const Crops: React.FC<CropsProps> = ({ cropsShipped }) => {
21-
const [maxShipped, setMaxShipped] = useState<{name: string, times: number}>({name: '', times: 0});
8+
const Crops= (cropsShipped : CropsShippedWrapperType) => {
9+
let _monocultureText = cropsShipped.cropsShipped.hasMonoculture ? "You already have the 'Monoculture' Achievement" : `You've shipped ${ cropsShipped.cropsShipped.maxMono?.name } the most and you require ${300 - cropsShipped.cropsShipped.maxMono?.shipped} more of it to get the 'Monoculture' Achievement`;
10+
let _polycultureText = cropsShipped.cropsShipped.hasPolyculture ? "You already have the 'Polyculture' Achievement" : `You need to ship 15 crops for each polyculture crop to get the 'Polyculture' achievement`;
2211

23-
const timesShipped = (arr: CropsShippedData) => {
24-
let Max: number[] = []
25-
let name: string[] = []
26-
arr.poly_crops.forEach( crop => {
27-
Max = (crop.shipped !== undefined) ? [...Max, parseInt(crop.shipped.times)] : [...Max]
28-
name = (crop.shipped !== undefined) ? [...name, crop.name] : [...name]
29-
})
30-
arr.mono_extras.forEach( crop => {
31-
Max = (crop.shipped !== undefined) ? [...Max, parseInt(crop.shipped.times)] : [...Max]
32-
name = (crop.shipped !== undefined) ? [...name, crop.name] : [...name]
33-
})
34-
35-
if (Max.length === 0 || name.length === 0) {
36-
setMaxShipped({name: 'None', times: 0});
37-
return;
38-
}
39-
40-
const indexOfMaxValue = Max.reduce((iMax: number, x: number, i: number, arr: number[]) => {
41-
return x > (arr[iMax] ?? 0) ? i : iMax;
42-
}, 0);
43-
setMaxShipped({
44-
name: name[indexOfMaxValue] || 'Unknown',
45-
times: Max[indexOfMaxValue] || 0
46-
});
47-
};
48-
49-
useEffect(() => {
50-
timesShipped(cropsShipped);
51-
}, [cropsShipped]);
52-
5312
return (
5413
<div className="progress-container">
55-
<span className="a-title"><h1>{(maxShipped.times < 300) ? `You've shipped ${ maxShipped.name } the most and you require ${300 - maxShipped.times} more of it to get the 'Monoculture' Achievement` : <span className="completed">`You already have the 'Monoculture' Achievement`</span> }</h1></span>
56-
<br /><br />
57-
<span className="a-title"><h1>Ship 15 of the following crops to get the 'Polyculture' achievement</h1></span>
58-
{cropsShipped.poly_crops.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="blank" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((parseInt(crop.shipped.times) >= 15) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? (parseInt(crop.shipped.times) >= 15) ? `You have shipped ${crop.name} ${crop.shipped.times} times` : `You have to ship ${ 15 - parseInt(crop.shipped.times)} more ${crop.name} ` : `You haven't shipped ${crop.name}`} ></img></a>)}
59-
60-
<span className="a-title"><h1>This crops are not counted for the 'Polyculture' achievement</h1></span>
61-
{cropsShipped.mono_extras.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="blank" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((parseInt(crop.shipped.times) > 0) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? `You have shipped ${crop.name} ${crop.shipped.times} times` : `You haven't shipped ${crop.name}`} ></img></a>)}
14+
{/* <span className="a-title"><h1>{_monocultureAchieved ? `You've shipped ${ maxShipped.name } the most and you require ${300 - maxShipped.times} more of it to get the 'Monoculture' Achievement` : <span className="completed">`You already have the 'Monoculture' Achievement`</span> }</h1></span> */}
15+
<br />
16+
<h2>Farming Achievements</h2>
17+
<ul className="a-List">
18+
<li>Monoculture: <span className={cropsShipped.cropsShipped.hasMonoculture ? "completed" : "pending"}>{_monocultureText}</span> </li>
19+
<li>Polyculture: <span className={cropsShipped.cropsShipped.hasPolyculture ? "completed" : "pending"}>{_polycultureText}</span></li>
20+
</ul>
21+
<span className="a-title"><p>Ship 15 of the following crops to get the 'Polyculture' achievement</p></span>
22+
{cropsShipped.cropsShipped.poly_crops.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="blank" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((crop.shipped >= 15) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? (crop.shipped >= 15) ? `You have shipped ${crop.name} ${crop.shipped} times` : `You have to ship ${ 15 - crop.shipped} more ${crop.name} ` : `You haven't shipped ${crop.name}`} ></img></a>)}
23+
24+
<span className="a-title"><p>These crops are not counted for the 'Polyculture' achievement</p></span>
25+
{cropsShipped.cropsShipped.mono_extras.map((crop, i) =><a href={`https://stardewvalleywiki.com/${crop.image}`} target="blank" key={i}> <img key={i} src={`https://stardew-tracker.s3.amazonaws.com/Crops/${crop.image}.png`} alt={crop.name} className={ (crop.shipped !== undefined) ? ((crop.shipped > 0) ? "done" : "known" ): "" } title={(crop.shipped !== undefined) ? `You have shipped ${crop.name} ${crop.shipped} times` : `You haven't shipped ${crop.name}`} ></img></a>)}
6226
</div>
6327
);
6428
};

src/Components/AchieveTabs/Food.tsx

Lines changed: 0 additions & 44 deletions
This file was deleted.

src/Components/AchieveTabs/quests.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ const Quests: React.FC<QuestsProps> = ({ questsDone, specialReq, pendingSpecialR
4444
</ul>
4545
<span className="a-title-big"><h1>Special Orders.</h1></span>
4646
<ul className="m-List">
47-
{specialReq.map((m,i) => <li key={i}> <span className="completed">{m.name}: {m.description}</span> </li>)}
47+
{specialReq ? specialReq.map((m,i) => <li key={i}> <span className="completed">{m.name}: {m.description}</span> </li>) : null}
4848
</ul>
4949
<ul className="m-List">
50-
{pendingSpecialReq.map((m,i) => <li key={i}><span className="pending" >{m.name}: {m.description}.</span></li>)}
50+
{pendingSpecialReq ? pendingSpecialReq.map((m,i) => <li key={i}><span className="pending" >{m.name}: {m.description}.</span></li>) : null}
5151
</ul>
5252
</div>
5353
);

0 commit comments

Comments
 (0)