-Class match
stub-api
Thomas Chazot 3 years ago
parent 0adc05c2f7
commit dec83bf0c3

@ -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 (

@ -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