From dec83bf0c3b2db90c158c6432baee4f804aae465 Mon Sep 17 00:00:00 2001 From: Thomas Chazot Date: Mon, 17 Oct 2022 15:57:23 +0200 Subject: [PATCH 1/2] ADD: -Class match --- bob_party/src/constCov.ts | 8 ++-- bob_party/src/core/Game.ts | 18 ++++++-- bob_party/src/core/conversation.ts | 4 +- bob_party/src/core/gameCasino.ts | 4 +- bob_party/src/core/gameMulti.ts | 4 +- bob_party/src/core/gameSolo.ts | 4 +- bob_party/src/core/match.ts | 67 ++++++++++++++++++++++++++++ bob_party/src/screens/GameChoice.tsx | 2 +- bob_party/src/testGameSolo.ts | 2 +- 9 files changed, 96 insertions(+), 17 deletions(-) create mode 100644 bob_party/src/core/match.ts diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts index 7dee778..5918814 100644 --- a/bob_party/src/constCov.ts +++ b/bob_party/src/constCov.ts @@ -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 tabMessageTest:Message[]=[ - new Message("Salut", UserActu, new Date(2022,12,12)), - new Message("Wesh", UserTest, new Date(2022,12,13)), - new Message("Ca va", UserActu, new Date(2022,12,14)), - new Message("Ouais et toi?", UserTest, new Date(2022,12,15)), + new Message("Salut", UserActu, new Date(2022,12,12,11,30,40)), + new Message("Wesh", UserTest, new Date(2022,12,13,12,20,40)), + new Message("Ca va", UserActu, new Date(2022,12,14, 12, 30, 35)), + new Message("Ouais et toi?", UserTest, new Date(2022,12,14,12,35,0)), ] let tabUS:User[]=[UserActu, UserTest]; diff --git a/bob_party/src/core/Game.ts b/bob_party/src/core/Game.ts index 7abbad5..52c1b0a 100644 --- a/bob_party/src/core/Game.ts +++ b/bob_party/src/core/Game.ts @@ -4,13 +4,15 @@ import { ImageSourcePropType } from "react-native"; export class Game{ private Name:string; private ImageSource:ImageSourcePropType; - private GameSource:string ; + private GameSource:string; + private NbPlayer: number; /* Constructor of the class */ - constructor (name:string, imageSource:ImageSourcePropType, gameSource:string){ + constructor (name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number){ this.Name=name; this.ImageSource=imageSource; this.GameSource=gameSource; + this.NbPlayer=nbPlayer; } /* Brief : Function getting the name of a game */ @@ -38,8 +40,18 @@ export class Game{ return this.GameSource; } - /* Brief : Function getting the source of a game */ + /* Brief : Function setting the source of a game */ setGameSource(gameSource:string){ 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; + } } \ No newline at end of file diff --git a/bob_party/src/core/conversation.ts b/bob_party/src/core/conversation.ts index dcc0db0..76a49cc 100644 --- a/bob_party/src/core/conversation.ts +++ b/bob_party/src/core/conversation.ts @@ -5,10 +5,10 @@ import { User } from "./user"; export class Conversation{ private TabUser: User[]; private TabMessage: Message[]; - private Name?: string; + private Name: string; /* Constructor of the class */ - constructor(tabUser: User[], tabMessage:Message[], name?:string){ + constructor(tabUser: User[], tabMessage:Message[], name:string){ this.TabUser=[...tabUser]; this.TabMessage=[...tabMessage]; this.Name=name; diff --git a/bob_party/src/core/gameCasino.ts b/bob_party/src/core/gameCasino.ts index 3e37553..b58caa4 100644 --- a/bob_party/src/core/gameCasino.ts +++ b/bob_party/src/core/gameCasino.ts @@ -4,8 +4,8 @@ import { Game } from './game' export class GameCasino extends Game{ readonly Coef:number; - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, coef:number){ - super(name, imageSource, gameSource); + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, coef:number){ + super(name, imageSource, gameSource, nbPlayer); this.Coef=coef; } diff --git a/bob_party/src/core/gameMulti.ts b/bob_party/src/core/gameMulti.ts index f8e5a77..4555331 100644 --- a/bob_party/src/core/gameMulti.ts +++ b/bob_party/src/core/gameMulti.ts @@ -4,8 +4,8 @@ import { Game } from './game' export class GameMulti extends Game{ readonly RankToCoins:Map - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, rankToCoins:Map){ - super(name, imageSource, gameSource); + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, rankToCoins:Map){ + super(name, imageSource, gameSource, nbPlayer); this.RankToCoins=rankToCoins; } diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index 30c3f2a..64cecdb 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -4,8 +4,8 @@ import { Game } from './game' export class GameSolo extends Game{ readonly PtsToCoins:Map - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, ptsToCoins:Map){ - super(name, imageSource, gameSource); + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, nbPlayer:number, ptsToCoins:Map){ + super(name, imageSource, gameSource, nbPlayer); this.PtsToCoins=ptsToCoins; } diff --git a/bob_party/src/core/match.ts b/bob_party/src/core/match.ts new file mode 100644 index 0000000..8365997 --- /dev/null +++ b/bob_party/src/core/match.ts @@ -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); + } + } + +} \ No newline at end of file diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index 1540849..c5088d5 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -15,7 +15,7 @@ let tabConv:Conversation[]=[]; 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 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; }) { const { navigation } = props return ( diff --git a/bob_party/src/testGameSolo.ts b/bob_party/src/testGameSolo.ts index f1c8f3d..c8d6c14 100644 --- a/bob_party/src/testGameSolo.ts +++ b/bob_party/src/testGameSolo.ts @@ -7,6 +7,6 @@ let myMap = new Map([ [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; \ No newline at end of file From e393cad4b842ccf67b1a9f03d574937e1278860a Mon Sep 17 00:00:00 2001 From: Lucie Bedouret Date: Mon, 17 Oct 2022 17:44:51 +0200 Subject: [PATCH 2/2] ADD: composant textInput, SignIn et SignUp --- bob_party/src/components/CustomTextInput.tsx | 30 +++++++++++++++++++ .../src/components/style/TextInput.style.js | 19 ++++++++++++ bob_party/src/screens/SignIn.tsx | 29 ++++++++++++++++++ bob_party/src/screens/SignUp.tsx | 30 +++++++++++++++++++ bob_party/src/screens/style/SignIn.style.js | 27 +++++++++++++++++ 5 files changed, 135 insertions(+) create mode 100644 bob_party/src/components/CustomTextInput.tsx create mode 100644 bob_party/src/components/style/TextInput.style.js create mode 100644 bob_party/src/screens/SignIn.tsx create mode 100644 bob_party/src/screens/SignUp.tsx create mode 100644 bob_party/src/screens/style/SignIn.style.js diff --git a/bob_party/src/components/CustomTextInput.tsx b/bob_party/src/components/CustomTextInput.tsx new file mode 100644 index 0000000..20ad69f --- /dev/null +++ b/bob_party/src/components/CustomTextInput.tsx @@ -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 ( + + {text} + + + ) +} \ No newline at end of file diff --git a/bob_party/src/components/style/TextInput.style.js b/bob_party/src/components/style/TextInput.style.js new file mode 100644 index 0000000..70e38be --- /dev/null +++ b/bob_party/src/components/style/TextInput.style.js @@ -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', + }, +}) \ No newline at end of file diff --git a/bob_party/src/screens/SignIn.tsx b/bob_party/src/screens/SignIn.tsx new file mode 100644 index 0000000..953a3e2 --- /dev/null +++ b/bob_party/src/screens/SignIn.tsx @@ -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 ( + + + + + + Se connecter + + + Pas de compte? Inscrivez vous ! + + + + ); +} + +export default SignIn diff --git a/bob_party/src/screens/SignUp.tsx b/bob_party/src/screens/SignUp.tsx new file mode 100644 index 0000000..a72a638 --- /dev/null +++ b/bob_party/src/screens/SignUp.tsx @@ -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 ( + + + + + + + + + + S'inscrire + + + + ); +} + +export default SignUp diff --git a/bob_party/src/screens/style/SignIn.style.js b/bob_party/src/screens/style/SignIn.style.js new file mode 100644 index 0000000..e8abeb6 --- /dev/null +++ b/bob_party/src/screens/style/SignIn.style.js @@ -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", + }, + }); \ No newline at end of file