当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript factory.define方法代码示例

本文整理汇总了TypeScript中factory-girl.factory.define方法的典型用法代码示例。如果您正苦于以下问题:TypeScript factory.define方法的具体用法?TypeScript factory.define怎么用?TypeScript factory.define使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在factory-girl.factory的用法示例。


在下文中一共展示了factory.define方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: createPiece

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊♜⚊⚊⚊
    ⚊⚊♜⚊⚊⚊⚊⚊
*/
factory.define("board-rook-movement", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("e2", PieceType.Rook, PieceColor.White, true, model),
            createPiece("c1", PieceType.Rook, PieceColor.White, true, model),
        ];

        return model;
    },
});

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊♖⚊⚊⚊
    ⚊⚊⚊⚊♖⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊♜⚊⚊⚊
    ⚊⚊⚊⚊♜⚊⚊⚊
*/
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:RookFactory.ts

示例2: createPiece

/*  Board Description
    ⚊⚊⚊⚊⚊♚⚊⚊
    ⚊⚊⚊⚊⚊♟⚊⚊
    ⚊⚊⚊⚊♗♔⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
*/
factory.define("board-stalemate-1", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("f8", PieceType.King, PieceColor.Black, true, model),
            createPiece("f7", PieceType.Pawn, PieceColor.Black, false, model),
            createPiece("e6", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("f6", PieceType.King, PieceColor.White, true, model),
        ]

        return model
    },
})

/*  Board Description
    ⚊♝⚊⚊⚊⚊⚊♖
    ♚⚊⚊⚊⚊⚊⚊⚊
    ⚊♔⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:32,代码来源:StalemateFactory.ts

示例3: createPiece

import { factory } from "factory-girl"
import BoardBase from "../../src/common/BoardBase"
import { PieceColor, PieceType } from "../../src/common/GamePieces"
import { createPiece, stringToPosition } from "./BoardHelper"

// king vs king
factory.define("board-draw-notenoughpieces-1", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("e7", PieceType.King, PieceColor.Black, true, model),
            createPiece("e2", PieceType.King, PieceColor.White, true, model),
            createPiece("e3", PieceType.Pawn, PieceColor.Black, true, model),
        ]

        return model
    },
})

// King + bishop vs King + bishop on the same color
factory.define("board-draw-notenoughpieces-2", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("e7", PieceType.King, PieceColor.Black, true, model),
            createPiece("e2", PieceType.King, PieceColor.White, true, model),
            createPiece("c2", PieceType.Bishop, PieceColor.White, true, model),
            createPiece("f7", PieceType.Bishop, PieceColor.Black, true, model),
            createPiece("e3", PieceType.Pawn, PieceColor.Black, true, model),
        ]

        return model
    },
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:DrawFactory.ts

示例4: createPiece

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊♜⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊♔⚊⚊⚊⚊⚊
*/
factory.define("board-check", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("b3", PieceType.Rook, PieceColor.Black, false, model),
            createPiece("c1", PieceType.King, PieceColor.White, false, model),
        ]

        return model
    },
})

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊♞⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ♖⚊♜♔⚊⚊⚊⚊
*/
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:CheckFactory.ts

示例5: createPiece

    ⚊⚊⚊⚊⚊⚊♙⚊
    ⚊⚊⚊⚊⚊♙⚊⚊
    ♙♙♙♙♙⚊⚊♙
    ⚊⚊⚊♕♔♗⚊⚊
*/
factory.define("board-foolsmate", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("a2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("b2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("c2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("d2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("e2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("f3", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("g4", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("h2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("d1", PieceType.Queen, PieceColor.White, false, model),
            createPiece("e1", PieceType.King, PieceColor.White, false, model),
            createPiece("f1", PieceType.Bishop, PieceColor.White, false, model),

            createPiece("d8", PieceType.Queen, PieceColor.Black, true, model),
        ]

        return model
    },
})

