Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rc 1 #1851

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open

Rc 1 #1851

Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
1cc8ae7
configManager: travelStaminaCostConfig
bob0005 Oct 14, 2024
2a9d74f
explore reward
bob0005 Oct 14, 2024
2de3144
move consts into config type, update func, cleanups
ponderingdemocritus Oct 15, 2024
643adfe
fix config issue
ponderingdemocritus Oct 15, 2024
7071408
improve config
ponderingdemocritus Oct 15, 2024
bb455dc
pretteir
ponderingdemocritus Oct 15, 2024
8bf1719
fix build
ponderingdemocritus Oct 15, 2024
6801555
prettier
ponderingdemocritus Oct 15, 2024
0863069
types
ponderingdemocritus Oct 15, 2024
3114173
types
ponderingdemocritus Oct 15, 2024
81dcb2f
fix config
ponderingdemocritus Oct 15, 2024
b1399f5
fix issue with buildings enum'
ponderingdemocritus Oct 15, 2024
ac53635
remove console.log
aymericdelab Oct 15, 2024
4df7593
tick config
bob0005 Oct 15, 2024
9caaa22
fix config manager
aymericdelab Oct 15, 2024
98ca85a
Merge branch 'feat/config-work' into enh/client-config-manager
bob0005 Oct 15, 2024
18c265b
Merge branch 'feat/config-work' into enh/client-config-manager
bob0005 Oct 15, 2024
1216d97
Merge remote-tracking branch 'origin/main' into enh/client-config-man…
bob0005 Oct 15, 2024
6cdd454
Fix claim on structures + selected army
edisontim Oct 15, 2024
95c1ffe
fix add chat icon + hide chat icon
aymericdelab Oct 15, 2024
44189da
change values from sdk to onchain
bob0005 Oct 15, 2024
da9095c
prettier
bob0005 Oct 15, 2024
906b7ae
add guild chat
aymericdelab Oct 15, 2024
aa2e6b8
Fix tests
bob0005 Oct 15, 2024
7b8a269
Merge pull request #1850 from BibliothecaDAO/feat-chat
ponderingdemocritus Oct 15, 2024
cff9d59
Merge pull request #1847 from BibliothecaDAO/fix/battle-actions
ponderingdemocritus Oct 15, 2024
a4259e4
conflict
ponderingdemocritus Oct 16, 2024
32b2ce0
remove console log
ponderingdemocritus Oct 16, 2024
616a06f
Improve chat (#1854)
aymericdelab Oct 16, 2024
ef1e3fe
add destination for resource arrivals
bob0005 Oct 16, 2024
cbc538d
Fix max army buy + amm swap client crash
bob0005 Oct 16, 2024
963dd7d
Revert "Fix max army buy + amm swap client crash"
bob0005 Oct 16, 2024
8d05f50
Revert "add destination for resource arrivals"
bob0005 Oct 16, 2024
4f571d5
Add destination name for resource arrivals
bob0005 Oct 16, 2024
4dc6fe3
Fix army buy max + amm swap client crash
bob0005 Oct 16, 2024
4b1634f
Address rabbit comments
bob0005 Oct 16, 2024
3d22735
Fix fragment mine resource production + armies production
edisontim Oct 16, 2024
b216174
prettier
edisontim Oct 16, 2024
ad9b156
Fix bug with bigints
edisontim Oct 16, 2024
abe2e34
remove dupe hook
ponderingdemocritus Oct 16, 2024
734981b
removes unused zustand
ponderingdemocritus Oct 16, 2024
94ba145
prettier
ponderingdemocritus Oct 17, 2024
44c2368
Merge pull request #1860 from BibliothecaDAO/chore/clean-hook
ponderingdemocritus Oct 17, 2024
0a2fab3
update market
ponderingdemocritus Oct 17, 2024
841da49
Fetch onchain config
bob0005 Oct 17, 2024
c99cbdc
classes
ponderingdemocritus Oct 17, 2024
ca54d5e
Cleanup sdk usage in client
bob0005 Oct 17, 2024
fc32c71
Merge branch 'rc-1' into enh/client-config-manager
bob0005 Oct 17, 2024
07e63ac
prettier
ponderingdemocritus Oct 17, 2024
96bf29a
battle screen
ponderingdemocritus Oct 17, 2024
6538de4
prettier?
ponderingdemocritus Oct 17, 2024
f26eaa8
fix issue
ponderingdemocritus Oct 17, 2024
364e7aa
Merge pull request #1856 from BibliothecaDAO/fix/market-crash
ponderingdemocritus Oct 17, 2024
d3bd7cb
Merge pull request #1863 from BibliothecaDAO/styles/ui-work
ponderingdemocritus Oct 17, 2024
43456ea
feat: randomize mercenaries number (#1861)
edisontim Oct 17, 2024
5c0bf58
Address comments
bob0005 Oct 17, 2024
0e25f47
Merge pull request #1848 from BibliothecaDAO/enh/client-config-manager
ponderingdemocritus Oct 17, 2024
29f4920
optimize re-renders on balance
edisontim Oct 17, 2024
bc98bc6
Merge branch 'rc-1' of github.com:BibliothecaDAO/eternum into fix/res…
edisontim Oct 17, 2024
51fddb3
Merge pull request #1857 from BibliothecaDAO/fix/resource-prod-fragme…
ponderingdemocritus Oct 17, 2024
78a9a12
bump (#1871)
ponderingdemocritus Oct 18, 2024
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
2 changes: 1 addition & 1 deletion balancing/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ResourceTable } from "./components/modules/resource-table";
function App() {
return (
<>
<div className="bg-black text-white">
<div className="bg-brown text-white">
<Tabs defaultValue="account">
<TabsList>
<TabsTrigger value="resources">Production</TabsTrigger>
Expand Down
2 changes: 1 addition & 1 deletion client/src/assets/icons/Coins.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/src/assets/icons/Crown.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/src/assets/icons/Scroll.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/src/assets/icons/Sparkles.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion client/src/assets/icons/Swap.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 2 additions & 9 deletions client/src/dojo/modelManager/BattleManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export enum ClaimStatus {
Claimable = "Claim",
NoSelectedArmy = "No selected army",
BattleOngoing = "Battle ongoing",
DefenderPresent = "An army's defending the structure",
NoStructureToClaim = "No structure to claim",
StructureIsMine = "Can't claim your own structure",
SelectedArmyIsDead = "Selected army is dead",
Expand All @@ -65,7 +66,6 @@ export class BattleManager {
battleEntityId: ID;
dojo: DojoResult;
battleType: BattleType | undefined;
private battleIsClaimable: ClaimStatus | undefined;

constructor(battleEntityId: ID, dojo: DojoResult) {
this.battleEntityId = battleEntityId;
Expand Down Expand Up @@ -253,36 +253,30 @@ export class BattleManager {
defender: ArmyInfo | undefined,
): ClaimStatus {
if (!selectedArmy) return ClaimStatus.NoSelectedArmy;
if (this.battleIsClaimable) return this.battleIsClaimable;

if (this.isBattleOngoing(currentTimestamp)) {
return ClaimStatus.BattleOngoing;
}

if (!structure) {
this.battleIsClaimable = ClaimStatus.NoStructureToClaim;
return ClaimStatus.NoStructureToClaim;
}

if (this.getBattleType(structure) !== BattleType.Structure) {
this.battleIsClaimable = ClaimStatus.NoStructureToClaim;
return ClaimStatus.NoStructureToClaim;
}

if (defender === undefined) {
this.battleIsClaimable = ClaimStatus.Claimable;
return ClaimStatus.Claimable;
}

const updatedBattle = this.getUpdatedBattle(currentTimestamp);
if (updatedBattle && updatedBattle.defence_army_health.current > 0n) {
this.battleIsClaimable = ClaimStatus.BattleOngoing;
return ClaimStatus.BattleOngoing;
}

if (defender.health.current > 0n) {
this.battleIsClaimable = ClaimStatus.BattleOngoing;
return ClaimStatus.BattleOngoing;
return ClaimStatus.DefenderPresent;
}

if (structure.isMine) {
Expand All @@ -293,7 +287,6 @@ export class BattleManager {
return ClaimStatus.SelectedArmyIsDead;
}

this.battleIsClaimable = ClaimStatus.Claimable;
return ClaimStatus.Claimable;
}

Expand Down
4 changes: 2 additions & 2 deletions client/src/dojo/modelManager/__tests__/BattleManager.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ describe("isClaimable", () => {

const isClaimable = battleManager.isClaimable(CURRENT_TIMESTAMP, army, structure, defender);

expect(isClaimable).toBe(ClaimStatus.BattleOngoing);
expect(isClaimable).toBe(ClaimStatus.DefenderPresent);
});

it("should return false if structure protector has health", () => {
Expand All @@ -652,7 +652,7 @@ describe("isClaimable", () => {

const isClaimable = battleManager.isClaimable(CURRENT_TIMESTAMP, army, structure, defender);

expect(isClaimable).toBe(ClaimStatus.BattleOngoing);
expect(isClaimable).toBe(ClaimStatus.DefenderPresent);
});

it("should return false if the structure is mine", () => {
Expand Down
54 changes: 1 addition & 53 deletions client/src/hooks/helpers/useEntities.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,7 @@ import {
type ID,
} from "@bibliothecadao/eternum";
import { useEntityQuery } from "@dojoengine/react";
import {
Has,
HasValue,
getComponentValue,
runQuery,
type Component,
type ComponentValue,
type Entity,
} from "@dojoengine/recs";
import { Has, getComponentValue, type Component, type ComponentValue, type Entity } from "@dojoengine/recs";
import { useMemo } from "react";
import { shortString } from "starknet";
import { useDojo } from "../context/DojoContext";
Expand Down Expand Up @@ -179,22 +171,6 @@ export const useEntities = () => {
};
};

export const getPlayerStructures = () => {
const {
setup: {
components: { Structure, Owner, Realm, Position },
},
} = useDojo();
const { getEntityName } = useEntitiesUtils();

const getStructures = (playerAddress: ContractAddress) => {
const playerStructures = runQuery([Has(Structure), HasValue(Owner, { address: playerAddress })]);
return formatStructures(Array.from(playerStructures), Structure, Realm, Position, getEntityName);
};

return getStructures;
};

export const useEntitiesUtils = () => {
const {
account: { account },
Expand Down Expand Up @@ -330,31 +306,3 @@ export const getAddressNameFromEntityIds = (
owner !== undefined,
);
};

const formatStructures = (
structures: Entity[],
Structure: Component<ClientComponents["Structure"]["schema"]>,
Realm: Component<ClientComponents["Realm"]["schema"]>,
Position: Component<ClientComponents["Position"]["schema"]>,
getEntityName: (entityId: ID) => string | undefined,
) => {
return structures
.map((id) => {
const structure = getComponentValue(Structure, id);
if (!structure) return;

const realm = getComponentValue(Realm, id);
const position = getComponentValue(Position, id);

const structureName = getEntityName(structure.entity_id);

const name = realm
? getRealmNameById(realm.realm_id)
: structureName
? `${structure?.category} ${structureName}`
: structure.category || "";
return { ...structure, position: position!, name };
})
.filter((structure): structure is PlayerStructure => structure !== undefined)
.sort((a, b) => (b.category || "").localeCompare(a.category || ""));
};
6 changes: 3 additions & 3 deletions client/src/hooks/helpers/useGetAllPlayers.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ContractAddress } from "@bibliothecadao/eternum";
import { ContractAddress, Player } from "@bibliothecadao/eternum";
import { Has, NotValue, runQuery } from "@dojoengine/recs";
import { useDojo } from "../context/DojoContext";
import { getAddressNameFromEntityIds, useEntitiesUtils } from "./useEntities";
Expand All @@ -14,7 +14,7 @@ export const useGetAllPlayers = () => {

const playersEntityIds = runQuery([Has(Owner), Has(Realm)]);

const getPlayers = () => {
const getPlayers = (): Player[] => {
const players = getAddressNameFromEntityIds(Array.from(playersEntityIds), Owner, getAddressNameFromEntity);

const uniquePlayers = Array.from(new Map(players.map((player) => [player.address, player])).values());
Expand All @@ -40,7 +40,7 @@ export const useGetOtherPlayers = () => {
NotValue(Owner, { address: ContractAddress(account.address) }),
]);

const getPlayers = () => {
const getPlayers = (): Player[] => {
const players = getAddressNameFromEntityIds(Array.from(playersEntityIds), Owner, getAddressNameFromEntity);

const uniquePlayers = Array.from(new Map(players.map((player) => [player.address, player])).values());
Expand Down
Loading
Loading