a bit smart way

This commit is contained in:
Djeeberjr 2021-11-15 19:18:43 +01:00
parent 231018ce39
commit 49fb1d90a0

View File

@ -2,26 +2,27 @@ import Card from "./Card"
import Deck from "./Deck" import Deck from "./Deck"
class RetakesConfig { class RetakesConfig {
readonly ctPistol: Deck readonly ctPistol: Deck = new Deck(0)
readonly tPistol: Deck readonly tPistol: Deck = new Deck(0)
readonly ctUpgradedPistol: Deck readonly ctUpgradedPistol: Deck = new Deck(0)
readonly tUpgradedPistol: Deck readonly tUpgradedPistol: Deck = new Deck(0)
readonly ctLight: Deck readonly ctLight: Deck = new Deck(0)
readonly tLight: Deck readonly tLight: Deck = new Deck(0)
readonly ctFull: Deck readonly ctFull: Deck = new Deck(0)
readonly tFull: Deck readonly tFull: Deck = new Deck(0)
readonly ctEnemy: Card readonly ctEnemy: Card = new Card("CT Enemy card",false,false)
readonly tEnemy: Card readonly tEnemy: Card = new Card("T Enemy card",false,false)
readonly ctBonus: Card readonly ctBonus: Card = new Card("CT Bonus card",false,false)
readonly tBonus: Card readonly tBonus: Card = new Card("T Bonus card",false,false)
readonly ctBonusAvailability: number[] // If not set to [1] or a valid value the game will crash
readonly tBonusAvailability: number[] readonly ctBonusAvailability: number[] = [1]
readonly tBonusAvailability: number[] = [1]
// TODO: there must be some smarter way to do this // TODO: there must be some smarter way to do this
constructor(args? :{ constructor(args? :{
@ -40,30 +41,26 @@ class RetakesConfig {
ctBonusAvailability?: number[], ctBonusAvailability?: number[],
tBonusAvailability?: number[], tBonusAvailability?: number[],
}){ }){
this.ctPistol = args?.ctPistol ?? new Deck(0) if (args){
this.tPistol = args?.tPistol ?? new Deck(0) args.ctPistol && (this.ctPistol = args.ctPistol)
args.tPistol && (this.tPistol = args.tPistol)
this.ctUpgradedPistol = args?.ctUpgradedPistol ?? new Deck(0) args.ctUpgradedPistol && (this.ctUpgradedPistol = args.ctUpgradedPistol)
this.tUpgradedPistol = args?.tUpgradedPistol ?? new Deck(0) args.tUpgradedPistol && (this.tUpgradedPistol = args.tUpgradedPistol)
args.ctLight && (this.ctLight = args.ctLight)
this.ctLight = args?.ctLight ?? new Deck(0) args.tLight && (this.tLight = args.tLight)
this.tLight = args?.tLight ?? new Deck(0) args.ctFull && (this.ctFull = args.ctFull)
args.tFull && (this.tFull = args.tFull)
this.ctFull = args?.ctFull ?? new Deck(0) args.ctEnemy && (this.ctEnemy = args.ctEnemy)
this.tFull = args?.tFull ?? new Deck(0) args.tEnemy && (this.tEnemy = args.tEnemy)
args.ctBonus && (this.ctBonus = args.ctBonus)
this.ctEnemy = args?.ctEnemy ?? new Card("CT Enemy card",false,false) args.tBonus && (this.tBonus = args.tBonus)
this.tEnemy = args?.tEnemy ?? new Card("T Enemy Card",false,false) args.ctBonusAvailability && (this.ctBonusAvailability = args.ctBonusAvailability)
args.tBonusAvailability && (this.tBonusAvailability = args.tBonusAvailability)
this.ctBonus = args?.ctBonus ?? new Card("CT Bonus card",false,false) }
this.tBonus = args?.tBonus ?? new Card("T Bonus card",false,false)
this.ctBonusAvailability = args?.ctBonusAvailability ?? [1] // Has to be 1 or the game will crash
this.tBonusAvailability = args?.tBonusAvailability ?? [1]
} }
public toCvar(){ public toCvar(){
} }
} }