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