當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript battlemovr.IOnChoice類代碼示例

本文整理匯總了TypeScript中battlemovr.IOnChoice的典型用法代碼示例。如果您正苦於以下問題:TypeScript IOnChoice類的具體用法?TypeScript IOnChoice怎麽用?TypeScript IOnChoice使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了IOnChoice類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: nextAction

    /**
     * Determines the next action to take.
     *
     * @param battleInfo   State for an ongoing battle.
     * @param onChoice   Callback for when an action is chosen.
     * @see http://wiki.pokemonspeedruns.com/index.php/Pok%C3%A9mon_Red/Blue/Yellow_Trainer_AI
     * @todo Items?
     */
    public nextAction(battleInfo: IBattleInfo, team: Team, onChoice: IOnChoice): void {
        const attackingTeam: IBattleTeam = battleInfo.teams[Team[team]];
        const defendingTeam: IBattleTeam = team === Team.opponent
            ? battleInfo.teams.player
            : battleInfo.teams.opponent;
        const attackingActor: IPokemon = battleInfo.teams[Team[team]].selectedActor;

        // Wild Pokemon just choose randomly
        if (!attackingTeam.leader) {
            onChoice({
                move: this.eightBitter.numberMaker.randomArrayMember(attackingActor.moves).title,
                type: "move",
            });

            return;
        }

        let possibilities: IMovePossibility[] = this.movePriorityGenerator.generate(attackingTeam, defendingTeam, attackingActor.moves);

        // The AI uses rejection sampling on the four moves with ratio 63:64:63:66,
        // with only the moves that are most favored after applying the modifications being acceptable.
        let lowest: number = possibilities[0].priority;
        if (possibilities.length > 1) {
            for (const possibility of possibilities) {
                if (possibility.priority < lowest) {
                    lowest = possibility.priority;
                }
            }

            possibilities = possibilities.filter((possibility: IMovePossibility): boolean =>
                possibility.priority === lowest);
        }

        onChoice({
            move: this.eightBitter.numberMaker.randomArrayMember(possibilities).move,
            type: "move",
        });
    }
開發者ID:FullScreenShenanigans,項目名稱:FullScreenPokemon,代碼行數:46,代碼來源:OpponentSelector.ts

示例2: attemptToFlee

 /**
  * Chooses to attempt to flee the battle.
  */
 private attemptToFlee(onChoice: IOnChoice): void {
     onChoice({
         type: "flee",
     });
 }
開發者ID:FullScreenShenanigans,項目名稱:FullScreenPokemon,代碼行數:8,代碼來源:PlayerSelector.ts

示例3: onChoice

 onUse: (listing: IInventoryListing): void => {
     onChoice({
         item: listing.item,
         type: "item",
     });
 },
開發者ID:FullScreenShenanigans,項目名稱:FullScreenPokemon,代碼行數:6,代碼來源:PlayerSelector.ts

示例4: onChoice

 (): void => {
     onChoice({
         newActor: pokemon,
         type: "switch",
     });
 });
開發者ID:FullScreenShenanigans,項目名稱:FullScreenPokemon,代碼行數:6,代碼來源:Switching.ts


注:本文中的battlemovr.IOnChoice類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。