stub-api
Alban GUILHOT 3 years ago
commit 9a6dfd4809

@ -4,8 +4,8 @@ import tabSkinApp from './constSkin'
import { User } from "./core/user"; 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 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, 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[]=[ let tabMessageTest:Message[]=[
new Message("Salut", UserActu, new Date(2022,12,12)), new Message("Salut", UserActu, new Date(2022,12,12)),

@ -2,9 +2,26 @@ import { ImageSourcePropType } from 'react-native';
import { Game } from './game' import { Game } from './game'
export class GameSolo extends Game{ export class GameSolo extends Game{
readonly [Index:number]:number; readonly PtsToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, [index:number]:number){ constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, ptsToCoins:Map<number,number>){
super(name, imageSource, gameSource); 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<key ){
return coins;
}
}
return coins;
} }
} }

@ -1,26 +1,29 @@
import { Skin } from './Skin' import { Skin } from './Skin'
import { Conversation } from './conversation'; import { Conversation } from './conversation';
import { sign } from 'crypto';
export class User{ export class User{
private Id: string; readonly Id: string;
private Username: string; private Username: string;
private Nationality: string; private Nationality: string;
private Sexe: string; private Sexe: string;
private DateOfBirth: Date; private DateOfBirth: Date;
private CurrentCoins: number; private CurrentCoins: number;
private TotalCoins: number; private TotalCoins: number;
private NbGamePlayed: number;
private CurrentSkin: Skin; private CurrentSkin: Skin;
private TabSkin: Skin[]; private TabSkin: Skin[];
private TabConv?: Conversation[]; private TabConv?: Conversation[];
/* Consturctor of the class */ /* Consturctor of the class */
constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number, constructor(id: string, username: string, nationality: string, sexe: string, dateOfBirth: Date, currentCoins: number, totalCoins: number,
currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){ nbGamePlayed:number, currentSkin: Skin, tabSkin: Skin[], tabConv?: Conversation[] ){
this.Id=id; this.Id=id;
this.Username=username; this.Username=username;
this.Nationality=nationality; this.Nationality=nationality;
this.Sexe=sexe; this.Sexe=sexe;
this.DateOfBirth=dateOfBirth; this.DateOfBirth=dateOfBirth;
this.NbGamePlayed=nbGamePlayed;
this.CurrentCoins=currentCoins; this.CurrentCoins=currentCoins;
this.TotalCoins=totalCoins; this.TotalCoins=totalCoins;
this.CurrentSkin=currentSkin; this.CurrentSkin=currentSkin;
@ -45,11 +48,6 @@ export class User{
return this.Id; 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 */ /* Brief : Function getting the current number of coins of an user */
getCurrentCoins(){ getCurrentCoins(){
return this.CurrentCoins; return this.CurrentCoins;
@ -100,7 +98,20 @@ export class User{
this.TotalCoins=totalCoins; this.TotalCoins=totalCoins;
} }
/* 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 */ /* Brief : Function getting the current skin of an user */
getCurrentSkin(){ getCurrentSkin(){
return this.CurrentSkin; return this.CurrentSkin;
} }
@ -131,4 +142,20 @@ export class User{
this.TabConv?.push(conv); 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);
}
} }

@ -14,7 +14,7 @@ let tabConv:Conversation[]=[];
const msc = require('../../assets/Icons/FondGris.png'); 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"); const jeuTest= new Game("SNAKE", require('../../assets/Icons/UnSelected/Gamepad.png'),"ouin");
function GameChoice(props: { navigation: any; }) { function GameChoice(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props

@ -8,8 +8,6 @@ import { TopBar } from '../components/TopBar';
import { BotBar } from '../components/BotBar'; import { BotBar } from '../components/BotBar';
import { Conversation } from '../core/conversation'; import { Conversation } from '../core/conversation';
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice'; import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
import tabSkinApp from '../constSkin'; import tabSkinApp from '../constSkin';
import { GameSolo } from '../core/gameSolo'; 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", ); //const test= new GameSolo("test", require('bob_party/assets/ImagesJeux/BatailleNavale.jpeg'), "test", );
let tabConv:Conversation[]=[]; 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; }) { function Home(props: { navigation: any; }) {
const { navigation } = props const { navigation } = props

@ -0,0 +1,12 @@
import { GameSolo } from "./core/gameSolo";
let myMap = new Map<number, number>([
[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;
Loading…
Cancel
Save