Skip to content

Commit

Permalink
Merge pull request #332 from jeremyckahn/feature/halloween-background
Browse files Browse the repository at this point in the history
feat: Halloween background 🎃
  • Loading branch information
jeremyckahn authored Oct 7, 2022
2 parents 2afb478 + 6f26a86 commit 627be40
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 13 deletions.
18 changes: 7 additions & 11 deletions src/components/Stage/Stage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useEffect, useRef } from 'react'
import { array, arrayOf, bool, string } from 'prop-types'
import classNames from 'classnames'
import { array, arrayOf, string } from 'prop-types'

import FarmhandContext from '../Farmhand/Farmhand.context'
import Field from '../Field'
Expand All @@ -8,16 +9,11 @@ import CowPen from '../CowPen'
import Shop from '../Shop'
import Workshop from '../Workshop'
import { stageFocusType } from '../../enums'
import { isOctober } from '../../utils'

import './Stage.sass'

export const Stage = ({
field,
isMenuOpen,
playerInventory,
stageFocus,
viewTitle,
}) => {
export const Stage = ({ field, stageFocus, viewTitle }) => {
const ref = useRef(null)

useEffect(() => {
Expand All @@ -36,7 +32,9 @@ export const Stage = ({
return (
<div
{...{
className: 'Stage',
className: classNames('Stage', {
'is-october': isOctober(),
}),
'data-stage-focus': stageFocus,
role: 'main',
ref,
Expand All @@ -62,8 +60,6 @@ export const Stage = ({

Stage.propTypes = {
field: arrayOf(array).isRequired,
isMenuOpen: bool.isRequired,
playerInventory: array.isRequired,
stageFocus: string.isRequired,
viewTitle: string.isRequired,
}
Expand Down
3 changes: 3 additions & 0 deletions src/components/Stage/Stage.sass
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@
&[data-stage-focus=HOME]
background-image: url('../../img/ui/brown-dot-bg.png')

&.is-october
background-image: url('../../img/ui/jack-o-lantern-bg.png')

&[data-stage-focus=SHOP]
background-image: url('../../img/ui/yellow-dot-bg.png')

Expand Down
2 changes: 0 additions & 2 deletions src/components/Stage/Stage.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@ beforeEach(() => {
<Stage
{...{
field: [[]],
isMenuOpen: true,
playerInventory: [],
stageFocus: stageFocusType.FIELD,
viewTitle: '',
}}
Expand Down
1 change: 1 addition & 0 deletions src/img/ui/jack-o-lantern-bg.piskel
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"modelVersion":2,"piskel":{"name":"jack-o-lantern-bg","description":"","fps":12,"height":30,"width":32,"layers":["{\"name\":\"Base\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAeCAYAAABNChwpAAAAMElEQVRYR+3QQREAAAjDMCYQw5gDGXxSBb1kp7ceiwECBAgQIECAAAECBAgQIPAtcM1dWrXZuNiZAAAAAElFTkSuQmCC\"}]}","{\"name\":\"Pattern\",\"opacity\":1,\"frameCount\":1,\"chunks\":[{\"layout\":[[0]],\"base64PNG\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAeCAYAAABNChwpAAAA4klEQVRYR+2VMQ6DMAxFw2k6MTCx9yY9GTfp3omhE6dp5cGVCaF2rG9ZqpoJOYb/7Jj8oSSvIVm/qADbcn0R5OV2V3M9xXz9aLQ4AR8ApOjZs6fSs3d2ACyoCSCP4wMgxZ/ro4zTvOOoYyiIAwAJ8WKIViwMQGs/74cCpB4BVyjbTrF6JuAdIJHUv4ArlxBcZStmnRUtL+R61UTl/h/g9zugOWpoBzTxph33THArt9fOoR3wXGQwAK+dwwF67RwOYJ0hvuZDAHrsPASAumC1cxiA186hADWExc7hANYh5Lx0gDd/7JofAE1pxwAAAABJRU5ErkJggg==\"}]}"]}}
Binary file added src/img/ui/jack-o-lantern-bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -1286,5 +1286,10 @@ export const shouldStormToday = () => Math.random() < STORM_CHANCE
export const isCowInBreedingPen = (cow, cowBreedingPen) =>
cowBreedingPen.cowId1 === cow.id || cowBreedingPen.cowId2 === cow.id

/**
* @returns {boolean}
*/
export const isOctober = () => new Date().getMonth() === 9

export { default as isRandomNumberLessThan } from './utils/isRandomNumberLessThan'
export { default as totalIngredientsInRecipe } from './utils/totalIngredientsInRecipe'

0 comments on commit 627be40

Please sign in to comment.