/*  Board Description
    ⚊♕⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊♟♚⚊
    ⚊⚊♟⚊⚊⚊♟⚊
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:CheckmateFactory.ts

示例6: createPiece

    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊♕♗⚊⚊⚊
    ♖⚊⚊⚊♔⚊⚊♖
*/
factory.define("board-castling", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("a1", PieceType.Rook, PieceColor.White, false, model),
            createPiece("d2", PieceType.Queen, PieceColor.White, false, model),
            createPiece("e1", PieceType.King, PieceColor.White, false, model),
            createPiece("e2", PieceType.Bishop, PieceColor.White, false, model),
            createPiece("h1", PieceType.Rook, PieceColor.White, false, model),
        ];

        return model;
    },
});

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ♜⚊⚊⚊⚊⚊⚊⚊
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:CastlingFactory.ts

示例7: createPiece

import { factory } from "factory-girl";
import BoardBase from "../../src/common/BoardBase";
import { PieceColor, PieceType } from "../../src/common/GamePieces"
import { createPiece } from "./BoardHelper"

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ♙⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊♙⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊♟⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
*/
factory.define("board-enpassant", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("c2", PieceType.Pawn, PieceColor.White, false, model),
            createPiece("d4", PieceType.Pawn, PieceColor.Black, true, model),
            createPiece("a7", PieceType.Pawn, PieceColor.Black, false, model),
        ];

        return model;
    },
});

export default factory;
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:28,代码来源:EnPassantFactory.ts

示例8: createPiece

    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊♙⚊⚊
    ♖♘♗♕♔⚊⚊
*/
factory.define("board-an-movement", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("a1", PieceType.Rook, PieceColor.White, false, model),
            createPiece("b1", PieceType.Knight, PieceColor.White, false, model),
            createPiece("c1", PieceType.Bishop, PieceColor.White, false, model),
            createPiece("d1", PieceType.Queen, PieceColor.White, false, model),
            createPiece("e1", PieceType.King, PieceColor.White, false, model),
            createPiece("f2", PieceType.Pawn, PieceColor.White, false, model),
        ]

        return model
    },
})

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊♟⚊⚊⚊⚊⚊⚊
    ♟⚊⚊⚊⚊⚊⚊⚊
    ♟⚊⚊⚊⚊⚊⚊⚊
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:32,代码来源:AlgebraicNotationFactory.ts

示例9: createPiece

import { factory } from "factory-girl";
import BoardBase from "../../src/common/BoardBase";
import { PieceColor, PieceType } from "../../src/common/GamePieces"
import { createPiece } from "./BoardHelper"

factory.define("board", BoardBase, {});

/*  Board Description
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊♙♟♟⚊⚊⚊
    ⚊⚊⚊♙♙♟⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
*/
factory.define("board-pawn-capture", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("c5", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("d5", PieceType.Pawn, PieceColor.Black, true, model),
            createPiece("e5", PieceType.Pawn, PieceColor.Black, true, model),
            createPiece("d4", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("e4", PieceType.Pawn, PieceColor.White, true, model),
            createPiece("f4", PieceType.Pawn, PieceColor.Black, true, model),
        ];

        return model;
    },
});
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:31,代码来源:PawnFactory.ts

示例10: createPiece

/*  Board Description ♔♚
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊♔⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
*/
factory.define("board-king-movement", BoardBase, {}, {
    afterBuild: (model, attrs, buildOptions) => {
        model.pieces = [
            createPiece("c2", PieceType.King, PieceColor.White, true, model),
        ];

        return model;
    },
});

/*  Board Description ♔♚ ♟♙
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊⚊⚊⚊⚊⚊⚊⚊
    ⚊♟⚊⚊⚊⚊⚊⚊
    ⚊♟♔⚊⚊⚊⚊⚊
    ⚊⚊♙⚊⚊⚊⚊⚊
*/
开发者ID:Majavapaja,项目名称:Mursushakki,代码行数:30,代码来源:KingFactory.ts


注:本文中的factory-girl.factory.define方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。