Skip to content
Extraits de code Groupes Projets
Vérifiée Valider d150c7e2 rédigé par ‮'s avatar :moyai:
Parcourir les fichiers

KISS2

parent b34f7152
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Pipeline #1067 en échec
......@@ -89,26 +89,12 @@ export const joinGame = new ValidatedMethod<{ _id: string }, void>({
}
})
export const nextCards = new ValidatedMethod<{}, void>({
name: 'Game.nextCards',
mixins: [schemaMixin, loggedInMixin, inGameMixin],
validate: new SimpleSchema({}),
run () {
callSystem(this, this.game.sys.nextCards)
}
})
export const nextCards = newGameMethod('nextCards')
export const giveCards = new ValidatedMethod<{ cards: Card[] }, void>({
name: 'Game.giveCards',
mixins: [schemaMixin, loggedInMixin, inGameMixin],
validate: new SimpleSchema({
export const giveCards = newGameMethod('giveCards', new SimpleSchema({
cards: {type: Array, minCount: 3, maxCount: 3},
'cards.$': Card
}),
run ({cards}) {
callSystem(this, this.game.sys.giveCards, cards)
}
})
}), 'cards')
export const playCards = new ValidatedMethod({
name: 'Game.playCards',
......@@ -135,38 +121,17 @@ export const playCards = new ValidatedMethod({
}
})
export const skipTurn = new ValidatedMethod<{}, void>({
name: 'Game.skipTurn',
mixins: [schemaMixin, loggedInMixin, inGameMixin],
validate: new SimpleSchema({}),
run () {
callSystem(this, this.game.sys.skipTurn)
}
})
export const skipTurn = newGameMethod('skipTurn')
export const giveDragon = new ValidatedMethod<{ to: number }, void>({
name: 'game.giveDragon',
mixins: [schemaMixin, loggedInMixin, inGameMixin],
validate: new SimpleSchema({
export const giveDragon = newGameMethod('giveDragon', new SimpleSchema({
to: {type: Number, allowedValues: [0, 1]}
}),
run ({to}) {
callSystem(this, this.game.sys.giveDragon, to)
}
})
}), 'to')
export const makeCall = new ValidatedMethod<{ bet: number }, void>({
name: 'Game.makeCall',
mixins: [schemaMixin, loggedInMixin, inGameMixin],
validate: new SimpleSchema({
export const makeCall = newGameMethod('makeCall', new SimpleSchema({
bet: {type: Number, allowedValues: [Bet.TICHU, Bet.GRAND]}
}),
run ({bet}) {
callSystem(this, this.game.sys.makeCall, bet)
}
})
}), 'bet')
function newGameMethod (name: string, schema: SimpleSchema, argName?: string): ValidatedMethod<any, void> {
function newGameMethod (name: string, schema: SimpleSchema = new SimpleSchema({}), argName?: string): ValidatedMethod<any, void> {
return new ValidatedMethod<any, void>({
name: 'Game.' + name,
mixins: [schemaMixin, loggedInMixin, inGameMixin],
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter