-
Notifications
You must be signed in to change notification settings - Fork 25
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
[FEATURE] control initial number of mages drawn #380
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"ExpandedNodes": [""], | ||
"SelectedNode": "\\src\\Redux\\Store\\Expeditions\\Expeditions\\helpers\\convertExpeditionToConfig.ts", | ||
"PreviewInSolutionExplorer": false | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
import * as types from 'aer-types' | ||
import shortid from 'shortid' | ||
import { selectors } from 'Redux/Store' | ||
import { getMageIdsFromSimpleArray } from 'Redux/Store/Expeditions/Expeditions/sideEffects/helpers' | ||
import { determineUsedExpansions } from 'Redux/Store/Expeditions/Expeditions/sideEffects/createSettingsSnapshot/determineUsedExpansions' | ||
import { RootState } from 'Redux/Store' | ||
import { getLatestMigrationVersion } from 'Redux/Store/Expeditions/Expeditions/migrations' | ||
|
@@ -9,17 +11,32 @@ export const convertExpeditionFromConfig = ( | |
state: RootState | ||
): types.Expedition => { | ||
const expeditionId = shortid.generate() | ||
|
||
const seed = { | ||
seed: config.seedConfig || shortid.generate(), | ||
supplyState: true, | ||
nemesisState: true, | ||
} | ||
const allMages = selectors.Settings.Expansions.Mages.content.getContent(state) | ||
.ENG | ||
const mageArray = Object.keys(allMages).map(function (id) { | ||
let mage = allMages[id] | ||
return mage | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can just return |
||
}) | ||
if (config.initialBarracksConfig) { | ||
config.initialBarracksConfig.mageIds = getMageIdsFromSimpleArray({ | ||
mage: config.initialBarracksConfig.mageIds, | ||
seed, | ||
stillAvailableMageIds: mageArray.map(({ id }) => id), | ||
}).result | ||
} | ||
console.log(allMages) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. remove the console.logs please :) |
||
console.log(mageArray.map(({ id }) => id)) | ||
const expedition = { | ||
id: expeditionId, | ||
name: config.name, | ||
bigPocketVariant: config.bigPocketVariantConfig, | ||
score: 0, | ||
seed: { | ||
seed: config.seedConfig || shortid.generate(), | ||
supplyState: true, | ||
nemesisState: true, | ||
}, | ||
seed: seed, | ||
barracks: { | ||
supplyIds: config.initialBarracksConfig?.supplyIds || [], | ||
mageIds: config.initialBarracksConfig?.mageIds || [], | ||
|
@@ -40,7 +57,7 @@ export const convertExpeditionFromConfig = ( | |
sequence: { | ||
firstBranchId: config.sequenceConfig.firstBranchId, | ||
branches: Object.keys(config.sequenceConfig.branches) | ||
.map(key => { | ||
.map((key) => { | ||
const branch = { | ||
...config.sequenceConfig.branches[key], | ||
id: key, | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -66,7 +66,7 @@ export const getSupplyIds = ({ | |
// 1.) it lets us filter available cards by those ids, which have been explicitely specified | ||
// 2.) it makes the reduce call a bit easer to read and maintain, as we don't have to handle the 'string' case | ||
const ids = supply.ids.filter( | ||
idOrBlueprint => typeof idOrBlueprint === 'string' | ||
(idOrBlueprint) => typeof idOrBlueprint === 'string' | ||
) | ||
const bluePrints = supply.ids.filter( | ||
(idOrBlueprint): idOrBlueprint is types.IBluePrint => | ||
|
@@ -77,7 +77,7 @@ export const getSupplyIds = ({ | |
(acc: RewardResult, blueprint) => { | ||
const cardType = blueprint.type | ||
const stillAvailableCards = stillAvailableCardsByType[cardType].filter( | ||
card => ids.indexOf(card.id) === -1 | ||
(card) => ids.indexOf(card.id) === -1 | ||
) | ||
|
||
const cardCreationResult = createCardList( | ||
|
@@ -90,7 +90,7 @@ export const getSupplyIds = ({ | |
return { | ||
result: [ | ||
...acc.result, | ||
...cardCreationResult.result.map(card => card.id), | ||
...cardCreationResult.result.map((card) => card.id), | ||
], | ||
seed: cardCreationResult.seed, | ||
} | ||
|
@@ -125,7 +125,7 @@ export const getTreasureIds = ({ | |
return baseResult | ||
} else { | ||
const ids = treasure.ids.filter( | ||
idOrRandom => typeof idOrRandom === 'string' | ||
(idOrRandom) => typeof idOrRandom === 'string' | ||
) | ||
|
||
const randomTreasureConfigs = treasure.ids.filter( | ||
|
@@ -138,7 +138,7 @@ export const getTreasureIds = ({ | |
const treasureLevel = config.level | ||
const stillAvailableCards = stillAvailableTreasureIdsByLevel[ | ||
treasureLevel | ||
].filter(treasureId => ids.indexOf(treasureId) === -1) | ||
].filter((treasureId) => ids.indexOf(treasureId) === -1) | ||
|
||
const treasureIdsResult = createIdList( | ||
stillAvailableCards, | ||
|
@@ -177,7 +177,7 @@ export const getMageIds = ({ | |
if (mage === undefined) { | ||
return baseResult | ||
} else { | ||
const ids = mage.ids.filter(idOrRandom => typeof idOrRandom === 'string') | ||
const ids = mage.ids.filter((idOrRandom) => typeof idOrRandom === 'string') | ||
|
||
const randomTreasureConfigs = mage.ids.filter( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. we should definitely change the naming here - this is probably a copy and paste issue (i copied some internals from the treasure generation), but its very misleading. -> in turn we should also change it in your code as well. |
||
(idOrRandom): idOrRandom is { random: true } => | ||
|
@@ -187,7 +187,57 @@ export const getMageIds = ({ | |
return randomTreasureConfigs.reduce( | ||
(acc: RewardResult, _) => { | ||
const filteredMageIds = stillAvailableMageIds.filter( | ||
mageId => ids.indexOf(mageId) === -1 | ||
(mageId) => ids.indexOf(mageId) === -1 | ||
) | ||
|
||
const mageIdsResult = createIdList( | ||
filteredMageIds, | ||
['EMPTY'], | ||
undefined, | ||
acc.seed | ||
) | ||
|
||
return { | ||
result: [...acc.result, ...mageIdsResult.result], | ||
seed: mageIdsResult.seed, | ||
} | ||
}, | ||
{ | ||
...baseResult, | ||
result: ids, | ||
} as RewardResult // FIXME casting should technically not be necessary (but i could make it work without) | ||
) | ||
} | ||
} | ||
|
||
export const getMageIdsFromSimpleArray = ({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hm, this function seems to be almost identical to We could probably type our The only thing we then will have to do, is to write a new migration. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had thought about this. I wasn't sure if thats the route we wanted to go because technically its not really a reward, and the rewards config is just a slightly more complex object compared to what I have. But I also see the merit of not having to keep both functions up to date going forward. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah - I think an additional benefit of this would be the consistency for users writing these configs. |
||
mage, | ||
stillAvailableMageIds, | ||
seed, | ||
}: { | ||
mage: Array<string | { random: true }> | undefined | ||
seed: types.Seed | ||
stillAvailableMageIds: string[] | ||
}) => { | ||
const baseResult = { | ||
result: [], | ||
seed, | ||
} | ||
|
||
if (mage === undefined) { | ||
return baseResult | ||
} else { | ||
const ids = mage.filter((idOrRandom) => typeof idOrRandom === 'string') | ||
|
||
const randomTreasureConfigs = mage.filter( | ||
(idOrRandom): idOrRandom is { random: true } => | ||
typeof idOrRandom !== 'string' | ||
) | ||
|
||
return randomTreasureConfigs.reduce( | ||
(acc: RewardResult, _) => { | ||
const filteredMageIds = stillAvailableMageIds.filter( | ||
(mageId) => ids.indexOf(mageId) === -1 | ||
) | ||
|
||
const mageIdsResult = createIdList( | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// This schema has been created by using https://github.com/YousefED/typescript-json-schema | ||
// To recreate the schema run and replace it in here: | ||
// To recreate the schema run: | ||
// | ||
// typescript-json-schema tsconfig.json ExpeditionConfig --include ./node_modules/aer-types/types/**/*.ts --required --aliasRefs | ||
// | ||
|
@@ -86,10 +86,7 @@ export const schema = { | |
Barracks: { | ||
properties: { | ||
mageIds: { | ||
items: { | ||
type: 'string', | ||
}, | ||
type: 'array', | ||
$ref: '#/definitions/Array_1', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unfortunately this wont do. We will probably need to:
The type will probably look like this: type InitialBarracksConfig = {
mageIds: [
{ type: 'random' },
{ type: 'custom', id: 'someMage' }
],
supplyIds: string[],
treasureIds: string[]
}
We need to do this, to make the app as typesafe as possible (during compilation as well as at runtime, when users try to import an expedition)
(7.) It would probably make sense, to also allow treasureIds and supplyIds to be randomly rolled in that scenario. So maybe we should change these in the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you need help here, just let me know. We can also make a call over on discord, so I could guide you through necessary steps, if that would help you :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think a discord call would be good here to show me some of this process. The other issues above are things I can easily amend before our call but the relationship between the aer-types package and the json-schema are something I'm still pretty fuzzy on. I'm thinking this weekend is the time that makes the most sense to try to get together over discord. I'm also starting to think we might be in pretty different timezones. I live in Arizona so I use MST (Mountain Standard Time). Not sure what time would maybe work for you or if you want to play it by ear. And I don't mind trying to get supplyids and treasureids working as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cool - yeah we definitely would have to check timezones before hand :D I am currently thinking about migrating aer-types back into this repository (but keep publishing it as a separate type-library to npm...). That would make collaborating way easier. I probably wont be able to make a call during the upcoming weekend because of the timezone issue (this weekend is rather full either) so maybe the weekend after? I will definitely review your code this weekend and leave a few more comments, though. So that way you should be able to already make a few more adjusments. Would that work for you? (unfortunately you catched me durng a rather busy time with project dead lines at work as well as lots of family stuff to attend to in my spare time) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (we are nine hours apart btw - so when its 10:00 am in your country its 7:00pm in mine) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @Quicksav I changed the way this code base works regarding types and data. Both are now part of the repository again (we will still publish them to NPM, so that they can be consumed by other libraries). This will make it way easier to adjust typing while working on a feature, because we no longer need to publish the typings in between etc. For you to receive these changes, you need to do the following things on your feature branch:
Unfortunately I am out of time for now and haven't been able to look at your changes, yet. I will try to do so asap. But if you want you could play around with the typings a bit and try to type the initialBarracksConfig. If you have any questions, let me know :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Having some trouble understanding what I'm supposed to do with this. Unfortunately I think most of my confusion stems from my unfamiliarity with proper git usage. Really just not understanding number 1 of the above steps. Am I supposed to fork the original repository again? Am i just making an 'upstream' branch on my local machine? Or is it that I need to make the 'upstream' branch remote? Sorry for my ineptitude with this I am used to using Visual Studio to handle git commands in a relatively straightforward development environment. Would having a call next Saturday at ~10AM your time (it'd be Friday after midnight for me) work to go over some of this? I've fixed the other feedback locally but this is the big outstanding thing. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hey, no problem :) So the thing we are trying to achieve is, to get all the new changes made to this repository (so everything which has been merged to The first step outlined above, is that you need this repository as a remote source for fetching changes.
However the url to will point to your forked repository, not our original aeons-end-randomizer repo. So what you will have to do, is the following (locally):
Afterwards the PR should be mergable to Edit: Oh, regarding a pair programming session: unfortunately I can't promise that I will have time on saturday. I might be away during the day. We could either schedule something a few hours later (so it would be saturday morning for you and evening for me or maybe do it on sunday) |
||
}, | ||
supplyIds: { | ||
items: { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please remove these vs-code files :) It would be awesome, if you could add a
.gitignore
part for vscode. You can probably find something useful here https://github.com/github/gitignoreThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(same goes for the .vs/slnx.sqlite file)