Skip to content

Commit

Permalink
Merge pull request #1037 from ben/si-locations
Browse files Browse the repository at this point in the history
Extend location sheet for SI
  • Loading branch information
ben authored Nov 9, 2024
2 parents 1aaec9f + 3c2fd8a commit eba5a34
Show file tree
Hide file tree
Showing 7 changed files with 231 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Next Release

- Fix a bug where clicking "+Vow" would create a "progress" item instead of a "vow" item.
- Extend the location sheet to include IS islands and settlements ([#1037](https://github.com/ben/foundry-ironsworn/pull/1037))

## 1.24.6

Expand Down
42 changes: 34 additions & 8 deletions src/module/features/sceneButtons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ function newVault() {
newLocation('vault', 'ACTOR.SubtypeVault', 2)
}

function newIsland() {
newLocation('island', 'ACTOR.SubtypeIsland')
}

function newSiSettlement() {
newLocation('sunderedsettlement', 'ACTOR.SubtypeSettlement')
}

let ORACLE_WINDOW: OracleWindow | undefined
function theOracleWindow() {
if (ORACLE_WINDOW == null) ORACLE_WINDOW = new OracleWindow()
Expand Down Expand Up @@ -265,14 +273,32 @@ function sunderedIslifyControl(control: SceneControl) {
})

if (game.user?.isGM) {
control.tools.push({
name: 'edit',
icon: 'isicon-region-si',
title: game.i18n.format('DOCUMENT.Update', {
type: game.i18n.localize('IRONSWORN.SCENE.TypeChart')
}),
onClick: editSector
})
control.tools.push(
{
name: 'edit',
icon: 'isicon-region-si',
title: game.i18n.format('DOCUMENT.Update', {
type: game.i18n.localize('IRONSWORN.SCENE.TypeChart')
}),
onClick: editSector
},
{
name: 'island',
icon: 'isicon-island',
title: game.i18n.format('DOCUMENT.Create', {
type: game.i18n.localize('IRONSWORN.ACTOR.SubtypeDerelict')
}),
onClick: newIsland
},
{
name: 'sisettlement',
icon: 'isicon-settlement-si',
title: game.i18n.format('DOCUMENT.Create', {
type: game.i18n.localize('IRONSWORN.ACTOR.SubtypeSettlement')
}),
onClick: newSiSettlement
}
)
}
}

Expand Down
211 changes: 189 additions & 22 deletions src/module/vue/sf-locationsheet.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,8 @@
>
<span class="select-label">{{ $t('IRONSWORN.Region') }}</span>
<select v-model="region" @change="regionChanged">
<option value="terminus">
{{ $t('IRONSWORN.REGION.Terminus') }}
</option>
<option value="outlands">
{{ $t('IRONSWORN.REGION.Outlands') }}
</option>
<option value="expanse">
{{ $t('IRONSWORN.REGION.Expanse') }}
<option v-for="r in regions" :value="r.value">
{{ $t(r.label) }}
</option>
</select>
</label>
Expand All @@ -28,11 +22,9 @@
>
{{ $t('IRONSWORN.LocationType') }}
<select v-model="data.actor.system.subtype" @change="subtypeChanged">
<option value="planet">Planet</option>
<option value="settlement">Settlement</option>
<option value="star">Stellar Object</option>
<option value="derelict">Derelict</option>
<option value="vault">Precursor Vault</option>
<option v-for="st in subtypes" :value="st.value">
{{ st.label }}
</option>
</select>
</label>
</div>
Expand All @@ -41,6 +33,7 @@
<label
class="flexrow nogrow"
style="position: relative; gap: var(--ironsworn-spacer-xl)"
v-if="klassOptions.length > 0"
>
<!-- TODO: i18n and subtype text -->
<span class="select-label">{{ subtypeSelectText }}:</span>
Expand Down Expand Up @@ -157,6 +150,7 @@ import { IdParser } from '../datasworn2'
import MceEditor from './components/mce-editor.vue'
import SheetBasic from './sheet-basic.vue'
import IronBtn from './components/buttons/iron-btn.vue'
import { IronswornSettings } from '../helpers/settings'
const props = defineProps<{
data: { actor: ActorSource<'location'> }
Expand All @@ -174,6 +168,59 @@ const state = reactive({
firstLookHighlight: false
})
type Selectable = {
label: string
value: string
}
const regions: Selectable[] = []
const subtypes: Selectable[] = []
for (const ruleset of IronswornSettings.enabledRulesets) {
if (ruleset === 'starforged') {
regions.push(
{
label: game.i18n.localize('IRONSWORN.REGION.Terminus'),
value: 'terminus'
},
{
label: game.i18n.localize('IRONSWORN.REGION.Outlands'),
value: 'outlands'
},
{
label: game.i18n.localize('IRONSWORN.REGION.Expanse'),
value: 'expanse'
}
)
subtypes.push(
{ value: 'planet', label: 'Planet' },
{ value: 'settlement', label: 'Settlement' },
{ value: 'star', label: 'Stellar' },
{ value: 'derelict', label: 'Derelict' },
{ value: 'vault', label: 'Precursor' }
)
}
if (ruleset === 'sundered_isles') {
regions.push(
{
label: game.i18n.localize('IRONSWORN.REGION.Myriads'),
value: 'myriads'
},
{
label: game.i18n.localize('IRONSWORN.REGION.Margins'),
value: 'margins'
},
{
label: game.i18n.localize('IRONSWORN.REGION.Reaches'),
value: 'reaches'
}
)
subtypes.push(
{ value: 'island', label: 'Island' },
{ value: 'sunderedsettlement', label: 'Settlement' }
)
}
}
function randomImage(subtype, klass): string | void {
if (subtype === 'planet') {
const name = klass.capitalize()
Expand All @@ -198,6 +245,12 @@ function randomImage(subtype, klass): string | void {
''
)}.webp`
}
if (subtype === 'sunderedsettlement') {
return `systems/foundry-ironsworn/assets/icons/settlement-si.svg`
}
if (subtype === 'island') {
return `systems/foundry-ironsworn/assets/icons/island.svg`
}
}
const klassOptions = computed((): { value: string; label: string }[] => {
Expand Down Expand Up @@ -271,8 +324,15 @@ const klassOptions = computed((): { value: string; label: string }[] => {
}
]
case 'sunderedsettlement':
return [
{ value: 'shore', label: 'Shore' },
{ value: 'inland', label: 'Inland' },
{ value: 'waterside', label: 'Waterside' }
]
default:
throw new Error('bad type yo')
return []
}
})
Expand Down Expand Up @@ -483,8 +543,100 @@ const oracles = computed((): OracleSpec[][] => {
]
]
case 'island':
return [
[
{
title: 'Island size',
dsid: `oracle_rollable:sundered_isles/island/landscape/size`,
fl: true
},
{
title: 'Terrain',
dsid: `oracle_rollable:sundered_isles/island/landscape/terrain`,
fl: true
},
{
title: 'Vitality',
dsid: `oracle_rollable:sundered_isles/island/landscape/vitality/${rc}`,
fl: true
}
],
[
{
title: 'Habitation',
dsid: `oracle_rollable:sundered_isles/island/visible_habitation/${rc}`
},
{
title: 'Nearby Islands',
dsid: `oracle_rollable:sundered_isles/island/nearby_islands/${rc}`
}
],
[
{
title: 'Coastline Aspect',
qty: '1-2',
dsid: `oracle_rollable:sundered_isles/island/coastline_aspects`
},
{
title: 'Offshore Observations',
qty: '1-2',
dsid: `oracle_rollable:sundered_isles/island/offshore_observations`
}
]
]
case 'sunderedsettlement':
return [
[
{
title: 'Settlement size',
dsid: `oracle_rollable:sundered_isles/settlement/size/${rc}`,
fl: true
},
{
title: 'Aesthetics',
dsid: `oracle_rollable:sundered_isles/settlement/aesthetics`,
fl: true,
qty: '1-2'
},
{
title: 'First look',
dsid: `oracle_rollable:sundered_isles/settlement/first_look`,
fl: true,
qty: '1-2'
}
],
[
{
title: 'Controlling faction',
dsid: `oracle_rollable:sundered_isles/settlement/identity/controlling_faction/${rc}`
},
{
title: 'Disposition',
dsid: `oracle_rollable:sundered_isles/settlement/identity/disposition`
},
{
title: 'Authority',
dsid: `oracle_rollable:sundered_isles/settlement/identity/authority`
}
],
[
{
title: 'Settlement focus',
dsid: `oracle_rollable:sundered_isles/settlement/focus/${kc}`,
qty: '1-2'
},
{
title: 'Settlement details',
dsid: `oracle_rollable:sundered_isles/settlement/details`,
qty: '1-2'
}
]
]
default:
throw new Error('bad type yo')
return []
}
})
Expand All @@ -500,7 +652,7 @@ const canRandomizeName = computed(() => {
const dskey = `oracle_rollable:starforged/planet/${kc}/name`
const obj = IdParser.get(dskey)
if (obj) return true
} else if (subtype === 'settlement') {
} else if (['island', 'settlement', 'sunderedsettlement'].includes(subtype)) {
return true
}
return false
Expand Down Expand Up @@ -563,7 +715,9 @@ async function saveSubtype(subtype) {
settlement: 2,
star: 1,
derelict: 2,
vault: 2
vault: 2,
sunderedsettlement: 1,
island: 1
}[subtype]
await updateAllTokens({
img, // v11
Expand Down Expand Up @@ -611,6 +765,16 @@ async function randomizeName() {
'oracle_rollable:starforged/settlement/name'
)
name = await drawAndReturnResult(table)
} else if (subtype === 'sunderedsettlement') {
const table = await OracleTable.getByDsId(
'oracle_rollable:sundered_isles/settlement/name'
)
name = await drawAndReturnResult(table)
} else if (subtype === 'island') {
const table = await OracleTable.getByDsId(
'oracle_rollable:sundered_isles/island/name'
)
name = await drawAndReturnResult(table)
}
if (name) {
Expand All @@ -621,16 +785,19 @@ async function randomizeName() {
async function randomizeKlass() {
let tableKey
if (props.data.actor.system.subtype === 'planet') {
const subtype = props.data.actor.system.subtype
if (subtype === 'planet') {
tableKey = 'oracle_rollable:starforged/planet/class'
} else if (props.data.actor.system.subtype === 'settlement') {
} else if (subtype === 'settlement') {
tableKey = 'oracle_rollable:starforged/settlement/location'
} else if (props.data.actor.system.subtype === 'star') {
} else if (subtype === 'star') {
tableKey = 'oracle_rollable:starforged/space/stellar_object'
} else if (props.data.actor.system.subtype === 'derelict') {
} else if (subtype === 'derelict') {
tableKey = 'oracle_rollable:starforged/derelict/location'
} else if (props.data.actor.system.subtype === 'vault') {
} else if (subtype === 'vault') {
tableKey = 'oracle_rollable:starforged/precursor_vault/location'
} else if (subtype === 'sunderedsettlement') {
tableKey = 'oracle_rollable:sundered_isles/settlement/location'
}
const table = await OracleTable.getByDsId(tableKey)
Expand Down
2 changes: 2 additions & 0 deletions src/styles/icons.less
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ i {
delve-site: 'https://game-icons.net/1x1/delapouite/dungeon-gate.html';
derelict: 'https://game-icons.net/1x1/delapouite/crime-scene-tape.html';
faction: 'https://game-icons.net/1x1/delapouite/vertical-banner.html';
island: 'https://game-icons.net/1x1/delapouite/island.html';
monstrosity: 'https://game-icons.net/1x1/lorc/beast-eye.html'; // AKA the creature oracles from delve
npc: 'https://game-icons.net/1x1/lorc/drama-masks.html';
precursor-vault: 'https://game-icons.net/1x1/lorc/moebius-triangle.html';
Expand All @@ -252,6 +253,7 @@ i {
sector: 'https://game-icons.net/1x1/skoll/hexes.html';
settlement-is: 'https://game-icons.net/1x1/delapouite/huts-village.html';
settlement-sf: 'https://game-icons.net/1x1/delapouite/modern-city.html';
settlement-si: 'https://game-icons.net/1x1/delapouite/village.html';
starship: 'https://game-icons.net/1x1/delapouite/spaceship.html';
stellar-object: 'https://game-icons.net/1x1/lorc/star-prominences.html';
waypoint: 'https://game-icons.net/1x1/delapouite/position-marker.html';
Expand Down
1 change: 1 addition & 0 deletions system/assets/icons/island.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions system/assets/icons/settlement-si.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit eba5a34

Please sign in to comment.