diff --git a/bob_party/src/constCov.ts b/bob_party/src/constCov.ts index f139f22..0321cd9 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, tabSkinApp[0], tabSkinApp, undefined); -let UserTest:User=new User("48", "Wesh Wesh", "ouioui", "grand", new Date(2022,12,12), 12222, 123324, tabSkinApp[0], tabSkinApp, undefined); +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[0], tabSkinApp, undefined); let tabMessageTest:Message[]=[ new Message("Salut", UserActu, new Date(2022,12,12)), diff --git a/bob_party/src/core/gameSolo.ts b/bob_party/src/core/gameSolo.ts index 9b1b59d..9403bd4 100644 --- a/bob_party/src/core/gameSolo.ts +++ b/bob_party/src/core/gameSolo.ts @@ -2,9 +2,26 @@ import { ImageSourcePropType } from 'react-native'; import { Game } from './game' export class GameSolo extends Game{ - readonly [Index:number]:number; + readonly PtsToCoins:Map - constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, [index:number]:number){ + constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, ptsToCoins:Map){ super(name, imageSource, gameSource); + this.PtsToCoins=ptsToCoins; + } + + + getSoloMap(){ + return this.PtsToCoins; + } + + CoinsWithPoints(nbPoints:number){ + let coins; + for (let key of this.PtsToCoins.keys()){ + coins = this.PtsToCoins.get(key); + if (nbPoints { - this.TabConv?.push(conv); - }); - } + nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ + this.Id=id; + this.Username=username; + this.Nationality=nationality; + this.Sexe=sexe; + this.DateOfBirth=dateOfBirth; + this.NbGamePlayed=nbGamePlayed; + this.CurrentCoins=currentCoins; + this.TotalCoins=totalCoins; + this.CurrentSkin=currentSkin; + this.TabSkin=[...tabSkin]; + tabConv?.forEach(conv => { + this.TabConv?.push(conv); + }); + } /* Brief : Function getting the name of an user */ getUsername(){ @@ -44,11 +47,6 @@ export class User{ getId(){ return this.Id; } - - /* Brief : Function setting the id of an user */ - setId(id: string){ - this.Id=id; - } /* Brief : Function getting the current number of coins of an user */ getCurrentCoins(){ @@ -100,7 +98,20 @@ export class User{ this.TotalCoins=totalCoins; } - /* Brief : Function getting the current skin of an user */ + /* Brief : Function getting the current number of game played by an user */ + + getGamePlayed(){ + return this.NbGamePlayed; + } + + /* Brief : Function setting the current number of game played by an user */ + + setGamePlayed(nb: number){ + this.NbGamePlayed=nb; + } + + /* Brief : Function getting the current skin of an user */ + getCurrentSkin(){ return this.CurrentSkin; } @@ -131,4 +142,20 @@ export class User{ this.TabConv?.push(conv); }); } + + + changeUserCoins(coin:number){ + this.CurrentCoins+=coin; + if (coin>0){ + this.TotalCoins+=coin; + } + } + + changerCurrentSkin(skin:Skin){ + this.CurrentSkin=skin; + } + + ajouterSkin(skin:Skin){ + this.TabSkin.push(skin); + } } \ No newline at end of file diff --git a/bob_party/src/screens/GameChoice.tsx b/bob_party/src/screens/GameChoice.tsx index c560e50..cebbc89 100644 --- a/bob_party/src/screens/GameChoice.tsx +++ b/bob_party/src/screens/GameChoice.tsx @@ -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, tabSkinApp[0], tabSkinApp, tabConv); +const UserActu=new User("14", "leBg", "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 4e6bc7e..cfcf35f 100644 --- a/bob_party/src/screens/Home.tsx +++ b/bob_party/src/screens/Home.tsx @@ -8,8 +8,6 @@ import { TopBar } from '../components/TopBar'; import { BotBar } from '../components/BotBar'; import { Conversation } from '../core/conversation'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; - - import tabSkinApp from '../constSkin'; import { GameSolo } from '../core/gameSolo'; @@ -17,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, tabSkinApp[0], tabSkinApp, tabConv); +const UserActu=new User("14", "leBg", "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/testGameSolo.ts b/bob_party/src/testGameSolo.ts new file mode 100644 index 0000000..f1c8f3d --- /dev/null +++ b/bob_party/src/testGameSolo.ts @@ -0,0 +1,12 @@ +import { GameSolo } from "./core/gameSolo"; + +let myMap = new Map([ + [50, 3], + [75, 4], + [100, 5], + [150, 6] +]); + +let game=new GameSolo("bo jeu", require('bob_party/assets/ImagesJeux/blackjack.jpg'), "super jeu", myMap); + +export default game; \ No newline at end of file