Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: house icon, not home anymore #181

Merged
merged 3 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
"dbaeumer.vscode-eslint",
"svelte.svelte-vscode",
"ms-azuretools.vscode-docker",
"vitest.explorer"
"vitest.explorer",
"Codeium.codeium"
]
}
},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"@twurple/auth": "^7.1.0",
"howler": "^2.2.4",
"jsonwebtoken": "^9.0.2",
"lucide-svelte": "^0.395.0",
"lucide-svelte": "^0.396.0",
"pixi.js": "^8.1.8"
},
"devDependencies": {
Expand Down
42 changes: 18 additions & 24 deletions src/lib/utils/__tests__/date.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,72 +3,66 @@ import { getDateMinusMinutes, getDatePlusMinutes, getDatePlusSeconds } from '$li

describe('getDatePlusMinutes()', () => {
it('returns the current date and time plus the specified minutes', () => {
const now = new Date()
const minutesToAdd = 5
const result = getDatePlusMinutes(minutesToAdd)
const expected = new Date(now.getTime() + minutesToAdd * 60 * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() + minutesToAdd * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero minutes', () => {
const now = new Date()
const result = getDatePlusMinutes(0)
expect(result.getTime()).toBeCloseTo(now.getTime(), 2)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative minutes', () => {
const now = new Date()
const minutesToAdd = -5
const result = getDatePlusMinutes(minutesToAdd)
const expected = new Date(now.getTime() + minutesToAdd * 60 * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() + minutesToAdd * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})

describe('getDateMinusMinutes()', () => {
it('returns the current date and time minus the specified minutes', () => {
const now = new Date()
const minutesToSubtract = 5
const result = getDateMinusMinutes(minutesToSubtract)
const expected = new Date(now.getTime() - minutesToSubtract * 60 * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() - minutesToSubtract * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero minutes', () => {
const now = new Date()
const result = getDateMinusMinutes(0)
expect(result.getTime()).toBeCloseTo(now.getTime(), 2)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative minutes', () => {
const now = new Date()
const minutesToSubtract = -5
const result = getDateMinusMinutes(minutesToSubtract)
const expected = new Date(now.getTime() - minutesToSubtract * 60 * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() - minutesToSubtract * 60 * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})

describe('getDatePlusSeconds()', () => {
it('returns the current date and time plus the specified seconds', () => {
const now = new Date()
const secondsToAdd = 5
const result = getDatePlusSeconds(secondsToAdd)
const expected = new Date(now.getTime() + secondsToAdd * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() + secondsToAdd * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of zero seconds', () => {
const now = new Date()
const result = getDatePlusSeconds(0)
expect(result.getTime()).toBeCloseTo(now.getTime(), 2)
const expected = new Date()
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})

it('handles the edge case of negative seconds', () => {
const now = new Date()
const secondsToAdd = -5
const result = getDatePlusSeconds(secondsToAdd)
const expected = new Date(now.getTime() + secondsToAdd * 1000)
expect(result.getTime()).toBeCloseTo(expected.getTime(), 2)
const expected = new Date(Date.now() + secondsToAdd * 1000)
expect(expected.getTime() - result.getTime()).toBeLessThanOrEqual(1)
})
})
13 changes: 6 additions & 7 deletions src/lib/utils/date.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
export function getDatePlusMinutes(minutes: number): Date {
const milliseconds = minutes * 60 * 1000
return new Date(new Date().getTime() + milliseconds)
export function getDatePlusMinutes(minuteOffset: number): Date {
const millisecondOffset = minuteOffset * 60 * 1000
return new Date(Date.now() + millisecondOffset)
}

export function getDateMinusMinutes(minutes: number): Date {
const milliseconds = minutes * 60 * 1000
return new Date(new Date().getTime() - milliseconds)
const millisecondsOffset = minutes * 60 * 1000
return new Date(Date.now() - millisecondsOffset)
}

export function getDatePlusSeconds(seconds: number): Date {
const milliseconds = seconds * 1000
return new Date(new Date().getTime() + milliseconds)
return new Date(Date.now() + seconds * 1000)
}
4 changes: 2 additions & 2 deletions src/routes/[lang]/(game)/play/GameChunkInfo.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang='ts'>
import Home from 'lucide-svelte/icons/home'
import House from 'lucide-svelte/icons/house'
import TreeDeciduous from 'lucide-svelte/icons/tree-deciduous'
import Waves from 'lucide-svelte/icons/waves'
import type { GameChunk } from '$lib/game/services/chunk/interface'
Expand All @@ -10,7 +10,7 @@

<div class='block'>
{#if type === 'VILLAGE'}
<Home />
<House />
{:else if type === 'FOREST'}
<TreeDeciduous />
{:else if type === 'LAKE'}
Expand Down
39 changes: 7 additions & 32 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3863,10 +3863,10 @@ lru-cache@^10.2.0:
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-10.2.2.tgz#48206bc114c1252940c41b25b41af5b545aca878"
integrity sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==

lucide-svelte@^0.395.0:
version "0.395.0"
resolved "https://registry.yarnpkg.com/lucide-svelte/-/lucide-svelte-0.395.0.tgz#e7383add33725b68a79c7ac375cb8a76247866ed"
integrity sha512-gl4HIIGUyj3seZf/CQ6vG38oMnNmdO1lcBQaMsB5pFpnL1T13qlfqjMjfTCnsKMFjiIFr3LttE/LFVi/GXmV0A==
lucide-svelte@^0.396.0:
version "0.396.0"
resolved "https://registry.yarnpkg.com/lucide-svelte/-/lucide-svelte-0.396.0.tgz#8ad40f5e75112d44f2dcb79526303b5b3facb95b"
integrity sha512-0oU3ZwQYzlFB1VyXcCRn1/cTsA+J7d+6MTC9t8lyIz12l0Rcrnoq0LUrGjX1I3r14uwSGrNDUTkdRdrHsl8L1Q==

lz-string@^1.5.0:
version "1.5.0"
Expand Down Expand Up @@ -5063,16 +5063,7 @@ string-argv@^0.3.1, string-argv@~0.3.2:
resolved "https://registry.yarnpkg.com/string-argv/-/string-argv-0.3.2.tgz#2b6d0ef24b656274d957d54e0a4bbf6153dc02b6"
integrity sha512-aqD2Q0144Z+/RqG52NeHEkZauTAUWJO8c6yTftGJKO3Tja5tUgIfmIl6kExvhtxSDP7fXB6DvzkfMpCd/F3G+Q==

"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -5115,14 +5106,7 @@ stringify-object@^3.2.1:
is-obj "^1.0.1"
is-regexp "^1.0.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -5642,16 +5626,7 @@ word-wrap@^1.2.5:
resolved "https://registry.yarnpkg.com/word-wrap/-/word-wrap-1.2.5.tgz#d2c45c6dd4fbce621a66f136cbe328afd0410b34"
integrity sha512-BN22B5eaMMI9UMtjrGd5g5eCYPpCPDUy0FJXbYsaT5zYxjFOckS53SQDE3pWkVoWpHXVb3BrYcEN4Twa55B5cA==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down
Loading