-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: make ResourceFactory private static variables fully private * feat: add salt rock art * feat: implement Salt Rock mining * feat: make ore respawn logic more challenging * refactor: improve ore code typing * refactor: improve factory types * fix: remove Twitter links - Badgen no longer supports Twitter badges. * docs: explain interface system * feat: add salt art * feat: improve salt rock art * feat: add salt recipe * feat: add salt to various recipes * test: improve expectation for minePlot * refactor(StoneFactory): simplify generate method * refactor(file naming): rename salt-rock.js to saltRock.js
- Loading branch information
1 parent
d214631
commit 9e626f9
Showing
28 changed files
with
165 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/** @typedef {import("../../index").farmhand.item} farmhand.item */ | ||
import { itemType } from '../../enums' | ||
import { SALT_ROCK_SPAWN_CHANCE } from '../../constants' | ||
|
||
const { freeze } = Object | ||
|
||
/** | ||
* @property farmhand.module:items.saltRock | ||
* @type {farmhand.item} | ||
*/ | ||
export const saltRock = freeze({ | ||
description: 'A large chunk of salt.', | ||
doesPriceFluctuate: true, | ||
id: 'salt-rock', | ||
name: 'Salt Rock', | ||
spawnChance: SALT_ROCK_SPAWN_CHANCE, | ||
type: itemType.STONE, | ||
value: 10, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,37 @@ | ||
import { coal, stone } from '../data/ores' | ||
import { COAL_SPAWN_CHANCE } from '../constants' | ||
/** @typedef {import("../index").farmhand.item} farmhand.item */ | ||
import { randomNumberService } from '../common/services/randomNumber' | ||
import { Factory } from '../interfaces/Factory' | ||
import { coal, saltRock, stone } from '../data/ores' | ||
import { | ||
COAL_SPAWN_CHANCE, | ||
SALT_ROCK_SPAWN_CHANCE, | ||
STONE_SPAWN_CHANCE, | ||
} from '../constants' | ||
|
||
const spawnableResources = [ | ||
[stone, STONE_SPAWN_CHANCE], | ||
[saltRock, SALT_ROCK_SPAWN_CHANCE], | ||
[coal, COAL_SPAWN_CHANCE], | ||
] | ||
|
||
/** | ||
* Resource factory used for spawning stone | ||
* @constructor | ||
*/ | ||
export default class StoneFactory { | ||
export default class StoneFactory extends Factory { | ||
/** | ||
* Generate resources | ||
* @returns {Array} an array of stone and coal resources | ||
* @returns {Array.<farmhand.item>} an array of stone and coal resources | ||
*/ | ||
generate() { | ||
let resources = [] | ||
|
||
resources.push(this.spawnStone()) | ||
|
||
if (randomNumberService.isRandomNumberLessThan(COAL_SPAWN_CHANCE)) { | ||
resources.push(this.spawnCoal()) | ||
for (const [resource, spawnChance] of spawnableResources) { | ||
if (randomNumberService.isRandomNumberLessThan(spawnChance)) { | ||
resources.push(resource) | ||
} | ||
} | ||
|
||
return resources | ||
} | ||
|
||
/** | ||
* Spawn a piece of stone | ||
* @returns {Object} stone item | ||
* @private | ||
*/ | ||
spawnStone() { | ||
return stone | ||
} | ||
|
||
/** | ||
* Spawn a piece of coal | ||
* @returns {Object} coal item | ||
* @private | ||
*/ | ||
spawnCoal() { | ||
return coal | ||
} | ||
} |
Oops, something went wrong.