revamping map

master
lza_menace 2 years ago
parent eca745dbca
commit 8630bc443c

@ -81,6 +81,19 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [],
"name": "bombsExploded",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [ "inputs": [
{ {

@ -87,12 +87,11 @@
} }
.dots { .dots {
width: 10px; width: 6px;
height: 10px; height: 6px;
position: absolute; position: absolute;
background-color: red;
border-radius: 50%; border-radius: 50%;
filter: drop-shadow(0 0 4px crimson); filter: drop-shadow(0 0 4px rgb(255, 230, 0, .5));
animation: pulse .75s ease-out infinite alternate; animation: pulse .75s ease-out infinite alternate;
} }

@ -90,7 +90,7 @@ class GenerateBombOverlay extends React.Component {
} }
render() { render() {
return this.state.coords.map((obj) => <div className="dots" style={{top: obj.y, left: obj.x}} />) return this.state.coords.map((obj) => <div className="dots" style={{top: obj.y, left: obj.x, backgroundColor: this.props.color}} />)
} }
} }
@ -104,6 +104,8 @@ export function Section3() {
const [bombBalance, setBombBalance] = useState(0); const [bombBalance, setBombBalance] = useState(0);
const [bombSupply, setBombSupply] = useState(0); const [bombSupply, setBombSupply] = useState(0);
const [boomerSupply, setBoomerSupply] = useState(0); const [boomerSupply, setBoomerSupply] = useState(0);
const [bombExploded, setBombExploded] = useState(0);
const [boomerKillCount, setBoomerKillCount] = useState(0);
const { isConnected, address } = useAccount(); const { isConnected, address } = useAccount();
useContractReads({ useContractReads({
contracts: [ contracts: [
@ -144,10 +146,22 @@ export function Section3() {
abi: MainABI, abi: MainABI,
enabled: isConnected, enabled: isConnected,
functionName: 'bombSupply' functionName: 'bombSupply'
},
{
address: contractAddress,
abi: MainABI,
enabled: isConnected,
functionName: 'bombsExploded'
},
{
address: contractAddress,
abi: MainABI,
enabled: isConnected,
functionName: 'boomerKillCount'
} }
], ],
watch: true, watch: true,
cacheTime: 4_000, cacheTime: 5000,
onSuccess(data) { onSuccess(data) {
setBoomerPrice(data[0].toString()); setBoomerPrice(data[0].toString());
setBombPrice(data[1].toString()); setBombPrice(data[1].toString());
@ -155,6 +169,8 @@ export function Section3() {
setBombBalance(data[3].toString()); setBombBalance(data[3].toString());
setBoomerSupply(data[4].toString()); setBoomerSupply(data[4].toString());
setBombSupply(data[5].toString()); setBombSupply(data[5].toString());
setBombExploded(data[6].toString());
setBoomerKillCount(data[7].toString());
} }
}); });
const radicalizeBoomersPrepare = usePrepareContractWrite({ const radicalizeBoomersPrepare = usePrepareContractWrite({
@ -181,6 +197,14 @@ export function Section3() {
} }
}); });
const assembleBombsWrite = useContractWrite(assembleBombsPrepare.config); const assembleBombsWrite = useContractWrite(assembleBombsPrepare.config);
const sendBombsPrepare = usePrepareContractWrite({
address: contractAddress,
abi: MainABI,
enabled: isConnected,
functionName: 'sendBombs',
args: [sendBombAmount]
});
const sendBombsWrite = useContractWrite(sendBombsPrepare.config);
return ( return (
<section className="section"> <section className="section">
{isConnected && {isConnected &&
@ -195,10 +219,7 @@ export function Section3() {
{radicalizeBoomersWrite.isLoading && <>minting {boomerAmount}</> || <>mint {boomerAmount} ({ethers.utils.formatEther((boomerPrice * boomerAmount).toString())} Ξ)</>} {radicalizeBoomersWrite.isLoading && <>minting {boomerAmount}</> || <>mint {boomerAmount} ({ethers.utils.formatEther((boomerPrice * boomerAmount).toString())} Ξ)</>}
</AwesomeButton> </AwesomeButton>
</p> </p>
<Slider className="slider" min={1} max={30} trackStyle={{ <Slider className="slider" min={1} max={30} onChange={v => debounce(setBoomerAmount(v), 500)} />
backgroundColor:'rgba(125, 46, 104, .8)',
borderColor:'rgba(37, 19, 81, .8)'
}} onChange={v => debounce(setBoomerAmount(v), 500)} />
</div> </div>
<div className="mintItem"> <div className="mintItem">
<h1>Assemble Bombs</h1> <h1>Assemble Bombs</h1>
@ -210,29 +231,25 @@ export function Section3() {
{assembleBombsWrite.isLoading && <>minting {bombAmount}</> || <>mint {bombAmount} ({ethers.utils.formatEther((bombPrice * bombAmount).toString())} Ξ)</>} {assembleBombsWrite.isLoading && <>minting {bombAmount}</> || <>mint {bombAmount} ({ethers.utils.formatEther((bombPrice * bombAmount).toString())} Ξ)</>}
</AwesomeButton> </AwesomeButton>
</p> </p>
<Slider className="slider" min={1} max={30} trackStyle={{ <Slider className="slider" min={1} max={30} onChange={v => setBombAmount(v)} />
backgroundColor:'rgba(125, 46, 104, .8)',
borderColor:'rgba(37, 19, 81, .8)'
}} onChange={v => setBombAmount(v)} />
</div> </div>
<div className="mintItem"> <div className="mintItem">
<h1>Send Bombs</h1> <h1>Send Bombs</h1>
<p>Sending bombs will burn your BOMB token and kill a BOOMR token at random. Be careful not to kill yourself in the process.</p> <p>Sending bombs will burn your BOMB token and kill a BOOMR token at random. Be careful not to kill yourself in the process.</p>
<p>There are {boomerSupply} BOOMR available to kill</p> <p>There are {boomerSupply - boomerKillCount} BOOMR available to kill</p>
<img src={Explosion} alt="" width="120px" /> <img src={Explosion} alt="" width="120px" />
<p> <p>
<AwesomeButton type="secondary" ripple={true} disabled={bombAmount}> <AwesomeButton type="secondary" ripple={true} disabled={!sendBombsWrite.write} onPress={() => sendBombsWrite.write?.()}>
send {sendBombAmount} (~0 Ξ) send {sendBombAmount} (~0 Ξ)
</AwesomeButton> </AwesomeButton>
</p> </p>
<Slider className="slider" min={1} max={30} trackStyle={{ <Slider className="slider" min={1} max={30} onChange={v => setSendBombAmount(v)} />
backgroundColor:'rgba(125, 46, 104, .8)',
borderColor:'rgba(37, 19, 81, .8)'
}} onChange={v => setSendBombAmount(v)} />
</div> </div>
<div className="map"> <div className="map">
<img src={Map} /> <img src={Map} />
<GenerateBombOverlay amount={bombSupply} /> <GenerateBombOverlay amount={bombSupply - bombBalance - bombExploded} color={'white'} />
<GenerateBombOverlay amount={bombExploded} color={'red'} />
<GenerateBombOverlay amount={bombBalance} color={'yellow'} />
</div> </div>
</div> </div>
|| ||

Loading…
Cancel
Save