-Class GameMulti
-Class GameCasino
stub-api
Thomas Chazot 3 years ago
parent 3422518fd8
commit 0eb056ab03

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

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

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

@ -0,0 +1,28 @@
import { ImageSourcePropType } from 'react-native';
import { Game } from './game'
export class GameMulti extends Game{
readonly RankToCoins:Map<number,number>
constructor(name:string, imageSource:ImageSourcePropType, gameSource:string, rankToCoins:Map<number,number>){
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;
}
}

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

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

@ -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() {
<Tab.Screen name='StoreTab' component={StoreStackScreen} />
<Tab.Screen name='ChatTab' component={ChatStackScreen} />
<Tab.Screen name='ProfileTab' component={ProfileStackScreen} />
<Tab.Screen name='Test' component={Test} />
</Tab.Navigator>
</NavigationContainer>
)

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

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

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

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

@ -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
export default Test
*/
Loading…
Cancel
Save