Skip to content

Commit

Permalink
feat: ダイスロール機能の実装
Browse files Browse the repository at this point in the history
  • Loading branch information
raiga0310 committed Sep 18, 2022
1 parent 6da27eb commit 6d98596
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/adaptor/dice-queen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { DiceQueen } from '../service/command/dice.js';

export interface RandomGenerator {
uniform(from: number, to: number): number;
}

export class GenDiceQueen implements DiceQueen {
constructor(private readonly rng: RandomGenerator) {}

roll(faces: number, HowManyRoll: number): Array<number> {
const diceLog: number[] = [];
for (let i = 0; i < HowManyRoll; ++i) {
diceLog.push(this.rng.uniform(1, faces));
}

return diceLog;
}
}

0 comments on commit 6d98596

Please sign in to comment.