diff --git a/bob_party/src/components/GameComponent.tsx b/bob_party/src/components/GameComponent.tsx index 53a7d5c..fdaa8b7 100644 --- a/bob_party/src/components/GameComponent.tsx +++ b/bob_party/src/components/GameComponent.tsx @@ -2,7 +2,7 @@ import { FC, ReactNode } from "react" import { Pressable, Image, ImageStyle, Text, View, Alert, ImageSourcePropType, TextStyle } from "react-native" import React from "react" import { trace } from "console" -import { Game } from "../core/Game" +import { Game } from "../core/game" /* Importing the correct stylesheet diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts index e3f9a3a..7dee778 100644 --- a/bob_party/src/constCov.ts +++ b/bob_party/src/constCov.ts @@ -4,8 +4,8 @@ import tabSkinApp from './constSkin' import { User } from "./core/user"; -let UserActu:User=new User("14", "leBg", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], tabSkinApp, undefined); -let UserTest:User=new User("48", "Wesh Wesh", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[1], tabSkinApp, undefined); +let UserActu:User=new User("14", "leBg", "MdpDeOuf", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, 12, tabSkinApp[0], 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[]=[ new Message("Salut", UserActu, new Date(2022,12,12)), diff --git a/bob_party/src/core/gameCasino.ts b/bob_party/src/core/gameCasino.ts new file mode 100644 index 0000000..3e37553 --- /dev/null +++ b/bob_party/src/core/gameCasino.ts @@ -0,0 +1,21 @@ +import { ImageSourcePropType } from 'react-native'; +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); + this.Coef=coef; + } + + //Get the coefficient of the casino game + getCoef(){ + return this.Coef; + } + + //Returns the coins gained with the initial bet of the user times the coefficient of the game + betToCoins(bet:number){ + return this.Coef*bet; + } +} \ No newline at end of file diff --git a/bob_party/src/core/gameMulti.ts b/bob_party/src/core/gameMulti.ts new file mode 100644 index 0000000..f8e5a77 --- /dev/null +++ b/bob_party/src/core/gameMulti.ts @@ -0,0 +1,28 @@ +import { ImageSourcePropType } from 'react-native'; +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); + this.RankToCoins=rankToCoins; + } + + //Get the map of the game with the rank as the key and the coins as the values + getMultiMap(){ + return this.RankToCoins; + } + + //Returns the coins gained depending on the rank + CoinsWithRank(rank:number){ + let coins; + for (let key of this.RankToCoins.keys()){ + coins = this.RankToCoins.get(key); + if (rank==key ){ + return coins; + } + } + return coins; + } +} \ No newline at end of file diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index 9403bd4..30c3f2a 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -9,11 +9,12 @@ export class GameSolo extends Game{ this.PtsToCoins=ptsToCoins; } - + //Get the map of the game with points millestone as the keys and coins as the values getSoloMap(){ return this.PtsToCoins; } + //Returns the gained depending on the number of points CoinsWithPoints(nbPoints:number){ let coins; for (let key of this.PtsToCoins.keys()){ diff --git a/bob_party/src/core/user.ts b/bob_party/src/core/user.ts index c4b6807..f2ce858 100644 --- a/bob_party/src/core/user.ts +++ b/bob_party/src/core/user.ts @@ -5,6 +5,7 @@ import { sign } from 'crypto'; export class User{ readonly Id: string; private Username: string; + private Password: string; private Nationality: string; private Sexe: string; private DateOfBirth: Date; @@ -16,10 +17,11 @@ export class User{ private TabConv?: Conversation[]; /* Consturctor of the class */ - constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, + constructor(id: string, username: string, password:string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ this.Id=id; this.Username=username; + this.Password=password; this.Nationality=nationality; this.Sexe=sexe; this.DateOfBirth=dateOfBirth; @@ -48,6 +50,14 @@ export class User{ return this.Id; } + getPassword(){ + return this.Password; + } + + setPassword(password:string){ + this.Password=password; + } + /* Brief : Function getting the current number of coins of an user */ getCurrentCoins(){ return this.CurrentCoins; @@ -158,4 +168,11 @@ export class User{ ajouterSkin(skin:Skin){ this.TabSkin.push(skin); } + + canConnect(username:string, mdp:string){ + if (this.Username==username){ + return this.Password==mdp; + } + return false; + } } \ No newline at end of file diff --git a/bob_party/src/navigation/AppNavigator.tsx b/bob_party/src/navigation/AppNavigator.tsx index 9d28d72..034b2ed 100644 --- a/bob_party/src/navigation/AppNavigator.tsx +++ b/bob_party/src/navigation/AppNavigator.tsx @@ -12,8 +12,6 @@ import SkinList from '../screens/SkinList' import GameChoice from '../screens/GameChoice' -import Test from '../screens/Test' - const HomeStack = createStackNavigator(); @@ -85,7 +83,6 @@ function MainTabNavigator() { - ) diff --git a/bob_party/src/screens/Chat.tsx b/bob_party/src/screens/Chat.tsx index a1305e9..01fa2ae 100644 --- a/bob_party/src/screens/Chat.tsx +++ b/bob_party/src/screens/Chat.tsx @@ -14,7 +14,7 @@ import tabSkinApp from '../constSkin'; import tabConv from '../constCov'; -const UserActu=new User("14", "leBg", "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); function Chat(props: { navigation: any; }) { const { navigation } = props diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index cebbc89..3db5d5b 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -1,7 +1,7 @@ import { StatusBar } from 'expo-status-bar' import { StyleSheet, View, Text, Alert, Pressable, Image} from 'react-native' import React from 'react'; -import { Game } from '../core/Game'; +import { Game } from '../core/game'; import { Skin } from '../core/skin'; import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; @@ -14,7 +14,7 @@ let tabConv:Conversation[]=[]; const msc = require('../../assets/Icons/FondGris.png'); -const UserActu=new User("14", "leBg", "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"); function GameChoice(props: { navigation: any; }) { const { navigation } = props diff --git a/bob_party/src/screens/Home.tsx b/bob_party/src/screens/Home.tsx index cfcf35f..73d774b 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -15,7 +15,7 @@ import { GameSolo } from '../core/gameSolo'; //const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", ); let tabConv:Conversation[]=[]; -const UserActu=new User("14", "leBg", "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); function Home(props: { navigation: any; }) { const { navigation } = props diff --git a/bob_party/src/screens/Profile.tsx b/bob_party/src/screens/Profile.tsx index 16c5e78..b073fd7 100644 --- a/bob_party/src/screens/Profile.tsx +++ b/bob_party/src/screens/Profile.tsx @@ -14,7 +14,7 @@ import { ScreenIndicator } from '../components/ScreenIndicator'; const coin = require('../../assets/Icons/Coin.png') -const UserActu=new User("14", "leBg", "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); function Profile(props: { navigation: any; }) { const { navigation } = props diff --git a/bob_party/src/screens/Test.tsx b/bob_party/src/screens/Test.tsx index f7c0311..d70c639 100644 --- a/bob_party/src/screens/Test.tsx +++ b/bob_party/src/screens/Test.tsx @@ -6,6 +6,7 @@ import { FlatList } from 'react-native-gesture-handler'; import { SkinComponent } from '../components/Skin'; import { Skin } from '../core/skin'; +/* const skinTest = new Skin("S0001","Bob",require('../../assets/BobsSkins/BobClassic.png')); const skinBleu = new Skin("S0001","Bob Bleu", require('../../assets/BobsSkins/BobBlue.png')) const skinBW = new Skin("S0001","Bob BW", require('../../assets/BobsSkins/BobBW.png')) @@ -35,4 +36,5 @@ function Test(props: { navigation: any; }) { ); } -export default Test \ No newline at end of file +export default Test +*/ \ No newline at end of file