master
lza_menace 2 years ago
parent df8fdee967
commit 15a9407309

@ -125,6 +125,57 @@
"stateMutability": "view", "stateMutability": "view",
"type": "function" "type": "function"
}, },
{
"inputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"name": "killCount",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"name": "leaderboard",
"outputs": [
{
"internalType": "address",
"name": "",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "leaderboardPointer",
"outputs": [
{
"internalType": "uint256",
"name": "",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
},
{ {
"inputs": [], "inputs": [],
"name": "mailbomb", "name": "mailbomb",

@ -72,11 +72,11 @@
} }
#gameMapTitle { #gameMapTitle {
margin: 1em 0 0 0; margin: 1em 0 1em 0;
} }
#gameStats { #gameStats {
margin: .5em 0 .5em 0; margin: .5em 0 0 0;
position: absolute; position: absolute;
z-index: 99; z-index: 99;
background-color: rgba(0,0,0,.6); background-color: rgba(0,0,0,.6);
@ -130,3 +130,14 @@
75% { opacity: .9 } 75% { opacity: .9 }
100% { opacity: 1 } 100% { opacity: 1 }
} }
#killLeader {
margin: .5em 0 .5em 0;
position: absolute;
z-index: 99;
background-color: rgba(0,0,0,.6);
padding: 2px;
border-radius: 4px;
text-align: left;
right: 0;
}

