Annointed is actually spelled anointed

This commit is contained in:
mic0 2024-10-23 10:07:49 +02:00
parent 684d752b08
commit 20fa42cfca
Signed by: mico
GPG Key ID: A3F8023524CF1C8D
13 changed files with 178 additions and 86 deletions

BIN
app/public/roles/druid2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.6 KiB

View 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

View File

@ -1,8 +1,9 @@
import React from "react"
import styles from '../styles/Background.module.css';
import Tower from "./Tower";
import Army from "./Army";
const Background = () => {
const Scene = () => {
return <div className={styles.frame}>
<div className={`${styles.air} ${styles.background_asset}`} />
<div className={`${styles.clouds_small} ${styles.background_asset}`} />
@ -10,9 +11,9 @@ const Background = () => {
<Tower />
<div className={`${styles.mountains} ${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}`} />
<Army />
</div>
}
export default Background
export default Scene

View File

@ -3,7 +3,7 @@ import type { NextPage } from 'next';
import Head from 'next/head';
import styles from '../styles/Home.module.css';
import Header from '../components/Header';
import Background from '../components/Background';
import Scene from '../components/Scene';
const Home: NextPage = () => {
return (
@ -22,7 +22,7 @@ const Home: NextPage = () => {
<ConnectButton />
</div>
<Header />
<Background />
<Scene />
</main>
<footer className={styles.footer}>

View File

@ -8,15 +8,20 @@ const abi = contractAbi.abi
export interface PlayerContextType {
isRegistered: boolean,
user: null | string,
player: null | string,
army: null | { profit_per_second: bigint },
balance: bigint,
register: () => void;
raid: () => void
}
export interface Player { }
export interface Army { }
const PlayerContext = createContext<PlayerContextType>({
isRegistered: false,
user: null,
player: null,
army: null,
balance: BigInt(0),
register: () => { },
raid: () => { },
@ -26,6 +31,9 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
const { address, isConnected } = useAccount();
const { writeContract, error } = useWriteContract();
useEffect(() => {
console.warn(error)
}, [error])
const { data: isRegistered } = useReadContract({
address: contractAddress,
@ -49,7 +57,7 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
}
});
const { data: playerData } = useReadContract({
const { data: player } = useReadContract({
address: contractAddress,
abi,
functionName: 'getPlayer',
@ -60,11 +68,16 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
}
});
console.log(playerData)
useEffect(() => {
console.warn(error, playerData)
}, [error])
const { data: army } = useReadContract({
address: contractAddress,
abi,
functionName: 'getArmy',
args: [address],
query: {
enabled: isConnected,
refetchInterval: 15
}
});
const register = useCallback(() => {
writeContract({
@ -83,10 +96,13 @@ const PlayerProvider = ({ children }: { children: ReactNode }) => {
})
}, [writeContract])
console.log(player, army)
return (
<PlayerContext.Provider value={{
isRegistered: isRegistered as boolean,
user: null,
player: player,
army: army,
balance: balance as bigint,
register,
raid

View 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);
}

View File

@ -50,7 +50,8 @@
height: 240px;
top: 200px;
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 {
cursor: pointer;
transform: scale(1.05, 1.1);
@ -94,67 +95,6 @@
bonfire 12s linear infinite,
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 {
0% {
background-position: 0 0;

View File

@ -12,7 +12,7 @@ struct Raider {
struct Army {
Raider moloch_denier;
Raider apprentice;
Raider annointed;
Raider anointed;
Raider champion;
uint256 profit_per_second;
}
@ -53,7 +53,7 @@ contract RaidGeld is ERC20, Ownable {
armies[msg.sender] = Army({
moloch_denier: Raider({level: 0}),
apprentice: Raider({level: 0}),
annointed: Raider({level: 0}),
anointed: Raider({level: 0}),
champion: Raider({level: 0}),
profit_per_second: 0
});
@ -111,8 +111,8 @@ contract RaidGeld is ERC20, Ownable {
// apprentice
currentLevel = army.apprentice.level;
} else if (unit == 2) {
// annointed
currentLevel = army.annointed.level;
// anointed
currentLevel = army.anointed.level;
} else if (unit == 3) {
// champion
currentLevel = army.champion.level;
@ -130,8 +130,8 @@ contract RaidGeld is ERC20, Ownable {
// apprentice
army.apprentice.level += n_units;
} else if (unit == 2) {
// annointed
army.annointed.level += n_units;
// anointed
army.anointed.level += n_units;
} else if (unit == 3) {
// champion
army.champion.level += n_units;

View File

@ -24,8 +24,8 @@ library RaidGeldUtils {
// Each next unit scales progressivelly better
uint256 moloch_denier_profit = army.moloch_denier.level;
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;
return moloch_denier_profit + apprentice_profit + annointed_profit + champion_profit;
return moloch_denier_profit + apprentice_profit + anointed_profit + champion_profit;
}
}

View File

@ -61,7 +61,7 @@ contract raid_geldTest is Test {
assertEq(army.moloch_denier.level, 0);
assertEq(army.apprentice.level, 0);
assertEq(army.annointed.level, 0);
assertEq(army.anointed.level, 0);
assertEq(army.champion.level, 0);
}
@ -117,7 +117,7 @@ contract raid_geldTest is Test {
// Add 2 units
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 income_per_sec = army.profit_per_second;
raid_geld.addUnit(0, 2);