stub-api
Alban GUILHOT 3 years ago
commit 5caa3895db

@ -0,0 +1,30 @@
import { FC, ReactNode } from "react"
import { View, TextInput,Text } from "react-native"
import React from "react"
import { trace } from "console"
import { Game } from "../core/game"
/*
Importing the correct stylesheet
*/
import styles from "./style/TextInput.style"
export const CustomTextInput :
/*
* game : Game that must be displayed
* nav : tool needed to allow the navigation between the screens
*/
FC<{placeholder:String,text:String}> =
({placeholder, text}) =>
{
const [value, onChangeText] = React.useState(placeholder);
return (
<View>
<Text style={styles.section}>{text}</Text>
<TextInput
style={styles.input}
onChangeText= {onChangeText}
/>
</View>
)
}

@ -0,0 +1,19 @@
import { StyleSheet } from 'react-native';
export default StyleSheet.create({
input: {
height: 40,
width: 250,
marginBottom:12,
borderWidth: 1,
padding: 10,
alignContent:'center',
backgroundColor:'white'
},
section:{
fontSize:15,
alignSelf:'left',
marginLeft:10,
color:'white',
},
})

@ -8,10 +8,10 @@ let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date
let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[1], tabSkinApp, undefined); let UserTest:User=new User("48", "Wesh Wesh", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[1], tabSkinApp, undefined);
let tabMessageTest:Message[]=[ let tabMessageTest:Message[]=[
new Message("Salut", UserActu, new Date(2022,12,12)), new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)),
new Message("Wesh", UserTest, new Date(2022,12,13)), new Message("Wesh", UserTest, new Date(2022,12,13,12,20,40)),
new Message("Ca va", UserActu, new Date(2022,12,14)), new Message("Ca va", UserActu, new Date(2022,12,14, 12, 30, 35)),
new Message("Ouais et toi?", UserTest, new Date(2022,12,15)), new Message("Ouais et toi?", UserTest, new Date(2022,12,14,12,35,0)),
] ]
let tabUS:User[]=[UserActu, UserTest]; let tabUS:User[]=[UserActu, UserTest];

@ -4,13 +4,15 @@ import { ImageSourcePropType } from "react-native";
export class Game{ export class Game{
private Name:string; private Name:string;
private ImageSource:ImageSourcePropType; private ImageSource:ImageSourcePropType;
private GameSource:string ; private GameSource:string;
private NbPlayer: number;
/* Constructor of the class */ /* Constructor of the class */
constructor (name:string, imageSource:ImageSourcePropType, gameSource:string){ constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number){
this.Name=name; this.Name=name;
this.ImageSource=imageSource; this.ImageSource=imageSource;
this.GameSource=gameSource; this.GameSource=gameSource;
this.NbPlayer=nbPlayer;
} }
/* Brief : Function getting the name of a game */ /* Brief : Function getting the name of a game */
@ -38,8 +40,18 @@ export class Game{
return this.GameSource; return this.GameSource;
} }
/* Brief : Function getting the source of a game */ /* Brief : Function setting the source of a game */
setGameSource(gameSource:string){ setGameSource(gameSource:string){
this.GameSource=gameSource; this.GameSource=gameSource;
} }
/* Brief : Function getting the number of player */
getNbPlayer(){
return this.NbPlayer;
}
/* Brief : Function setting the number of player*/
setNbPlayer(nbPlayer:number){
this.NbPlayer=nbPlayer;
}
} }

