• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript factory-girl.factory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了factory类的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类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript faker.address类代码示例发布时间:2022-05-25
下一篇:
TypeScript factories.createUser函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap