parent
cb2661924e
commit
ad0fb89c50
@ -1,5 +1,5 @@
|
|||||||
class ApiError extends Error {
|
class ApiError extends Error {
|
||||||
constructor(message) {
|
constructor(message: string) {
|
||||||
super(message);
|
super(message);
|
||||||
this.name = 'ApiError';
|
this.name = 'ApiError';
|
||||||
}
|
}
|
@ -1,9 +0,0 @@
|
|||||||
class Card {
|
|
||||||
constructor(id,value,suit,image){
|
|
||||||
this.value = value;
|
|
||||||
this.suit = suit;
|
|
||||||
this.image = image;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* might extend from Component */
|
|
@ -0,0 +1,13 @@
|
|||||||
|
class Card {
|
||||||
|
value: number;
|
||||||
|
suit: string;
|
||||||
|
image: string;
|
||||||
|
|
||||||
|
constructor(id: number, value: number, suit: string, image: string) {
|
||||||
|
this.value = value;
|
||||||
|
this.suit = suit;
|
||||||
|
this.image = image;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* might extend from Component */
|
@ -1,26 +0,0 @@
|
|||||||
/* passer en tsx */
|
|
||||||
export default class Game {
|
|
||||||
constructor(deckId) {
|
|
||||||
console.warn("I am inside the constructor!")
|
|
||||||
try {
|
|
||||||
this.deckId = deckId;
|
|
||||||
this.playerHand = [];
|
|
||||||
this.dealerHand = [];
|
|
||||||
} catch (error) {
|
|
||||||
console.error(error);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Draw(card, who) {
|
|
||||||
if(who == 'player')
|
|
||||||
this.playerHand.push(card);
|
|
||||||
else
|
|
||||||
this.dealerHand.push(card);
|
|
||||||
}
|
|
||||||
|
|
||||||
toObject() {
|
|
||||||
return {
|
|
||||||
deckId: this.deckId,
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,27 @@
|
|||||||
|
export default class Game {
|
||||||
|
deckId: string;
|
||||||
|
playerHand: Card[];
|
||||||
|
dealerHand: Card[];
|
||||||
|
|
||||||
|
constructor(deckId: string) {
|
||||||
|
console.warn('I am inside the constructor!');
|
||||||
|
try {
|
||||||
|
this.deckId = deckId;
|
||||||
|
this.playerHand = [];
|
||||||
|
this.dealerHand = [];
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Draw(card: Card, who: 'player' | 'dealer') {
|
||||||
|
if (who == 'player') this.playerHand.push(card);
|
||||||
|
else this.dealerHand.push(card);
|
||||||
|
}
|
||||||
|
|
||||||
|
toObject() {
|
||||||
|
return {
|
||||||
|
deckId: this.deckId,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +0,0 @@
|
|||||||
import { FETCH_DECK_FAILED } from "../constants"
|
|
||||||
|
|
||||||
export const fetchDeckFailed = (error) => {
|
|
||||||
return {
|
|
||||||
type: FETCH_DECK_FAILED,
|
|
||||||
payload: error
|
|
||||||
}
|
|
||||||
}
|
|
@ -0,0 +1,8 @@
|
|||||||
|
import { FETCH_DECK_FAILED } from "../constants";
|
||||||
|
|
||||||
|
export const fetchDeckFailed = (error: string) => {
|
||||||
|
return {
|
||||||
|
type: FETCH_DECK_FAILED,
|
||||||
|
payload: error
|
||||||
|
};
|
||||||
|
};
|
@ -1,10 +1,10 @@
|
|||||||
import { FETCH_DECK } from "../constants"
|
import { FETCH_DECK } from "../constants"
|
||||||
|
|
||||||
const initialState = {
|
const initialState = {
|
||||||
game: null
|
game: null,
|
||||||
}
|
}
|
||||||
|
|
||||||
export default appReducer = (state = initialState, action) => {
|
export default wjReducer = (state = initialState, action ) => {
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
case FETCH_DECK:
|
case FETCH_DECK:
|
||||||
return {...state, game: action.payload };
|
return {...state, game: action.payload };
|
@ -1,5 +1,5 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { StyleSheet, Text, View, SafeAreaView, ScrollView, Image} from 'react-native';
|
import { StyleSheet, Text, View, ScrollView, Image} from 'react-native';
|
||||||
import { ColorContext } from '../context/ColorContext';
|
import { ColorContext } from '../context/ColorContext';
|
||||||
|
|
||||||
export default function CheatSheetScreen() {
|
export default function CheatSheetScreen() {
|
@ -1,6 +1,6 @@
|
|||||||
import React, { useContext } from 'react';
|
import React, { useContext } from 'react';
|
||||||
import { ColorContext } from '../context/ColorContext';
|
import { ColorContext } from '../context/ColorContext';
|
||||||
import { StyleSheet, Text, View, SafeAreaView, ScrollView, Image} from 'react-native';
|
import { StyleSheet, Text, View, ScrollView, Image} from 'react-native';
|
||||||
|
|
||||||
export default function InformationScreen() {
|
export default function InformationScreen() {
|
||||||
|
|
@ -1,92 +0,0 @@
|
|||||||
import React, { useContext } from 'react';
|
|
||||||
import { ColorContext } from '../context/ColorContext';
|
|
||||||
import { DealerContext } from '../context/DealerContext';
|
|
||||||
import { StyleSheet, Text, Image, View, TouchableOpacity, SafeAreaView, ScrollView} from 'react-native';
|
|
||||||
|
|
||||||
export default function PlayScreen() {
|
|
||||||
|
|
||||||
const { isDarkMode, toggleTheme } = useContext(ColorContext);
|
|
||||||
const { dealerName } = useContext(DealerContext);
|
|
||||||
|
|
||||||
const colors = [ 'blue', 'red', 'gold', 'green', 'purple']
|
|
||||||
const letters = ["H", "S", "P", "D", "R"]
|
|
||||||
|
|
||||||
const styles = StyleSheet.create({
|
|
||||||
container: {
|
|
||||||
backgroundColor: isDarkMode ? '#303030' : 'white',
|
|
||||||
},
|
|
||||||
top: {
|
|
||||||
justifyContent: 'flex-start',
|
|
||||||
},
|
|
||||||
dealer: {
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'center',
|
|
||||||
},
|
|
||||||
dealer_image: {
|
|
||||||
width: '100%',
|
|
||||||
resizeMode: 'contain',
|
|
||||||
},
|
|
||||||
dealer_name: {
|
|
||||||
fontSize: 20,
|
|
||||||
color: isDarkMode ? 'white' : '#303030',
|
|
||||||
},
|
|
||||||
text_top: {
|
|
||||||
fontSize: 20,
|
|
||||||
},
|
|
||||||
middle: {
|
|
||||||
alignItems: 'center'
|
|
||||||
},
|
|
||||||
text_middle: {
|
|
||||||
fontSize: 20,
|
|
||||||
fontWeight: 'bold',
|
|
||||||
color: isDarkMode ? 'white' : '#303030'
|
|
||||||
},
|
|
||||||
scroll: {
|
|
||||||
alignSelf: 'center',
|
|
||||||
},
|
|
||||||
button: {
|
|
||||||
height: 50,
|
|
||||||
width: 50,
|
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'center',
|
|
||||||
marginHorizontal: 10,
|
|
||||||
borderRadius: 5,
|
|
||||||
},
|
|
||||||
buttonText: {
|
|
||||||
color: 'white',
|
|
||||||
fontWeight: 'bold',
|
|
||||||
},
|
|
||||||
down: {
|
|
||||||
alignItems: 'center'
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
return (
|
|
||||||
<SafeAreaView style={styles.container}>
|
|
||||||
<View style={styles.dealer_part}>
|
|
||||||
<View style={styles.dealer}>
|
|
||||||
<Image style={styles.dealer_image} source={require('../assets/dealer.png')}/>
|
|
||||||
<Text style={styles.dealer_name}> {dealerName}</Text>
|
|
||||||
</View>
|
|
||||||
</View>
|
|
||||||
<View style={styles.middle}>
|
|
||||||
<Text style={styles.text_middle}>YOUR CHOICE</Text>
|
|
||||||
</View>
|
|
||||||
<ScrollView horizontal={true} style={styles.scroll}>
|
|
||||||
{colors.map((color, index) => (
|
|
||||||
<View key={index} style={[styles.button, { backgroundColor: color }]}>
|
|
||||||
<TouchableOpacity >
|
|
||||||
<Text style={styles.buttonText}>
|
|
||||||
{letters[index]}
|
|
||||||
</Text>
|
|
||||||
</TouchableOpacity>
|
|
||||||
</View>
|
|
||||||
))}
|
|
||||||
</ScrollView>
|
|
||||||
<View style={styles.down}>
|
|
||||||
<Image source={require('../assets/hands.png')}/>
|
|
||||||
</View>
|
|
||||||
</SafeAreaView>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,97 @@
|
|||||||
|
import React, { useContext } from "react";
|
||||||
|
import { ColorContext } from "../context/ColorContext";
|
||||||
|
import { DealerContext } from "../context/DealerContext";
|
||||||
|
import {
|
||||||
|
StyleSheet,
|
||||||
|
Text,
|
||||||
|
Image,
|
||||||
|
View,
|
||||||
|
TouchableOpacity,
|
||||||
|
SafeAreaView,
|
||||||
|
ScrollView,
|
||||||
|
} from "react-native";
|
||||||
|
|
||||||
|
export default function PlayScreen() {
|
||||||
|
const { isDarkMode, toggleTheme } = useContext(ColorContext);
|
||||||
|
const { dealerName } = useContext(DealerContext);
|
||||||
|
|
||||||
|
const colors = ["blue", "red", "gold", "green", "purple"];
|
||||||
|
const letters = ["H", "S", "P", "D", "R"];
|
||||||
|
|
||||||
|
const styles = StyleSheet.create({
|
||||||
|
container: {
|
||||||
|
backgroundColor: isDarkMode ? "#303030" : "white",
|
||||||
|
},
|
||||||
|
top: {
|
||||||
|
justifyContent: "flex-start",
|
||||||
|
},
|
||||||
|
dealer: {
|
||||||
|
flexDirection: "column",
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
dealer_image: {
|
||||||
|
width: "100%",
|
||||||
|
resizeMode: "contain",
|
||||||
|
},
|
||||||
|
dealer_name: {
|
||||||
|
fontSize: 20,
|
||||||
|
color: isDarkMode ? "white" : "#303030",
|
||||||
|
},
|
||||||
|
text_top: {
|
||||||
|
fontSize: 20,
|
||||||
|
},
|
||||||
|
middle: {
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
text_middle: {
|
||||||
|
fontSize: 20,
|
||||||
|
fontWeight: "bold",
|
||||||
|
color: isDarkMode ? "white" : "#303030",
|
||||||
|
},
|
||||||
|
scroll: {
|
||||||
|
alignSelf: "center",
|
||||||
|
},
|
||||||
|
button: {
|
||||||
|
height: 50,
|
||||||
|
width: 50,
|
||||||
|
alignItems: "center",
|
||||||
|
justifyContent: "center",
|
||||||
|
marginHorizontal: 10,
|
||||||
|
borderRadius: 5,
|
||||||
|
},
|
||||||
|
buttonText: {
|
||||||
|
color: "white",
|
||||||
|
fontWeight: "bold",
|
||||||
|
},
|
||||||
|
down: {
|
||||||
|
alignItems: "center",
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SafeAreaView style={styles.container}>
|
||||||
|
<View style={styles.dealer}>
|
||||||
|
<Image
|
||||||
|
style={styles.dealer_image}
|
||||||
|
source={require("../assets/dealer.png")}
|
||||||
|
/>
|
||||||
|
<Text style={styles.dealer_name}> {dealerName}</Text>
|
||||||
|
</View>
|
||||||
|
<View style={styles.middle}>
|
||||||
|
<Text style={styles.text_middle}>YOUR CHOICE</Text>
|
||||||
|
</View>
|
||||||
|
<ScrollView horizontal={true} style={styles.scroll}>
|
||||||
|
{colors.map((color, index) => (
|
||||||
|
<View key={index} style={[styles.button, { backgroundColor: color }]}>
|
||||||
|
<TouchableOpacity>
|
||||||
|
<Text style={styles.buttonText}>{letters[index]}</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
</View>
|
||||||
|
))}
|
||||||
|
</ScrollView>
|
||||||
|
<View style={styles.down}>
|
||||||
|
<Image source={require("../assets/hands.png")} />
|
||||||
|
</View>
|
||||||
|
</SafeAreaView>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in new issue