Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/client/src/components/HealthBar.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { Box, Flex, StackProps, Text, VStack } from '@chakra-ui/react';

export const HealthBar = ({
baseHp,
maxHp,
currentHp,
level,
...stackProps
}: {
baseHp: string;
maxHp: string;
currentHp: string;
level?: string;
} & StackProps): JSX.Element => {
const currentHpWithFloor = parseInt(currentHp) < 0 ? 0 : parseInt(currentHp);
const health = (currentHpWithFloor / parseInt(baseHp)) * 100;
const health = (currentHpWithFloor / parseInt(maxHp)) * 100;

const barColor = health > 50 ? 'green' : health > 15 ? 'yellow' : 'red';

Expand Down Expand Up @@ -50,7 +50,7 @@ export const HealthBar = ({
</Box>
</Flex>
<Text fontWeight={700} size={{ base: '2xs', md: 'xs' }}>
{currentHpWithFloor} / {baseHp}
{currentHpWithFloor} / {maxHp}
</Text>
</VStack>
);
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/LeaderboardRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import { type Character, StatsClasses } from '../utils/types';

export const LeaderboardRow = ({
agility,
baseHp,
maxHp,
entityClass,
id,
image,
Expand Down Expand Up @@ -67,7 +67,7 @@ export const LeaderboardRow = ({
</Center>
</HStack>
<Text size={{ base: '3xs', sm: '2xs', lg: 'sm' }}>
HP {baseHp} • STR {strength} • AGI
HP {maxHp} • STR {strength} • AGI
{agility} • INT {intelligence}
</Text>
</VStack>
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/LevelingPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export const LevelingPanel = ({

const newStats = {
agility: newAgility,
baseHp: character.baseHp,
maxHp: character.maxHp,
currentHp: character.currentHp,
class: character.entityClass,
experience: character.experience,
Expand Down Expand Up @@ -218,7 +218,7 @@ export const LevelingPanel = ({
<HStack justify="space-between" w="100%">
<Text>HP - Hit Points</Text>
<Text>
{currentHpWithFloor}/{character.baseHp}
{currentHpWithFloor}/{character.maxHp}
</Text>
</HStack>

Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/StatsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ export const StatsPanel = (): JSX.Element => {

const {
agility,
baseHp,
maxHp,
currentHp,
experience,
goldBalance,
Expand Down Expand Up @@ -122,7 +122,7 @@ export const StatsPanel = (): JSX.Element => {
</GridItem>
<GridItem>
<Text>
{currentHpWithFloor}/{baseHp}
{currentHpWithFloor}/{maxHp}
</Text>
</GridItem>
<GridItem>
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/components/TileDetailsPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export const TileDetailsPanel = (): JSX.Element => {
<HStack alignItems="start" w="100%">
<VStack spacing={{ base: 0, lg: 2 }} w="48%">
<HealthBar
baseHp={opponent.baseHp}
maxHp={opponent.maxHp}
currentHp={opponent.currentHp}
level={opponent.level}
w="90%"
Expand All @@ -275,7 +275,7 @@ export const TileDetailsPanel = (): JSX.Element => {
</VStack>
<VStack spacing={{ base: 0, lg: 2 }} w="48%">
<HealthBar
baseHp={userCharacterForBattleRendering.baseHp}
maxHp={userCharacterForBattleRendering.maxHp}
currentHp={userCharacterForBattleRendering.currentHp}
level={userCharacterForBattleRendering.level}
w="90%"
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/contexts/BattleContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const BattleProvider = ({
}: BattleProviderProps): JSX.Element => {
const { renderError } = useToast();
const {
components: { AttackOutcome, CombatEncounter, CombatOutcome },
components: { ActionOutcome, CombatEncounter, CombatOutcome },
delegatorAddress,
systemCalls: { endTurn },
} = useMUD();
Expand Down Expand Up @@ -173,9 +173,9 @@ export const BattleProvider = ({
return allCharacters.find(char => char.id === character.id) ?? null;
}, [allCharacters, character]);

const allAttackOutcomes = useEntityQuery([Has(AttackOutcome)])
const allAttackOutcomes = useEntityQuery([Has(ActionOutcome)])
.map(entity => {
const _attackOutcome = getComponentValueStrict(AttackOutcome, entity);
const _attackOutcome = getComponentValueStrict(ActionOutcome, entity);

const { encounterId, currentTurn, attackNumber } = decodeEntity(
{
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/contexts/CharacterContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export const CharacterProvider = ({

return {
agility: characterStats?.agility.toString() ?? '0',
baseHp: characterStats?.baseHp.toString() ?? '0',
maxHp: characterStats?.maxHp.toString() ?? '0',
currentHp: characterStats?.currentHp.toString() ?? '0',
entityClass: characterStats?.class ?? 0,
experience: characterStats?.experience.toString() ?? '0',
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/contexts/MapContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export const MapProvider = ({ children }: MapProviderProps): JSX.Element => {
return {
...fetachedMetadata,
agility: characterStats.agility.toString(),
baseHp: characterStats.baseHp.toString(),
maxHp: characterStats.maxHp.toString(),
currentHp: characterStats.currentHp.toString(),
entityClass: characterStats.class,
experience: characterStats.experience.toString(),
Expand Down Expand Up @@ -248,7 +248,7 @@ export const MapProvider = ({ children }: MapProviderProps): JSX.Element => {

return {
...monsterTemplate,
baseHp: monsterTemplate?.hitPoints.toString() ?? '0',
maxHp: monsterTemplate?.hitPoints.toString() ?? '0',
currentHp,
id: entity,
inBattle,
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/lib/mud/createSystemCalls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ export function createSystemCalls(
try {
const formattedNewStats = {
agility: BigInt(entityStats.agility),
baseHp: BigInt(entityStats.baseHp),
maxHp: BigInt(entityStats.maxHp),
class: entityStats.class,
currentHp: BigInt(entityStats.currentHp),
experience: BigInt(entityStats.experience),
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/pages/Character.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const CharacterPage = (): JSX.Element => {
const _character = {
...fetachedMetadata,
agility: characterStats.agility.toString(),
baseHp: characterStats.baseHp.toString(),
maxHp: characterStats.maxHp.toString(),
entityClass: characterStats.class,
currentHp: characterStats.currentHp.toString(),
experience: characterStats.experience.toString(),
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/pages/CharacterCreation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ export const CharacterCreation = (): JSX.Element => {

const rolledOnce = useMemo(() => {
if (!character) return false;
return character.baseHp !== '0';
return character.maxHp !== '0';
}, [character]);

const onEnterGame = useCallback(async () => {
Expand Down Expand Up @@ -583,7 +583,7 @@ export const CharacterCreation = (): JSX.Element => {
<VStack w="100%">
<HStack justify="space-between" w="100%">
<Text>HP - Hit Points</Text>
<Text>{character?.baseHp ?? '0'}</Text>
<Text>{character?.maxHp ?? '0'}</Text>
</HStack>
<HStack justify="space-between" w="100%">
<Text>STR - Strength</Text>
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/pages/Leaderboard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ export const Leaderboard = (): JSX.Element => {
return {
...fetachedMetadata,
agility: characterStats.agility.toString(),
baseHp: characterStats.baseHp.toString(),
maxHp: characterStats.maxHp.toString(),
entityClass: characterStats.class,
experience: characterStats.experience.toString(),
goldBalance: formatEther(goldBalance as bigint).toString(),
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ export type ConsiderationData = {

export type EntityStats = {
agility: string;
baseHp: string;
maxHp: string;
currentHp: string;
entityClass: StatsClasses;
experience: string;
Expand Down Expand Up @@ -147,7 +147,7 @@ export type Metadata = {
};

export type Monster = MonsterTemplate & {
baseHp: string;
maxHp: string;
currentHp: string;
id: Entity;
inBattle: boolean;
Expand Down
19 changes: 10 additions & 9 deletions packages/contracts/constants.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,20 @@ string constant ERC721_NAME = "UDCharacters";
string constant ERC721_SYMBOL = "UDC";
string constant TOKEN_URI = "ipfs://";

uint256 constant PRECISION = 100_000;
uint256 constant DEFAULT_MAX_TURNS = 15;
uint256 constant TO_HIT_MODIFIER = 1;
uint256 constant DEFENSE_MODIFIER = 1;
uint256 constant ATTACK_MODIFIER = 1;
uint256 constant TO_HIT_MODIFIER = 1.4 ether;
uint256 constant DEFENSE_MODIFIER = 1 ether;
uint256 constant ATTACK_MODIFIER = 1 ether;
// the amount crits damage is multiplied by
uint256 constant CRIT_MULTIPLIER = 2;
uint256 constant CRIT_MULTIPLIER = 4;
// attack roll has to be CRIT_MODIFIER times greater than the defense roll in order to crit
uint256 constant CRIT_MODIFIER = 8;
uint256 constant CRIT_MODIFIER = 9;
// the character's stats are divided by STAT_MODIFIER when applying stat bonuses
int256 constant STAT_MODIFIER = 200;

//Gold Drop constants
uint256 constant BASE_GOLD_DROP = 1e15; //
uint256 constant BASE_GOLD_DROP = 1e17; //

// LEVELING
uint256 constant BASE_HP_GAIN = 1;
uint256 constant ABILITY_POINTS_PER_LEVEL = 2;
int256 constant BASE_HP_GAIN = 1;
int256 constant ABILITY_POINTS_PER_LEVEL = 2;
9 changes: 9 additions & 0 deletions packages/contracts/effects.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,15 @@
"bonusDamage": 0,
"critChanceBonus": 0
}
},
{
"effectId": "0x2e0e6d5039f8c272000000000000000000000000000000000000000000000000",
"name": "basic magic heal",
"stats": {
"attackModifierBonus": 100,
"bonusDamage": -2,
"critChanceBonus": 10
}
}
],
"physicalDamage": [
Expand Down
4 changes: 2 additions & 2 deletions packages/contracts/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
"name": "minor healing potion",
"stats": {
"effects": [
"0xeee09063621624b3000000000000000000000000000000000000000000000000"
"0xd9d7d852ae6ef09c000000000000000000000000000000000000000000000000"
],
"maxDamage": -5,
"minDamage": -1,
Expand Down Expand Up @@ -145,7 +145,7 @@
"name": "Fireball",
"stats": {
"effects": [
"0xeee09063621624b3000000000000000000000000000000000000000000000000"
"0x2e0e6d5039f8c272000000000000000000000000000000000000000000000000"
],
"maxDamage": 8,
"minDamage": 4,
Expand Down
Loading