ADD: SaverMatchApi + persistance pour match
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
48dbae30d9
commit
0dd98f20f6
@ -1,11 +0,0 @@
|
||||
import { MANAGER_MATCH } from "../../../appManagers";
|
||||
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,26 @@
|
||||
import { MANAGER_MATCH } from "../../../appManagers";
|
||||
import { Game } from "../game";
|
||||
import { GameSolo } from "../gameSolo";
|
||||
import { User } from "../User/user";
|
||||
import { Match } from "./match";
|
||||
import MatchSolo from "./matchSolo";
|
||||
|
||||
export default class MatchModifier{
|
||||
|
||||
async createMatch(u:User, g:Game): Promise<Match>{
|
||||
if (g instanceof GameSolo){
|
||||
return new MatchSolo(0, false, [u], g);
|
||||
}
|
||||
return await MANAGER_MATCH.getsaverMatch().saveMatch(u, g);
|
||||
}
|
||||
|
||||
async quitMatch(u:User, m:Match): Promise<void>{
|
||||
const saver=MANAGER_MATCH.getsaverMatch();
|
||||
if (m.getTabUsers().length===1){
|
||||
saver.deleteMatch(m);
|
||||
}
|
||||
else{
|
||||
saver.deleteUserFromMatch(u);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue