# Debug 用測試碼 ```javascript= function showCardIndex(): void { let template: any[][] = []; template["♠"] = []; // ♠ template["♥"] = []; // ♥ template["♦"] = []; // ♦ template["♣"] = []; // ♣ for (let i = 1; i <= 13; ++i) template["♠"].push(i); for (let i = 1; i <= 13; ++i) template["♥"].push(13 + i); for (let i = 1; i <= 13; ++i) template["♣"].push(13 * 2 + i); for (let i = 1; i <= 13; ++i) template["♦"].push(13 * 3 + i); // 使用方式 let player1 = ("♣K ♠J ♠10 ♥10 ♦10 ♥9 ♠9 ♥8 ♦8 ♠8 ♣8 ♥7 ♣6 ♥4 ♥3 ♠3").split(" "); let player2 = ("♣A ♥A ♥K ♠K ♦K ♦Q ♥J ♣J ♣9 ♦9 ♠7 ♥5 ♠5 ♠4 ♦4 ♣4").split(" "); let player3 = ("♠2 ♦A ♥Q ♣Q ♠Q ♦J ♣10 ♦7 ♣7 ♦6 ♠6 ♥6 ♣5 ♦5 ♦3 ♣3").split(" "); console.log(converter(player1, template)); console.log(converter(player2, template)); console.log(converter(player3, template)); } function converter(input: string[], template: any[][]): string { let result = input.map(card => { let list = template[card[0]]; let value = 0; if (card.slice(1) == "J") value = 10; else if (card.slice(1) == "Q") value = 11; else if (card.slice(1) == "K") value = 12; else if (card.slice(1) == "A") value = 13; else value = parseInt(card.slice(1)) - 1; return list[value - 1]; }); return `[${result.join(",")}]`; } showCardIndex(); ``` ###### tags: `遊戲筆記`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up