Finished taking guild mage selection into account for EL restriction

This commit is contained in:
Elytherion
2019-06-11 14:38:33 +02:00
parent bc7ae2e5ed
commit 8005326471
3 changed files with 30 additions and 32 deletions
+17 -31
View File
@@ -3,10 +3,10 @@ import { ident, thrush } from "../../Data/Function";
import { fmap, fmapF } from "../../Data/Functor";
import { set } from "../../Data/Lens";
import { append, consF, countWith, elemF, List, map, notNull, partition } from "../../Data/List";
import { all, any, bindF, ensure, fromMaybe_, Just, liftM2, liftM3, listToMaybe, mapMaybe, Maybe, maybe, Nothing } from "../../Data/Maybe";
import { all, any, bindF, ensure, fromMaybe_, Just, liftM2, listToMaybe, mapMaybe, Maybe, maybe, Nothing } from "../../Data/Maybe";
import { elems, lookup, lookupF, OrderedMap } from "../../Data/OrderedMap";
import { member } from "../../Data/OrderedSet";
import { fst, snd, uncurryN, uncurryN3, uncurryN4, uncurryN5, uncurryN6, uncurryN8 } from "../../Data/Pair";
import { fst, snd, uncurryN, uncurryN3, uncurryN5, uncurryN6, uncurryN8 } from "../../Data/Pair";
import { Record } from "../../Data/Record";
import { ActivatableDependent } from "../Models/ActiveEntries/ActivatableDependent";
import { ActivatableSkillDependent, createInactiveActivatableSkillDependent } from "../Models/ActiveEntries/ActivatableSkillDependent";
@@ -27,6 +27,7 @@ import { createMaybeSelector } from "../Utilities/createMaybeSelector";
import { filterAndSortRecordsBy } from "../Utilities/filterAndSortBy";
import { prefixAdv, prefixDis, prefixSA } from "../Utilities/IDUtils";
import { isOwnTradition, isSpellDecreasable, isSpellIncreasable, isUnfamiliarSpell } from "../Utilities/Increasable/spellUtils";
import { lte } from "../Utilities/mathUtils";
import { pipe, pipe_ } from "../Utilities/pipe";
import { validatePrerequisites } from "../Utilities/Prerequisites/validatePrerequisitesUtils";
import { filterByAvailability } from "../Utilities/RulesUtils";
@@ -155,32 +156,6 @@ export const getInactiveCantrips = createMaybeSelector (
fmap (snd)
)
export const getAreMaxUnfamiliar = createMaybeSelector (
getMagicalTraditionsFromWiki,
getPhase,
getStartEl,
getActiveSpells,
uncurryN4 (trads =>
liftM3 (phase =>
start_el =>
xs => {
if (phase > 2) {
return false
}
const max = ELA.maxUnfamiliarSpells (start_el)
const unfamiliarSpells =
countWith ((x: Record<SpellWithRequirements>) =>
pipe_ (x, SWRA.wikiEntry, SA.gr) < 3
&& pipe_ (x, SWRA.stateEntry, ASDA.active)
&& !isOwnTradition (trads) (SWRA.wikiEntry (x)))
(xs)
return unfamiliarSpells >= max
}))
)
export const getActiveSpellsCounter = createMaybeSelector (
getActiveSpells,
pipe (
@@ -204,6 +179,17 @@ export const getIsMaximumOfSpellsReached = createMaybeSelector (
}))
)
const getUnfamiliarSpellsCount = createMaybeSelector (
getActiveSpells,
maybe (0) (countWith (SWRA.isUnfamiliar))
)
const isUnfamiliarSpellsActivationDisabled = createMaybeSelector (
getUnfamiliarSpellsCount,
getStartEl,
uncurryN (count => maybe (false) (pipe (ELA.maxUnfamiliarSpells, lte (count))))
)
type Combined = Record<SpellWithRequirements>
export const getInactiveSpells = createMaybeSelector (
@@ -212,8 +198,8 @@ export const getInactiveSpells = createMaybeSelector (
getWikiSpells,
getHeroProp,
getMagicalTraditionsFromWiki,
isUnfamiliarSpellsActivationDisabled,
getIsMaximumOfSpellsReached,
getAreMaxUnfamiliar,
getSpells,
uncurryN8 (
wiki =>
@@ -221,8 +207,8 @@ export const getInactiveSpells = createMaybeSelector (
wiki_spells =>
hero =>
trads_wiki =>
liftM3 (is_max =>
is_max_unfamiliar =>
is_max_unfamiliar =>
liftM2 (is_max =>
hero_spells => {
const isLastTrad = pipe_ (trads_wiki, listToMaybe, fmap (SAA.id), Maybe.elemF)
+12
View File
@@ -79,3 +79,15 @@ export const uncurryN8 =
(f: (a: A) => (b: B) => (c: C) => (d: D) => (e: E) => (f: F) => (g: G) => (h: H) => I) =>
(x: A, y: B, z: C, a: D, b: E, c: F, d: G, e: H): I =>
f (x) (y) (z) (a) (b) (c) (d) (e)
/**
* `uncurryN9 :: (a -> b -> c -> d -> e -> f -> g -> h -> i -> j) -> (a, b, c, d, e, f, g, h, i) -> j`
*
* `uncurryN9` converts a curried function to a function on pairs.
*/
export const uncurryN9 =
<A, B, C, D, E, F, G, H, I, J>
(f: (a: A) => (b: B) => (c: C) => (d: D) => (e: E) =>
(f: F) => (g: G) => (h: H) => (i: I) => J) =>
(x: A, y: B, z: C, a: D, b: E, c: F, d: G, e: H, g: I): J =>
f (x) (y) (z) (a) (b) (c) (d) (e) (g)
+1 -1
View File
@@ -84,7 +84,7 @@
true,
{
"limit": 100,
"ignore-pattern": "^import |^export {(.*?)}|class [a-zA-Z]+ implements "
"ignore-pattern": "^import |^export {(.*?)}|class [a-zA-Z]+ implements |^ \\* "
}
],
"no-default-export": true,