@@ -32,7 +32,7 @@ export interface CardConfig {
cost : number
weight : number
kind : CKind
lv : CardLV
pool_ lv : CardLV
hero_lv? : number
card_lv? :number
}
@@ -55,32 +55,35 @@ export const CARD_POOL_MAX_LEVEL = CardLV.LV5
/** 英雄最高等级限制 */
export const CARD_HERO_MAX_LEVEL = 3
/** 基础卡池(英雄、技能、功能) */
export const HERO_LV2_INIT_PROB = 0.1
export const HERO_LV2_PROB_INC_PER_LV = 0.05
export const CardPoolList : CardConfig [ ] = [
{ uuid : 5001 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5101 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5201 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5301 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5001 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5101 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5201 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5301 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 1 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5003 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5102 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5302 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5003 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5102 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5302 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 2 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5002 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5103 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5202 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5002 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5103 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5202 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 3 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5004 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5104 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5303 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5004 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5104 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5303 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 4 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5105 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 5 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5304 , type : CardType . Hero , cost : 3 , weight : 25 , lv : 5 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5105 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 5 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 5304 , type : CardType . Hero , cost : 3 , weight : 25 , pool_ lv : 5 , kind : CKind.Hero , hero_lv : 1 } ,
{ uuid : 7001 , type : CardType . SpecialUpgrade , cost : 6 , weight : 16 , lv : 1 , kind : CKind.Card } ,
{ uuid : 7002 , type : CardType . SpecialUpgrade , cost : 6 , weight : 14 , lv : 2 , kind : CKind.Card } ,
{ uuid : 7101 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , lv : 1 , kind : CKind.Card } ,
{ uuid : 7102 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , lv : 1 , kind : CKind.Card } ,
{ uuid : 7103 , type : CardType . SpecialRefresh , cost : 5 , weight : 12 , lv : 2 , kind : CKind.Card } ,
{ uuid : 7001 , type : CardType . SpecialUpgrade , cost : 6 , weight : 16 , pool_ lv : 1 , kind : CKind.Card } ,
{ uuid : 7002 , type : CardType . SpecialUpgrade , cost : 6 , weight : 14 , pool_ lv : 2 , kind : CKind.Card } ,
{ uuid : 7101 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , pool_ lv : 1 , kind : CKind.Card } ,
{ uuid : 7102 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , pool_ lv : 1 , kind : CKind.Card } ,
{ uuid : 7103 , type : CardType . SpecialRefresh , cost : 5 , weight : 12 , pool_ lv : 2 , kind : CKind.Card } ,
]
@@ -111,22 +114,22 @@ export interface SpecialRefreshCardConfig extends CardConfig {
export const SpecialUpgradeCardList : Record < number , SpecialUpgradeCardConfig > = {
7001 : { uuid : 7001 , type : CardType . SpecialUpgrade , cost : 6 , weight : 16 , lv : CardLV.LV1 , kind :CKind.Card , name : "战术晋升" , info : "升级场上随机1个1级英雄到2级" ,
7001 : { uuid : 7001 , type : CardType . SpecialUpgrade , cost : 6 , weight : 16 , pool_ lv : CardLV.LV1 , kind :CKind.Card , name : "战术晋升" , info : "升级场上随机1个1级英雄到2级" ,
currentLv : 1 , targetLv : 2 ,
} ,
7002 : { uuid : 7002 , type : CardType . SpecialUpgrade , cost : 6 , weight : 14 , lv : CardLV.LV2 , kind :CKind.Card , name : "进阶战术" , info : "升级场上随机1个2级英雄到3级" ,
7002 : { uuid : 7002 , type : CardType . SpecialUpgrade , cost : 6 , weight : 14 , pool_ lv : CardLV.LV2 , kind :CKind.Card , name : "进阶战术" , info : "升级场上随机1个2级英雄到3级" ,
currentLv : 2 , targetLv : 3 ,
} ,
}
export const SpecialRefreshCardList : Record < number , SpecialRefreshCardConfig > = {
7101 : { uuid : 7101 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , lv : CardLV.LV1 , kind :CKind.Card , name : "近战征召" , info : "刷新卡池,都是近战英雄" ,
7101 : { uuid : 7101 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , pool_ lv : CardLV.LV1 , kind :CKind.Card , name : "近战征召" , info : "刷新卡池,都是近战英雄" ,
refreshLv : 0 , refreshHeroType : SpecialRefreshHeroType.Melee ,
} ,
7102 : { uuid : 7102 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , lv : CardLV.LV1 , kind :CKind.Card , name : "远程征召" , info : "刷新卡池,都是远程英雄" ,
7102 : { uuid : 7102 , type : CardType . SpecialRefresh , cost : 4 , weight : 14 , pool_ lv : CardLV.LV1 , kind :CKind.Card , name : "远程征召" , info : "刷新卡池,都是远程英雄" ,
refreshLv : 0 , refreshHeroType : SpecialRefreshHeroType.Ranged ,
} ,
7103 : { uuid : 7103 , type : CardType . SpecialRefresh , cost : 5 , weight : 12 , lv : CardLV.LV2 , kind :CKind.Card , name : "精英筛选" , info : "刷新卡池, 都是3级卡池等级英雄" ,
7103 : { uuid : 7103 , type : CardType . SpecialRefresh , cost : 5 , weight : 12 , pool_ lv : CardLV.LV2 , kind :CKind.Card , name : "精英筛选" , info : "刷新卡池, 都是3级卡池等级英雄" ,
refreshLv : 3 , refreshHeroType : SpecialRefreshHeroType.Any ,
} ,
}
@@ -165,13 +168,26 @@ const pickCards = (cards: CardConfig[], count: number): CardConfig[] => {
return selected
}
/** 根据概率尝试将抽到的英雄卡的 hero_lv 提升到 2 */
const applyHeroLv2Probability = ( cards : CardConfig [ ] , currentPoolLv : number ) : CardConfig [ ] = > {
return cards . map ( card = > {
if ( card . type === CardType . Hero && card . hero_lv === 1 ) {
const prob = HERO_LV2_INIT_PROB + HERO_LV2_PROB_INC_PER_LV * ( currentPoolLv - card . pool_lv )
if ( Math . random ( ) < prob ) {
return { . . . card , hero_lv : 2 }
}
}
return card
} )
}
/** 获取指定等级可出现的基础卡池 */
export const getCardPoolByLv = ( lv : number , onlyCurrentLv : boolean = false ) : CardConfig [ ] = > {
const cardLv = clampCardLv ( lv )
if ( onlyCurrentLv ) {
return CardPoolList . filter ( card = > card . lv === cardLv )
return CardPoolList . filter ( card = > card . pool_ lv === cardLv )
}
return CardPoolList . filter ( card = > card . lv <= cardLv )
return CardPoolList . filter ( card = > card . pool_ lv <= cardLv )
}
const normalizeTypeFilter = ( type : CardType | CardType [ ] ) : Set < CardType > = > {
@@ -189,13 +205,13 @@ export const getCardsByLv = (
if ( type !== undefined ) {
const typeSet = normalizeTypeFilter ( type )
const filteredPool = pool . filter ( card = > typeSet . has ( card . type ) )
return pickCards ( filteredPool , 4 )
return applyHeroLv2Probability ( pickCards( filteredPool , 4 ) , lv )
}
const heroPool = pool . filter ( card = > card . type === CardType . Hero )
const otherPool = pool . filter ( card = > card . type !== CardType . Hero )
const heroes = pickCards ( heroPool , 2 )
const others = pickCards ( otherPool , 2 )
return [ . . . heroes , . . . others ]
return applyHeroLv2Probability ( [ . . . heroes , . . . others ] , lv )
}
export const drawCardsByRule = (
@@ -225,5 +241,10 @@ export const drawCardsByRule = (
return true
} )
}
return pickCards ( pool , count )
const picked = pickCards ( pool , count )
// 如果明确指定了需要的 heroLv, 则不触发升级概率
if ( options . heroLv !== undefined ) {
return picked
}
return applyHeroLv2Probability ( picked , lv )
}