@ -5,10 +5,10 @@ import { User } from "./user";
export class Conversation{ export class Conversation{
private TabUser: User[]; private TabUser: User[];
private TabMessage: Message[]; private TabMessage: Message[];
private Name?: string; private Name: string;
/* Constructor of the class */ /* Constructor of the class */
constructor(tabUser: User[], tabMessage:Message[], name?:string){ constructor(tabUser: User[], tabMessage:Message[], name:string){
this.TabUser=[...tabUser]; this.TabUser=[...tabUser];
this.TabMessage=[...tabMessage]; this.TabMessage=[...tabMessage];
this.Name=name; this.Name=name;

@ -4,8 +4,8 @@ import { Game } from './game'
export class GameCasino extends Game{ export class GameCasino extends Game{
readonly Coef:number; readonly Coef:number;
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, coef:number){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, coef:number){
super(name, imageSource, gameSource); super(name, imageSource, gameSource, nbPlayer);
this.Coef=coef; this.Coef=coef;
} }

@ -4,8 +4,8 @@ import { Game } from './game'
export class GameMulti extends Game{ export class GameMulti extends Game{
readonly RankToCoins:Map<number,number> readonly RankToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, rankToCoins:Map<number,number>){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, rankToCoins:Map<number,number>){
super(name, imageSource, gameSource); super(name, imageSource, gameSource, nbPlayer);
this.RankToCoins=rankToCoins; this.RankToCoins=rankToCoins;
} }

@ -4,8 +4,8 @@ import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly PtsToCoins:Map<number,number> readonly PtsToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, ptsToCoins:Map<number,number>){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, ptsToCoins:Map<number,number>){
super(name, imageSource, gameSource); super(name, imageSource, gameSource, nbPlayer);
this.PtsToCoins=ptsToCoins; this.PtsToCoins=ptsToCoins;
} }

@ -0,0 +1,67 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game';
import { GameCasino } from './gameCasino';
import { GameMulti } from './gameMulti';
import { GameSolo } from './gameSolo';
import { User } from "./user";
let index:number=0;
export class Match{
readonly Code:string;
private TabUsers:User[];
private TheGame:Game;
private GainingMechanism:number=0;
constructor(tabUser:User[], game:Game){
index++;
this.Code=index.toString();
this.TabUsers=[...tabUser];
this.TheGame=game;
}
getTabUsers(){
return this.TabUsers;
}
ajouterUser(us:User){
this.TabUsers.push(us);
}
setTabUser(tabUser:User[]){
this.TabUsers=[...tabUser];
}
getCode(){
return this.Code;
}
getGame(){
return this.TheGame;
}
setGame(game:Game){
this.TheGame=game;
}
getGainingMechanism(){
return this.GainingMechanism;
}
setGainingMechanism(gain:number){
this.GainingMechanism=gain;
}
convertMechanismToCoins(){
if (this.TheGame instanceof GameSolo){
return this.TheGame.CoinsWithPoints(this.GainingMechanism);
}
else if (this.TheGame instanceof GameMulti){
return this.TheGame.CoinsWithRank(this.GainingMechanism);
}
else if (this.TheGame instanceof GameCasino){
return this.TheGame.betToCoins(this.GainingMechanism);
}
}
}

@ -15,7 +15,7 @@ let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png'); const msc = require('../../assets/Icons/FondGris.png');
const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv); const UserActu=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, tabConv);
const jeuTest= new Game("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin"); const jeuTest= new Game("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin", 1);
function GameChoice(props: { navigation: any; }) { function GameChoice(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props
return ( return (

@ -0,0 +1,29 @@
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native'
import React from 'react';
import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler';
import { CustomTextInput } from '../components/CustomTextInput';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import styles from "./style/SignIn.style"
function SignIn(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}>
<CustomTextInput placeholder={""} text="ID"/>
<CustomTextInput placeholder={""} text="Password"/>
<Pressable style={styles.button} onPress={navigation.navigate('Home')}>
<Text style={styles.text}>Se connecter</Text>
</Pressable>
<Pressable>
<Text style={styles.signup}>Pas de compte? Inscrivez vous !</Text>
</Pressable>
</View>
</View>
);
}
export default SignIn

@ -0,0 +1,30 @@
import { StatusBar } from 'expo-status-bar'
import { StyleSheet, View, ImageSourcePropType, Pressable, Text} from 'react-native'
import React from 'react';
import stylesScreen from './style/screens.style'
import { TextInput } from 'react-native-gesture-handler';
import { CustomTextInput } from '../components/CustomTextInput';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import styles from "./style/SignIn.style"
function SignUp(props: { navigation: any; }) {
const { navigation } = props
return (
<View style={stylesScreen.container}>
<View style={stylesScreen.bodyCenter}>
<CustomTextInput placeholder={""} text="Pseudo"/>
<CustomTextInput placeholder={""} text="Mot de passe"/>
<CustomTextInput placeholder={""} text="Mot de passe"/>
<CustomTextInput placeholder={""} text="Nationalité"/>
<CustomTextInput placeholder={""} text="Date de naisance"/>
<CustomTextInput placeholder={""} text="Sexe"/>
<Pressable style={styles.button} onPress={navigation.navigate('Home')}>
<Text style={styles.text}>S'inscrire</Text>
</Pressable>
</View>
</View>
);
}
export default SignUp

@ -0,0 +1,27 @@
import { StyleSheet } from "react-native";
export default StyleSheet.create({
button: {
alignItems: 'center',
justifyContent: 'center',
height: 50,
width: 225,
marginTop: '15%',
margin:'5%',
borderRadius: 10,
elevation: 3,
backgroundColor: '#0085FF',
},
text: {
fontSize: 16,
lineHeight: 21,
fontWeight: 'bold',
letterSpacing: 0.25,
color: 'white',
},
signup:{
fontSize:15,
color:'white',
textDecorationLine:"underline",
},
});

@ -7,6 +7,6 @@ let myMap = new Map<number, number>([
[150, 6] [150, 6]
]); ]);
let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", myMap); let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", 1, myMap);
export default game; export default game;
Loading…
Cancel
Save