forked from kokonect-link/cherrypick
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: サイコロウィジェット * Update CHANGELOG
- Loading branch information
Showing
8 changed files
with
282 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,7 +24,7 @@ | |
- ノートの自動削除機能を追加 | ||
|
||
### Client | ||
- | ||
- ダイスウィジェットを追加 | ||
|
||
### Server | ||
- 管理者アカウントを別サーバーに移行できるように | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
<template> | ||
<div class="zmdxowus"> | ||
<div> | ||
<MkInput v-model="diceCount" small type="text" class="input"> | ||
<template #label>{{ i18n.ts._dice.diceCount }}</template> | ||
</MkInput> | ||
</div> | ||
<div> | ||
<MkInput v-model="diceFaces" small type="text" class="input"> | ||
<template #label>{{ i18n.ts._dice.diceFaces }}</template> | ||
</MkInput> | ||
</div> | ||
<div> | ||
<MkButton large primary style="margin: 0 auto;" @click="rollDice"> | ||
<i class="ti ti-dice-2"></i> | ||
{{ i18n.ts._dice.rollDice }} | ||
</MkButton> | ||
</div> | ||
<div v-if="diceResult" class="result">{{ diceResult }}</div> | ||
<div v-if="showMinTotal" class="option">{{ diceMinTotal }}</div> | ||
<div v-if="showMaxTotal" class="option">{{ diceMaxTotal }}</div> | ||
<dic v-if="showAverageTotal" class="option">{{ diceAverageTotal }}</dic> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { Ref, ref } from 'vue'; | ||
import { DiceRoll } from '@dice-roller/rpg-dice-roller'; | ||
import MkInput from '@/components/MkInput.vue'; | ||
import MkButton from '@/components/MkButton.vue'; | ||
import { i18n } from '@/i18n'; | ||
const props = withDefaults(defineProps<{ | ||
showMinTotal?: boolean; | ||
showMaxTotal?: boolean; | ||
showAverageTotal?: boolean; | ||
}>(), { | ||
showMinTotal: false, | ||
showMaxTotal: false, | ||
showAverageTotal: false, | ||
}); | ||
const diceCount = ref(1); | ||
const diceFaces = ref(6); | ||
const diceResult: Ref<number | null> = ref(null); | ||
const diceMinTotal: Ref<number | null> = ref(null); | ||
const diceMaxTotal: Ref<number | null> = ref(null); | ||
const diceAverageTotal: Ref<number | null> = ref(null); | ||
const rollDice = () => { | ||
let roll = new DiceRoll(`${diceCount.value}d${diceFaces.value}`); | ||
if (diceCount.value > 999) { | ||
return; | ||
} | ||
diceResult.value = roll.total; | ||
diceMinTotal.value = roll.minTotal; | ||
diceMaxTotal.value = roll.maxTotal; | ||
diceAverageTotal.value = roll.averageTotal; | ||
} | ||
</script> | ||
|
||
<style lang="scss" scoped> | ||
.zmdxowus { | ||
padding: 8px 16px; | ||
> div { | ||
margin: 8px 0; | ||
} | ||
> .input { | ||
flex: 1 1 auto; | ||
padding: 8px; | ||
} | ||
> .result { | ||
text-align: center; | ||
margin: auto; | ||
} | ||
> .option { | ||
padding: 8px 0; | ||
text-align: left; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<template> | ||
<div class="_monospace" :class="[$style.root, {_panel: !widgetProps.transparent}]"> | ||
<MkDice | ||
:showMinTotal="widgetProps.showMinTotal" | ||
:showMaxTotal="widgetProps.showMaxTotal" | ||
:showAverageTotal="widgetProps.showAverageTotal" | ||
/> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts" setup> | ||
import { Ref, ref } from 'vue'; | ||
import { GetFormResultType } from '@/scripts/form.js'; | ||
import { useWidgetPropsManager, WidgetComponentEmits, WidgetComponentExpose, WidgetComponentProps } from './widget.js'; | ||
import MkDice from '@/components/MkDice.vue'; | ||
import { i18n } from '@/i18n.js'; | ||
const name = 'dice'; | ||
const widgetPropsDef = { | ||
transparent: { | ||
type: 'boolean' as const, | ||
default: false, | ||
}, | ||
showMinTotal: { | ||
type: 'boolean' as const, | ||
default: false, | ||
}, | ||
showMaxTotal: { | ||
type: 'boolean' as const, | ||
default: false, | ||
}, | ||
showAverageTotal: { | ||
type: 'boolean' as const, | ||
default: false, | ||
}, | ||
} | ||
type WidgetProps = GetFormResultType<typeof widgetPropsDef>; | ||
const props = defineProps<WidgetComponentProps<WidgetProps>>(); | ||
const emit = defineEmits<WidgetComponentEmits<WidgetProps>>(); | ||
const { widgetProps, configure } = useWidgetPropsManager(name, | ||
widgetPropsDef, | ||
props, | ||
emit, | ||
); | ||
defineExpose<WidgetComponentExpose>({ | ||
name, | ||
configure, | ||
id: props.widget ? props.widget.id : null, | ||
}); | ||
</script> | ||
|
||
<style lang="scss" module> | ||
.root { | ||
position: relative; | ||
padding: 16px 0; | ||
> .input { | ||
flex: 1 1 auto; | ||
} | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.