Skip to content

Commit

Permalink
further reduced needless complexity of reflex check state
Browse files Browse the repository at this point in the history
  • Loading branch information
dan-atack committed Oct 21, 2021
1 parent 454eff3 commit dc0a872
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const CombatEnvironment = () => {

// Player Attack Data (damage and such) is fetched based on the ID of the 'move' fed to the Reflex Check component:
const [reflexCheck, setReflexCheck] = useRecoilState(combatState.reflexCheck);
const playerAttackData = playerMoveData.find((move) => move.id === reflexCheck.reflexCheckId); // Hacky but effective!

// Baddie Related State Values:
const [baddieHP, setBaddieHP] = useRecoilState(combatState.baddieHP);
Expand Down Expand Up @@ -209,7 +208,7 @@ const CombatEnvironment = () => {
const playerAttack = (x, y) => {
setPlayerAttackRadius([]); // Clear player attack radius once attack is selected.
if (baddieCoords.x === x && baddieCoords.y === y) {
setReflexCheck({...reflexCheck, isReflexCheck: true}); // If the player hits the baddie, begin a reflex check but don't advance combat round.
setReflexCheck(true); // If the player hits the baddie, begin a reflex check but don't advance combat round.
} else { // Otherwise, advance the combat round:
setCombatPhase('specialEvent')
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const CombatUi = ({turn, setEnemyAttackRadius}) => {
// This handles the clicking of any skill button, generated by the map function.
const handleClick = async (skill, cost) => {
if (!playerIsDead && combatPhase === 'playerAction') { // Skill can only be used if player is alive and it's their action phase
setReflexCheck({...reflexCheck, reflexCheckId : skill.id})
setSelectedSkill(skill);
setEnemyAttackRadius([])
setPlayerAttackSelecting(determineThrowOrTravel(skill))
Expand All @@ -70,12 +69,12 @@ const CombatUi = ({turn, setEnemyAttackRadius}) => {
<div className="Combat-UI">
{playerIsDead && <ResetButton />}
{combatPhase === 'victory' && <VictoryButton />}
{reflexCheck.isReflexCheck &&
{reflexCheck &&
<ReflexCheck
combo={randomCombo}
style={{ position: 'absolute', top: '0px', right: '50px' }}
/>}
<AttackAddMove/>
{playerAttackSelecting === 'doneSelecting' && <AttackAddMove/>}
<HealthHud src={healthbar}/>
<SkillHud src={skillborder}/>
<Wrapper>
Expand Down
4 changes: 2 additions & 2 deletions client/src/components/Game/ReflexCheck/ReflexCheck.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ function ReflexCheck({ combo }) {
const attackAnimationDelay = playerMovesInQueue.length * 1000; // TODO: consider making this depend on what the last attack in the queue was, to allow for more time for a more dramatic animation for the final move or for specific 'ultimate' moves.
// Firing alongside the regular attackSuccess function, this function introduces a longer delay and then advances the combat phase:
advanceCombatSequence(attackAnimationDelay, 'specialEvent', setCombatPhase);
setReflexCheck({...reflexCheck, isReflexCheck: false})
setReflexCheck(false);
}

// What happens if you are NOT on the last combo in the queue:
Expand Down Expand Up @@ -130,7 +130,7 @@ function ReflexCheck({ combo }) {
if (failStatus) {
setTimeString('00:00.00');
setCombatPhase('specialEvent');
setReflexCheck({...reflexCheck, isReflexCheck: false})
setReflexCheck(false);
}
// This whole effect will only fire until you have either failed or succeeded:
if (!failStatus && !successStatus) {
Expand Down
9 changes: 3 additions & 6 deletions client/src/state/combatState.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export const playerStatus = atom({
export const playerAttackSelecting = atom({
// Answers the question 'which part of their attack is the player configuring?'
key: 'playerAttackSelecting',
default: 'notSelecting' // Other EXPECTED values are: 'travelDestination', 'attackTarget', 'throwDestination' and 'selectingAttack' which represents the very start of the player action phase, as well as when the player has chosen to add an additional attack.
default: 'notSelecting' // Other EXPECTED values are: 'travelDestination', 'attackTarget', 'throwDestination' and 'selectingAttack' which represents the very start of the player action phase, as well as when the player has chosen to add an additional attack, and finally 'doneSelecting' for after an attack selection is finished.
})

// Baddie-Related Variables:
Expand Down Expand Up @@ -120,9 +120,6 @@ export const combatPhase = atom({
})

export const reflexCheck = atom ({
key: '',
default: {
isReflexCheck: false,
reflexCheckId: null,
},
key: 'reflexCheck',
default: false,
})

0 comments on commit dc0a872

Please sign in to comment.