eslint cleanup
This commit is contained in:
parent
35475e36db
commit
b0b6e7084e
@ -6,63 +6,63 @@ import Side from "./types/Side"
|
|||||||
* @param item what item
|
* @param item what item
|
||||||
* @param side CT or T
|
* @param side CT or T
|
||||||
*/
|
*/
|
||||||
function ItemToDisplay(item:Item, side: Side ):string {
|
function ItemToDisplay(item:Item, side: Side ):string {
|
||||||
switch (item) {
|
switch (item) {
|
||||||
case Item.DEFAULT_PISTOL:
|
case Item.DEFAULT_PISTOL:
|
||||||
return side === Side.CT ? "USP-S / P2000":"Glock-18"
|
return side === Side.CT ? "USP-S / P2000":"Glock-18"
|
||||||
case Item.DUAL_BERETTAS:
|
case Item.DUAL_BERETTAS:
|
||||||
return "Dual Berettas"
|
return "Dual Berettas"
|
||||||
case Item.P250:
|
case Item.P250:
|
||||||
return "P250"
|
return "P250"
|
||||||
case Item.TEC_9_FIVE_SEVEN:
|
case Item.TEC_9_FIVE_SEVEN:
|
||||||
return side === Side.CT ? "Five-Seven / CZ75-Auto":"Tec-9 / CZ75-Auto"
|
return side === Side.CT ? "Five-Seven / CZ75-Auto":"Tec-9 / CZ75-Auto"
|
||||||
case Item.DESERT_EAGLE:
|
case Item.DESERT_EAGLE:
|
||||||
return "Desert Eagle / R8 Revolver"
|
return "Desert Eagle / R8 Revolver"
|
||||||
case Item.NOVA:
|
case Item.NOVA:
|
||||||
return "Nova"
|
return "Nova"
|
||||||
case Item.XM1014:
|
case Item.XM1014:
|
||||||
return "XM1014"
|
return "XM1014"
|
||||||
case Item.MAG_7:
|
case Item.MAG_7:
|
||||||
return side === Side.CT ? "MAG-7":"Sawed-Off"
|
return side === Side.CT ? "MAG-7":"Sawed-Off"
|
||||||
case Item.M249:
|
case Item.M249:
|
||||||
return "M249"
|
return "M249"
|
||||||
case Item.NEGEV:
|
case Item.NEGEV:
|
||||||
return "Negev"
|
return "Negev"
|
||||||
case Item.MAC_10_MP9:
|
case Item.MAC_10_MP9:
|
||||||
return side === Side.CT ? "MP9":"MAC-10"
|
return side === Side.CT ? "MP9":"MAC-10"
|
||||||
case Item.MP7:
|
case Item.MP7:
|
||||||
return "MP7 / MP5-SD"
|
return "MP7 / MP5-SD"
|
||||||
case Item.UMP_45:
|
case Item.UMP_45:
|
||||||
return "UMP-45"
|
return "UMP-45"
|
||||||
case Item.P90:
|
case Item.P90:
|
||||||
return "P90"
|
return "P90"
|
||||||
case Item.PP_BIZON:
|
case Item.PP_BIZON:
|
||||||
return "PP-Bizon"
|
return "PP-Bizon"
|
||||||
case Item.FAMAS_GALIL:
|
case Item.FAMAS_GALIL:
|
||||||
return side === Side.CT ? "FAMAS":"Galil AR"
|
return side === Side.CT ? "FAMAS":"Galil AR"
|
||||||
case Item.AK_47_M4:
|
case Item.AK_47_M4:
|
||||||
return side === Side.CT ? "M4A4 / M4A1-S":"AK-47"
|
return side === Side.CT ? "M4A4 / M4A1-S":"AK-47"
|
||||||
case Item.SSG_08:
|
case Item.SSG_08:
|
||||||
return "SSG 08"
|
return "SSG 08"
|
||||||
case Item.SG_554_AUG:
|
case Item.SG_554_AUG:
|
||||||
return side === Side.CT ? "AUG":"SG 553"
|
return side === Side.CT ? "AUG":"SG 553"
|
||||||
case Item.AWP:
|
case Item.AWP:
|
||||||
return "AWP"
|
return "AWP"
|
||||||
case Item.G3_SCAR:
|
case Item.G3_SCAR:
|
||||||
return side === Side.CT ? "SCAR-20":"G3SG1"
|
return side === Side.CT ? "SCAR-20":"G3SG1"
|
||||||
case Item.MOLOTOV:
|
case Item.MOLOTOV:
|
||||||
return side === Side.CT ? "Incendiary Grenade":"Molotov"
|
return side === Side.CT ? "Incendiary Grenade":"Molotov"
|
||||||
case Item.DECOY:
|
case Item.DECOY:
|
||||||
return "Decoy"
|
return "Decoy"
|
||||||
case Item.FLASHBANG:
|
case Item.FLASHBANG:
|
||||||
return "Flashbang"
|
return "Flashbang"
|
||||||
case Item.HE:
|
case Item.HE:
|
||||||
return "HE Grenade"
|
return "HE Grenade"
|
||||||
case Item.SMOKE:
|
case Item.SMOKE:
|
||||||
return "Smoke"
|
return "Smoke"
|
||||||
default:
|
default:
|
||||||
throw new Error("Item not translatable")
|
throw new Error("Item not translatable")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ItemToDisplay
|
export default ItemToDisplay
|
||||||
|
@ -9,26 +9,26 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AddItem: React.FC<Props> = ({side,onChange}) => {
|
const AddItem: React.FC<Props> = ({side,onChange}) => {
|
||||||
const [selected,setSelected] = useState<Item>(Item.DEFAULT_PISTOL)
|
const [selected,setSelected] = useState<Item>(Item.DEFAULT_PISTOL)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<select
|
<select
|
||||||
className="bg-gray-600 border-2 border-gray-700"
|
className="bg-gray-600 border-2 border-gray-700"
|
||||||
onChange={(e)=>setSelected(Item[e.target.value as keyof typeof Item])}
|
onChange={(e)=>setSelected(Item[e.target.value as keyof typeof Item])}
|
||||||
>
|
>
|
||||||
{
|
{
|
||||||
Object.keys(Item).map(e=><option key={e} value={e}>{ItemToDisplay(Item[e as keyof typeof Item],side)}</option>)
|
Object.keys(Item).map(e=><option key={e} value={e}>{ItemToDisplay(Item[e as keyof typeof Item],side)}</option>)
|
||||||
}
|
}
|
||||||
</select>
|
</select>
|
||||||
<span
|
<span
|
||||||
onClick={()=>onChange?.(selected)}
|
onClick={()=>onChange?.(selected)}
|
||||||
className="cursor-pointer float-right"
|
className="cursor-pointer float-right"
|
||||||
>
|
>
|
||||||
Add
|
Add
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AddItem
|
export default AddItem
|
||||||
|
@ -10,43 +10,43 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const AllDecks: React.FC<Props> = ({retakesConfig,onChange}) => {
|
const AllDecks: React.FC<Props> = ({retakesConfig,onChange}) => {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<DeckComp title="CT Pistol" side={Side.CT} deck={retakesConfig.ctPistol}
|
<DeckComp title="CT Pistol" side={Side.CT} deck={retakesConfig.ctPistol}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctPistol:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctPistol:newDeck}}))} />
|
||||||
<DeckComp title="T Pistol" side={Side.T} deck={retakesConfig.tPistol}
|
<DeckComp title="T Pistol" side={Side.T} deck={retakesConfig.tPistol}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tPistol:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tPistol:newDeck}}))} />
|
||||||
|
|
||||||
<DeckComp title="CT Upgraded Pistol" side={Side.CT} deck={retakesConfig.ctUpgradedPistol}
|
<DeckComp title="CT Upgraded Pistol" side={Side.CT} deck={retakesConfig.ctUpgradedPistol}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctUpgradedPistol:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctUpgradedPistol:newDeck}}))} />
|
||||||
<DeckComp title="T Upgraded Pistol" side={Side.T} deck={retakesConfig.tUpgradedPistol}
|
<DeckComp title="T Upgraded Pistol" side={Side.T} deck={retakesConfig.tUpgradedPistol}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tUpgradedPistol:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tUpgradedPistol:newDeck}}))} />
|
||||||
|
|
||||||
<DeckComp title="CT Light" side={Side.CT} deck={retakesConfig.ctLight}
|
<DeckComp title="CT Light" side={Side.CT} deck={retakesConfig.ctLight}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctLight:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctLight:newDeck}}))} />
|
||||||
<DeckComp title="T Light" side={Side.T} deck={retakesConfig.tLight}
|
<DeckComp title="T Light" side={Side.T} deck={retakesConfig.tLight}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tLight:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tLight:newDeck}}))} />
|
||||||
|
|
||||||
<DeckComp title="CT Full" side={Side.CT} deck={retakesConfig.ctFull}
|
<DeckComp title="CT Full" side={Side.CT} deck={retakesConfig.ctFull}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctFull:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{ctFull:newDeck}}))} />
|
||||||
<DeckComp title="T Full" side={Side.T} deck={retakesConfig.tFull}
|
<DeckComp title="T Full" side={Side.T} deck={retakesConfig.tFull}
|
||||||
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tFull:newDeck}}))} />
|
onChange={(newDeck)=> onChange?.(new RetakesConfig({...retakesConfig,...{tFull:newDeck}}))} />
|
||||||
|
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<CardComp card={retakesConfig.ctEnemy} side={Side.T}
|
<CardComp card={retakesConfig.ctEnemy} side={Side.T}
|
||||||
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{ctEnemy:newCard}}))} />
|
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{ctEnemy:newCard}}))} />
|
||||||
<CardComp card={retakesConfig.tEnemy} side={Side.CT}
|
<CardComp card={retakesConfig.tEnemy} side={Side.CT}
|
||||||
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{tEnemy:newCard}}))} />
|
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{tEnemy:newCard}}))} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
<CardComp card={retakesConfig.ctBonus} side={Side.CT}
|
<CardComp card={retakesConfig.ctBonus} side={Side.CT}
|
||||||
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{ctBonus:newCard}}))} />
|
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{ctBonus:newCard}}))} />
|
||||||
<CardComp card={retakesConfig.tBonus} side={Side.T}
|
<CardComp card={retakesConfig.tBonus} side={Side.T}
|
||||||
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{tBonus:newCard}}))} />
|
onChange={(newCard)=>onChange?.(new RetakesConfig({...retakesConfig,...{tBonus:newCard}}))} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default AllDecks
|
export default AllDecks
|
@ -1,27 +1,27 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from "react"
|
||||||
import RetakesConfig from '../types/RetakesConfig';
|
import RetakesConfig from "../types/RetakesConfig"
|
||||||
import AllDecks from './AllDecks';
|
import AllDecks from "./AllDecks"
|
||||||
import MenuBar from './MenuBar';
|
import MenuBar from "./MenuBar"
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
|
|
||||||
const [retakesConfig,setRetakesConfig] = useState(new RetakesConfig())
|
const [retakesConfig,setRetakesConfig] = useState(new RetakesConfig())
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="text-white">
|
<div className="text-white">
|
||||||
<MenuBar
|
<MenuBar
|
||||||
onExport={()=>{
|
onExport={()=>{
|
||||||
const exportString = retakesConfig.toCvar()
|
const exportString = retakesConfig.toCvar()
|
||||||
console.log(exportString)
|
console.log(exportString)
|
||||||
}}
|
}}
|
||||||
onExportJson={()=>{
|
onExportJson={()=>{
|
||||||
const jsonString = JSON.stringify(retakesConfig)
|
const jsonString = JSON.stringify(retakesConfig)
|
||||||
console.log(jsonString)
|
console.log(jsonString)
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<AllDecks retakesConfig={retakesConfig} onChange={(newConfig)=>setRetakesConfig(newConfig)} />
|
<AllDecks retakesConfig={retakesConfig} onChange={(newConfig)=>setRetakesConfig(newConfig)} />
|
||||||
</div>
|
</div>
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default App;
|
export default App
|
||||||
|
@ -14,35 +14,35 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CardComp: React.FC<Props> = ({card,side,onChange,onRemove}) => {
|
const CardComp: React.FC<Props> = ({card,side,onChange,onRemove}) => {
|
||||||
return (
|
return (
|
||||||
<div className="bg-gray-600 m-1 p-1 w-72 min-h-card">
|
<div className="bg-gray-600 m-1 p-1 w-72 min-h-card">
|
||||||
<span className="float-right cursor-pointer" onClick={()=>{onRemove?.()}}>X</span>
|
<span className="float-right cursor-pointer" onClick={()=>{onRemove?.()}}>X</span>
|
||||||
<span className="font-bold"><TextEdit
|
<span className="font-bold"><TextEdit
|
||||||
text={card.title}
|
text={card.title}
|
||||||
onChange={(newTitle)=>onChange?.(new Card(newTitle,card.armor,card.helmet,...card.items))}
|
onChange={(newTitle)=>onChange?.(new Card(newTitle,card.armor,card.helmet,...card.items))}
|
||||||
/></span>
|
/></span>
|
||||||
<div>
|
<div>
|
||||||
<span>
|
<span>
|
||||||
Helmet: <SwitchButton active={card.helmet} onChange={(to)=>onChange?.(new Card(card.title,card.armor,to,...card.items))} />
|
Helmet: <SwitchButton active={card.helmet} onChange={(to)=>onChange?.(new Card(card.title,card.armor,to,...card.items))} />
|
||||||
</span>
|
</span>
|
||||||
<span className="float-right">
|
<span className="float-right">
|
||||||
Armor: <SwitchButton active={card.armor} onChange={(to)=>onChange?.(new Card(card.title,to,card.helmet,...card.items))} />
|
Armor: <SwitchButton active={card.armor} onChange={(to)=>onChange?.(new Card(card.title,to,card.helmet,...card.items))} />
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="border-2 border-gray-700 p-0.5">
|
<div className="border-2 border-gray-700 p-0.5">
|
||||||
{card.items.map((item,i)=>
|
{card.items.map((item,i)=>
|
||||||
<div
|
<div
|
||||||
key={item + i} // FIXME: this is just a "temporary" solution. Implement propper key
|
key={item + i} // FIXME: this is just a "temporary" solution. Implement propper key
|
||||||
>
|
>
|
||||||
{ItemToDisplay(item,side)} <span onClick={()=>{
|
{ItemToDisplay(item,side)} <span onClick={()=>{
|
||||||
onChange?.(new Card(card.title,card.armor,card.helmet,...card.items.filter((_,fi)=>i!==fi)))
|
onChange?.(new Card(card.title,card.armor,card.helmet,...card.items.filter((_,fi)=>i!==fi)))
|
||||||
}} className="float-right cursor-pointer" >X</span>
|
}} className="float-right cursor-pointer" >X</span>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<AddItem side={side} onChange={newItem => onChange?.(new Card(card.title,card.armor,card.helmet,...card.items,newItem))} />
|
<AddItem side={side} onChange={newItem => onChange?.(new Card(card.title,card.armor,card.helmet,...card.items,newItem))} />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CardComp
|
export default CardComp
|
||||||
|
@ -14,50 +14,50 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const DeckComp: React.FC<Props> = ({deck,side,title,onChange}) => {
|
const DeckComp: React.FC<Props> = ({deck,side,title,onChange}) => {
|
||||||
return (
|
return (
|
||||||
<div className="bg-gray-800 m-1 p-1 overflow-x-scroll">
|
<div className="bg-gray-800 m-1 p-1 overflow-x-scroll">
|
||||||
<span className="font-bold">{title}</span>
|
<span className="font-bold">{title}</span>
|
||||||
{ side === Side.CT && <span className="px-2">
|
{ side === Side.CT && <span className="px-2">
|
||||||
Defuser: <NumEdit
|
Defuser: <NumEdit
|
||||||
value={deck.numDefusers}
|
value={deck.numDefusers}
|
||||||
onChange={newNum => onChange?.(new Deck(Math.max(newNum,0),...deck.cardGroups))}
|
onChange={newNum => onChange?.(new Deck(Math.max(newNum,0),...deck.cardGroups))}
|
||||||
/> </span> }
|
/> </span> }
|
||||||
<div className="flex">
|
<div className="flex">
|
||||||
{deck.cardGroups.map((group,index) =>
|
{deck.cardGroups.map((group,index) =>
|
||||||
<CardGroupComp
|
<CardGroupComp
|
||||||
key={group.toString() + index} // FIXME: this is just a "temporary" solution. Implement propper key
|
key={group.toString() + index} // FIXME: this is just a "temporary" solution. Implement propper key
|
||||||
cardGroup={group}
|
cardGroup={group}
|
||||||
side={side}
|
side={side}
|
||||||
onChange={(newGroup)=>{
|
onChange={(newGroup)=>{
|
||||||
onChange?.(new Deck(
|
onChange?.(new Deck(
|
||||||
deck.numDefusers,
|
deck.numDefusers,
|
||||||
...deck.cardGroups.map((e,i)=>i===index?newGroup:e)
|
...deck.cardGroups.map((e,i)=>i===index?newGroup:e)
|
||||||
))
|
))
|
||||||
}}
|
}}
|
||||||
onRemove={()=>{
|
onRemove={()=>{
|
||||||
onChange?.(new Deck(
|
onChange?.(new Deck(
|
||||||
deck.numDefusers,
|
deck.numDefusers,
|
||||||
...deck.cardGroups.filter((e,i)=>i!==index)
|
...deck.cardGroups.filter((e,i)=>i!==index)
|
||||||
))
|
))
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="bg-gray-700 button my-auto"
|
<div className="bg-gray-700 button my-auto"
|
||||||
onClick={()=>onChange?.(
|
onClick={()=>onChange?.(
|
||||||
new Deck(
|
new Deck(
|
||||||
deck.numDefusers,
|
deck.numDefusers,
|
||||||
...deck.cardGroups,
|
...deck.cardGroups,
|
||||||
new CardGroup(1,new Card("New card",false,false))
|
new CardGroup(1,new Card("New card",false,false))
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<div>
|
<div>
|
||||||
Add Group
|
Add Group
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default DeckComp
|
export default DeckComp
|
||||||
|
@ -6,21 +6,21 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const MenuBar: React.FC<Props> = ({onExport,onExportJson}) => {
|
const MenuBar: React.FC<Props> = ({onExport,onExportJson}) => {
|
||||||
return (
|
return (
|
||||||
<div className="bg-gray-800 h-10 m-1 p-1 flex">
|
<div className="bg-gray-800 h-10 m-1 p-1 flex">
|
||||||
<div className="bg-gray-700 button" onClick={onExport}>
|
<div className="bg-gray-700 button" onClick={onExport}>
|
||||||
Export
|
Export
|
||||||
</div>
|
</div>
|
||||||
<div className="bg-gray-700 button" onClick={onExportJson}>
|
<div className="bg-gray-700 button" onClick={onExportJson}>
|
||||||
Export to JSON
|
Export to JSON
|
||||||
</div>
|
</div>
|
||||||
<a href="https://developer.valvesoftware.com/wiki/CS:GO_Game_Mode_-_Retakes" target="_blank" rel='noreferrer'>
|
<a href="https://developer.valvesoftware.com/wiki/CS:GO_Game_Mode_-_Retakes" target="_blank" rel='noreferrer'>
|
||||||
<div className="bg-gray-700 button">
|
<div className="bg-gray-700 button">
|
||||||
Help
|
Help
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default MenuBar
|
export default MenuBar
|
||||||
|
@ -6,19 +6,19 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const NumEdit: React.FC<Props> = ({value,onChange}) => {
|
const NumEdit: React.FC<Props> = ({value,onChange}) => {
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<span
|
<span
|
||||||
className="cursor-pointer select-none"
|
className="cursor-pointer select-none"
|
||||||
onClick={()=>onChange?.(value - 1)}
|
onClick={()=>onChange?.(value - 1)}
|
||||||
>-</span>
|
>-</span>
|
||||||
{value}
|
{value}
|
||||||
<span
|
<span
|
||||||
className="cursor-pointer select-none"
|
className="cursor-pointer select-none"
|
||||||
onClick={()=>onChange?.(value + 1)}
|
onClick={()=>onChange?.(value + 1)}
|
||||||
>+</span>
|
>+</span>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NumEdit
|
export default NumEdit
|
||||||
|
@ -6,9 +6,9 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const SwitchButton: React.FC<Props> = ({active,onChange}) => {
|
const SwitchButton: React.FC<Props> = ({active,onChange}) => {
|
||||||
return (
|
return (
|
||||||
<button onClick={()=>onChange(!active)} > {active?"YES":"NO"} </button>
|
<button onClick={()=>onChange(!active)} > {active?"YES":"NO"} </button>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default SwitchButton
|
export default SwitchButton
|
||||||
|
@ -6,41 +6,43 @@ interface Props {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const TextEdit: React.FC<Props> = ({text,onChange}) => {
|
const TextEdit: React.FC<Props> = ({text,onChange}) => {
|
||||||
const [edit,setEdit] = useState<boolean>(false)
|
const [edit,setEdit] = useState<boolean>(false)
|
||||||
const [inputValue,setinputValue] = useState(text)
|
const [inputValue,setinputValue] = useState(text)
|
||||||
const inputRef = useRef<HTMLInputElement>(null)
|
const inputRef = useRef<HTMLInputElement>(null)
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if (edit){
|
if (edit){
|
||||||
inputRef.current?.select()
|
inputRef.current?.select()
|
||||||
}else{
|
}else{
|
||||||
if (text !== inputValue){
|
if (text !== inputValue){
|
||||||
onChange?.(inputValue)
|
onChange?.(inputValue)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},[edit])
|
},[edit])
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
{!edit && <span className="cursor-pointer" onClick={()=>setEdit(true)} >{inputValue}</span>}
|
{!edit && <span className="cursor-pointer" onClick={()=>setEdit(true)} >{inputValue}</span>}
|
||||||
{edit &&
|
{edit &&
|
||||||
<form className="inline" onSubmit={(e)=>{
|
<form className="inline"
|
||||||
e.preventDefault()
|
onSubmit={(e)=>{
|
||||||
setEdit(false)
|
e.preventDefault()
|
||||||
}} >
|
setEdit(false)
|
||||||
<input
|
}}
|
||||||
type="text"
|
>
|
||||||
className="bg-transparent outline-none font-bold"
|
<input
|
||||||
value={inputValue}
|
type="text"
|
||||||
onChange={(e)=>setinputValue(e.target.value)}
|
className="bg-transparent outline-none font-bold"
|
||||||
onBlur={()=>setEdit(false)}
|
value={inputValue}
|
||||||
ref={inputRef}
|
onChange={(e)=>setinputValue(e.target.value)}
|
||||||
></input>
|
onBlur={()=>setEdit(false)}
|
||||||
</form>
|
ref={inputRef}
|
||||||
}
|
></input>
|
||||||
</>
|
</form>
|
||||||
)
|
}
|
||||||
|
</>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export default TextEdit
|
export default TextEdit
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
import React from 'react';
|
import React from "react"
|
||||||
import ReactDOM from 'react-dom';
|
import ReactDOM from "react-dom"
|
||||||
import App from './components/App';
|
import App from "./components/App"
|
||||||
import './index.css';
|
import "./index.css"
|
||||||
|
|
||||||
ReactDOM.render(
|
ReactDOM.render(
|
||||||
<React.StrictMode>
|
<React.StrictMode>
|
||||||
<App />
|
<App />
|
||||||
</React.StrictMode>,
|
</React.StrictMode>,
|
||||||
document.getElementById('root')
|
document.getElementById("root")
|
||||||
);
|
)
|
||||||
|
@ -1,28 +1,28 @@
|
|||||||
import Item from "./Item"
|
import Item from "./Item"
|
||||||
|
|
||||||
class Card {
|
class Card {
|
||||||
readonly title: string
|
readonly title: string
|
||||||
readonly armor: boolean
|
readonly armor: boolean
|
||||||
readonly helmet: boolean
|
readonly helmet: boolean
|
||||||
readonly items: Item[]
|
readonly items: Item[]
|
||||||
|
|
||||||
constructor(title: string,armor: boolean,helmet: boolean,...items:Item[]){
|
constructor(title: string,armor: boolean,helmet: boolean,...items:Item[]){
|
||||||
this.title = title
|
this.title = title
|
||||||
this.armor = armor
|
this.armor = armor
|
||||||
this.helmet = helmet
|
this.helmet = helmet
|
||||||
this.items = items
|
this.items = items
|
||||||
}
|
}
|
||||||
|
|
||||||
public toCvar(): string {
|
public toCvar(): string {
|
||||||
return `${this.title},${bToS(this.armor)},${bToS(this.helmet)},${this.items.join(",")}`
|
return `${this.title},${bToS(this.armor)},${bToS(this.helmet)},${this.items.join(",")}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Converts a boolean to 1 for true and 0 for false
|
* Converts a boolean to 1 for true and 0 for false
|
||||||
*/
|
*/
|
||||||
function bToS(bool: boolean): string{
|
function bToS(bool: boolean): string{
|
||||||
return bool?"1":"0"
|
return bool?"1":"0"
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Card
|
export default Card
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import Card from "./Card"
|
import Card from "./Card"
|
||||||
|
|
||||||
class CardGroup {
|
class CardGroup {
|
||||||
readonly numInDeck: number
|
readonly numInDeck: number
|
||||||
readonly cards: Card[]
|
readonly cards: Card[]
|
||||||
|
|
||||||
constructor(numInDeck: number, ...cards: Card[]) {
|
constructor(numInDeck: number, ...cards: Card[]) {
|
||||||
this.numInDeck = numInDeck
|
this.numInDeck = numInDeck
|
||||||
this.cards = cards
|
this.cards = cards
|
||||||
}
|
}
|
||||||
|
|
||||||
public toCvar(): string {
|
public toCvar(): string {
|
||||||
return `${this.numInDeck};${this.cards.map(e => e.toCvar()).join(";")}`
|
return `${this.numInDeck};${this.cards.map(e => e.toCvar()).join(";")}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default CardGroup
|
export default CardGroup
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
import CardGroup from "./CardGroup"
|
import CardGroup from "./CardGroup"
|
||||||
|
|
||||||
class Deck {
|
class Deck {
|
||||||
readonly numDefusers: number
|
readonly numDefusers: number
|
||||||
readonly cardGroups: CardGroup[]
|
readonly cardGroups: CardGroup[]
|
||||||
|
|
||||||
constructor(numDefusers: number,...cardGroups: CardGroup[]){
|
constructor(numDefusers: number,...cardGroups: CardGroup[]){
|
||||||
this.numDefusers = numDefusers
|
this.numDefusers = numDefusers
|
||||||
this.cardGroups = cardGroups
|
this.cardGroups = cardGroups
|
||||||
}
|
}
|
||||||
|
|
||||||
public toCvar(): string {
|
public toCvar(): string {
|
||||||
return `${this.numDefusers}|${this.cardGroups.map(e => e.toCvar()).join("|")}`
|
return `${this.numDefusers}|${this.cardGroups.map(e => e.toCvar()).join("|")}`
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Deck
|
export default Deck
|
||||||
|
@ -2,30 +2,30 @@ import Card from "./Card"
|
|||||||
import Deck from "./Deck"
|
import Deck from "./Deck"
|
||||||
|
|
||||||
class RetakesConfig {
|
class RetakesConfig {
|
||||||
readonly ctPistol: Deck = new Deck(0)
|
readonly ctPistol: Deck = new Deck(0)
|
||||||
readonly tPistol: Deck = new Deck(0)
|
readonly tPistol: Deck = new Deck(0)
|
||||||
|
|
||||||
readonly ctUpgradedPistol: Deck = new Deck(0)
|
readonly ctUpgradedPistol: Deck = new Deck(0)
|
||||||
readonly tUpgradedPistol: Deck = new Deck(0)
|
readonly tUpgradedPistol: Deck = new Deck(0)
|
||||||
|
|
||||||
readonly ctLight: Deck = new Deck(0)
|
readonly ctLight: Deck = new Deck(0)
|
||||||
readonly tLight: Deck = new Deck(0)
|
readonly tLight: Deck = new Deck(0)
|
||||||
|
|
||||||
readonly ctFull: Deck = new Deck(0)
|
readonly ctFull: Deck = new Deck(0)
|
||||||
readonly tFull: Deck = new Deck(0)
|
readonly tFull: Deck = new Deck(0)
|
||||||
|
|
||||||
readonly ctEnemy: Card = new Card("CT Enemy card",false,false)
|
readonly ctEnemy: Card = new Card("CT Enemy card",false,false)
|
||||||
readonly tEnemy: Card = new Card("T Enemy card",false,false)
|
readonly tEnemy: Card = new Card("T Enemy card",false,false)
|
||||||
|
|
||||||
readonly ctBonus: Card = new Card("CT Bonus card",false,false)
|
readonly ctBonus: Card = new Card("CT Bonus card",false,false)
|
||||||
readonly tBonus: Card = new Card("T Bonus card",false,false)
|
readonly tBonus: Card = new Card("T Bonus card",false,false)
|
||||||
|
|
||||||
// If not set to [1] or a valid value the game will crash
|
// If not set to [1] or a valid value the game will crash
|
||||||
readonly ctBonusAvailability: number[] = [1]
|
readonly ctBonusAvailability: number[] = [1]
|
||||||
readonly tBonusAvailability: 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? :{
|
||||||
ctPistol?: Deck,
|
ctPistol?: Deck,
|
||||||
tPistol?: Deck,
|
tPistol?: Deck,
|
||||||
ctUpgradedPistol?: Deck,
|
ctUpgradedPistol?: Deck,
|
||||||
@ -41,26 +41,26 @@ class RetakesConfig {
|
|||||||
ctBonusAvailability?: number[],
|
ctBonusAvailability?: number[],
|
||||||
tBonusAvailability?: number[],
|
tBonusAvailability?: number[],
|
||||||
}){
|
}){
|
||||||
if (args){
|
if (args){
|
||||||
args.ctPistol && (this.ctPistol = args.ctPistol)
|
args.ctPistol && (this.ctPistol = args.ctPistol)
|
||||||
args.tPistol && (this.tPistol = args.tPistol)
|
args.tPistol && (this.tPistol = args.tPistol)
|
||||||
args.ctUpgradedPistol && (this.ctUpgradedPistol = args.ctUpgradedPistol)
|
args.ctUpgradedPistol && (this.ctUpgradedPistol = args.ctUpgradedPistol)
|
||||||
args.tUpgradedPistol && (this.tUpgradedPistol = args.tUpgradedPistol)
|
args.tUpgradedPistol && (this.tUpgradedPistol = args.tUpgradedPistol)
|
||||||
args.ctLight && (this.ctLight = args.ctLight)
|
args.ctLight && (this.ctLight = args.ctLight)
|
||||||
args.tLight && (this.tLight = args.tLight)
|
args.tLight && (this.tLight = args.tLight)
|
||||||
args.ctFull && (this.ctFull = args.ctFull)
|
args.ctFull && (this.ctFull = args.ctFull)
|
||||||
args.tFull && (this.tFull = args.tFull)
|
args.tFull && (this.tFull = args.tFull)
|
||||||
args.ctEnemy && (this.ctEnemy = args.ctEnemy)
|
args.ctEnemy && (this.ctEnemy = args.ctEnemy)
|
||||||
args.tEnemy && (this.tEnemy = args.tEnemy)
|
args.tEnemy && (this.tEnemy = args.tEnemy)
|
||||||
args.ctBonus && (this.ctBonus = args.ctBonus)
|
args.ctBonus && (this.ctBonus = args.ctBonus)
|
||||||
args.tBonus && (this.tBonus = args.tBonus)
|
args.tBonus && (this.tBonus = args.tBonus)
|
||||||
args.ctBonusAvailability && (this.ctBonusAvailability = args.ctBonusAvailability)
|
args.ctBonusAvailability && (this.ctBonusAvailability = args.ctBonusAvailability)
|
||||||
args.tBonusAvailability && (this.tBonusAvailability = args.tBonusAvailability)
|
args.tBonusAvailability && (this.tBonusAvailability = args.tBonusAvailability)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public toCvar(): string{
|
public toCvar(): string{
|
||||||
return `mp_retake_ct_loadout_default_pistol_round "${this.ctPistol.toCvar()}"
|
return `mp_retake_ct_loadout_default_pistol_round "${this.ctPistol.toCvar()}"
|
||||||
mp_retake_t_loadout_default_pistol_round "${this.tPistol.toCvar()}"
|
mp_retake_t_loadout_default_pistol_round "${this.tPistol.toCvar()}"
|
||||||
mp_retake_ct_loadout_upgraded_pistol_round "${this.ctUpgradedPistol.toCvar()}"
|
mp_retake_ct_loadout_upgraded_pistol_round "${this.ctUpgradedPistol.toCvar()}"
|
||||||
mp_retake_t_loadout_upgraded_pistol_round "${this.tUpgradedPistol.toCvar()}"
|
mp_retake_t_loadout_upgraded_pistol_round "${this.tUpgradedPistol.toCvar()}"
|
||||||
@ -73,7 +73,7 @@ mp_retake_t_loadout_bonus_card "${this.tBonus.toCvar()}"
|
|||||||
mp_retake_ct_loadout_bonus_card_availability "${this.ctBonusAvailability.join(",")}"
|
mp_retake_ct_loadout_bonus_card_availability "${this.ctBonusAvailability.join(",")}"
|
||||||
mp_retake_t_loadout_bonus_card_availability "${this.tBonusAvailability.join(",")}"
|
mp_retake_t_loadout_bonus_card_availability "${this.tBonusAvailability.join(",")}"
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user