@ -149,20 +149,23 @@ class GameMap extends React.Component {
<h1 id="gameMapTitle">Metaverse Map</h1> <h1 id="gameMapTitle">Metaverse Map</h1>
<div id="gameStats"> <div id="gameStats">
<ul> <ul>
<li><span className="squares" style={{backgroundColor: 'white'}}></span> _ Alive Unaboomers: {this.state.unaboomerSupply - this.state.unaboomersKilled}</li> <li>Active Unaboomers: {this.state.unaboomerSupply - this.state.unaboomersKilled}</li>
<li><span className="squares" style={{backgroundColor: 'black'}}></span> _ Dead Unaboomers: {this.state.unaboomersKilled}</li> <li>Dead Unaboomers: {this.state.unaboomersKilled}</li>
<li><span className="dots" style={{backgroundColor: 'yellow'}}></span> _ Active Bombs: {this.state.bombSupply - this.state.bombsExploded}</li> <li><p className="dots" style={{backgroundColor: 'white'}}></p> _ Active Bombs: {this.state.bombSupply - this.state.bombsExploded}</li>
<li><span className="dots" style={{backgroundColor: 'cyan'}}></span> _ Exploded Bombs: {this.state.bombsExploded}</li> <li><p className="dots" style={{backgroundColor: '#5BC66E'}}></p> _ Exploded Bombs: {this.state.bombsExploded}</li>
<li><span className="dots" style={{backgroundColor: 'red'}}></span> _ Dud Bombs: {this.state.bombsExploded}</li> <li><p className="dots" style={{backgroundColor: '#c65bb3'}}></p> _ Dud Bombs: {this.state.bombsExploded}</li>
</ul> </ul>
</div> </div>
<div id="killLeader">
<img src={Boomer} width="50px" />
<p>Kill Leader: {this.props.killLeader}</p>
<p>{this.props.killLeaderCount} kills</p>
</div>
<div className="map"> <div className="map">
<img src={Map} /> <img src={Map} />
<GenerateBombOverlay amount={this.state.unaboomerSupply - this.state.unaboomersKilled} color={'white'} type={'squares'} /> <GenerateBombOverlay amount={this.state.bombSupply - this.state.bombsExploded} color={'white'} type={'dots'} />
<GenerateBombOverlay amount={this.state.unaboomersKilled} color={'black'} type={'squares'} /> <GenerateBombOverlay amount={this.state.bombsExploded} color={'#5BC66E'} type={'dots'} />
<GenerateBombOverlay amount={this.state.bombSupply - this.state.bombsExploded} color={'yellow'} type={'dots'} /> <GenerateBombOverlay amount={this.state.bombsExploded} color={'#c65bb3'} type={'dots'} />
<GenerateBombOverlay amount={this.state.bombsExploded} color={'cyan'} type={'dots'} />
<GenerateBombOverlay amount={this.state.bombsExploded} color={'red'} type={'dots'} />
</div> </div>
</> </>
) )
@ -182,6 +185,9 @@ function Section3() {
bombSupply: 0, bombSupply: 0,
bombsExploded: 0, bombsExploded: 0,
unaboomersKilled: 0, unaboomersKilled: 0,
leaderboardPointer: 0,
killLeader: '',
killLeaderCount: 0,
results: [], results: [],
tokensKilled: [] tokensKilled: []
}); });
@ -189,57 +195,50 @@ function Section3() {
setOptions(preState => ({...preState , ...obj})) setOptions(preState => ({...preState , ...obj}))
} }
const { isConnected, address } = useAccount(); const { isConnected, address } = useAccount();
const defOpt = {
address: contractAddress,
abi: MainABI,
enabled: isConnected
}
useContractReads({ useContractReads({
contracts: [ contracts: [
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'unaboomerPrice' functionName: 'unaboomerPrice'
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'bombPrice' functionName: 'bombPrice'
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'unaboomerBalance', functionName: 'unaboomerBalance',
args: [address] args: [address]
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'bombBalance', functionName: 'bombBalance',
args: [address] args: [address]
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'unaboomerSupply' functionName: 'unaboomerSupply'
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'bombSupply' functionName: 'bombSupply'
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'bombsExploded' functionName: 'bombsExploded'
}, },
{ {
address: contractAddress, ...defOpt,
abi: MainABI,
enabled: isConnected,
functionName: 'unaboomersKilled' functionName: 'unaboomersKilled'
},
{
...defOpt,
functionName: 'leaderboardPointer'
} }
], ],
watch: true, watch: true,
@ -254,6 +253,41 @@ function Section3() {
bombSupply: data[5].toString(), bombSupply: data[5].toString(),
bombsExploded: data[6].toString(), bombsExploded: data[6].toString(),
unaboomersKilled: data[7].toString(), unaboomersKilled: data[7].toString(),
leaderboardPointer: data[8].toString()
});
}
});
useContractReads({
contracts: [
{
...defOpt,
enabled: options.leaderboardPointer > 0,
functionName: 'leaderboard',
args: [options.leaderboardPointer]
}
],
watch: true,
cacheTime: 10000,
onSuccess(data) {
handleStateChange({
killLeader: data[0].toString(),
});
}
});
useContractReads({
contracts: [
{
...defOpt,
enabled: options.killLeader.length > 0,
functionName: 'killCount',
args: [options.killLeader]
}
],
watch: true,
cacheTime: 10000,
onSuccess(data) {
handleStateChange({
killLeaderCount: data[0].toString(),
}); });
} }
}); });
@ -298,7 +332,6 @@ function Section3() {
log.topics[0] === '0x38c7e2e8001cefb27535bd6bcc6363c6d6a6a83dbb77f092b78956334596f9ed' log.topics[0] === '0x38c7e2e8001cefb27535bd6bcc6363c6d6a6a83dbb77f092b78956334596f9ed'
).map((log) => { ).map((log) => {
const res = iface.decodeEventLog("SentBomb", log.data, log.topics); const res = iface.decodeEventLog("SentBomb", log.data, log.topics);
console.log(res);
if (res.hit) { if (res.hit) {
if (res.owned) { if (res.owned) {
NotificationManager.error(`Your bomb exploded during assembly and killed your Unaboomer ${res.tokenId.toString()}`, 'oof', 10000); NotificationManager.error(`Your bomb exploded during assembly and killed your Unaboomer ${res.tokenId.toString()}`, 'oof', 10000);
@ -361,6 +394,8 @@ function Section3() {
bombsExploded={options.bombsExploded} bombsExploded={options.bombsExploded}
unaboomerSupply={options.unaboomerSupply} unaboomerSupply={options.unaboomerSupply}
unaboomersKilled={options.unaboomersKilled} unaboomersKilled={options.unaboomersKilled}
killLeader={options.killLeader}
killLeaderCount={options.killLeaderCount}
/> />
</> </>
|| ||

Loading…
Cancel
Save