Skip to content

Commit

Permalink
fix(core): errors on loading empty game and trying to migrate items
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Feb 23, 2023
1 parent 6ab283e commit b7cc657
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/stores/charselect/charselect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ export class CharSelectState {
@Action(UpdateAllItems)
async updateAllItems(ctx: StateContext<ICharSelect>) {
const state = ctx.getState();
const characters = state.characters.map(char => {
const characters = (state.characters || []).map(char => {
if(!char) {
return;
}

const inventory = char.inventory.map((oldItem) => {
const inventory = (char.inventory || []).map((oldItem) => {

// can't migrate an item with no id
if(!oldItem.internalId) {
Expand Down
2 changes: 1 addition & 1 deletion src/stores/combat/combat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export class CombatState {
async updateAllItems(ctx: StateContext<IGameCombat>) {
const state = ctx.getState();

const activeItems = state.activeItems.map(item => {
const activeItems = (state.activeItems || []).map(item => {
if(!item) {
return undefined;
}
Expand Down
4 changes: 2 additions & 2 deletions src/stores/mercantile/mercantile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export class MercantileState {
async updateAllItems(ctx: StateContext<IGameMercantile>) {
const state = ctx.getState();

const shopItems = state.shop.forSale.map(item => {
const shopItems = (state.shop.forSale || []).map(item => {
const baseItem = this.itemCreatorService.createItem(item.internalId || '');
if(!baseItem) {
return undefined;
Expand All @@ -92,7 +92,7 @@ export class MercantileState {
};
}).filter(Boolean);

const stockpileItems = state.stockpile.items.map(item => {
const stockpileItems = (state.stockpile.items || []).map(item => {
const baseItem = this.itemCreatorService.createItem(item.internalId || '');
if(!baseItem) {
return undefined;
Expand Down

0 comments on commit b7cc657

Please sign in to comment.