Untitled
unknown
typescript
2 years ago
2.4 kB
5
Indexable
import { FreeBet, FreeBetPrimitives, FreeBetProps, FreeBetStates, FreeBetTypeProps, } from '@lionline/games/free-bet/domain'; import { NaturalNumber, Amount, NonEmptyString, Id } from '@lionline/shared-kernel/domain'; import { TripleXFreeBet } from './triple-x-free-bet.value-object'; interface TripleXFreeBetRoundTypeProps extends FreeBetTypeProps { name: NonEmptyString<'round'>; config: { roundsToPlay: NaturalNumber }; } interface TripleXFreeBetRoundTypePrimitives { name: 'round'; config: { roundsToPlay: number }; } export class TripleXFreeBetRound extends TripleXFreeBet<TripleXFreeBetRoundTypeProps> { incrementRound( numberOfRounds?: NaturalNumber | undefined, ): FreeBet<TripleXFreeBetRoundTypeProps> { return this.clone({ actualRound: this.props.actualRound.sum(numberOfRounds ?? 1), }); } incrementWinAmount(amount: Amount): FreeBet<TripleXFreeBetRoundTypeProps> { return this.clone({ winAmount: this.props.winAmount.sum(amount), }); } static fromPrimitives(props: FreeBetPrimitives<TripleXFreeBetRoundTypePrimitives>) { return new TripleXFreeBetRound({ id: new Id({ id: props.id }), actualRound: new NaturalNumber({ value: props.actualRound }), betValue: new Amount({ value: props.betValue }), dueDate: props.dueDate, offerId: new Id({ id: props.offerId }), state: new FreeBetStates({ state: props.state }), type: { name: new NonEmptyString({ value: props.type.name }), config: { roundsToPlay: new NaturalNumber({ value: props.type.config.roundsToPlay }) }, }, winAmount: new Amount({ value: props.winAmount }), }); } toPrimitives(): FreeBetPrimitives<TripleXFreeBetRoundTypePrimitives> { return { id: this.props.id.toPrimitives(), actualRound: this.props.actualRound.toPrimitives(), betValue: this.props.betValue.toPrimitives(), dueDate: this.props.dueDate, offerId: this.props.offerId.toPrimitives(), state: this.props.state.toPrimitives(), type: { name: this.props.type.name.toPrimitives(), config: { roundsToPlay: this.props.type.config.roundsToPlay.toPrimitives() }, }, winAmount: this.props.winAmount.toPrimitives(), }; } private clone(props: Partial<FreeBetProps<TripleXFreeBetRoundTypeProps>>) { return new TripleXFreeBetRound({ ...this.props, ...props, }); } }
Editor is loading...