Skip to content

Commit

Permalink
Merge pull request #1 from ef81sp/refactoring
Browse files Browse the repository at this point in the history
Refactoring
  • Loading branch information
ef81sp authored Jan 22, 2024
2 parents 46f6fd2 + 44c4f6f commit 3b697d0
Show file tree
Hide file tree
Showing 26 changed files with 989 additions and 306 deletions.
118 changes: 59 additions & 59 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 14 additions & 19 deletions src/components/ExplanationBlocks.vue
Original file line number Diff line number Diff line change
@@ -1,50 +1,45 @@
<script setup lang="ts">
import type { 牌 } from 'pairi'
import type { ExtractResult5ブロック } from 'pairi/dist/手牌utils/手牌utils.type'
import Divider from 'primevue/divider'
import ExplanationBlocksBlock from './ExplanationBlocksBlock.vue'
import ExplanationBlocksSinglePaiList from './ExplanationBlocksSinglePaiList.vue'
import { computed } from 'vue'
type Props = {
シャンテン数: number
ブロック: ExtractResult5ブロック
有効牌: 牌[]
}
const props = defineProps<Props>()
import type { AnalysisResult手牌13 } from '@/utils/type'
const props = defineProps<{ analysisResult手牌13: AnalysisResult手牌13 }>()
const block = computed(() => props.analysisResult手牌13.ブロック)
const shanten = computed(() => props.analysisResult手牌13.シャンテン数)
const yuuko = computed(() => props.analysisResult手牌13.有効牌)
const restList = computed(() => {
const rest = props.ブロック.rest
const rest = props.analysisResult手牌13.ブロック.rest
return Object.values(rest).flatMap((p) => p)
})
</script>
<template>
<Divider />
<div class="flex flex-col gap-y-2 lg:gap-y-4">
<ExplanationBlocksBlock
v-if="ブロック.雀頭 !== null"
v-if="block.雀頭 !== null"
title="雀頭"
:block-list="[ブロック.雀頭]"
:block-list="[block.雀頭]"
/>
<ExplanationBlocksBlock
v-if="ブロック.面子.length !== 0"
v-if="block.面子.length !== 0"
title="面子"
:block-list="ブロック.面子"
:block-list="block.面子"
/>
<ExplanationBlocksBlock
v-if="ブロック.塔子.length !== 0"
v-if="block.塔子.length !== 0"
title="塔子"
:block-list="ブロック.塔子"
:block-list="block.塔子"
/>
<ExplanationBlocksSinglePaiList
v-if="restList.length !== 0"
title="浮き"
:pai-list="restList"
/>
<ExplanationBlocksSinglePaiList
:title="シャンテン数 === 0 ? '待ち' : '有効'"
:pai-list="有効牌"
:title="shanten === 0 ? '待ち' : '有効'"
:pai-list="yuuko"
class="mt-3 lg:mt-6"
/>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExplanationBlocksBlock.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import type { PaiStr } from '@/composables/PaiStr.type'
import VPai from './VPai.vue'
import type { ExtractResult5ブロック } from 'pairi/dist/手牌utils/手牌utils.type'
import type { ExtractResult5ブロック } from '@/utils/type'
defineProps<{
title: string
blockList: Block[]
Expand Down
2 changes: 1 addition & 1 deletion src/components/ExplanationYuuko.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ const nShuNPai = computed(
<template>
<Divider />
<div class="flex flex-wrap items-center">
<h5 class="mt-3 text-lg font-bold flex items-center gap-x-1">
<h5 class="mt-3 flex items-center gap-x-1 text-lg font-bold">
<VPai
:pai-str="discarding.toString()"
Expand Down
5 changes: 2 additions & 3 deletions src/components/NanikiruExplanationDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { isTsumo } from '@/utils/isTsumo'
import type { 牌 } from 'pairi'
import { sortAnalysisResult14 } from '@/utils/sortAnalysisResult14'
import ExplanationYuuko from './ExplanationYuuko.vue'
import { seekMinimumShanten } from '@/utils/nanikiruJudgeUtils'
const props = defineProps<{
analysisResult: AnalysisResult14
Expand All @@ -19,9 +20,7 @@ const _analysisResultValues = computed(() =>
)
const _isTsumo = computed(() => isTsumo(props.analysisResult, props.tsumo))
const shanten = computed(() => {
return Math.min(..._analysisResultValues.value.map((a) => a.analysisResult.シャンテン数))
})
const shanten = computed(() => seekMinimumShanten(_analysisResultValues.value))
const minShantenAnalysisResultValues = computed(() =>
_analysisResultValues.value.filter((a) => a.analysisResult.シャンテン数 === shanten.value),
Expand Down
Loading

0 comments on commit 3b697d0

Please sign in to comment.