Merge branch 'Persistance' of https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY into Persistance
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
commit
0730d1621f
@ -0,0 +1,221 @@
|
||||
import React, { Component, useEffect, useState } from 'react'
|
||||
import {
|
||||
StyleSheet,
|
||||
TouchableOpacity,
|
||||
Text,
|
||||
View,
|
||||
Pressable,
|
||||
Image,
|
||||
TouchableHighlight,
|
||||
Alert,
|
||||
} from 'react-native'
|
||||
import { MANAGER_USER } from '../../../App';
|
||||
import { useMatchStore } from '../../context/matchContext';
|
||||
import { useUserStore } from '../../context/userContext';
|
||||
import { Match } from '../../core/Match/match';
|
||||
import { User } from '../../core/User/user';
|
||||
|
||||
|
||||
function CookieClicker(props: { navigation: any}){
|
||||
const { navigation } = props
|
||||
|
||||
|
||||
|
||||
const GAMING_TIME=15;
|
||||
|
||||
const setUser = useUserStore((state) => state.setUser);
|
||||
|
||||
const resetMatch = useMatchStore((state) => state.resetMatch);
|
||||
|
||||
|
||||
const [count, setCount] = useState(0);
|
||||
const [money, setMoney] = useState(0);
|
||||
const [clickSpeed, setClickSpeed] = useState(1);
|
||||
const [grandmaCost, setGrandmaCost] = useState(10);
|
||||
const [farmCost, setFarmCost] = useState(250);
|
||||
const [factoryCost, setFactoryCost] = useState(2000);
|
||||
const [wizardCost, setWizardCost] = useState(25000);
|
||||
const [portalCost, setPortalCost] = useState(200000);
|
||||
|
||||
const [timer, setTimer] = useState(GAMING_TIME);
|
||||
|
||||
|
||||
function onPressCookie(){
|
||||
setMoney(money+clickSpeed);
|
||||
setCount(count+clickSpeed);
|
||||
}
|
||||
|
||||
function onPressGrandma(){
|
||||
if (money>=grandmaCost){
|
||||
setMoney(money-grandmaCost);
|
||||
setClickSpeed(clickSpeed+1);
|
||||
setGrandmaCost(grandmaCost+10);
|
||||
}
|
||||
}
|
||||
|
||||
function onPressFarm(){
|
||||
if (money>=farmCost){
|
||||
setMoney(money-farmCost);
|
||||
setClickSpeed(clickSpeed+25);
|
||||
setFarmCost(farmCost+250);
|
||||
}
|
||||
}
|
||||
|
||||
function onPressFactory(){
|
||||
if (money>=factoryCost){
|
||||
setMoney(money-factoryCost);
|
||||
setClickSpeed(clickSpeed+200);
|
||||
setFactoryCost(factoryCost+2000);
|
||||
}
|
||||
}
|
||||
|
||||
function onPressWizard(){
|
||||
if (money>=wizardCost){
|
||||
setMoney(money-wizardCost);
|
||||
setClickSpeed(clickSpeed+2500);
|
||||
setWizardCost(wizardCost+25000);
|
||||
}
|
||||
}
|
||||
|
||||
function onPressPortal(){
|
||||
if (money>=portalCost){
|
||||
setMoney(money-portalCost);
|
||||
setClickSpeed(clickSpeed+20000);
|
||||
setPortalCost(portalCost+200000);
|
||||
}
|
||||
}
|
||||
|
||||
function endGame(){
|
||||
let tmp: User | null;
|
||||
tmp=MANAGER_USER.getCurrentUser();
|
||||
if (tmp!=null){
|
||||
if (useMatchStore().match?.getTabUsers().includes(tmp)){
|
||||
useMatchStore().match?.updatePostMatch(tmp, count);
|
||||
setUser(tmp);
|
||||
}
|
||||
resetMatch();
|
||||
navigation.goBack();
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
let counter=GAMING_TIME;
|
||||
var oneSecInterval = setInterval(() => {
|
||||
setTimer(timer => timer - 1);
|
||||
counter --;
|
||||
|
||||
if (counter == 0) {
|
||||
clearInterval(oneSecInterval);
|
||||
Alert.alert("fin du jeu");
|
||||
endGame();
|
||||
}
|
||||
}, 1000);
|
||||
},[]);
|
||||
|
||||
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<View >
|
||||
<Text>
|
||||
Timer: {timer}
|
||||
</Text>
|
||||
<TouchableHighlight onPress={onPressCookie} >
|
||||
<Image style={styles.photo} source={{uri: 'https://cdn-icons-png.flaticon.com/512/614/614131.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<Text>
|
||||
Argent {money}
|
||||
</Text>
|
||||
<Text>
|
||||
Points {count}
|
||||
</Text>
|
||||
</View>
|
||||
<View style={styles.containerRight}>
|
||||
<TouchableHighlight onPress={onPressGrandma}>
|
||||
<Image style={styles.photo} source={{uri: 'https://www.pngall.com/wp-content/uploads/12/Grandma-Happy-PNG-Photo.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<View>
|
||||
<Text style={styles.cout}>
|
||||
Cost {grandmaCost}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<TouchableHighlight onPress={onPressFarm} style={styles.photo}>
|
||||
<Image style={styles.photo} source={{uri: 'https://www.pngall.com/wp-content/uploads/8/Farming-PNG-Picture.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<View>
|
||||
<Text style={styles.cout}>
|
||||
Cost {farmCost}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<TouchableHighlight onPress={onPressFactory}>
|
||||
<Image style={styles.photo} source={{uri: 'https://cdn.pixabay.com/photo/2018/04/16/09/12/factory-3323977_960_720.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<View>
|
||||
<Text style={styles.cout}>
|
||||
Cost {factoryCost}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<TouchableHighlight onPress={onPressWizard}>
|
||||
<Image style={styles.photo} source={{uri: 'https://www.clasher.us/images/coc/units/Wizard_Tower7.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<View>
|
||||
<Text style={styles.cout}>
|
||||
Cost {wizardCost}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
<TouchableHighlight onPress={onPressPortal}>
|
||||
<Image style={styles.photo} source={{uri: 'https://i.pinimg.com/originals/98/29/21/9829215db6f9210c0ae4e318e854cb1f.png'}}/>
|
||||
</TouchableHighlight>
|
||||
<View>
|
||||
<Text style={styles.cout}>
|
||||
Cost {portalCost}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
</View>
|
||||
</View>
|
||||
)
|
||||
}
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
container: {
|
||||
top: 20,
|
||||
margin: 10,
|
||||
flex: 1,
|
||||
justifyContent: 'center',
|
||||
alignItems: 'center',
|
||||
},
|
||||
containerRight: {
|
||||
flex: 1,
|
||||
flexWrap: "wrap",
|
||||
top: 100,
|
||||
marginBottom: 20,
|
||||
left: 100,
|
||||
},
|
||||
|
||||
button: {
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#DDDDDD',
|
||||
padding: 10,
|
||||
marginBottom: 10
|
||||
},
|
||||
button2: {
|
||||
alignItems: 'center',
|
||||
backgroundColor: '#FFDDFF',
|
||||
padding: 10,
|
||||
marginBottom: 10
|
||||
},
|
||||
photo: {
|
||||
width: 50,
|
||||
height: 50
|
||||
},
|
||||
cout: {
|
||||
marginBottom: 20
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
export default CookieClicker;
|
@ -0,0 +1,20 @@
|
||||
import React from "react";
|
||||
import create from "zustand";
|
||||
import { MANAGER_USER } from "../../App";
|
||||
import { Conversation } from "../core/conversation";
|
||||
|
||||
|
||||
// Define store types
|
||||
interface ConversationState {
|
||||
tabConv: Conversation[] | undefined;
|
||||
setTabConv: (tabConv: Conversation[]) => void;
|
||||
resetTabConv: () => void;
|
||||
}
|
||||
|
||||
// Define store data and methods
|
||||
export const useConversationStore = create<ConversationState>()((set, get) => ({
|
||||
tabConv: undefined,
|
||||
setTabConv: (tabConv) => set((state) => ({ tabConv: tabConv })),
|
||||
resetTabConv: () => set((state) => ({tabConv: undefined})),
|
||||
}));
|
||||
|
@ -0,0 +1,18 @@
|
||||
import React from "react";
|
||||
import create from "zustand";
|
||||
import { Match } from "../core/Match/match";
|
||||
|
||||
|
||||
// Define store types
|
||||
interface MatchState {
|
||||
match: Match | null;
|
||||
setMatch: (match: Match|null) => void;
|
||||
resetMatch: () => void;
|
||||
}
|
||||
|
||||
// Define store data and methods
|
||||
export const useMatchStore = create<MatchState>()((set, get) => ({
|
||||
match: null,
|
||||
setMatch: (match) => set((state) => ({ match: match })),
|
||||
resetMatch: () => set((state) => ({ match: null })),
|
||||
}));
|
@ -0,0 +1,22 @@
|
||||
import React from "react";
|
||||
import create from "zustand";
|
||||
import { MANAGER_USER } from "../../App";
|
||||
import tabSkinApp from "../constSkin";
|
||||
import { Skin } from "../core/Skin";
|
||||
import { User } from "../core/User/user";
|
||||
|
||||
|
||||
// Define store types
|
||||
interface StoreState {
|
||||
tabSkin: Skin[];
|
||||
setTabSkin: (tabSkin: Skin[]) => void;
|
||||
resetTabSkin: () => void;
|
||||
}
|
||||
|
||||
// Define store data and methods
|
||||
export const useStoreStore = create<StoreState>()((set, get) => ({
|
||||
tabSkin: tabSkinApp,
|
||||
setTabSkin: (tabSkin) => set((state) => ({ tabSkin: tabSkin })),
|
||||
resetTabSkin: () => set((state) => ({ tabSkin: tabSkinApp })),
|
||||
}));
|
||||
|
@ -1,17 +1,17 @@
|
||||
import { ImageSourcePropType } from 'react-native';
|
||||
import { Game } from './game';
|
||||
import { User } from "./User/user";
|
||||
import { Game } from '../game';
|
||||
import { User } from "../User/user";
|
||||
|
||||
|
||||
export abstract class Match{
|
||||
readonly code:string;
|
||||
private inGame:Boolean;
|
||||
readonly code:number;
|
||||
private inGame:Boolean=false;
|
||||
private tabUsers:User[];
|
||||
private theGame:Game;
|
||||
|
||||
constructor(code:string, inGame:Boolean, tabUser:User[], game:Game){
|
||||
constructor(code:number, inGame:Boolean, tabUser:User[], game:Game){
|
||||
this.code=code;
|
||||
this.inGame=false;
|
||||
this.inGame=inGame;
|
||||
this.tabUsers=[...tabUser];
|
||||
this.theGame=game;
|
||||
}
|
@ -1,12 +1,12 @@
|
||||
import { Match } from "./match";
|
||||
import { User } from "./User/user";
|
||||
import { Game } from "./game";
|
||||
import { GameCasino } from "./gameCasino";
|
||||
import { ManagerCoinsUser } from "./User/userCoinsModifier";
|
||||
import { User } from "../User/user";
|
||||
import { Game } from "../game";
|
||||
import { GameCasino } from "../gameCasino";
|
||||
import { ManagerCoinsUser } from "../User/userCoinsModifier";
|
||||
|
||||
export class MatchMulti extends Match{
|
||||
export default class MatchCasino extends Match{
|
||||
|
||||
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameCasino){
|
||||
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameCasino){
|
||||
super(code, inGame, tabUser, game);
|
||||
}
|
||||
|
@ -0,0 +1,12 @@
|
||||
import { MANAGER_MATCH } from "../../../App";
|
||||
import ManagerMatch from "../../services/matchServices/managerMatch";
|
||||
import { Game } from "../game";
|
||||
import { User } from "../User/user";
|
||||
import { Match } from "./match";
|
||||
|
||||
export default class MatchCreator{
|
||||
|
||||
async createMatch(u:User, g:Game): Promise<Match>{
|
||||
return await MANAGER_MATCH.getsaverMatch().saveMatch(u, g);
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { Match } from "./match";
|
||||
import { User } from "../User/user";
|
||||
import { Game } from "../game";
|
||||
import { GameMulti } from "../gameMulti";
|
||||
import { ManagerCoinsUser } from "../User/userCoinsModifier";
|
||||
|
||||
export default class MatchMulti extends Match{
|
||||
|
||||
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameMulti){
|
||||
super(code, inGame, tabUser, game);
|
||||
}
|
||||
|
||||
updatePostMatch(user:User, points: number): void {
|
||||
const manage= new ManagerCoinsUser();
|
||||
manage.addCoins(user, this.getGame().coinsCalculator(points));
|
||||
}
|
||||
}
|
@ -0,0 +1,17 @@
|
||||
import { Match } from "./match";
|
||||
import { GameSolo } from "../gameSolo";
|
||||
import { User } from "../User/user";
|
||||
import { Game } from "../game";
|
||||
import { ManagerCoinsUser } from "../User/userCoinsModifier";
|
||||
|
||||
export default class MatchSolo extends Match{
|
||||
|
||||
constructor(code:number, inGame:Boolean, tabUser:User[], game:GameSolo){
|
||||
super(code, inGame, tabUser, game);
|
||||
}
|
||||
|
||||
updatePostMatch(user:User, points: number): void {
|
||||
const manage= new ManagerCoinsUser();
|
||||
manage.addCoins(user, this.getGame().coinsCalculator(points));
|
||||
}
|
||||
}
|
@ -1,28 +1,14 @@
|
||||
import { User } from "./user";
|
||||
import tabSkinApp from "../../constSkin";
|
||||
import { Conversation } from "../conversation";
|
||||
import ManagerUser from "../../services/userServices/ManagerUser";
|
||||
import ManagerUser from "../../services/userServices/managerUser";
|
||||
import { MANAGER_USER } from "../../../App";
|
||||
|
||||
export class UserCreator{
|
||||
|
||||
async createUser(username:string, password:string, nationality:string, sexe:string, date:Date){
|
||||
//Récup l'ID d'après dans la bdd
|
||||
let u:User;
|
||||
let newId:string="";
|
||||
|
||||
let oldId = await MANAGER_USER.getLoaderUser().loadLastId();
|
||||
oldId=oldId.slice(1);
|
||||
let leInt=parseInt(oldId);
|
||||
newId+="U";
|
||||
for (let i = 0; i < 4-leInt.toString().length; i++) {
|
||||
newId = newId + "0";
|
||||
}
|
||||
leInt+=1;
|
||||
newId=newId+leInt;
|
||||
console.log(newId);
|
||||
u = new User(newId, username, password, nationality, sexe, date, 0, 0, 0, tabSkinApp[0], [tabSkinApp[0]]);
|
||||
await MANAGER_USER.getsaverUser().saveUser(u);
|
||||
let u:null|User = await MANAGER_USER.getsaverUser().saveUser(username, password, nationality, sexe, date);
|
||||
MANAGER_USER.setCurrentUser(u);
|
||||
return u;
|
||||
}
|
||||
|
@ -1,17 +0,0 @@
|
||||
import { Match } from "./match";
|
||||
import { User } from "./User/user";
|
||||
import { Game } from "./game";
|
||||
import { GameMulti } from "./gameMulti";
|
||||
import { ManagerCoinsUser } from "./User/userCoinsModifier";
|
||||
|
||||
export class MatchMulti extends Match{
|
||||
|
||||
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameMulti){
|
||||
super(code, inGame, tabUser, game);
|
||||
}
|
||||
|
||||
updatePostMatch(user:User, points: number): void {
|
||||
const manage= new ManagerCoinsUser();
|
||||
manage.addCoins(user, this.getGame().coinsCalculator(points));
|
||||
}
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
import { Match } from "./match";
|
||||
import { GameSolo } from "./gameSolo";
|
||||
import { User } from "./User/user";
|
||||
import { Game } from "./game";
|
||||
import { ManagerCoinsUser } from "./User/userCoinsModifier";
|
||||
|
||||
export class MatchSolo extends Match{
|
||||
|
||||
constructor(code:string, inGame:Boolean, tabUser:User[], game:GameSolo){
|
||||
super(code, inGame, tabUser, game);
|
||||
}
|
||||
|
||||
updatePostMatch(user:User, points: number): void {
|
||||
const manage= new ManagerCoinsUser();
|
||||
manage.addCoins(user, this.getGame().coinsCalculator(points));
|
||||
}
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
import { StatusBar } from 'expo-status-bar'
|
||||
import { View, Image} from 'react-native'
|
||||
import React from 'react';
|
||||
import stylesScreen from './style/screens.style'
|
||||
import { TopBar } from '../components/TopBar';
|
||||
import { BotBar } from '../components/BotBar';
|
||||
import { Conversation } from '../core/conversation';
|
||||
import { ButtonGameTypeChoice } from '../components/ButtonGameTypeChoice';
|
||||
import { MANAGER_MATCH } from '../../App';
|
||||
import { useMatchStore } from '../context/matchContext';
|
||||
|
||||
|
||||
function LobbySolo(props: { navigation: any; }) {
|
||||
|
||||
const { navigation } = props
|
||||
|
||||
const match = useMatchStore().match;
|
||||
|
||||
return (
|
||||
<View style={stylesScreen.container}>
|
||||
<TopBar
|
||||
nav={navigation}
|
||||
state='matchmacking'
|
||||
/>
|
||||
<View style={stylesScreen.bodyCenter}>
|
||||
<ButtonGameTypeChoice
|
||||
title='Lancer la partie'
|
||||
onPress={() => navigation.navigate(match?.getGame().getName().replace(/\s/g, ''))}
|
||||
/>
|
||||
</View>
|
||||
|
||||
<Image
|
||||
style={{width:100, height:100}}
|
||||
source={{uri: match?.getGame().getImageSource()}}
|
||||
/>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
export default LobbySolo
|
@ -0,0 +1,14 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import ISaverConversation from "./ISaverConversation";
|
||||
|
||||
export class FakeSaverConversation implements ISaverConversation{
|
||||
async saveConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
async deleteConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
async updateConversation(c: Conversation): Promise<void> {
|
||||
return;
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { Message } from "../../core/message";
|
||||
import { Skin } from "../../core/skin";
|
||||
import { User } from "../../core/User/user";
|
||||
import ILoaderConversation from "./ILoaderConversation";
|
||||
|
||||
export class LoaderConversationApi implements ILoaderConversation{
|
||||
|
||||
private axios = require('axios').default;
|
||||
|
||||
loadAllConversation(): Promise<Conversation[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
loadByID(id: string): Promise<Conversation | null> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async loadByUser(u: User): Promise<Conversation[]> {
|
||||
|
||||
let tabConv:Conversation[]=[];
|
||||
await this.axios({
|
||||
method: 'get',
|
||||
url: 'https://jsonplaceholder.typicode.com/todos/1',
|
||||
params: {
|
||||
name: "getConversationByUser",
|
||||
//Les params genre nom de la fonction en php
|
||||
}
|
||||
})
|
||||
.then(function (response: any) {
|
||||
let skin= new Skin(1, "Bob","https://codefirst.iut.uca.fr/git/BOB_PARTEAM/BOB_PARTY/raw/branch/typescript/bob_party/assets/BobsSkins/BobClassic.png", 0);
|
||||
tabConv=[new Conversation(1,
|
||||
[new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]),
|
||||
new User(3, "Fefe63", "jesuishm", "ouioui", "homme", new Date(2022,12,12), 12222, 123324, 12, skin, [skin])],
|
||||
[new Message(1, "bonjour", new User(1, "Alban", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,12)),
|
||||
new Message(2, "test", new User(2, "Fefe63", "oui", "ouioui", "homme", new Date(2022,12,12), 555, 667, 12, skin, [skin]), new Date(2022,12,13))], "leNom")];
|
||||
});
|
||||
return tabConv;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
import { Conversation } from "../../core/conversation";
|
||||
import { User } from "../../core/User/user";
|
||||
import ILoaderConversation from "./ILoaderConversation";
|
||||
import ISaverConversation from "./ISaverConversation";
|
||||
|
||||
export default class ManagerConversation{
|
||||
|
||||
private currentTabConv:Conversation[]=[];
|
||||
|
||||
private loaderConversation: ILoaderConversation;
|
||||
|
||||
private saverConversation: ISaverConversation;
|
||||
|
||||
constructor(loaderConversation:ILoaderConversation, saverConversation:ISaverConversation){
|
||||
this.loaderConversation=loaderConversation;
|
||||
this.saverConversation=saverConversation;
|
||||
}
|
||||
|
||||
getCurrentTabConv(){
|
||||
return this.currentTabConv;
|
||||
}
|
||||
|
||||
setCurrentTabConv(c:Conversation[]){
|
||||
this.currentTabConv=c;
|
||||
}
|
||||
|
||||
getLoaderConversation(){
|
||||
return this.loaderConversation;
|
||||
}
|
||||
|
||||
getsaverConversation(){
|
||||
return this.saverConversation;
|
||||
}
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
import { Match } from "../../core/Match/match";
|
||||
import ILoaderMatch from "./ILoaderMatch";
|
||||
|
||||
export default class LoaderMatchApi implements ILoaderMatch{
|
||||
|
||||
async loadAllMatch(): Promise<Match[]> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async loadByID(id: string): Promise<Match | null> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
import { Match } from "../../core/Match/Match";
|
||||
import ILoaderMatch from "./ILoaderMatch";
|
||||
import ISaverMatch from "./ISaverMatch";
|
||||
|
||||
export default class ManagerMatch{
|
||||
|
||||
private currentMatch: Match | null=null;
|
||||
|
||||
private loaderMatch: ILoaderMatch;
|
||||
|
||||
private saverMatch: ISaverMatch;
|
||||
|
||||
constructor(loader:ILoaderMatch, saver:ISaverMatch){
|
||||
this.loaderMatch=loader;
|
||||
this.saverMatch=saver;
|
||||
}
|
||||
|
||||
getCurrentMatch(){
|
||||
return this.currentMatch;
|
||||
}
|
||||
|
||||
setCurrentMatch(u:Match | null){
|
||||
this.currentMatch=u;
|
||||
}
|
||||
|
||||
getLoaderMatch(){
|
||||
return this.loaderMatch;
|
||||
}
|
||||
|
||||
setLoaderMatch(l:ILoaderMatch){
|
||||
this.loaderMatch=l;
|
||||
}
|
||||
|
||||
getsaverMatch(){
|
||||
return this.saverMatch;
|
||||
}
|
||||
|
||||
setsaverMatch(s:ISaverMatch){
|
||||
this.saverMatch=s;
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
import { Game } from "../../core/game";
|
||||
import { Match } from "../../core/Match/match";
|
||||
|
||||
import { User } from "../../core/User/user";
|
||||
import ISaverMatch from "./ISaverMatch";
|
||||
import { GameSolo } from "../../core/gameSolo";
|
||||
import { GameMulti } from "../../core/gameMulti";
|
||||
import MatchSolo from "../../core/Match/matchSolo";
|
||||
import MatchMulti from "../../core/Match/matchMulti";
|
||||
import MatchCasino from "../../core/Match/matchCasino";
|
||||
|
||||
export default class SaverMatchApi implements ISaverMatch{
|
||||
|
||||
async saveMatch(u:User, g:Game): Promise<Match> {
|
||||
//match = mettre dans bdd
|
||||
if (g instanceof GameSolo){
|
||||
return new MatchSolo(12, false, [u], g);
|
||||
}
|
||||
else if(g instanceof GameMulti){
|
||||
return new MatchMulti(12, false, [u], g);
|
||||
}
|
||||
return new MatchCasino(12, false, [u], g);
|
||||
|
||||
}
|
||||
async deleteMatch(m: Match): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
async updateMatch(m: Match): Promise<void> {
|
||||
throw new Error("Method not implemented.");
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue