forked from mico/idle_moloch
Annointed is actually spelled anointed
This commit is contained in:
parent
684d752b08
commit
20fa42cfca
BIN
app/public/roles/druid2.png
Normal file
BIN
app/public/roles/druid2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 10 KiB |
BIN
app/public/roles/ranger2.png
Normal file
BIN
app/public/roles/ranger2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
app/public/roles/scribe2.png
Normal file
BIN
app/public/roles/scribe2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.8 KiB |
BIN
app/public/roles/warrior2.png
Normal file
BIN
app/public/roles/warrior2.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.6 KiB |
20
app/src/components/Army.tsx
Normal file
20
app/src/components/Army.tsx
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
import { usePlayer } from '../providers/PlayerProvider';
|
||||||
|
import styles from '../styles/Army.module.css';
|
||||||
|
|
||||||
|
const Army = () => {
|
||||||
|
|
||||||
|
const { army } = usePlayer()
|
||||||
|
|
||||||
|
|
||||||
|
return <div className="styles.armyGathering">
|
||||||
|
<div className={`${styles.tavern_keeper} ${styles.person} ${styles.static}`} />
|
||||||
|
<div className={`${styles.scribe} ${styles.person} ${styles.moloch_denier} ${styles.static}`}>
|
||||||
|
<div className="supply"></div>
|
||||||
|
</div>
|
||||||
|
<div className={`${styles.druid} ${styles.person} ${styles.apprentice} ${styles.static}`} ></div>
|
||||||
|
<div className={`${styles.ranger} ${styles.person} ${styles.anointed} ${styles.static}`} ></div>
|
||||||
|
<div className={`${styles.warrior} ${styles.person} ${styles.champion} ${styles.static}`} ></div>
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Army
|
||||||
@ -1,8 +1,9 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import styles from '../styles/Background.module.css';
|
import styles from '../styles/Background.module.css';
|
||||||
import Tower from "./Tower";
|
import Tower from "./Tower";
|
||||||
|
import Army from "./Army";
|
||||||
|
|
||||||
const Background = () => {
|
const Scene = () => {
|
||||||
return <div className={styles.frame}>
|
return <div className={styles.frame}>
|
||||||
<div className={`${styles.air} ${styles.background_asset}`} />
|
<div className={`${styles.air} ${styles.background_asset}`} />
|
||||||
<div className={`${styles.clouds_small} ${styles.background_asset}`} />
|
<div className={`${styles.clouds_small} ${styles.background_asset}`} />
|
||||||
@ -10,9 +11,9 @@ const Background = () => {
|
|||||||
<Tower />
|
<Tower />
|
||||||
<div className={`${styles.mountains} ${styles.background_asset}`} />
|
<div className={`${styles.mountains} ${styles.background_asset}`} />
|
||||||
<div className={`${styles.village} ${styles.background_asset}`} />
|
<div className={`${styles.village} ${styles.background_asset}`} />
|
||||||
<div className={`${styles.tavern_keeper} ${styles.person} ${styles.static_keeper}`} />
|
|
||||||
<div className={`${styles.bonfire} ${styles.background_asset}`} />
|
<div className={`${styles.bonfire} ${styles.background_asset}`} />
|
||||||
|
<Army />
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
|
|
||||||
export default Background
|
export default Scene
|
||||||
@ -3,7 +3,7 @@ import type { NextPage } from 'next';
|
|||||||
import Head from 'next/head';
|
import Head from 'next/head';
|
||||||
import styles from '../styles/Home.module.css';
|
import styles from '../styles/Home.module.css';
|
||||||
import Header from '../components/Header';
|
import Header from '../components/Header';
|
||||||
import Background from '../components/Background';
|
import Scene from '../components/Scene';
|
||||||
|
|
||||||
const Home: NextPage = () => {
|
const Home: NextPage = () => {
|
||||||
return (
|
return (
|
||||||
@ -22,7 +22,7 @@ const Home: NextPage = () => {
|
|||||||
<ConnectButton />
|
<ConnectButton />
|
||||||
</div>
|
</div>
|
||||||
<Header />
|
<Header />
|
||||||
<Background />
|
<Scene />
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
<footer className={styles.footer}>
|
<footer className={styles.footer}>
|
||||||
|
|||||||
@ -8,15 +8,20 @@ const abi = contractAbi.abi
|
|||||||
|
|
||||||
export interface PlayerContextType {
|
export interface PlayerContextType {
|
||||||
isRegistered: boolean,
|
isRegistered: boolean,
|
||||||
user: null | string,
|
player: null | string,
|
||||||
|
army: null | { profit_per_second: bigint },
|
||||||
balance: bigint,
|
balance: bigint,
|
||||||
register: () => void;
|
register: () => void;
|
||||||
raid: () => void
|
raid: () => void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface Player { }
|
||||||
|
export interface Army { }
|
||||||
|
|
||||||
const PlayerContext = createContext<PlayerContextType>({
|
const PlayerContext = createContext<PlayerContextType>({
|
||||||
isRegistered: false,
|
isRegistered: false,
|
||||||
user: null,
|
player: null,
|
||||||
|
army: null,
|
||||||
balance: BigInt(0),
|
balance: BigInt(0),
|
||||||
register: () => { },
|
register: () => { },
|
||||||
raid: () => { },
|
raid: () => { },
|
||||||
@ -26,6 +31,9 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
const { address, isConnected } = useAccount();
|
const { address, isConnected } = useAccount();
|
||||||
const { writeContract, error } = useWriteContract();
|
const { writeContract, error } = useWriteContract();
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
console.warn(error)
|
||||||
|
}, [error])
|
||||||
|
|
||||||
const { data: isRegistered } = useReadContract({
|
const { data: isRegistered } = useReadContract({
|
||||||
address: contractAddress,
|
address: contractAddress,
|
||||||
@ -49,7 +57,7 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data: playerData } = useReadContract({
|
const { data: player } = useReadContract({
|
||||||
address: contractAddress,
|
address: contractAddress,
|
||||||
abi,
|
abi,
|
||||||
functionName: 'getPlayer',
|
functionName: 'getPlayer',
|
||||||
@ -60,11 +68,16 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(playerData)
|
const { data: army } = useReadContract({
|
||||||
|
address: contractAddress,
|
||||||
useEffect(() => {
|
abi,
|
||||||
console.warn(error, playerData)
|
functionName: 'getArmy',
|
||||||
}, [error])
|
args: [address],
|
||||||
|
query: {
|
||||||
|
enabled: isConnected,
|
||||||
|
refetchInterval: 15
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
const register = useCallback(() => {
|
const register = useCallback(() => {
|
||||||
writeContract({
|
writeContract({
|
||||||
@ -83,10 +96,13 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
|
|||||||
})
|
})
|
||||||
}, [writeContract])
|
}, [writeContract])
|
||||||
|
|
||||||
|
console.log(player, army)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PlayerContext.Provider value={{
|
<PlayerContext.Provider value={{
|
||||||
isRegistered: isRegistered as boolean,
|
isRegistered: isRegistered as boolean,
|
||||||
user: null,
|
player: player,
|
||||||
|
army: army,
|
||||||
balance: balance as bigint,
|
balance: balance as bigint,
|
||||||
register,
|
register,
|
||||||
raid
|
raid
|
||||||
|
|||||||
115
app/src/styles/Army.module.css
Normal file
115
app/src/styles/Army.module.css
Normal file
@ -0,0 +1,115 @@
|
|||||||
|
.army-gathering {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 22px;
|
||||||
|
left: 22px;
|
||||||
|
right: 22px;
|
||||||
|
}
|
||||||
|
.person {
|
||||||
|
position: absolute;
|
||||||
|
width: 80px;
|
||||||
|
height: 80px;
|
||||||
|
background-size: contain;
|
||||||
|
background-position: bottom center;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
transform-origin: bottom center;
|
||||||
|
}
|
||||||
|
.tavern_keeper {
|
||||||
|
background-image: url("/roles/tavern-keeper.svg");
|
||||||
|
}
|
||||||
|
.alchemist {
|
||||||
|
background-image: url("/roles/alchemist.svg");
|
||||||
|
}
|
||||||
|
.archer {
|
||||||
|
background-image: url("/roles/archer.svg");
|
||||||
|
}
|
||||||
|
.cleric {
|
||||||
|
background-image: url("/roles/cleric.svg");
|
||||||
|
}
|
||||||
|
.druid {
|
||||||
|
background-image: url("/roles/druid.svg");
|
||||||
|
}
|
||||||
|
.dwarf {
|
||||||
|
background-image: url("/roles/dwarf.svg");
|
||||||
|
}
|
||||||
|
.monk {
|
||||||
|
background-image: url("/roles/monk.svg");
|
||||||
|
}
|
||||||
|
.necromancer {
|
||||||
|
background-image: url("/roles/necromancer.svg");
|
||||||
|
}
|
||||||
|
.paladin {
|
||||||
|
background-image: url("/roles/paladin.svg");
|
||||||
|
}
|
||||||
|
.ranger {
|
||||||
|
background-image: url("/roles/ranger.svg");
|
||||||
|
}
|
||||||
|
.rogue {
|
||||||
|
background-image: url("/roles/rogue.svg");
|
||||||
|
}
|
||||||
|
.scribe {
|
||||||
|
background-image: url("/roles/scribe.svg");
|
||||||
|
}
|
||||||
|
.warrior {
|
||||||
|
background-image: url("/roles/warrior.svg");
|
||||||
|
}
|
||||||
|
.wizard {
|
||||||
|
background-image: url("/roles/wizard.svg");
|
||||||
|
}
|
||||||
|
.healer {
|
||||||
|
background-image: url("/roles/healer.svg");
|
||||||
|
}
|
||||||
|
.hunter {
|
||||||
|
background-image: url("/roles/hunter.svg");
|
||||||
|
}
|
||||||
|
.static {
|
||||||
|
width: 110px;
|
||||||
|
height: 110px;
|
||||||
|
transition: all 100ms cubic-bezier(0.265, 1.4, 0.68, 1.65);
|
||||||
|
&:not(.locked) {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
&:hover {
|
||||||
|
transform: scale(1.08, 1.08);
|
||||||
|
}
|
||||||
|
&:active {
|
||||||
|
transform: scale(1.2, 1.2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.static.tavern_keeper {
|
||||||
|
right: 130px;
|
||||||
|
bottom: 160px;
|
||||||
|
width: 90px;
|
||||||
|
height: 90px;
|
||||||
|
}
|
||||||
|
.static.moloch_denier {
|
||||||
|
left: calc(20% - 60px);
|
||||||
|
bottom: 70px;
|
||||||
|
background-image: url("/roles/scribe2.png");
|
||||||
|
}
|
||||||
|
.static.apprentice {
|
||||||
|
left: calc(36% - 60px);
|
||||||
|
background-image: url("/roles/druid2.png");
|
||||||
|
bottom: 72px;
|
||||||
|
}
|
||||||
|
.static.anointed {
|
||||||
|
left: calc(50% - 60px);
|
||||||
|
bottom: 64px;
|
||||||
|
background-image: url("/roles/ranger2.png");
|
||||||
|
}
|
||||||
|
.static.champion {
|
||||||
|
left: calc(64% - 60px);
|
||||||
|
bottom: 66px;
|
||||||
|
background-image: url("/roles/warrior2.png");
|
||||||
|
}
|
||||||
|
|
||||||
|
.moloch_denier {
|
||||||
|
filter: sepia(0.1);
|
||||||
|
}
|
||||||
|
.apprentice {
|
||||||
|
}
|
||||||
|
.anointed {
|
||||||
|
filter: saturate(1.1);
|
||||||
|
}
|
||||||
|
.champion {
|
||||||
|
filter: saturate(2);
|
||||||
|
}
|
||||||
@ -50,7 +50,8 @@
|
|||||||
height: 240px;
|
height: 240px;
|
||||||
top: 200px;
|
top: 200px;
|
||||||
animation: thunder_hue_hard 12s linear infinite;
|
animation: thunder_hue_hard 12s linear infinite;
|
||||||
transition: all ease-in-out 0.05s;
|
transition: all 0.1s cubic-bezier(0.265, 1.4, 0.68, 1.65);
|
||||||
|
transform-origin: bottom center;
|
||||||
&:hover {
|
&:hover {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
transform: scale(1.05, 1.1);
|
transform: scale(1.05, 1.1);
|
||||||
@ -94,67 +95,6 @@
|
|||||||
bonfire 12s linear infinite,
|
bonfire 12s linear infinite,
|
||||||
bonfire_skew 5s infinite linear;
|
bonfire_skew 5s infinite linear;
|
||||||
}
|
}
|
||||||
.person {
|
|
||||||
position: absolute;
|
|
||||||
width: 80px;
|
|
||||||
height: 80px;
|
|
||||||
background-size: contain;
|
|
||||||
background-position: bottom center;
|
|
||||||
background-repeat: no-repeat;
|
|
||||||
}
|
|
||||||
.tavern_keeper {
|
|
||||||
background-image: url("/roles/tavern-keeper.svg");
|
|
||||||
}
|
|
||||||
.alchemist {
|
|
||||||
background-image: url("/roles/alchemist.svg");
|
|
||||||
}
|
|
||||||
.archer {
|
|
||||||
background-image: url("/roles/archer.svg");
|
|
||||||
}
|
|
||||||
.cleric {
|
|
||||||
background-image: url("/roles/cleric.svg");
|
|
||||||
}
|
|
||||||
.druid {
|
|
||||||
background-image: url("/roles/druid.svg");
|
|
||||||
}
|
|
||||||
.dwarf {
|
|
||||||
background-image: url("/roles/dwarf.svg");
|
|
||||||
}
|
|
||||||
.monk {
|
|
||||||
background-image: url("/roles/monk.svg");
|
|
||||||
}
|
|
||||||
.necromancer {
|
|
||||||
background-image: url("/roles/necromancer.svg");
|
|
||||||
}
|
|
||||||
.paladin {
|
|
||||||
background-image: url("/roles/paladin.svg");
|
|
||||||
}
|
|
||||||
.ranger {
|
|
||||||
background-image: url("/roles/ranger.svg");
|
|
||||||
}
|
|
||||||
.rogue {
|
|
||||||
background-image: url("/roles/rogue.svg");
|
|
||||||
}
|
|
||||||
.scribe {
|
|
||||||
background-image: url("/roles/scribe.svg");
|
|
||||||
}
|
|
||||||
.warrior {
|
|
||||||
background-image: url("/roles/warrior.svg");
|
|
||||||
}
|
|
||||||
.wizard {
|
|
||||||
background-image: url("/roles/wizard.svg");
|
|
||||||
}
|
|
||||||
.healer {
|
|
||||||
background-image: url("/roles/healer.svg");
|
|
||||||
}
|
|
||||||
.hunter {
|
|
||||||
background-image: url("/roles/hunter.svg");
|
|
||||||
}
|
|
||||||
.static_keeper {
|
|
||||||
right: 130px;
|
|
||||||
bottom: 160px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@keyframes scrollBackground {
|
@keyframes scrollBackground {
|
||||||
0% {
|
0% {
|
||||||
background-position: 0 0;
|
background-position: 0 0;
|
||||||
|
|||||||
@ -12,7 +12,7 @@ struct Raider {
|
|||||||
struct Army {
|
struct Army {
|
||||||
Raider moloch_denier;
|
Raider moloch_denier;
|
||||||
Raider apprentice;
|
Raider apprentice;
|
||||||
Raider annointed;
|
Raider anointed;
|
||||||
Raider champion;
|
Raider champion;
|
||||||
uint256 profit_per_second;
|
uint256 profit_per_second;
|
||||||
}
|
}
|
||||||
@ -53,7 +53,7 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
armies[msg.sender] = Army({
|
armies[msg.sender] = Army({
|
||||||
moloch_denier: Raider({level: 0}),
|
moloch_denier: Raider({level: 0}),
|
||||||
apprentice: Raider({level: 0}),
|
apprentice: Raider({level: 0}),
|
||||||
annointed: Raider({level: 0}),
|
anointed: Raider({level: 0}),
|
||||||
champion: Raider({level: 0}),
|
champion: Raider({level: 0}),
|
||||||
profit_per_second: 0
|
profit_per_second: 0
|
||||||
});
|
});
|
||||||
@ -111,8 +111,8 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
// apprentice
|
// apprentice
|
||||||
currentLevel = army.apprentice.level;
|
currentLevel = army.apprentice.level;
|
||||||
} else if (unit == 2) {
|
} else if (unit == 2) {
|
||||||
// annointed
|
// anointed
|
||||||
currentLevel = army.annointed.level;
|
currentLevel = army.anointed.level;
|
||||||
} else if (unit == 3) {
|
} else if (unit == 3) {
|
||||||
// champion
|
// champion
|
||||||
currentLevel = army.champion.level;
|
currentLevel = army.champion.level;
|
||||||
@ -130,8 +130,8 @@ contract RaidGeld is ERC20, Ownable {
|
|||||||
// apprentice
|
// apprentice
|
||||||
army.apprentice.level += n_units;
|
army.apprentice.level += n_units;
|
||||||
} else if (unit == 2) {
|
} else if (unit == 2) {
|
||||||
// annointed
|
// anointed
|
||||||
army.annointed.level += n_units;
|
army.anointed.level += n_units;
|
||||||
} else if (unit == 3) {
|
} else if (unit == 3) {
|
||||||
// champion
|
// champion
|
||||||
army.champion.level += n_units;
|
army.champion.level += n_units;
|
||||||
|
|||||||
@ -24,8 +24,8 @@ library RaidGeldUtils {
|
|||||||
// Each next unit scales progressivelly better
|
// Each next unit scales progressivelly better
|
||||||
uint256 moloch_denier_profit = army.moloch_denier.level;
|
uint256 moloch_denier_profit = army.moloch_denier.level;
|
||||||
uint256 apprentice_profit = army.apprentice.level * 61 / 10;
|
uint256 apprentice_profit = army.apprentice.level * 61 / 10;
|
||||||
uint256 annointed_profit = army.annointed.level * 6 * 64 / 10;
|
uint256 anointed_profit = army.anointed.level * 6 * 64 / 10;
|
||||||
uint256 champion_profit = army.champion.level * 61 / 10 * 64 / 10 * 67 / 10;
|
uint256 champion_profit = army.champion.level * 61 / 10 * 64 / 10 * 67 / 10;
|
||||||
return moloch_denier_profit + apprentice_profit + annointed_profit + champion_profit;
|
return moloch_denier_profit + apprentice_profit + anointed_profit + champion_profit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ contract raid_geldTest is Test {
|
|||||||
|
|
||||||
assertEq(army.moloch_denier.level, 0);
|
assertEq(army.moloch_denier.level, 0);
|
||||||
assertEq(army.apprentice.level, 0);
|
assertEq(army.apprentice.level, 0);
|
||||||
assertEq(army.annointed.level, 0);
|
assertEq(army.anointed.level, 0);
|
||||||
assertEq(army.champion.level, 0);
|
assertEq(army.champion.level, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,7 +117,7 @@ contract raid_geldTest is Test {
|
|||||||
|
|
||||||
// Add 2 units
|
// Add 2 units
|
||||||
Army memory army = raid_geld.getArmy(player1);
|
Army memory army = raid_geld.getArmy(player1);
|
||||||
uint256 unit_level = army.annointed.level;
|
uint256 unit_level = army.moloch_denier.level;
|
||||||
uint256 balance = raid_geld.balanceOf(player1);
|
uint256 balance = raid_geld.balanceOf(player1);
|
||||||
uint256 income_per_sec = army.profit_per_second;
|
uint256 income_per_sec = army.profit_per_second;
|
||||||
raid_geld.addUnit(0, 2);
|
raid_geld.addUnit(0, 2);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user