Skip to content
Open
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
56 changes: 8 additions & 48 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,50 +1,10 @@
# Welcome to your Expo app 👋
# Hot Potato Club

This is an [Expo](https://expo.dev) project created with [`create-expo-app`](https://www.npmjs.com/package/create-expo-app).
Hot Potato Club is a fun party game where players pass a ticking "potato" around until the timer runs out. The player holding the potato when the timer goes off loses the round. The game is played in rounds, the player with least number of losses at the end of the game wins. The game is designed to be played with a group of friends or family, and can be played in person or virtually. The game is easy to set up and can be played in a short amount of time, making it perfect for parties or gatherings.

## Get started

1. Install dependencies

```bash
npm install
```

2. Start the app

```bash
npx expo start
```

In the output, you'll find options to open the app in a

- [development build](https://docs.expo.dev/develop/development-builds/introduction/)
- [Android emulator](https://docs.expo.dev/workflow/android-studio-emulator/)
- [iOS simulator](https://docs.expo.dev/workflow/ios-simulator/)
- [Expo Go](https://expo.dev/go), a limited sandbox for trying out app development with Expo

You can start developing by editing the files inside the **app** directory. This project uses [file-based routing](https://docs.expo.dev/router/introduction).

## Get a fresh project

When you're ready, run:

```bash
npm run reset-project
```

This command will move the starter code to the **app-example** directory and create a blank **app** directory where you can start developing.

## Learn more

To learn more about developing your project with Expo, look at the following resources:

- [Expo documentation](https://docs.expo.dev/): Learn fundamentals, or go into advanced topics with our [guides](https://docs.expo.dev/guides).
- [Learn Expo tutorial](https://docs.expo.dev/tutorial/introduction/): Follow a step-by-step tutorial where you'll create a project that runs on Android, iOS, and the web.

## Join the community

Join our community of developers creating universal apps.

- [Expo on GitHub](https://github.com/expo/expo): View our open source platform and contribute.
- [Discord community](https://chat.expo.dev): Chat with Expo users and ask questions.
### How to play:
1. Read the rules of the game and instructions carefully.
2. Enter the names of the players in the game.
3. Choose the category of the game.
4. Set the number of rounds and the time limit for each round.
5. Start the game and pass the potato around while the timer counts down.
6 changes: 5 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"slug": "hot-potato-club",
"version": "1.0.0",
"orientation": "portrait",
"icon": "./app/assets/images/icon.png",
"icon": "./app/assets/images/logo_t.png",
"scheme": "hotpotatoclub",
"userInterfaceStyle": "automatic",
"newArchEnabled": true,
Expand Down Expand Up @@ -33,6 +33,10 @@
}
]
],
"splash": {
"image": "./app/assets/images/logo.png",
"resizeMode": "contain"
},
"experiments": {
"typedRoutes": true
},
Expand Down
5 changes: 5 additions & 0 deletions app/_context/GameContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type GameContextType = {
nextRound: () => void;
resetGame: () => void;
isGameSetupComplete: () => boolean;
setRoundLoser: (playerIndex: number) => void;
};

export const GameContext = createContext<GameContextType | undefined>(undefined);
Expand All @@ -34,6 +35,9 @@ export const GameProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
const explode = () => dispatch({ type: 'EXPLODE' });
const nextRound = () => dispatch({ type: 'NEXT_ROUND' });
const resetGame = () => dispatch({ type: 'RESET_GAME' });
const setRoundLoser = (playerIndex: number) => {
dispatch({ type: 'SET_ROUND_LOSER', payload: playerIndex });
};

const value = useMemo(() => {
const isGameSetupComplete = () => {
Expand All @@ -55,6 +59,7 @@ export const GameProvider: React.FC<{ children: ReactNode }> = ({ children }) =>
nextRound,
resetGame,
isGameSetupComplete,
setRoundLoser,
};
}, [state]);

Expand Down
19 changes: 19 additions & 0 deletions app/_context/gameReducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,25 @@ export function gameReducer(state: GameState = initialGameState, action: GameAct
...state,
exploded: true,
timerRunning: false,
};
}
case 'SET_ROUND_LOSER': {
const updatedPlayers = [...state.settings.players];
updatedPlayers[action.payload] = {
...updatedPlayers[action.payload],
roundsLost: (updatedPlayers[action.payload].roundsLost || 0) + 1
};

const playerId = state.settings.players[action.payload].id;

return {
...state,
settings: {
...state.settings,
players: updatedPlayers
},
exploded: true,
timerRunning: false,
roundResults: [...state.roundResults, { playerId, exploded: true }],
};
}
Expand Down
2 changes: 2 additions & 0 deletions app/_layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { GameProvider } from '@/_context/GameContext';
import * as Font from 'expo-font';
import { Stack } from 'expo-router';
import * as SplashScreen from 'expo-splash-screen';
import { StatusBar } from 'expo-status-bar';
import { useCallback, useEffect, useState } from 'react';
import { View } from 'react-native';

Expand Down Expand Up @@ -48,6 +49,7 @@ export default function RootLayout() {
// If we're ready to show the app, render it with our custom splash screen animation
return (
<GameProvider>
<StatusBar style="dark" />
<View
style={{ flex: 1 }}
onLayout={onLayoutRootView}
Expand Down
25 changes: 14 additions & 11 deletions app/_types/GameTypes.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,31 @@
// Define data models and state types for the Hot Potato game
export type Category = {
export interface Category {
id: string;
name: string;
questions: string[];
};
}

export type Player = {
export interface Player {
id: string;
name: string;
};
color: string;
roundsLost: number;
}

export type GameSettings = {
export interface GameSettings {
players: Player[];
selectedCategories: string[];
rounds: number;
minTimer: number;
maxTimer: number;
};
}

export type RoundResult = {
export interface RoundResult {
playerId: string;
exploded: boolean;
};
}

export type GameState = {
export interface GameState {
settings: GameSettings;
currentRound: number;
currentQuestion: string;
Expand All @@ -33,7 +35,7 @@ export type GameState = {
exploded: boolean;
gameOver: boolean;
roundResults: RoundResult[];
};
}

// Action types for reducer
export type GameAction =
Expand All @@ -47,6 +49,7 @@ export type GameAction =
| { type: 'SKIP_QUESTION' }
| { type: 'EXPLODE' }
| { type: 'NEXT_ROUND' }
| { type: 'RESET_GAME' };
| { type: 'RESET_GAME' }
| { type: 'SET_ROUND_LOSER'; payload: number };

export default {} as any;
Binary file removed app/assets/images/PayPalLogo.png
Binary file not shown.
Binary file removed app/assets/images/UPILogo.jpg
Binary file not shown.
77 changes: 74 additions & 3 deletions app/home.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,44 @@
import * as Haptics from 'expo-haptics';
import * as Linking from 'expo-linking';
import { router } from 'expo-router';
import { StatusBar } from 'expo-status-bar';
import React from 'react';
import { Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import { Alert, Image, StyleSheet, Text, TouchableOpacity, View } from 'react-native';
import Animated, { FadeIn } from 'react-native-reanimated';

export default function Home() {
const navigateTo = (path: "/screens/setup-players" | "/screens/how-to-play") => {
const navigateTo = (path: "/screens/setup-players" | "/screens/how-to-play" | "/screens/feedback") => {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);
router.push(path);
};

const handleDonate = async () => {
Haptics.impactAsync(Haptics.ImpactFeedbackStyle.Medium);

const donateUrl = 'https://www.hawkslab.online/donate';

try {
const supported = await Linking.canOpenURL(donateUrl);
if (supported) {
await Linking.openURL(donateUrl);
} else {
Alert.alert(
'Unable to Open',
'Sorry, we couldn\'t open the donation page. Please visit https://www.hawkslab.online/donate directly in your browser.'
);
}
} catch (error) {
console.error('Error opening donation URL:', error);
Alert.alert(
'Error',
'Something went wrong. Please visit https://www.hawkslab.online/donate directly in your browser.'
);
}
};

return (
<View style={styles.container}>
<StatusBar style="auto" />
<StatusBar style="dark" />

<Animated.View
entering={FadeIn.duration(1000)}
Expand Down Expand Up @@ -45,6 +70,22 @@ export default function Home() {
>
<Text style={[styles.buttonText, styles.secondaryButtonText]}>How to Play</Text>
</TouchableOpacity>

<View style={styles.bottomButtonsContainer}>
<TouchableOpacity
style={[styles.smallButton, styles.feedbackButton]}
onPress={() => navigateTo('/screens/feedback')}
>
<Text style={styles.smallButtonText}>💬 Feedback</Text>
</TouchableOpacity>

<TouchableOpacity
style={[styles.smallButton, styles.donateButton]}
onPress={handleDonate}
>
<Text style={styles.smallButtonText}>❤️ Donate</Text>
</TouchableOpacity>
</View>
</Animated.View>
</View>
);
Expand Down Expand Up @@ -110,4 +151,34 @@ const styles = StyleSheet.create({
secondaryButtonText: {
color: '#FE6244',
},
bottomButtonsContainer: {
flexDirection: 'row',
justifyContent: 'space-between',
marginTop: 20,
},
smallButton: {
backgroundColor: '#F0F0F0',
paddingVertical: 12,
paddingHorizontal: 20,
borderRadius: 20,
flex: 0.48,
alignItems: 'center',
shadowColor: '#000',
shadowOffset: { width: 0, height: 1 },
shadowOpacity: 0.1,
shadowRadius: 2,
elevation: 2,
},
feedbackButton: {
backgroundColor: '#E8F5E8',
},
donateButton: {
backgroundColor: '#FFE8E8',
},
smallButtonText: {
color: '#666',
fontSize: 14,
fontFamily: 'SpaceMono',
fontWeight: 'bold',
},
});
Loading