Skip to content
Merged
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
"prettier": "^3.8.1",
"typescript": "^4.4.2",
"vite": "^8.0.0",
"vite-plugin-pwa": "^1.2.0",
"vitest": "^4.1.0"
},
"browserslist": {
Expand Down
117 changes: 98 additions & 19 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -549,11 +549,16 @@ function App() {
>
{showTutorial && <Tutorial onDismiss={handleDismissTutorial} t={t} />}
<View style={styles.gameContainer}>
<BackgroundSound url={musicTracks[mode] || musicTracks.addition} />
<View style={styles.content}>
{/* === TOP BAR: Title + Score + Settings gear === */}
<View style={styles.topBar}>
<Text
style={[styles.title, { color: activeTheme.textColor }]}
style={[
styles.title,
isMobile && { fontSize: 22 },
{ color: activeTheme.textColor },
]}
accessibilityRole="header"
>
{t.title}
Expand Down Expand Up @@ -596,7 +601,17 @@ function App() {
{/* === SCORE BAR === */}
{gameScreen !== 'levelSelect' && (
<View
style={[styles.scoreBar, styles.cardPanel, streakGlowStyle]}
style={[
styles.scoreBar,
styles.cardPanel,
isMobile && {
paddingVertical: 4,
paddingHorizontal: 8,
padding: 8,
marginVertical: 2,
},
streakGlowStyle,
]}
accessibilityLiveRegion="polite"
>
<Text
Expand Down Expand Up @@ -718,9 +733,6 @@ function App() {
/>
</View>
<View style={styles.soundControls}>
<BackgroundSound
url={musicTracks[mode] || musicTracks.addition}
/>
<TouchableOpacity
onPress={handleSoundToggle}
style={styles.touchTarget}
Expand Down Expand Up @@ -764,7 +776,12 @@ function App() {
)}
{gameScreen !== 'levelSelect' && (
<>
<View style={styles.battlefield}>
<View
style={[
styles.battlefield,
isMobile && styles.battlefieldMobile,
]}
>
<View style={styles.heroContainer}>
<View
nativeID="hero"
Expand All @@ -773,14 +790,26 @@ function App() {
<Image
source={won ? heroImages.victory : heroImages[heroAnim]}
style={[
styles.characterImage,
isMobile
? styles.characterImageMobile
: styles.characterImage,
heroAnimStyle[heroAnim] as any,
]}
accessibilityLabel="Hero"
/>
</View>
</View>
<View style={styles.enemiesContainer}>
<View
style={[
styles.enemiesContainer,
isMobile && styles.enemiesContainerMobile,
]}
>
{!isBossLevel && (
<Text style={styles.enemyCountText} testID="enemy-count">
{`Enemies: ${numOfEnemies}`}
</Text>
)}
{isBossLevel ? (
<View testID="enemies" style={{ alignItems: 'center' }}>
<View
Expand Down Expand Up @@ -847,7 +876,9 @@ function App() {
<Image
source={enemyImages[mode] || enemyImages.addition}
style={[
styles.characterImage,
isMobile
? styles.characterImageMobile
: styles.characterImage,
defeatingEnemy && i === numOfEnemies - 1
? undefined
: newEnemyIndex === i
Expand All @@ -873,7 +904,13 @@ function App() {
</View>
{/* === ATTEMPT HEARTS === */}
{!won && (
<View style={styles.heartsContainer} testID="hearts-container">
<View
style={[
styles.heartsContainer,
isMobile && { paddingVertical: 2, gap: 4 },
]}
testID="hearts-container"
>
{[0, 1, 2].map((i) => (
<Text
key={i}
Expand Down Expand Up @@ -986,6 +1023,11 @@ function App() {
style={[
styles.mathContainer,
styles.cardPanel,
isMobile && {
paddingVertical: 8,
padding: 10,
marginVertical: 4,
},
shaking
? ({
animationName: 'shake',
Expand All @@ -1012,31 +1054,51 @@ function App() {
<View style={styles.mathRow}>
<Text
nativeID="val1"
style={[styles.mathText, { color: '#fff' }]}
style={[
styles.mathText,
isMobile && { fontSize: 28 },
{ color: '#fff' },
]}
>
{val1 < 0 ? `(${val1})` : val1}
</Text>
<Text
nativeID="operator"
style={[styles.mathText, { color: '#fff' }]}
style={[
styles.mathText,
isMobile && { fontSize: 28 },
{ color: '#fff' },
]}
>
{displayOperator(operator)}
</Text>
<Text
nativeID="val2"
style={[styles.mathText, { color: '#fff' }]}
style={[
styles.mathText,
isMobile && { fontSize: 28 },
{ color: '#fff' },
]}
>
{val2 < 0 ? `(${val2})` : val2}
</Text>
<Text style={[styles.mathText, { color: '#fff' }]}>=</Text>
<Text
style={[
styles.mathText,
isMobile && { fontSize: 28 },
{ color: '#fff' },
]}
>
=
</Text>
{answerMode !== 'choose' &&
(isMobile ? (
<Text
nativeID="answer-input"
style={[
styles.input,
highContrast && highContrastStyles.input,
{ lineHeight: 56 },
{ lineHeight: 40, height: 40, fontSize: 22 },
]}
accessibilityLabel="Current answer"
>
Expand Down Expand Up @@ -1093,6 +1155,7 @@ function App() {
showMinus={modeType === 'negative'}
showDecimal={modeType === 'decimals'}
buttonColor={activeTheme.buttonColor}
compact
/>
</View>
) : (
Expand Down Expand Up @@ -1152,7 +1215,7 @@ const styles = StyleSheet.create({
flex: 1,
justifyContent: 'flex-start' as const,
alignItems: 'center' as const,
paddingVertical: 8,
paddingVertical: 4,
},
topBar: {
flexDirection: 'row' as const,
Expand Down Expand Up @@ -1243,6 +1306,10 @@ const styles = StyleSheet.create({
justifyContent: 'center' as const,
gap: 8,
},
battlefieldMobile: {
paddingVertical: 4,
gap: 4,
},
heroContainer: {
alignItems: 'center',
justifyContent: 'center',
Expand All @@ -1255,15 +1322,20 @@ const styles = StyleSheet.create({
alignItems: 'center',
justifyContent: 'space-evenly',
},
enemiesContainerMobile: {
gap: 2,
justifyContent: 'center',
},
characterImage: { width: 120, height: 120, resizeMode: 'contain' as any },
characterImageMobile: { width: 60, height: 60, resizeMode: 'contain' as any },
heartsContainer: {
flexDirection: 'row' as const,
justifyContent: 'center' as const,
gap: 8,
paddingVertical: 4,
},
heart: {
fontSize: 28,
fontSize: 22,
},
heartFull: {
opacity: 1,
Expand Down Expand Up @@ -1298,7 +1370,7 @@ const styles = StyleSheet.create({
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
paddingBottom: 16,
paddingBottom: 8,
flexWrap: 'wrap',
},
mathText: {
Expand Down Expand Up @@ -1589,9 +1661,16 @@ const styles = StyleSheet.create({
},
enemyCount: { paddingVertical: 4 },
enemyCountText: {
fontSize: 20,
fontSize: 16,
fontFamily: '"Quicksand", sans-serif',
fontWeight: 'bold',
color: '#fff',
textShadowColor: 'rgba(0, 0, 0, 0.8)',
textShadowOffset: { width: 0, height: 1 },
textShadowRadius: 3,
width: '100%',
textAlign: 'center' as any,
paddingBottom: 2,
},
msgTextErrorHC: {
color: '#FFD93D',
Expand Down
3 changes: 2 additions & 1 deletion src/AppReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ export const reducer: Reducer<AppState, ActionType> = (state, action) => {

let newDifficulty = state.difficulty;
let adaptiveMessage: string | null = null;
if (state.adaptiveDifficulty) {
// Don't auto-adjust difficulty during structured levels
if (state.adaptiveDifficulty && !state.currentLevel) {
const suggested = getAdaptiveDifficulty(
state.difficulty,
newRecentResults,
Expand Down
Loading
Loading