Added all editable decks

This commit is contained in:
Djeeberjr 2021-11-15 02:25:41 +01:00
parent a18ac47c72
commit 231018ce39
3 changed files with 118 additions and 17 deletions

View File

@ -0,0 +1,35 @@
import React, { useState } from "react"
import RetakesConfig from "../types/RetakesConfig"
import Side from "../types/Side"
import DeckComp from "./Deck"
const AllDecks: React.FC = () => {
const [retakesConfig,setRetakesConfig] = useState(new RetakesConfig())
return (
<div>
<DeckComp title="CT Pistol" side={Side.CT} deck={retakesConfig.ctPistol}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{ctPistol:newDeck}}))} />
<DeckComp title="T Pistol" side={Side.T} deck={retakesConfig.tPistol}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{tPistol:newDeck}}))} />
<DeckComp title="CT Upgraded Pistol" side={Side.CT} deck={retakesConfig.ctUpgradedPistol}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{ctUpgradedPistol:newDeck}}))} />
<DeckComp title="T Upgraded Pistol" side={Side.T} deck={retakesConfig.tUpgradedPistol}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{tUpgradedPistol:newDeck}}))} />
<DeckComp title="CT Light" side={Side.CT} deck={retakesConfig.ctLight}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{ctLight:newDeck}}))} />
<DeckComp title="T Light" side={Side.T} deck={retakesConfig.tLight}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{tLight:newDeck}}))} />
<DeckComp title="CT Full" side={Side.CT} deck={retakesConfig.ctFull}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{ctFull:newDeck}}))} />
<DeckComp title="T Full" side={Side.T} deck={retakesConfig.tFull}
onChange={(newDeck)=> setRetakesConfig(new RetakesConfig({...retakesConfig,...{tFull:newDeck}}))} />
</div>
)
}
export default AllDecks

View File

@ -1,25 +1,20 @@
import React, { useState } from 'react'; import React from 'react';
import DeckComp from './Deck'; import AllDecks from './AllDecks';
import Card from '../types/Card';
import CardGroup from '../types/CardGroup';
import Deck from '../types/Deck';
import Item from '../types/Item';
import Side from '../types/Side';
function App() { function App() {
const [CTDeck,setCTDeck] = useState<Deck>(new Deck( // const [CTDeck,setCTDeck] = useState<Deck>(new Deck(
2,new CardGroup( // 2,new CardGroup(
2,new Card("AWE fake",false,false,Item.AWP,Item.DECOY), // 2,new Card("AWE fake",false,false,Item.AWP,Item.DECOY),
new Card("M4 Flash",true,true,Item.AK_47_M4,Item.FLASHBANG) // new Card("M4 Flash",true,true,Item.AK_47_M4,Item.FLASHBANG)
), // ),
new CardGroup( // new CardGroup(
3,new Card("One deag",true,false,Item.DESERT_EAGLE) // 3,new Card("One deag",true,false,Item.DESERT_EAGLE)
) // )
)) // ))
return ( return (
<div className="text-white"> <div className="text-white">
<DeckComp title="CT Normal" side={Side.CT} deck={CTDeck} onChange={(newDeck)=> setCTDeck(newDeck)} /> <AllDecks />
</div> </div>
); );
} }

View File

@ -0,0 +1,71 @@
import Card from "./Card"
import Deck from "./Deck"
class RetakesConfig {
readonly ctPistol: Deck
readonly tPistol: Deck
readonly ctUpgradedPistol: Deck
readonly tUpgradedPistol: Deck
readonly ctLight: Deck
readonly tLight: Deck
readonly ctFull: Deck
readonly tFull: Deck
readonly ctEnemy: Card
readonly tEnemy: Card
readonly ctBonus: Card
readonly tBonus: Card
readonly ctBonusAvailability: number[]
readonly tBonusAvailability: number[]
// TODO: there must be some smarter way to do this
constructor(args? :{
ctPistol?: Deck,
tPistol?: Deck,
ctUpgradedPistol?: Deck,
tUpgradedPistol?: Deck,
ctLight?: Deck,
tLight?: Deck,
ctFull?: Deck,
tFull?:Deck,
ctEnemy?: Card,
tEnemy?: Card,
ctBonus?: Card,
tBonus?: Card,
ctBonusAvailability?: number[],
tBonusAvailability?: number[],
}){
this.ctPistol = args?.ctPistol ?? new Deck(0)
this.tPistol = args?.tPistol ?? new Deck(0)
this.ctUpgradedPistol = args?.ctUpgradedPistol ?? new Deck(0)
this.tUpgradedPistol = args?.tUpgradedPistol ?? new Deck(0)
this.ctLight = args?.ctLight ?? new Deck(0)
this.tLight = args?.tLight ?? new Deck(0)
this.ctFull = args?.ctFull ?? new Deck(0)
this.tFull = args?.tFull ?? new Deck(0)
this.ctEnemy = args?.ctEnemy ?? new Card("CT Enemy card",false,false)
this.tEnemy = args?.tEnemy ?? new Card("T Enemy Card",false,false)
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(){
}
}
export default RetakesConfig