Fix bugs relating to [party]
This commit is contained in:
parent
b2f64f1d78
commit
d0535d6031
8 changed files with 165 additions and 153 deletions
|
|
@ -46,7 +46,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
const [errorAlertOpen, setErrorAlertOpen] = useState(false)
|
const [errorAlertOpen, setErrorAlertOpen] = useState(false)
|
||||||
|
|
||||||
// Set up state for view management
|
// Set up state for view management
|
||||||
const { party, grid } = useSnapshot(appState)
|
const { party } = useSnapshot(appState)
|
||||||
const [modalOpen, setModalOpen] = useState(false)
|
const [modalOpen, setModalOpen] = useState(false)
|
||||||
|
|
||||||
// Set up state for conflict management
|
// Set up state for conflict management
|
||||||
|
|
@ -88,7 +88,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
||||||
})
|
})
|
||||||
setPreviousUncapValues(initialPreviousUncapValues)
|
setPreviousUncapValues(initialPreviousUncapValues)
|
||||||
}, [appState.grid.characters])
|
}, [appState.party.grid.characters])
|
||||||
|
|
||||||
// Methods: Adding an object from search
|
// Methods: Adding an object from search
|
||||||
function receiveCharacterFromSearch(
|
function receiveCharacterFromSearch(
|
||||||
|
|
@ -146,7 +146,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function storeGridCharacter(gridCharacter: GridCharacter) {
|
function storeGridCharacter(gridCharacter: GridCharacter) {
|
||||||
appState.grid.characters[gridCharacter.position] = gridCharacter
|
appState.party.grid.characters[gridCharacter.position] = gridCharacter
|
||||||
}
|
}
|
||||||
|
|
||||||
async function resolveConflict() {
|
async function resolveConflict() {
|
||||||
|
|
@ -164,7 +164,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
|
|
||||||
// Remove conflicting characters from state
|
// Remove conflicting characters from state
|
||||||
conflicts.forEach(
|
conflicts.forEach(
|
||||||
(c) => (appState.grid.characters[c.position] = undefined)
|
(c) => (appState.party.grid.characters[c.position] = undefined)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Reset conflict
|
// Reset conflict
|
||||||
|
|
@ -186,7 +186,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
async function removeCharacter(id: string) {
|
async function removeCharacter(id: string) {
|
||||||
try {
|
try {
|
||||||
const response = await api.endpoints.grid_characters.destroy({ id: id })
|
const response = await api.endpoints.grid_characters.destroy({ id: id })
|
||||||
appState.grid.characters[response.data.position] = undefined
|
appState.party.grid.characters[response.data.position] = undefined
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
}
|
}
|
||||||
|
|
@ -378,10 +378,10 @@ const CharacterGrid = (props: Props) => {
|
||||||
position: number,
|
position: number,
|
||||||
uncapLevel: number | undefined
|
uncapLevel: number | undefined
|
||||||
) => {
|
) => {
|
||||||
const character = appState.grid.characters[position]
|
const character = appState.party.grid.characters[position]
|
||||||
if (character && uncapLevel) {
|
if (character && uncapLevel) {
|
||||||
character.uncapLevel = uncapLevel
|
character.uncapLevel = uncapLevel
|
||||||
appState.grid.characters[position] = character
|
appState.party.grid.characters[position] = character
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -389,8 +389,8 @@ const CharacterGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (grid.characters[position]) {
|
if (party.grid.characters[position]) {
|
||||||
newPreviousValues[position] = grid.characters[position]?.uncapLevel
|
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
||||||
setPreviousUncapValues(newPreviousValues)
|
setPreviousUncapValues(newPreviousValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -474,10 +474,10 @@ const CharacterGrid = (props: Props) => {
|
||||||
position: number,
|
position: number,
|
||||||
stage: number | undefined
|
stage: number | undefined
|
||||||
) => {
|
) => {
|
||||||
const character = appState.grid.characters[position]
|
const character = appState.party.grid.characters[position]
|
||||||
if (character && stage !== undefined) {
|
if (character && stage !== undefined) {
|
||||||
character.transcendenceStep = stage
|
character.transcendenceStep = stage
|
||||||
appState.grid.characters[position] = character
|
appState.party.grid.characters[position] = character
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -485,8 +485,8 @@ const CharacterGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (grid.characters[position]) {
|
if (party.grid.characters[position]) {
|
||||||
newPreviousValues[position] = grid.characters[position]?.uncapLevel
|
newPreviousValues[position] = party.grid.characters[position]?.uncapLevel
|
||||||
setPreviousTranscendenceStages(newPreviousValues)
|
setPreviousTranscendenceStages(newPreviousValues)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -540,7 +540,7 @@ const CharacterGrid = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<li key={`grid_unit_${i}`}>
|
<li key={`grid_unit_${i}`}>
|
||||||
<CharacterUnit
|
<CharacterUnit
|
||||||
gridCharacter={grid.characters[i]}
|
gridCharacter={party.grid.characters[i]}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
position={i}
|
position={i}
|
||||||
updateObject={receiveCharacterFromSearch}
|
updateObject={receiveCharacterFromSearch}
|
||||||
|
|
|
||||||
|
|
@ -11,14 +11,14 @@ import SearchModal from '~components/search/SearchModal'
|
||||||
|
|
||||||
import api from '~utils/api'
|
import api from '~utils/api'
|
||||||
import { appState } from '~utils/appState'
|
import { appState } from '~utils/appState'
|
||||||
import type { JobSkillObject, SearchableObject } from '~types'
|
import type { SearchableObject } from '~types'
|
||||||
|
|
||||||
import styles from './index.module.scss'
|
import styles from './index.module.scss'
|
||||||
|
|
||||||
// Props
|
// Props
|
||||||
interface Props {
|
interface Props {
|
||||||
job?: Job
|
job?: Job
|
||||||
jobSkills: JobSkillObject
|
jobSkills: JobSkillList
|
||||||
jobAccessory?: JobAccessory
|
jobAccessory?: JobAccessory
|
||||||
editable: boolean
|
editable: boolean
|
||||||
saveJob: (job?: Job) => void
|
saveJob: (job?: Job) => void
|
||||||
|
|
|
||||||
|
|
@ -58,7 +58,7 @@ const Party = (props: Props) => {
|
||||||
// Reset state on first load
|
// Reset state on first load
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const resetState = clonedeep(initialAppState)
|
const resetState = clonedeep(initialAppState)
|
||||||
appState.grid = resetState.grid
|
appState.party.grid = resetState.party.grid
|
||||||
if (props.party) {
|
if (props.party) {
|
||||||
storeParty(props.party)
|
storeParty(props.party)
|
||||||
setUpdatedParty(props.party)
|
setUpdatedParty(props.party)
|
||||||
|
|
@ -268,10 +268,12 @@ const Party = (props: Props) => {
|
||||||
appState.party.name = team.name
|
appState.party.name = team.name
|
||||||
appState.party.description = team.description ? team.description : ''
|
appState.party.description = team.description ? team.description : ''
|
||||||
appState.party.raid = team.raid
|
appState.party.raid = team.raid
|
||||||
appState.party.protagonist.job = team.job
|
appState.party.protagonist.job = team.protagonist.job
|
||||||
appState.party.protagonist.skills = team.job_skills
|
appState.party.protagonist.skills = team.protagonist.skills
|
||||||
appState.party.protagonist.accessory = team.accessory
|
appState.party.protagonist.accessory = team.protagonist.accessory
|
||||||
|
appState.party.protagonist.masterLevel = team.protagonist.master_level
|
||||||
|
appState.party.protagonist.ultimateMastery =
|
||||||
|
team.protagonist.ultimate_mastery
|
||||||
appState.party.details.chargeAttack = team.charge_attack
|
appState.party.details.chargeAttack = team.charge_attack
|
||||||
appState.party.details.fullAuto = team.full_auto
|
appState.party.details.fullAuto = team.full_auto
|
||||||
appState.party.details.autoGuard = team.auto_guard
|
appState.party.details.autoGuard = team.auto_guard
|
||||||
|
|
@ -296,17 +298,14 @@ const Party = (props: Props) => {
|
||||||
appState.party.timestamps.createdAt = team.created_at
|
appState.party.timestamps.createdAt = team.created_at
|
||||||
appState.party.timestamps.updatedAt = team.updated_at
|
appState.party.timestamps.updatedAt = team.updated_at
|
||||||
|
|
||||||
|
appState.party.grid = team.grid
|
||||||
|
|
||||||
// Store the edit key in local storage
|
// Store the edit key in local storage
|
||||||
if (team.edit_key) {
|
if (team.edit_key) {
|
||||||
storeEditKey(team.id, team.edit_key)
|
storeEditKey(team.id, team.edit_key)
|
||||||
setEditKey(team.id, team.user)
|
setEditKey(team.id, team.user)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Populate state
|
|
||||||
storeCharacters(team.characters)
|
|
||||||
storeWeapons(team.weapons)
|
|
||||||
storeSummons(team.summons)
|
|
||||||
|
|
||||||
// Create a string to send the user back to the tab they're currently on
|
// Create a string to send the user back to the tab they're currently on
|
||||||
let tab = ''
|
let tab = ''
|
||||||
if (props.selectedTab === GridType.Character) {
|
if (props.selectedTab === GridType.Character) {
|
||||||
|
|
@ -324,56 +323,56 @@ const Party = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeCharacters = (list: Array<GridCharacter>) => {
|
const storeCharacters = (list: Array<GridCharacter>) => {
|
||||||
list.forEach((object: GridCharacter) => {
|
// list.forEach((object: GridCharacter) => {
|
||||||
let character = clonedeep(object)
|
// let character = clonedeep(object)
|
||||||
|
// if (character.mastery.overMastery) {
|
||||||
if (character.mastery.overMastery) {
|
// const overMastery: CharacterOverMastery = {
|
||||||
const overMastery: CharacterOverMastery = {
|
// 1: object.mastery.overMastery[0],
|
||||||
1: object.mastery.overMastery[0],
|
// 2: object.mastery.overMastery[1],
|
||||||
2: object.mastery.overMastery[1],
|
// 3: object.mastery.overMastery[2],
|
||||||
3: object.mastery.overMastery[2],
|
// 4: object.mastery.overMastery[3],
|
||||||
4: object.mastery.overMastery[3],
|
// }
|
||||||
}
|
// character.mastery.overMastery = overMastery
|
||||||
|
// }
|
||||||
character.mastery.overMastery = overMastery
|
// if (character.position != null) {
|
||||||
}
|
// appState.grid.characters[object.position] = character
|
||||||
|
// }
|
||||||
if (character.position != null) {
|
// })
|
||||||
appState.grid.characters[object.position] = character
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeWeapons = (list: Array<GridWeapon>) => {
|
const storeWeapons = (
|
||||||
list.forEach((gridObject: GridWeapon) => {
|
allWeapons: Array<GridWeapon>,
|
||||||
if (gridObject.mainhand) {
|
mainWeapon?: GridWeapon
|
||||||
appState.grid.weapons.mainWeapon = gridObject
|
) => {
|
||||||
appState.party.element = gridObject.object.element
|
// appState.grid.weapons.mainWeapon = mainWeapon
|
||||||
} else if (!gridObject.mainhand && gridObject.position !== null) {
|
// list.forEach((gridObject: GridWeapon) => {
|
||||||
let weapon = clonedeep(gridObject)
|
// if (gridObject.mainhand) {
|
||||||
if (
|
// appState.grid.weapons.mainWeapon = gridObject
|
||||||
weapon.object.element === ElementMap.null &&
|
// appState.party.element = gridObject.object.element
|
||||||
weapon.element === ElementMap.null
|
// } else if (!gridObject.mainhand && gridObject.position !== null) {
|
||||||
)
|
// let weapon = clonedeep(gridObject)
|
||||||
weapon.element = gridObject.object.element
|
// if (
|
||||||
|
// weapon.object.element === ElementMap.null &&
|
||||||
appState.grid.weapons.allWeapons[gridObject.position] = weapon
|
// weapon.element === ElementMap.null
|
||||||
}
|
// )
|
||||||
})
|
// weapon.element = gridObject.object.element
|
||||||
|
// appState.grid.weapons.allWeapons[gridObject.position] = weapon
|
||||||
|
// }
|
||||||
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
const storeSummons = (list: Array<GridSummon>) => {
|
const storeSummons = (list: Array<GridSummon>) => {
|
||||||
list.forEach((gridObject: GridSummon) => {
|
// list.forEach((gridObject: GridSummon) => {
|
||||||
if (gridObject.main) appState.grid.summons.mainSummon = gridObject
|
// if (gridObject.main) appState.grid.summons.mainSummon = gridObject
|
||||||
else if (gridObject.friend)
|
// else if (gridObject.friend)
|
||||||
appState.grid.summons.friendSummon = gridObject
|
// appState.grid.summons.friendSummon = gridObject
|
||||||
else if (
|
// else if (
|
||||||
!gridObject.main &&
|
// !gridObject.main &&
|
||||||
!gridObject.friend &&
|
// !gridObject.friend &&
|
||||||
gridObject.position != null
|
// gridObject.position != null
|
||||||
)
|
// )
|
||||||
appState.grid.summons.allSummons[gridObject.position] = gridObject
|
// appState.grid.summons.allSummons[gridObject.position] = gridObject
|
||||||
})
|
// })
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Navigating with segmented control
|
// Methods: Navigating with segmented control
|
||||||
|
|
|
||||||
|
|
@ -31,12 +31,12 @@ const PartySegmentedControl = (props: Props) => {
|
||||||
// Set up translations
|
// Set up translations
|
||||||
const { t } = useTranslation('common')
|
const { t } = useTranslation('common')
|
||||||
|
|
||||||
const { party, grid } = useSnapshot(appState)
|
const { party } = useSnapshot(appState)
|
||||||
|
|
||||||
const getElement = () => {
|
const getElement = () => {
|
||||||
let element: GranblueElement
|
let element: GranblueElement
|
||||||
if (party.element === ElementMap.null && grid.weapons.mainWeapon)
|
if (party.element === ElementMap.null && party.grid.weapons.mainWeapon)
|
||||||
element = grid.weapons.mainWeapon.element
|
element = party.grid.weapons.mainWeapon?.element
|
||||||
else if (party.element) element = party.element
|
else if (party.element) element = party.element
|
||||||
else element = ElementMap.null
|
else element = ElementMap.null
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ const PartySegmentedControl = (props: Props) => {
|
||||||
gender={
|
gender={
|
||||||
accountState.account.user ? accountState.account.user.gender : 0
|
accountState.account.user ? accountState.account.user.gender : 0
|
||||||
}
|
}
|
||||||
grid={grid.characters}
|
grid={party.grid.characters}
|
||||||
/>
|
/>
|
||||||
</RepSegment>
|
</RepSegment>
|
||||||
)
|
)
|
||||||
|
|
@ -87,7 +87,7 @@ const PartySegmentedControl = (props: Props) => {
|
||||||
selected={props.selectedTab === GridType.Weapon}
|
selected={props.selectedTab === GridType.Weapon}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
>
|
>
|
||||||
<WeaponRep grid={grid.weapons} />
|
<WeaponRep grid={party.grid.weapons} />
|
||||||
</RepSegment>
|
</RepSegment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
@ -102,7 +102,7 @@ const PartySegmentedControl = (props: Props) => {
|
||||||
selected={props.selectedTab === GridType.Summon}
|
selected={props.selectedTab === GridType.Summon}
|
||||||
onClick={props.onClick}
|
onClick={props.onClick}
|
||||||
>
|
>
|
||||||
<SummonRep grid={grid.summons} />
|
<SummonRep grid={party.grid.summons} />
|
||||||
</RepSegment>
|
</RepSegment>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,8 +5,8 @@ import styles from './index.module.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
grid: {
|
grid: {
|
||||||
mainSummon: GridSummon | undefined
|
mainSummon?: GridSummon | undefined
|
||||||
friendSummon: GridSummon | undefined
|
friendSummon?: GridSummon | undefined
|
||||||
allSummons: GridArray<GridSummon>
|
allSummons: GridArray<GridSummon>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import styles from './index.module.scss'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
grid: {
|
grid: {
|
||||||
mainWeapon: GridWeapon | undefined
|
mainWeapon?: GridWeapon | undefined
|
||||||
allWeapons: GridArray<GridWeapon>
|
allWeapons: GridArray<GridWeapon>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ const SummonGrid = (props: Props) => {
|
||||||
const [errorAlertOpen, setErrorAlertOpen] = useState(false)
|
const [errorAlertOpen, setErrorAlertOpen] = useState(false)
|
||||||
|
|
||||||
// Set up state for view management
|
// Set up state for view management
|
||||||
const { party, grid } = useSnapshot(appState)
|
const { party } = useSnapshot(appState)
|
||||||
|
|
||||||
// Create a temporary state to store previous weapon uncap values and transcendence stages
|
// Create a temporary state to store previous weapon uncap values and transcendence stages
|
||||||
const [previousUncapValues, setPreviousUncapValues] = useState<{
|
const [previousUncapValues, setPreviousUncapValues] = useState<{
|
||||||
|
|
@ -64,13 +64,13 @@ const SummonGrid = (props: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let initialPreviousUncapValues: { [key: number]: number } = {}
|
let initialPreviousUncapValues: { [key: number]: number } = {}
|
||||||
|
|
||||||
if (appState.grid.summons.mainSummon)
|
if (appState.party.grid.summons.mainSummon)
|
||||||
initialPreviousUncapValues[-1] =
|
initialPreviousUncapValues[-1] =
|
||||||
appState.grid.summons.mainSummon.uncapLevel
|
appState.party.grid.summons.mainSummon.uncapLevel
|
||||||
|
|
||||||
if (appState.grid.summons.friendSummon)
|
if (appState.party.grid.summons.friendSummon)
|
||||||
initialPreviousUncapValues[6] =
|
initialPreviousUncapValues[6] =
|
||||||
appState.grid.summons.friendSummon.uncapLevel
|
appState.party.grid.summons.friendSummon.uncapLevel
|
||||||
|
|
||||||
Object.values(appState.party.grid.summons.allSummons).map((o) =>
|
Object.values(appState.party.grid.summons.allSummons).map((o) =>
|
||||||
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
||||||
|
|
@ -78,9 +78,9 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
setPreviousUncapValues(initialPreviousUncapValues)
|
setPreviousUncapValues(initialPreviousUncapValues)
|
||||||
}, [
|
}, [
|
||||||
appState.grid.summons.mainSummon,
|
appState.party.grid.summons.mainSummon,
|
||||||
appState.grid.summons.friendSummon,
|
appState.party.grid.summons.friendSummon,
|
||||||
appState.grid.summons.allSummons,
|
appState.party.grid.summons.allSummons,
|
||||||
])
|
])
|
||||||
|
|
||||||
// Methods: Adding an object from search
|
// Methods: Adding an object from search
|
||||||
|
|
@ -119,11 +119,11 @@ const SummonGrid = (props: Props) => {
|
||||||
const position = data.meta['replaced']
|
const position = data.meta['replaced']
|
||||||
|
|
||||||
if (position == -1) {
|
if (position == -1) {
|
||||||
appState.grid.summons.mainSummon = undefined
|
appState.party.grid.summons.mainSummon = undefined
|
||||||
} else if (position == 6) {
|
} else if (position == 6) {
|
||||||
appState.grid.summons.friendSummon = undefined
|
appState.party.grid.summons.friendSummon = undefined
|
||||||
} else {
|
} else {
|
||||||
appState.grid.summons.allSummons[position] = undefined
|
appState.party.grid.summons.allSummons[position] = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -147,10 +147,12 @@ const SummonGrid = (props: Props) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
function storeGridSummon(gridSummon: GridSummon) {
|
function storeGridSummon(gridSummon: GridSummon) {
|
||||||
if (gridSummon.position == -1) appState.grid.summons.mainSummon = gridSummon
|
if (gridSummon.position == -1)
|
||||||
|
appState.party.grid.summons.mainSummon = gridSummon
|
||||||
else if (gridSummon.position == 6)
|
else if (gridSummon.position == 6)
|
||||||
appState.grid.summons.friendSummon = gridSummon
|
appState.party.grid.summons.friendSummon = gridSummon
|
||||||
else appState.grid.summons.allSummons[gridSummon.position] = gridSummon
|
else
|
||||||
|
appState.party.grid.summons.allSummons[gridSummon.position] = gridSummon
|
||||||
}
|
}
|
||||||
|
|
||||||
// Methods: Updating uncap level
|
// Methods: Updating uncap level
|
||||||
|
|
@ -216,15 +218,15 @@ const SummonGrid = (props: Props) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
||||||
if (appState.grid.summons.mainSummon && position == -1)
|
if (appState.party.grid.summons.mainSummon && position == -1)
|
||||||
appState.grid.summons.mainSummon.uncapLevel = uncapLevel
|
appState.party.grid.summons.mainSummon.uncapLevel = uncapLevel
|
||||||
else if (appState.grid.summons.friendSummon && position == 6)
|
else if (appState.party.grid.summons.friendSummon && position == 6)
|
||||||
appState.grid.summons.friendSummon.uncapLevel = uncapLevel
|
appState.party.grid.summons.friendSummon.uncapLevel = uncapLevel
|
||||||
else {
|
else {
|
||||||
const summon = appState.grid.summons.allSummons[position]
|
const summon = appState.party.grid.summons.allSummons[position]
|
||||||
if (summon) {
|
if (summon) {
|
||||||
summon.uncapLevel = uncapLevel
|
summon.uncapLevel = uncapLevel
|
||||||
appState.grid.summons.allSummons[position] = summon
|
appState.party.grid.summons.allSummons[position] = summon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -233,13 +235,14 @@ const SummonGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (appState.grid.summons.mainSummon && position == -1)
|
if (appState.party.grid.summons.mainSummon && position == -1)
|
||||||
newPreviousValues[position] = appState.grid.summons.mainSummon.uncapLevel
|
|
||||||
else if (appState.grid.summons.friendSummon && position == 6)
|
|
||||||
newPreviousValues[position] =
|
newPreviousValues[position] =
|
||||||
appState.grid.summons.friendSummon.uncapLevel
|
appState.party.grid.summons.mainSummon.uncapLevel
|
||||||
|
else if (appState.party.grid.summons.friendSummon && position == 6)
|
||||||
|
newPreviousValues[position] =
|
||||||
|
appState.party.grid.summons.friendSummon.uncapLevel
|
||||||
else {
|
else {
|
||||||
const summon = appState.grid.summons.allSummons[position]
|
const summon = appState.party.grid.summons.allSummons[position]
|
||||||
newPreviousValues[position] = summon ? summon.uncapLevel : 0
|
newPreviousValues[position] = summon ? summon.uncapLevel : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -320,15 +323,15 @@ const SummonGrid = (props: Props) => {
|
||||||
)
|
)
|
||||||
|
|
||||||
const updateTranscendenceStage = (position: number, stage: number) => {
|
const updateTranscendenceStage = (position: number, stage: number) => {
|
||||||
if (appState.grid.summons.mainSummon && position == -1)
|
if (appState.party.grid.summons.mainSummon && position == -1)
|
||||||
appState.grid.summons.mainSummon.transcendenceStep = stage
|
appState.party.grid.summons.mainSummon.transcendenceStep = stage
|
||||||
else if (appState.grid.summons.friendSummon && position == 6)
|
else if (appState.party.grid.summons.friendSummon && position == 6)
|
||||||
appState.grid.summons.friendSummon.transcendenceStep = stage
|
appState.party.grid.summons.friendSummon.transcendenceStep = stage
|
||||||
else {
|
else {
|
||||||
const summon = appState.grid.summons.allSummons[position]
|
const summon = appState.party.grid.summons.allSummons[position]
|
||||||
if (summon) {
|
if (summon) {
|
||||||
summon.transcendenceStep = stage
|
summon.transcendenceStep = stage
|
||||||
appState.grid.summons.allSummons[position] = summon
|
appState.party.grid.summons.allSummons[position] = summon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -337,13 +340,14 @@ const SummonGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (appState.grid.summons.mainSummon && position == -1)
|
if (appState.party.grid.summons.mainSummon && position == -1)
|
||||||
newPreviousValues[position] = appState.grid.summons.mainSummon.uncapLevel
|
|
||||||
else if (appState.grid.summons.friendSummon && position == 6)
|
|
||||||
newPreviousValues[position] =
|
newPreviousValues[position] =
|
||||||
appState.grid.summons.friendSummon.uncapLevel
|
appState.party.grid.summons.mainSummon.uncapLevel
|
||||||
|
else if (appState.party.grid.summons.friendSummon && position == 6)
|
||||||
|
newPreviousValues[position] =
|
||||||
|
appState.party.grid.summons.friendSummon.uncapLevel
|
||||||
else {
|
else {
|
||||||
const summon = appState.grid.summons.allSummons[position]
|
const summon = appState.party.grid.summons.allSummons[position]
|
||||||
newPreviousValues[position] = summon ? summon.uncapLevel : 0
|
newPreviousValues[position] = summon ? summon.uncapLevel : 0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -356,11 +360,12 @@ const SummonGrid = (props: Props) => {
|
||||||
const data = response.data
|
const data = response.data
|
||||||
|
|
||||||
if (data.position === -1) {
|
if (data.position === -1) {
|
||||||
appState.grid.summons.mainSummon = undefined
|
appState.party.grid.summons.mainSummon = undefined
|
||||||
} else if (data.position === 6) {
|
} else if (data.position === 6) {
|
||||||
appState.grid.summons.friendSummon = undefined
|
appState.party.grid.summons.friendSummon = undefined
|
||||||
} else {
|
} else {
|
||||||
appState.grid.summons.allSummons[response.data.position] = undefined
|
appState.party.grid.summons.allSummons[response.data.position] =
|
||||||
|
undefined
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
@ -384,7 +389,7 @@ const SummonGrid = (props: Props) => {
|
||||||
<div className="LabeledUnit">
|
<div className="LabeledUnit">
|
||||||
<div className={styles.label}>{t('summons.main')}</div>
|
<div className={styles.label}>{t('summons.main')}</div>
|
||||||
<SummonUnit
|
<SummonUnit
|
||||||
gridSummon={grid.summons.mainSummon}
|
gridSummon={party.grid.summons.mainSummon}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
key="grid_main_summon"
|
key="grid_main_summon"
|
||||||
position={-1}
|
position={-1}
|
||||||
|
|
@ -408,7 +413,7 @@ const SummonGrid = (props: Props) => {
|
||||||
{t('summons.friend')}
|
{t('summons.friend')}
|
||||||
</div>
|
</div>
|
||||||
<SummonUnit
|
<SummonUnit
|
||||||
gridSummon={grid.summons.friendSummon}
|
gridSummon={party.grid.summons.friendSummon}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
key="grid_friend_summon"
|
key="grid_friend_summon"
|
||||||
position={6}
|
position={6}
|
||||||
|
|
@ -429,7 +434,7 @@ const SummonGrid = (props: Props) => {
|
||||||
return (
|
return (
|
||||||
<li key={`grid_unit_${i}`}>
|
<li key={`grid_unit_${i}`}>
|
||||||
<SummonUnit
|
<SummonUnit
|
||||||
gridSummon={grid.summons.allSummons[i]}
|
gridSummon={party.grid.summons.allSummons[i]}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
position={i}
|
position={i}
|
||||||
unitType={1}
|
unitType={1}
|
||||||
|
|
@ -447,7 +452,7 @@ const SummonGrid = (props: Props) => {
|
||||||
|
|
||||||
const subAuraSummonElement = (
|
const subAuraSummonElement = (
|
||||||
<ExtraSummonsGrid
|
<ExtraSummonsGrid
|
||||||
grid={grid.summons.allSummons}
|
grid={party.grid.summons.allSummons}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
exists={false}
|
exists={false}
|
||||||
offset={numSummons}
|
offset={numSummons}
|
||||||
|
|
|
||||||
|
|
@ -75,16 +75,19 @@ const WeaponGrid = (props: Props) => {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let initialPreviousUncapValues: { [key: number]: number } = {}
|
let initialPreviousUncapValues: { [key: number]: number } = {}
|
||||||
|
|
||||||
if (appState.grid.weapons.mainWeapon)
|
if (appState.party.grid.weapons.mainWeapon)
|
||||||
initialPreviousUncapValues[-1] =
|
initialPreviousUncapValues[-1] =
|
||||||
appState.grid.weapons.mainWeapon.uncapLevel
|
appState.party.grid.weapons.mainWeapon.uncapLevel
|
||||||
|
|
||||||
Object.values(appState.party.grid.weapons.allWeapons).map((o) =>
|
Object.values(appState.party.grid.weapons.allWeapons).map((o) =>
|
||||||
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
o ? (initialPreviousUncapValues[o.position] = o.uncapLevel) : 0
|
||||||
)
|
)
|
||||||
|
|
||||||
setPreviousUncapValues(initialPreviousUncapValues)
|
setPreviousUncapValues(initialPreviousUncapValues)
|
||||||
}, [appState.grid.weapons.mainWeapon, appState.grid.weapons.allWeapons])
|
}, [
|
||||||
|
appState.party.grid.weapons.mainWeapon,
|
||||||
|
appState.party.grid.weapons.allWeapons,
|
||||||
|
])
|
||||||
|
|
||||||
// Methods: Adding an object from search
|
// Methods: Adding an object from search
|
||||||
function receiveWeaponFromSearch(object: SearchableObject, position: number) {
|
function receiveWeaponFromSearch(object: SearchableObject, position: number) {
|
||||||
|
|
@ -147,10 +150,10 @@ const WeaponGrid = (props: Props) => {
|
||||||
const position = data.meta['replaced']
|
const position = data.meta['replaced']
|
||||||
|
|
||||||
if (position == -1) {
|
if (position == -1) {
|
||||||
appState.grid.weapons.mainWeapon = undefined
|
appState.party.grid.weapons.mainWeapon = undefined
|
||||||
appState.party.element = ElementMap.null
|
appState.party.element = ElementMap.null
|
||||||
} else {
|
} else {
|
||||||
appState.grid.weapons.allWeapons[position] = undefined
|
appState.party.grid.weapons.allWeapons[position] = undefined
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,16 +167,17 @@ const WeaponGrid = (props: Props) => {
|
||||||
let post = false
|
let post = false
|
||||||
if (
|
if (
|
||||||
position === -1 &&
|
position === -1 &&
|
||||||
(!appState.grid.weapons.mainWeapon ||
|
(!appState.party.grid.weapons.mainWeapon ||
|
||||||
(appState.grid.weapons.mainWeapon &&
|
(appState.party.grid.weapons.mainWeapon &&
|
||||||
appState.grid.weapons.mainWeapon.object.id !== weapon.id))
|
appState.party.grid.weapons.mainWeapon.object.id !== weapon.id))
|
||||||
) {
|
) {
|
||||||
post = true
|
post = true
|
||||||
} else if (
|
} else if (
|
||||||
position !== -1 &&
|
position !== -1 &&
|
||||||
(!appState.grid.weapons.allWeapons[position] ||
|
(!appState.party.grid.weapons.allWeapons[position] ||
|
||||||
(appState.grid.weapons.allWeapons[position] &&
|
(appState.party.grid.weapons.allWeapons[position] &&
|
||||||
appState.grid.weapons.allWeapons[position]?.object.id !== weapon.id))
|
appState.party.grid.weapons.allWeapons[position]?.object.id !==
|
||||||
|
weapon.id))
|
||||||
) {
|
) {
|
||||||
post = true
|
post = true
|
||||||
}
|
}
|
||||||
|
|
@ -193,11 +197,11 @@ const WeaponGrid = (props: Props) => {
|
||||||
|
|
||||||
function storeGridWeapon(gridWeapon: GridWeapon) {
|
function storeGridWeapon(gridWeapon: GridWeapon) {
|
||||||
if (gridWeapon.position === -1) {
|
if (gridWeapon.position === -1) {
|
||||||
appState.grid.weapons.mainWeapon = gridWeapon
|
appState.party.grid.weapons.mainWeapon = gridWeapon
|
||||||
appState.party.element = gridWeapon.object.element
|
appState.party.element = gridWeapon.object.element
|
||||||
} else {
|
} else {
|
||||||
// Store the grid unit at the correct position
|
// Store the grid unit at the correct position
|
||||||
appState.grid.weapons.allWeapons[gridWeapon.position] = gridWeapon
|
appState.party.grid.weapons.allWeapons[gridWeapon.position] = gridWeapon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -213,11 +217,13 @@ const WeaponGrid = (props: Props) => {
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
// Remove conflicting characters from state
|
// Remove conflicting characters from state
|
||||||
conflicts.forEach((c) => {
|
conflicts.forEach((c) => {
|
||||||
if (appState.grid.weapons.mainWeapon?.object.id === c.object.id) {
|
if (
|
||||||
appState.grid.weapons.mainWeapon = undefined
|
appState.party.grid.weapons.mainWeapon?.object.id === c.object.id
|
||||||
|
) {
|
||||||
|
appState.party.grid.weapons.mainWeapon = undefined
|
||||||
appState.party.element = ElementMap.null
|
appState.party.element = ElementMap.null
|
||||||
} else {
|
} else {
|
||||||
appState.grid.weapons.allWeapons[c.position] = undefined
|
appState.party.grid.weapons.allWeapons[c.position] = undefined
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
@ -245,9 +251,10 @@ const WeaponGrid = (props: Props) => {
|
||||||
const data = response.data
|
const data = response.data
|
||||||
|
|
||||||
if (data.position === -1) {
|
if (data.position === -1) {
|
||||||
appState.grid.weapons.mainWeapon = undefined
|
appState.party.grid.weapons.mainWeapon = undefined
|
||||||
} else {
|
} else {
|
||||||
appState.grid.weapons.allWeapons[response.data.position] = undefined
|
appState.party.grid.weapons.allWeapons[response.data.position] =
|
||||||
|
undefined
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error)
|
console.error(error)
|
||||||
|
|
@ -311,13 +318,13 @@ const WeaponGrid = (props: Props) => {
|
||||||
|
|
||||||
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
const updateUncapLevel = (position: number, uncapLevel: number) => {
|
||||||
// console.log(`Updating uncap level at position ${position} to ${uncapLevel}`)
|
// console.log(`Updating uncap level at position ${position} to ${uncapLevel}`)
|
||||||
if (appState.grid.weapons.mainWeapon && position == -1)
|
if (appState.party.grid.weapons.mainWeapon && position == -1)
|
||||||
appState.grid.weapons.mainWeapon.uncapLevel = uncapLevel
|
appState.party.grid.weapons.mainWeapon.uncapLevel = uncapLevel
|
||||||
else {
|
else {
|
||||||
const weapon = appState.grid.weapons.allWeapons[position]
|
const weapon = appState.party.grid.weapons.allWeapons[position]
|
||||||
if (weapon) {
|
if (weapon) {
|
||||||
weapon.uncapLevel = uncapLevel
|
weapon.uncapLevel = uncapLevel
|
||||||
appState.grid.weapons.allWeapons[position] = weapon
|
appState.party.grid.weapons.allWeapons[position] = weapon
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -326,10 +333,11 @@ const WeaponGrid = (props: Props) => {
|
||||||
// Save the current value in case of an unexpected result
|
// Save the current value in case of an unexpected result
|
||||||
let newPreviousValues = { ...previousUncapValues }
|
let newPreviousValues = { ...previousUncapValues }
|
||||||
|
|
||||||
if (appState.grid.weapons.mainWeapon && position == -1) {
|
if (appState.party.grid.weapons.mainWeapon && position == -1) {
|
||||||
newPreviousValues[position] = appState.grid.weapons.mainWeapon.uncapLevel
|
newPreviousValues[position] =
|
||||||
|
appState.party.grid.weapons.mainWeapon.uncapLevel
|
||||||
} else {
|
} else {
|
||||||
const weapon = appState.grid.weapons.allWeapons[position]
|
const weapon = appState.party.grid.weapons.allWeapons[position]
|
||||||
if (weapon) {
|
if (weapon) {
|
||||||
newPreviousValues[position] = weapon.uncapLevel
|
newPreviousValues[position] = weapon.uncapLevel
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -349,7 +357,7 @@ const WeaponGrid = (props: Props) => {
|
||||||
// Render: JSX components
|
// Render: JSX components
|
||||||
const mainhandElement = (
|
const mainhandElement = (
|
||||||
<WeaponUnit
|
<WeaponUnit
|
||||||
gridWeapon={appState.grid.weapons.mainWeapon}
|
gridWeapon={appState.party.grid.weapons.mainWeapon}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
key="grid_mainhand"
|
key="grid_mainhand"
|
||||||
position={-1}
|
position={-1}
|
||||||
|
|
@ -362,13 +370,13 @@ const WeaponGrid = (props: Props) => {
|
||||||
|
|
||||||
const weaponGridElement = Array.from(Array(numWeapons)).map((x, i) => {
|
const weaponGridElement = Array.from(Array(numWeapons)).map((x, i) => {
|
||||||
const itemClasses = classNames({
|
const itemClasses = classNames({
|
||||||
Empty: appState.grid.weapons.allWeapons[i] === undefined,
|
Empty: appState.party.grid.weapons.allWeapons[i] === undefined,
|
||||||
})
|
})
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<li className={itemClasses} key={`grid_unit_${i}`}>
|
<li className={itemClasses} key={`grid_unit_${i}`}>
|
||||||
<WeaponUnit
|
<WeaponUnit
|
||||||
gridWeapon={appState.grid.weapons.allWeapons[i]}
|
gridWeapon={appState.party.grid.weapons.allWeapons[i]}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
position={i}
|
position={i}
|
||||||
unitType={1}
|
unitType={1}
|
||||||
|
|
@ -381,13 +389,13 @@ const WeaponGrid = (props: Props) => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const extraElement = () => {
|
const extraElement = () => {
|
||||||
if (appState.party.raid && appState.party.raid.group.extra) {
|
if (appState.party.raid && appState.party.raid.group?.extra) {
|
||||||
return (
|
return (
|
||||||
<ExtraContainer>
|
<ExtraContainer>
|
||||||
<ExtraContainerItem title={t('extra_weapons')} className="weapons">
|
<ExtraContainerItem title={t('extra_weapons')} className="weapons">
|
||||||
{appState.party.raid && appState.party.raid.group.extra && (
|
{appState.party.raid && appState.party.raid.group.extra && (
|
||||||
<ExtraWeaponsGrid
|
<ExtraWeaponsGrid
|
||||||
grid={appState.grid.weapons.allWeapons}
|
grid={appState.party.grid.weapons.allWeapons}
|
||||||
editable={props.editable}
|
editable={props.editable}
|
||||||
offset={numWeapons}
|
offset={numWeapons}
|
||||||
removeWeapon={removeWeapon}
|
removeWeapon={removeWeapon}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue