Add: Match Services
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
parent
570ade854a
commit
8e1b296011
@ -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 createMatchSolo(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,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,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