;================================================================
; mahjong/mahjong_hand 麻将游戏 手牌算法相关
; shark_trick.erb 出千
;================================================================


;;;真·天地创造
;;;（The real Beginning of the Cosmos）
;;;- str hand_code 目标手牌代码
;;;- (option)int seat 目标座位（默认为玩家座位）
;;;@return 1成功 0失败
@MahjongCreateHand(hand_code, seat=-1)
    #DIMS hand_code
    #DIM seat
    #DIM DYNAMIC i
    SIF seat < 0 || seat >= MJ_PLAYER_COUNT
        seat = MJ_PLAYER_SEAT
    IF STRLENSU(hand_code) % 6 != 4 && STRLENSU(hand_code) % 6 != 2
        CALL PrintLog(@"天地创造失败！目标牌型「%hand_code%」数量({STRLENSU(hand_code) / 2})有误！", "warn")
        RETURN 0
    ENDIF
    FOR i, 0, VARSIZE("MJ_HAND", 1)
        MJ_HAND:seat:i = 999
    NEXT
    FOR i, 0, STRLENSU(hand_code), 2
        MJ_HAND:seat:(i / 2) = mj_code_to_value(SUBSTRINGU(hand_code, i, 2)) * 10
        SIF MJ_HAND:seat:(i / 2) % 100 == 0
            MJ_HAND:seat:(i / 2) += 54
    NEXT
    ;#; CALL PrintLog(@"真·天地创造！%MJ_ENUM_SEAT:seat%家的手牌变为「%mj_get_hand_code(seat)%」！", "warn")
    RETURN 1
