{"id":774,"date":"2024-10-24T16:41:23","date_gmt":"2024-10-24T07:41:23","guid":{"rendered":"https:\/\/xcode15.shimayugu.jp\/?p=774"},"modified":"2024-12-29T07:36:30","modified_gmt":"2024-12-28T22:36:30","slug":"%e6%96%b0swift%e3%81%a7%e8%a1%8c%e3%81%93%e3%81%86%e7%ac%ac%ef%bc%97%ef%bc%96%e5%9b%9e%e3%80%8c%e3%83%9d%e3%83%bc%e3%82%ab%e3%83%bc%ef%bc%91%ef%bc%94%e8%a7%a3%e8%aa%ac%e3%80%8d%e3%80%80","status":"publish","type":"post","link":"https:\/\/xcode15.shimayugu.jp\/?p=774","title":{"rendered":"\u65b0Swift\u3067\u884c\u3053\u3046\u2026\u7b2c\uff17\uff16\u56de\u300c\u30dd\u30fc\u30ab\u30fc\uff11\uff14\u89e3\u8aac\u300d\u3000\u7530\u90e8\u4e95\u4fdd"},"content":{"rendered":"\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=301\">\u901a\u5e38\u7248<\/a><\/p>\n\n\n\n<p>\u3000yaku\u95a2\u6570\u3067\u3001\u5f97\u70b9\u306e\u4ed6\u306b\u5f79\u540d\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism line-numbers lang-swift\" data-lang=\"Swift\" data-line=\"2,18-19,27,31,35,39,43,121,125,132,136,144,149,154,159-164,218-223\" data-show-lang=\"1\"><code>    \/\/\/\u5f79\u5224\u5b9a\u95a2\u6570\n    func yaku() -&gt; (Int, String) {\n        \/\/\u30c1\u30a7\u30c3\u30af\u5909\u6570\n        var ck = 0\n        \/\/\u57fa\u6e96\u30ab\u30fc\u30c9\n        for i in 0 ..&lt; 4 {\n            \/\/\u6bd4\u8f03\u30ab\u30fc\u30c9\n            for j in i + 1 ..&lt; 5 {\n                \/\/\u30ca\u30f3\u30d0\u30fc\u304c\u540c\u3058\u306a\u3089\n                if eachCard[i].tag % 13 == eachCard[j].tag % 13 {\n                    \/\/\u30c1\u30a7\u30c3\u30af\u5909\u6570\u3092\uff0b\uff11\u3059\u308b\n                    ck += 1\n                }\n            }\n        }\n        \/\/\u30ea\u30bf\u30fc\u30f3\u500d\u7387\n        var mul = 0\n        \/\/\u5f79\u540d\n        var msg:String = &quot;&quot;\n        \/\/\u30da\u30a2\u306a\u3089\n        if ck &gt; 0 {\n            \/\/\u30c1\u30a7\u30c3\u30af\u5909\u6570\u306e\u5024\u306b\u3088\u308a\u30da\u30a2\u540d\u3092\u6307\u5b9a\u3059\u308b\n            switch ck {\n            case 1:\n                \/\/\u30ef\u30f3\u30da\u30a2\n                mul = 1\n                msg = &quot;\u30ef\u30f3\u30da\u30a2&quot;\n            case 2:\n                \/\/\u30c4\u30fc\u30da\u30a2\n                mul = 2\n                msg = &quot;\u30c4\u30fc\u30da\u30a2&quot;\n            case 3:\n                \/\/\u30b9\u30ea\u30fc\u30ab\u30fc\u30c9\n                mul = 3\n                msg = &quot;\u30b9\u30ea\u30fc\u30ab\u30fc\u30c9&quot;\n            case 4:\n                \/\/\u30d5\u30eb\u30cf\u30a6\u30b9\n                mul = 6\n                msg = &quot;\u30d5\u30eb\u30cf\u30a6\u30b9&quot;\n            case 6:\n                \/\/\u30d5\u30a9\u30fc\u30ab\u30fc\u30c9\n                mul = 8\n                msg = &quot;\u30d5\u30a9\u30fc\u30ab\u30fc\u30c9&quot;\n            default:\n                mul = 0\n            }\n        \/\/\u30da\u30a2\u4ee5\u5916\n        } else {\n            \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u5909\u6570\u3068\u308a\u3042\u3048\u305a\u30d5\u30e9\u30c3\u30b7\u30e5\n            var chk = true\n            \/\/\uff11\u756a\u76ee\uff08\uff10\u306e\u4f4d\u7f6e\uff09\u306e\u30de\u30fc\u30af\u3092\u53d6\u5f97\uff08\uff10\u301c\uff13\uff09\n            let mark: Int = eachCard[0].tag \/ 13\n            \/\/\uff12\u756a\u76ee\u304b\u3089\uff15\u756a\u76ee\u306e\u4f4d\u7f6e\u306e\u30de\u30fc\u30af\u3068\u6bd4\u8f03\n            for i in 1 ..&lt; 5 {\n                \/\/\uff11\u756a\u76ee\u306e\u30de\u30fc\u30af\u3068\uff12\u301c\uff15\u756a\u76ee\u306e\u30de\u30fc\u30af\u3092\u6bd4\u8f03\u3057\u3066\u9055\u3063\u3066\u3044\u305f\u3089\n                if mark != eachCard[i].tag \/ 13 {\n                    \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u5909\u6570\u3092false\uff08\u30d5\u30e9\u30c3\u30b7\u30e5\u3067\u306f\u306a\u3044\uff09\u306b\n                    chk = false\n                    \/\/\u30eb\u30fc\u30d7\u3092\u7d42\u4e86\n                    break\n                }\n            }\n            \/\/\u30a8\u30fc\u30b9\u304c\u3042\u308b\u304b\n            var isAce = false\n            \/\/\u30ad\u30f3\u30b0\u304c\u3042\u308b\u304b\n            var isKing = false\n            \/\/\uff15\u679a\u306e\u30ab\u30fc\u30c9\u306b\u3064\u3044\u3066\u8abf\u3079\u308b\n            for i in 0 ..&lt; 5 {\n                \/\/\u30a8\u30fc\u30b9\u304c\u3042\u3063\u305f\u3089\n                if eachCard[i].tag % 13 == 0 {\n                    isAce = true\n                }\n                \/\/\u30ad\u30f3\u30b0\u304c\u3042\u3063\u305f\u3089\n                if eachCard[i].tag % 13 == 12 {\n                    isKing = true\n                }\n            }\n            \/\/\u30a8\u30fc\u30b9\u3068\u30ad\u30f3\u30b0\u4e21\u65b9\u3042\u3063\u305f\u3089up\u5909\u6570\u3092true\u306b\n            let up = isAce && isKing\n            \/\/\u6700\u5c0f\u5024\u5909\u6570\u3092\u5ba3\u8a00\n            var min = 0\n            \/\/\u6700\u5927\u5024\u5909\u6570\u3092\u5ba3\u8a00\n            var max = 0\n            \/\/\uff11\u756a\u76ee\u304b\u3089\uff15\u756a\u76ee\u307e\u3067\u30eb\u30fc\u30d7\n            for i in 0 ..&lt; 5 {\n                \/\/\u5909\u6570\u306b\u305d\u306e\u30ab\u30fc\u30c9\u306e\u30ca\u30f3\u30d0\u30fc\u3092\u5165\u308c\u308b\n                var val = eachCard[i].tag % 13\n                \/\/\u30a8\u30fc\u30b9\u3068\u30ad\u30f3\u30b0\u4e21\u65b9\u304c\u3042\u3063\u305f\u5834\u5408\n                if up {\n                    \/\/\uff14\u4ee5\u4e0b\u306e\u30ab\u30fc\u30c9\u306b\n                    if val &lt; 4 {\n                        \/\/\uff11\uff13\u52a0\u3048\u308b\n                        val = val + 13\n                    }\n                }\n                \/\/\uff11\u756a\u76ee\u306a\u3089min,max\u306bval\u3092\u5165\u308c\u308b\n                if i == 0 {\n                    min = val\n                    max = val\n                \/\/\uff12\u756a\u76ee\u4ee5\u964d\n                } else {\n                    \/\/\u5909\u6570\u304c\u6700\u5c0f\u5024\u3088\u308a\u5c0f\u3055\u3044\u6642\n                    if val &lt; min {\n                        \/\/\u6700\u5c0f\u5024\u3092\u5909\u6570\u306b\n                        min = val\n                    }\n                    \/\/\u5909\u6570\u304c\u6700\u5927\u5024\u3088\u308a\u5927\u304d\u3044\u6642\n                    if max &lt; val {\n                        \/\/\u6700\u5927\u5024\u3092\u5909\u6570\u306b\n                        max = val\n                    }\n                }\n            }\n            \/\/\u30b9\u30c8\u30ec\u30fc\u30c8\u306a\u3089\n            if max - min == 4 {\n                \/\/\u30ed\u30a4\u30e4\u30eb\u306a\u3089\n                if max == 13 {\n                    \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u306a\u3089\n                    if chk {\n                        mul = 10\n                        msg = &quot;\u30ed\u30a4\u30e4\u30eb\u30b9\u30c8\u30ec\u30fc\u30c8\u30d5\u30e9\u30c3\u30b7\u30e5&quot;\n                    \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u3067\u306a\u3044\n                    } else {\n                        mul = 9\n                        msg = &quot;\u30ed\u30a4\u30e4\u30eb\u30b9\u30c8\u30ec\u30fc\u30c8&quot;\n                    }\n                \/\/\u30ed\u30a4\u30e4\u30eb\u3067\u306a\u3044\n                } else {\n                    \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u306a\u3089\n                    if chk {\n                        mul = 7\n                        msg = &quot;\u30b9\u30c8\u30ec\u30fc\u30c8\u30d5\u30e9\u30c3\u30b7\u30e5&quot;\n                    \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u3067\u306a\u3044\n                    } else {\n                        mul = 4\n                        msg = &quot;\u30b9\u30c8\u30ec\u30fc\u30c8&quot;\n                    }\n                }\n            \/\/\u30b9\u30c8\u30ec\u30fc\u30c8\u3067\u306a\u3044\n            } else {\n                \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u306a\u3089\n                if chk {\n                    mul = 5\n                    msg = &quot;\u30d5\u30e9\u30c3\u30b7\u30e5&quot;\n                \/\/\u30d5\u30e9\u30c3\u30b7\u30e5\u3067\u306a\u3044\n                } else {\n                    \/\/\u30d6\u30bf\n                    mul = 0\n                    msg = &quot;\u30d6\u30bf&quot;\n                }\n            }\n        }\n        \/\/\u500d\u7387\u3092\u8fd4\u3059\n        return (mul, msg)\n    }\n    \n    \/\/\/\u70b9\u6570\u8a08\u7b97\u95a2\u6570\n    func flush() {\n        \/\/\u30ea\u30bf\u30fc\u30f3\u500d\u7387\n        var mul = 0\n        \/\/\u30e1\u30c3\u30bb\u30fc\u30b8\u4fdd\u6301\u5909\u6570\n        var msg: String\n        \/\/\u30ea\u30bf\u30fc\u30f3\u500d\u7387\n        (mul, msg) = yaku()\n        \/\/\u30bf\u30a4\u30c8\u30eb\u4fdd\u6301\u5909\u6570\n        var title: String\n        \/\/\u30e1\u30c3\u30bb\u30fc\u30b8\u3092\u30bf\u30a4\u30c8\u30eb\u306b\u5165\u308c\u308b\n        title = msg\n        \/\/\u5b9f\u969b\u306e\u500d\u7387(\u30ea\u30bf\u30fc\u30f3\u500d\u7387\u3000\u30fc\u3000\u914d\u3063\u305f\u6642\u306e\u5f79)\n        var realMul = mul - beforeMul\n        \/\/\u30de\u30a4\u30ca\u30b9\u306f\u7121\u3044\n        if realMul &lt; 0 {\n            realMul = 0\n        }\n        \/\/\u30dd\u30a4\u30f3\u30c8\u306b\u8ced\u3051\u70b9\u00d7\u5b9f\u969b\u306e\u500d\u7387\u3092\u8db3\u3059\n        point = point + betPoint * realMul\n        \/\/\u8ced\u3051\u70b9\uff10\n        betPoint = 0\n\n        \/\/\u30dd\u30a4\u30f3\u30c8\u304c\uff10\u306a\u3089\u30b2\u30fc\u30e0\u30aa\u30fc\u30d0\u30fc\n        if point == 0 {\n            title = &quot;\u30b2\u30fc\u30e0\u30aa\u30fc\u30d0\u30fc &quot;\n            msg = &quot;\u30b2\u30fc\u30e0\u30aa\u30fc\u30d0\u30fc &quot;\n            \/\/\u6700\u521d\u304b\u3089\u30b2\u30fc\u30e0\u3092\u7d9a\u3051\u3089\u308c\u308b\n            point = 10\n        }\n        \/\/\u30c0\u30a4\u30a2\u30ed\u30b0\u3092\u8868\u793a\n        let alert = UIAlertController()\n        alert.title = title\n        alert.message = msg + &quot;\u3067\u3059&quot;\n        alert.addAction(UIAlertAction(title: &quot;OK&quot;, style: .default))\n        present(alert, animated: true, completion: nil)\n        \/\/\u70b9\u6570\u8868\u793a\n        display()\n    }\n    \n    \/\/\u914d\u3063\u305f\u6642\u306e\u5f79\n    var beforeMul = 0\n\n    \/\/\/\u958b\u59cb\u30dc\u30bf\u30f3\u62bc\u4e0b\u6642\u51e6\u7406\n    @IBAction func btnGoTouch(_ sender: Any) {\n        \/\/\u30ea\u30bb\u30c3\u30c8\n        \/\/\u5168\u30ab\u30fc\u30c9\u51fa\u3066\u3044\u306a\u3044\u4e8b\u306b\n        for i in 0 ..&lt; EnumCard.Count {\n            check[i] = false\n        }\n        \/\/\u6b8b\u308a\u679a\u6570\uff15\uff12\u679a\n        count = EnumCard.Count\n        \/\/\uff15\u679a\u5f15\u304f\n        for i in 0 ..&lt; 5 {\n            \/\/\u30ab\u30fc\u30c9\u3092\u5f15\u3044\u3066i\u306e\u4f4d\u7f6e\u306b\u51fa\u529b\u3059\u308b\n            put(i: i)\n        }\n        \/\/\u5f79\u5224\u5b9a\n        \/\/flush()\n        \/\/\u518d\u914d\u5e03\u30dc\u30bf\u30f3\u6709\u52b9\n        btnRe.isEnabled = true\n        \/\/\u5f79\u540d\n        var msg:String\n        \/\/\u914d\u3063\u305f\u6642\u306e\u5f79\u3092\u53d6\u5f97\n        (beforeMul, msg) = yaku()\n        \/\/\u57fa\u6e96\u306e\u5f79\u540d\u3001\u500d\u7387\u3092\u8868\u793a\n        lblBefore.text = &quot;\u57fa\u6e96:&quot; + msg + &quot;:&quot; +  beforeMul.description\n    }<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\uff12\u884c\u76ee\u3067\u3001Int\u578b\u3068 String\u578b\u3092\u8fd4\u3059\u4e8b\u3092\u5ba3\u8a00\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>    func yaku() -&gt; (Int, String) {<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\uff11\uff15\uff14\u884c\u76ee\u3067\u3001\u500d\u7387\u3068\u5f79\u540d\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>        return (mul, msg)<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\uff11\uff16\uff14\u884c\u76ee\u3067<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>        (mul, msg) = yaku()<\/code><\/pre><\/div>\n\n\n\n<p>\u3000\uff12\uff12\uff11\u884c\u76ee\u3067<\/p>\n\n\n\n<div class=\"hcb_wrap\"><pre class=\"prism off-numbers lang-swift\" data-lang=\"Swift\" data-show-lang=\"1\"><code>        (beforeMul, msg) = yaku()<\/code><\/pre><\/div>\n\n\n\n<p>\u3068\u3044\u3046\u69d8\u306b\u3001\u500d\u7387\u3068\u5f79\u540d\u3092\u53d7\u3051\u53d6\u3063\u3066\u3044\u307e\u3059\u3002<\/p>\n\n\n\n<p><a href=\"https:\/\/shimayugu.sakura.ne.jp\/?p=2473\">\u76ee\u6b21<\/a>\u3000<a href=\"https:\/\/xcode15.shimayugu.jp\/?p=301\">\u901a\u5e38\u7248<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u6b21\u3000\u901a\u5e38\u7248 \u3000yaku\u95a2\u6570\u3067\u3001\u5f97\u70b9\u306e\u4ed6\u306b\u5f79\u540d\u3092\u8fd4\u3059\u3088\u3046\u306b\u3057\u307e\u3059\u3002 \u3000\uff12\u884c\u76ee\u3067\u3001Int\u578b\u3068 String\u578b\u3092\u8fd4\u3059\u4e8b\u3092\u5ba3\u8a00\u3057\u3066\u3044\u307e\u3059\u3002 \u3000\uff11\uff15\uff14\u884c\u76ee\u3067\u3001\u500d\u7387\u3068\u5f79\u540d\u3092\u8fd4\u3057\u3066\u3044\u307e\u3059\u3002 \u3000\uff11\uff16\uff14\u884c\u76ee\u3067 \u3000\uff12\uff12\uff11\u884c\u76ee\u3067 \u3068\u3044\u3046\u69d8\u306b [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-774","post","type-post","status-publish","format-standard","hentry","category-swift"],"_links":{"self":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/774","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=774"}],"version-history":[{"count":7,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/774\/revisions"}],"predecessor-version":[{"id":1073,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=\/wp\/v2\/posts\/774\/revisions\/1073"}],"wp:attachment":[{"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=774"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=774"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/xcode15.shimayugu.jp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=774"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}