tsgammon-core
Version:
A Backgammon library for Typescript, formerly developed as a part of tsgammon-ui
41 lines • 1.81 kB
TypeScript
import { DiceRoll } from '../Dices';
import { DiceSource } from '../utils/DiceSource';
import { SingleGameDispatcher } from './SingleGameDispatcher';
import { SingleGameListener } from './SingleGameListener';
import { SGOpening, SGToRoll } from './SingleGameState';
/**
* ロールが必要な処理を受け付けるListener: これは、ダイスロールを非同期的に行うために設けられている
*/
export interface RollListener {
onRollRequest: (rollReq: (dices: DiceRoll) => void) => void;
}
/**
* ダイスロールを要求するタスクの定義
*/
export declare type RollReqs = {
reqs: ((dices: DiceRoll) => void)[];
};
/**
* 設定情報からRollListenerオブジェクトを生成する
* @param conf RollReqを受け付ける関数、または単純にロール目を生成するDiceSourceオブジェクトを指定する
* @returns
*/
export declare function rollListener(conf?: {
onRollRequest?: (rollReq: (dices: DiceRoll) => void) => void;
diceSource?: DiceSource;
}): RollListener;
/**
* SingleGameDispatcherを、ロール目を意識しない形に読み替えた形
*/
export declare type SingleGameDispatcherWithRL = Omit<SingleGameDispatcher, 'doRoll' | 'doOpeningRoll'> & {
doRoll: (state: SGToRoll) => (listener: Pick<SingleGameListener, 'onCheckerPlayStarted'>) => void;
doOpeningRoll: (state: SGOpening) => (listener: Pick<SingleGameListener, 'onOpeningCheckerPlayStarted' | 'onRerollOpening'>) => void;
};
/**
* SingleGameDispatcherをロール目を意識しない形に読み替える
* @param singleGameDispatcher
* @param rollListener
* @returns
*/
export declare function withRL(singleGameDispatcher: SingleGameDispatcher, rollListener: RollListener): SingleGameDispatcherWithRL;
//# sourceMappingURL=RollDispatcher.d.ts.map