Skip to content

Commit af46e6d

Browse files
committed
Added money upgrade
1 parent 236226e commit af46e6d

File tree

3 files changed

+31
-4
lines changed

3 files changed

+31
-4
lines changed

jam-25/src/components/Tile.jsx

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,14 +167,25 @@ const Tile = ({ sx, letter, id, dealable, disabled, bagTile }) => {
167167
) : null
168168
}
169169
{
170-
letter.multiplier || letter.rarity || bagTile ? (
170+
letter.money ? (
171+
<Box sx={{ position: 'absolute', bottom: 0, left: 0, fontSize: '10px', color: 'white', backgroundColor: '#a17e02', px: '3px', borderRadius: '4px 2px 2px 2px' }}>
172+
${letter.money}
173+
</Box>
174+
) : null
175+
}
176+
{
177+
letter.multiplier || letter.rarity || letter.money || bagTile ? (
171178
<Tooltip arrow placement="top" title={(
172179
<Box sx={{ fontSize: 12, color: 'white', borderRadius: '4px', display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
173180
<Typography variant='h6' sx={{ fontFamily: 'Orbitron'}}>{letter.letter}</Typography>
174181
{
175182
letter.multiplier ? (<Typography variant='body2'>{letter.scope === 'letter' ? `${letter.multiplier} x ${letter.value} ${letter.value !== 1 ? 'points' : 'point'}` : `${letter.multiplier} x word score`}</Typography>)
176183
: (<Typography variant='body2'>{letter.value} {letter.value !== 1 ? 'points' : 'point'}</Typography>)
177184
}
185+
{
186+
letter.money ? (<Typography variant='body2'>+${letter.money}</Typography>)
187+
: null
188+
}
178189
<Typography variant='overline' sx={{ fontFamily: 'Orbitron', fontSize: 8 }}>{letter.rarity ? ['Common', 'Uncommon', 'Rare', 'Shiny'][letter.rarity] : 'Common'}</Typography>
179190
</Box>
180191
)}>
@@ -189,10 +200,20 @@ const Tile = ({ sx, letter, id, dealable, disabled, bagTile }) => {
189200
<Box sx={{ position: 'absolute', bottom: displayedLetter.length > 2 ? -1 : 1, right: 4, fontSize: '10px', fontFamily: 'Orbitron' }}>
190201
{letter.value}
191202
</Box>
192-
<Tooltip arrow open={!!scoringTileTop} title={<span style={{ fontFamily: 'Orbitron', fontSize: 16, color: scoringTileTop?.score < 0 ? '#ff9ca7' : '#b3faaa'}}>{scoringTileTop?.score >= 0 ? '+' : ''} {scoringTileTop?.score ?? ''}</span>} placement="top">
203+
<Tooltip arrow open={!!scoringTileTop} title={<span style={{ fontFamily: 'Orbitron', fontSize: 16, color: scoringTileTop?.score < 0 ? '#ff9ca7' : '#b3faaa'}}>
204+
{scoringTileTop?.score >= 0 ? '+' : ''} {scoringTileTop?.score ?? ''}
205+
{
206+
scoringTileTop?.newMoney !== 0 ? <span style={{ color: scoringTileTop?.newMoney < 0 ? '#ff9ca7' : 'gold' }}>{scoringTileTop?.newMoney > 0 ? ` +$${scoringTileTop?.newMoney}` : ` -$${Math.abs(scoringTileTop?.newMoney)}`}</span> : null
207+
}
208+
</span>} placement="top">
193209
<Box sx={{ width: '100%', height: '100%', pointerEvents: 'none', position: 'absolute' }} />
194210
</Tooltip>
195-
<Tooltip arrow open={!!scoringTileLeft} title={<span style={{ fontFamily: 'Orbitron', fontSize: 16, color: scoringTileLeft?.score < 0 ? '#ff9ca7' : '#b3faaa'}}>{scoringTileLeft?.score >= 0 ? '+' : ''} {scoringTileLeft?.score ?? ''}</span>} placement="left">
211+
<Tooltip arrow open={!!scoringTileLeft} title={<span style={{ fontFamily: 'Orbitron', fontSize: 16, color: scoringTileLeft?.score < 0 ? '#ff9ca7' : '#b3faaa'}}>
212+
{scoringTileLeft?.score >= 0 ? '+' : ''} {scoringTileLeft?.score ?? ''}
213+
{
214+
scoringTileLeft?.newMoney !== 0 ? <span style={{ color: scoringTileLeft?.newMoney < 0 ? '#ff9ca7' : 'gold' }}>{scoringTileLeft?.newMoney > 0 ? ` +$${scoringTileLeft?.newMoney}` : ` -$${Math.abs(scoringTileLeft?.newMoney ?? 0)}`}</span> : null
215+
}
216+
</span>} placement="left">
196217
<Box sx={{ width: '100%', height: '100%', pointerEvents: 'none', position: 'absolute' }} />
197218
</Tooltip>
198219
</Box>

jam-25/src/routes/App.jsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ const App = () => {
120120
const scoreWord = useCallback(async (word, scoreRound) => {
121121
let baseScore = word.score || word.word.length;
122122
const bonuses = bonusSpacesRef.current.map((s) => ({ id: s.id, ...BONUSES[s.bonus] }));
123+
let newMoney = 0;
123124
// Tile bonuses first
124125
word.tiles.forEach((t) => {
125126
if (t.props.letter.adder) {
@@ -128,6 +129,9 @@ const App = () => {
128129
if (t.props.letter.multiplier) {
129130
baseScore *= t.props.letter.multiplier;
130131
}
132+
if (t.props.letter.money) {
133+
newMoney += word.valid ? t.props.letter.money : -t.props.letter.money;
134+
}
131135
});
132136
// Board bonuses
133137
bonuses.filter((b) => b.scope === 'letter').forEach((b) => {
@@ -147,7 +151,8 @@ const App = () => {
147151
}
148152
});
149153
return new Promise((resolve) => setTimeout(async () => {
150-
setScoringTiles((old) => [...old, { id: word.tiles[0]?.props?.id, score: word?.valid ? baseScore : -baseScore, scoreRound, placement: word.orientation === 'horizontal' ? 'left' : 'top' }]);
154+
setFunds((old) => old + newMoney);
155+
setScoringTiles((old) => [...old, { id: word.tiles[0]?.props?.id, score: word?.valid ? baseScore : -baseScore, scoreRound, placement: word.orientation === 'horizontal' ? 'left' : 'top', newMoney }]);
151156
setTimeout(() => {
152157
setScoringTiles((old) => old.filter((t) => t.id !== word.tiles[0]?.props?.id || t.placement !== (word.orientation === 'horizontal' ? 'left' : 'top') || t.scoreRound !== scoreRound));
153158
}, 1000);

jam-25/src/upgrades.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export const BONUSES = {
1616
BP1: { rarity: 1, price: 4, name: '+1 Letter Space', description: 'Increase the base score of any word played on it by one', text: '+1L', multiplier: 0, adder: 1, placement: 'board', scope: 'letter', style: { backgroundColor: 'rgba(224, 88, 70, 0.4)', border: '4px double rgb(224, 88, 70)' }, threshhold: 4 },
1717
BP3: { rarity: 2, price: 6, name: '+3 Letter Space', description: 'Increase the base score of any word played on it by three', text: '+3L', multiplier: 0, adder: 3, placement: 'board', scope: 'letter', style: { backgroundColor: 'rgba(230, 53, 97, 0.4)', border: '4px double rgb(230, 53, 97)' }, threshhold: 4 },
1818
BP5: { rarity: 3, price: 8, name: '+5 Letter Space', description: 'Increase the base score of any word played on it by five', text: '+5L', multiplier: 0, adder: 5, placement: 'board', scope: 'letter', style: { backgroundColor: 'rgba(166, 113, 227, 0.4)', border: '4px double rgb(166, 113, 227)' }, threshhold: 4 },
19+
TM1: { rarity: 3, price: 3, name: '+$1', description: 'Place this upgrade on a tile to earn $1 every time it is scored', text: '+$1', money: 1, multiplier: 0, adder: 0, placement: 'tile', scope: 'letter', style: { backgroundColor: 'rgba(214, 168, 0, 0.4)', border: '4px double rgb(214, 168, 0)' }, threshhold: 4 },
1920
};
2021

2122
export const JOKERS = [

0 commit comments

Comments
 (0)