Skip to content

Commit

Permalink
fix: [#385] allow any eligible cow to be moved to breeding pen
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Jan 28, 2023
1 parent da43b44 commit 274281b
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/components/CowCard/Subheader/Subheader.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,28 +46,22 @@ const Subheader = ({
handleCowAutomaticHugChange,
handleCowBreedChange,
huggingMachinesRemain,
id,
id, // Player ID, not cow ID
isCowPurchased,
}) => {
const numberOfFullHearts = cow.happiness * 10
const isInBreedingPen = isCowInBreedingPen(cow, cowBreedingPen)
const isBreedingPenFull =
cowBreedingPen.cowId1 !== null && cowBreedingPen.cowId2 !== null
const isRoomInBreedingPen =
cowBreedingPen.cowId1 === null || cowBreedingPen.cowId2 === null
const isThisCowOfferedForTrade = cowIdOfferedForTrade === cow.id

const isCowOfferedForTrade = !!cowInventory.find(
({ id }) => id === cowIdOfferedForTrade
)

let canBeMovedToBreedingPen = !isBreedingPenFull && !isCowOfferedForTrade
const mateId = cowBreedingPen.cowId1 ?? cowBreedingPen.cowId2
const mate = getCowMapById(cowInventory)[mateId]

if (canBeMovedToBreedingPen) {
const potentialMateId = cowBreedingPen.cowId2 ?? cowBreedingPen.cowId1
const isEligibleToBreed =
(!mate || cow.gender !== mate.gender) && !isThisCowOfferedForTrade

if (potentialMateId !== null) {
canBeMovedToBreedingPen =
cow.gender !== getCowMapById(cowInventory)[potentialMateId].gender
}
}
const canBeMovedToBreedingPen = isRoomInBreedingPen && isEligibleToBreed

const disableBreedingControlTooltip =
!canBeMovedToBreedingPen && !isInBreedingPen
Expand Down

0 comments on commit 274281b

Please sign in to comment.