Skip to content

Commit

Permalink
refactor(types): [wip] define stub context values
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyckahn committed Dec 14, 2024
1 parent 7e99a12 commit a136ba9
Showing 1 changed file with 96 additions and 2 deletions.
98 changes: 96 additions & 2 deletions src/components/Farmhand/Farmhand.context.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { createContext } from 'react'

// eslint-disable-next-line no-unused-vars
import uiEventHandlers from '../../handlers/ui-events.js'
import { generateCow } from '../../utils/index.js'

/**
* @type {import('react').Context<{
Expand All @@ -26,9 +27,102 @@ import uiEventHandlers from '../../handlers/ui-events.js'
* handlers: uiEventHandlers & { debounced: uiEventHandlers }
* }>}
*/
// @ts-expect-error
const FarmhandContext = createContext({
gameState: {},
/** @type {farmhand.state} */
gameState: {
activePlayers: null,
allowCustomPeerCowNames: false,
cellarInventory: [],
currentDialogView: '',
completedAchievements: {},
cowForSale: generateCow(),
cowBreedingPen: {
cowId1: null,
cowId2: null,
daysUntilBirth: 0,
},
cowInventory: [],
cowColorsPurchased: {},
cowIdOfferedForTrade: '',
cowsSold: {},
cowsTraded: 0,
cowTradeTimeoutId: null,
cropsHarvested: {},
dayCount: 0,
experience: 0,
farmName: '',
field: [[]],
forest: [[]],
fieldMode: 'default',
getCowAccept: () => {},
getCowReject: () => {},
getCowTradeRequest: () => {},
getPeerMetadata: () => {},
hasBooted: true,
heartbeatTimeoutId: null,
historicalDailyLosses: [],
historicalDailyRevenue: [],
historicalValueAdjustments: [], // empty array for now
hoveredPlotRangeSize: 0,
id: '',
inventory: [{ id: '', quantity: 0 }],
inventoryLimit: -1,
isAwaitingCowTradeRequest: false,
isAwaitingNetworkRequest: false,
isCombineEnabled: true,
isMenuOpen: false,
itemsSold: {},
cellarItemsSold: {},
isChatOpen: false,
isDialogViewOpen: false,
isOnline: true,
isWaitingForDayToCompleteIncrementing: false,
learnedRecipes: {},
loanBalance: 0,
loansTakenOut: 0,
money: 0,
latestNotification: null,
newDayNotifications: [],
notificationLog: [],
peers: {}, // empty object for now
peerRoom: null,
pendingPeerMessages: [],
latestPeerMessages: [],
sendCowAccept: () => {},
sendCowReject: () => {},
sendCowTradeRequest: () => {},
sendPeerMetadata: () => {},
selectedCowId: '',
selectedItemId: '',
priceCrashes: {},
priceSurges: {},
purchasedCombine: 0,
purchasedComposter: 0,
purchasedCowPen: 0,
purchasedCellar: 0,
purchasedField: 0,
purchasedForest: 0,
purchasedSmelter: 0,
profitabilityStreak: 0,
record7dayProfitAverage: 0,
recordProfitabilityStreak: 0,
recordSingleDayProfit: 0,
revenue: 0,
redirect: '',
room: '',
showHomeScreen: true,
showNotifications: true,
stageFocus: 'default',
todaysLosses: -0.01, // always negative
todaysPurchases: {},
todaysRevenue: 10.01, // always positive
todaysStartingInventory: {},
toolLevels: {}, // empty object for now
valueAdjustments: {},
version: '1.0.0',
todaysNotifications: [],
useAlternateEndDayButtonPosition: false,
},
handlers: {},
})

Expand Down

0 comments on commit a136ba9

Please sign in to comment.