Skip to content

Commit

Permalink
feat: 副本类型
Browse files Browse the repository at this point in the history
  • Loading branch information
Souma-Sumire committed Oct 7, 2024
1 parent 15309c7 commit cb1ec75
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 54 deletions.
2 changes: 0 additions & 2 deletions src/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
"Yes": "Yes",
"passwordPlaceholder": "WebSocket Server Password",
"portPlaceholder": "WebSocket Server Port",
"RaidsLimitToEightOrLess": "Record only when the number of team members is less than or equal to 8 (to exclude 24 person content)",
"PvpLimitToEightOrLess": "Record only when the number of team members is less than or equal to 5 (to exclude 72 person content)",
"Leave Zone": "Leave Zone",
"Savage": "Savage",
"Extreme": "Extreme",
Expand Down
2 changes: 0 additions & 2 deletions src/locales/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
"CombatStart": "戦闘開始",
"ACT Not Ready": "ACT未接続",
"Extra Rule": "追加ルール",
"RaidsLimitToEightOrLess": "メンバー数が8以下の場合に録画(24人を除くため)",
"PvpLimitToEightOrLess": "メンバー数が5以下の場合に録画(72人を除くため)",
"Leave Zone": "エリア出場",
"Savage": "零式",
"Extreme": "",
Expand Down
2 changes: 0 additions & 2 deletions src/locales/zhCn.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
"CountDown": "倒计时开始",
"CombatStart": "进入战斗",
"Extra Rule": "额外规则",
"RaidsLimitToEightOrLess": "队员数量小于等于 8 人时才录制(用于排除 24 人本)",
"PvpLimitToEightOrLess": "队员数量小于等于 5 人时才录制(用于排除 72 人战场)",
"Leave Zone": "离开区域",
"Savage": "零式",
"Extreme": "极神",
Expand Down
90 changes: 42 additions & 48 deletions src/pages/obs2.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ContentType from '../../cactbot/resources/content_type'
import { addOverlayListener, callOverlayHandler, removeOverlayListener } from '../../cactbot/resources/overlay_plugin_api'
import NetRegexes, { commonNetRegex } from '../../cactbot/resources/netregexes'
import logDefinitions from '../../cactbot/resources/netlog_defs'
import zoneInfo from '@/resources/zoneInfo'
import ZoneInfo from '@/resources/zoneInfo'
/*
TODO:
Expand All @@ -22,12 +22,10 @@ type ConditionType = 'enter' | 'combatStart' | 'combatEnd' | 'countdown' | 'wipe
type ContentUsedType = typeof CONTENT_TYPES[number]
const userConfig = useStorage('obs-user-config', { host: 4455, password: '' })
const userContentSetting = useStorage('obs-user-content-setting', [] as Settings[])
const userContentSettingExtra = useStorage('obs-user-content-setting-extra', { raidLimitToEightOrLess: true, pvpLimitToEightOrLess: true })
const isFirstTime = useStorage('obs-is-first-time', true)
const actReady = ref(false)
const debug = ref(false)
let partyLength: number = 0
const playerContentType = ref('' as keyof typeof ContentType)
const playerZoneInfo = ref({} as typeof ZoneInfo[number])
function checkWebSocket(): Promise<void> {
return new Promise((resolve) => {
Expand All @@ -50,9 +48,11 @@ const REGEXES: Record<string, RegExp> = {
} as const
const CONTENT_TYPES = [
'Savage', // 零式
'Extreme', // 歼殛战
'Ultimate', // 绝境战
'Dungeons', // 四人副本
'Raids', // 大型任务
'UltimateRaids', // 绝境战
'Dungeons', // 地牢(四人副本)
'Trials', // 讨伐任务
'VCDungeonFinder', // 多变迷宫
'DeepDungeons', // 深层迷宫
Expand All @@ -66,7 +66,7 @@ const CONTENT_TYPES = [
] as const
function initializeContentSettings() {
const defaultEnabled: ContentUsedType[] = ['Raids', 'UltimateRaids']
const defaultEnabled: ContentUsedType[] = ['Savage', 'Extreme', 'Ultimate']
if (isFirstTime.value) {
isFirstTime.value = false
// 大型任务、绝境战默认开启
Expand Down Expand Up @@ -198,17 +198,8 @@ const obs = new Obs()
const handleChangeZone: EventMap['ChangeZone'] = (e) => {
const zoneID = e.zoneID
const contentType = zoneInfo[zoneID]?.contentType
for (const key in ContentType) {
if (Object.prototype.hasOwnProperty.call(ContentType, key)) {
const element = ContentType[key as keyof typeof ContentType]
if (element === contentType) {
playerContentType.value = key as keyof typeof ContentType
checkCondition('enter')
return
}
}
}
const zoneInfo = ZoneInfo[zoneID]
playerZoneInfo.value = zoneInfo
}
const handleLogLine: EventMap['LogLine'] = (e) => {
Expand Down Expand Up @@ -250,19 +241,43 @@ const handleLogLine: EventMap['LogLine'] = (e) => {
}
}
const handlePartyChanged: EventMap['PartyChanged'] = (e) => {
partyLength = e.party.length
function getZoneType(zoneInfo: (typeof ZoneInfo)[number]): typeof CONTENT_TYPES[number] {
switch (zoneInfo.contentType) {
case ContentType.UltimateRaids:
return 'Ultimate'
case ContentType.Pvp:
return 'Pvp'
case ContentType.DeepDungeons:
return 'DeepDungeons'
case ContentType.VCDungeonFinder:
return 'VCDungeonFinder'
case ContentType.Trials:
if (zoneInfo.name.fr?.includes('(extrême)'))
return 'Extreme'
return 'Trials'
case ContentType.Raids:
if (zoneInfo.name.en?.includes('(Savage)'))
return 'Savage'
return 'Raids'
case ContentType.DisciplesOfTheLand:
return 'DisciplesOfTheLand'
case ContentType.Eureka:
return 'Eureka'
case ContentType.GrandCompany:
return 'GrandCompany'
case ContentType.QuestBattles:
return 'QuestBattles'
case ContentType.TreasureHunt:
return 'TreasureHunt'
default:
throw new Error(`Unknown content type: ${zoneInfo.contentType}`)
}
}
function checkCondition(condition: ConditionType) {
const recording = obs.status.recording
if (!userContentSetting.value.find(item => item.type === playerContentType.value && item[condition])) {
return
}
if (playerContentType.value === 'Raids' && userContentSettingExtra.value.raidLimitToEightOrLess && partyLength > 8) {
return
}
if (playerContentType.value === 'Pvp' && userContentSettingExtra.value.pvpLimitToEightOrLess && partyLength > 5) {
const zoneType = getZoneType(playerZoneInfo.value)
if (!userContentSetting.value.find(item => item.type === zoneType && item[condition])) {
return
}
switch (condition) {
Expand All @@ -289,15 +304,13 @@ onMounted(async () => {
obs.connect()
addOverlayListener('ChangeZone', handleChangeZone)
addOverlayListener('LogLine', handleLogLine)
addOverlayListener('PartyChanged', handlePartyChanged)
initializeContentSettings()
})
onUnmounted(() => {
obs.disconnect()
removeOverlayListener('ChangeZone', handleChangeZone)
removeOverlayListener('LogLine', handleLogLine)
removeOverlayListener('PartyChanged', handlePartyChanged)
})
</script>

Expand Down Expand Up @@ -457,25 +470,6 @@ onUnmounted(() => {
</el-table-column>
</el-table>
</el-card>
<el-card class="table-card">
<template #header>
<div class="card-header">
<span>{{ t('Extra Rule') }}</span>
</div>
</template>
<el-form label-position="top" class="extra-rule-form">
<el-form-item :label="t('Raids')">
<el-checkbox v-model="userContentSettingExtra.raidLimitToEightOrLess">
{{ t('RaidsLimitToEightOrLess') }}
</el-checkbox>
</el-form-item>
<el-form-item :label="t('Pvp')">
<el-checkbox v-model="userContentSettingExtra.pvpLimitToEightOrLess">
{{ t('PvpLimitToEightOrLess') }}
</el-checkbox>
</el-form-item>
</el-form>
</el-card>
</div>
</main>
</div>
Expand Down

0 comments on commit cb1ec75

Please sign in to comment.