Skip to content

Commit

Permalink
[contracts + client] season pass (#1862)
Browse files Browse the repository at this point in the history
* season pass wip

* season pass contracts

* - use order and resource mapping consistent with realms l2 contracts
- separate season pass contracts from eternum because of compilation issues
- make realm model smaller
- use season pass in client

* update season pass config & contracts

* update indexer script for season pass

* update sason pass tests

* update bot

* comment

* season pass contracts test

* minor update

* update deploy.sh

* season pass: client compilation fix

* client: update resource ids arrangement

* contracts+client: allow lords attachment to season pass

* fix tests

* fix tests

* update world address
  • Loading branch information
credence0x authored Oct 18, 2024
1 parent e2c3420 commit f6db602
Show file tree
Hide file tree
Showing 98 changed files with 11,274 additions and 853 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/test-season-pass.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: test season pass

on:
pull_request:
paths-ignore:
- "contracts/**"
- "client/**"
- "**/manifest.json"
- "discord-bot/**"
- "config/**"
- ".github/**"
- "pnpm-lock.yaml"

env:
SCARB_VERSION: v2.8.2

jobs:
test-season-pass:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: software-mansion/setup-scarb@v1
with:
tool-versions: season_pass/contracts/.tool-versions
- uses: foundry-rs/setup-snfoundry@v3
with:
tool-versions: season_pass/contracts/.tool-versions
- run: scarb build
working-directory: season_pass/contracts
- run: snforge test
working-directory: season_pass/contracts
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
node_modules
node_modules
target
.snfoundry_cache
2 changes: 1 addition & 1 deletion .tool-versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
scarb 2.7.0
dojo 1.0.0-alpha.12
dojo 1.0.0-alpha.16
2 changes: 1 addition & 1 deletion client/.env.preview
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VITE_PUBLIC_MASTER_ADDRESS="0x1a3e37c77be7de91a9177c6b57956faa6da25607e567b10a25cf64fea5e533b"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0x4ab5a607d92f0870cfd82ef9cecb2fe903830441180fd432b831a8863c08097"
VITE_PUBLIC_WORLD_ADDRESS="0x76ca3dfc3e96843716f882546f0db96b7da0cf988bdba284b469d0defb2f48f"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="https://api.cartridge.gg/x/eternum-42/torii"
Expand Down
6 changes: 5 additions & 1 deletion client/.env.production
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
VITE_PUBLIC_MASTER_ADDRESS="0x779c2c098f066ddde5850ec8426511e46e6499adf0b5c77e8961917413b57db"
VITE_PUBLIC_MASTER_PRIVATE_KEY="0x189765c7b9daa2efdd3025d3236a929ce5e510834b8cba4f002a0d5c1accb5a"
VITE_PUBLIC_WORLD_ADDRESS="0x76ca3dfc3e96843716f882546f0db96b7da0cf988bdba284b469d0defb2f48f"
VITE_PUBLIC_WORLD_ADDRESS="0x320b2713e324fe3125bbc42d85ff69cb3c0908b436fa38a35746dbc45deeb11"
VITE_PUBLIC_ACCOUNT_CLASS_HASH="0x05400e90f7e0ae78bd02c77cd75527280470e2fe19c54970dd79dc37a9d3645c"
VITE_EVENT_KEY="0x1a2f334228cee715f1f0f54053bb6b5eac54fa336e0bc1aacf7516decb0471d"
VITE_PUBLIC_TORII="https://api.cartridge.gg/x/eternum-42/torii"
Expand All @@ -10,3 +10,7 @@ VITE_PUBLIC_GAME_VERSION="v0.9.0"
VITE_PUBLIC_SHOW_FPS=false
VITE_PUBLIC_GRAPHICS_DEV=false
VITE_PUBLIC_TORII_RELAY="/dns4/api.cartridge.gg/tcp/443/x-parity-wss/%2Fx%2Feternum-42%2Ftorii%2Fwss"

VITE_SEASON_PASS_ADDRESS="0x0"
VITE_REALMS_ADDRESS="0x0"
VITE_LORDS_ADDRESS="0x0"
21 changes: 10 additions & 11 deletions client/src/data/orders.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
export const order_statments = [
"The Order of Power are one of the oldest orders and fixtures of the history of the realms. They compete by working harder and smarter than everyone else, are natural leaders, and have endless self-confidence. Their confidence can also be their greatest weakness.",
"The Order of Anger loves the intensity of high strung situations, their emotions welling deep inside to provide fuel for the challenge. They are always seeking conflict and particularly so with the Order of Protection, who despises their constant troublemaking. Their need for confrontation can often be their downfall, as there is always a bigger fish.",
"The Order of Brilliance believes that true perfection lies in the school of thought. They are renowned for their academies, in which they provide basic education in order to find the most promising minds. In the lifelong pursuit of knowledge they catalog and store the history of the realms and conduct extensive research into mana usage.",
"The Order of Detection are attuned to empathy. Some use it for good, some use it for manipulation. They can communicate wordlessly. Their leadership hierarchy is through persuasion not physical power, and are masters of propoganda. Their rumors can be enough to change the tides of fate though, as an army location is misreported or a merchant caravan route leaked.",
"The Order of Enlightenment seeks harmony and peace above all else, instead using their intelligence to help guide the world and those around them. The path to enlightenment is unique to every individual, and this Order wishes to turn swords into plows wherever they go. As skilled diplomats many seek them out for negotiations, their wisdom and countenance more valuble than gold. Although strangers to violence in general, their individual defensive measures can be extreme.",
"The Order of Giants values physical might, not just to crush their foes, but as the backbone of the great constructions in the Realms, their strength making them invaluable to Builders. Their size also makes them vulnerable to faster and smaller opponents and their leaders often win their position through combat prowess, which has led to a culture of poor strategic decisions in preference of displaying their full strength.",
"The Order of Perfection loves to both appreciate and create beautiful things. They disregard confrontation in favor of creation, appreciation, and protection of art and and refinement of culture. Although often dismissed as just artists and bards, those with intelligence know that the most dangerous creations originate from the Order of Perfection, and hope to never see those creations come to light.",

"The Order of Rage was said to be birthed from the Order of Anger, as not all could display their anger without losing their life. Instead, the Order of Rage values an implacable front to hide a deep well of anger. When they reach positions of power, they tend to enact schemes of revenge on those who hurt them, and in doing so often dig a grave for two.",
"The order of the Fox thrives off of mischief and competition. They can hide, then are sly, they compete with cunning and trickery, not raw strength. The children of the Fox play tricks on other orders, and with age those trucks become increasingly severe.",
"The Twins are another one of the oldest orders. Amongst themselves, they tend to morph to the styles and sensibilities of the most dominant member of their order. They move in-sync with one-another and live communally. Amongst other orders, they have an uncanny ability to mimic the mannerisms and patterns of those they choose. They can change personalities as one would change outfits.",
"The Order of Fury values extreme and overwhelming force in all situations. They have a need to dominate, and if they cannot dominate, to destroy it with utter frenzied rage. The Order of Fury has little care for life itself, only the ability to end a life. Their disciples are pitted against each other over years until only the most vicious remain. The nature of the Order ensures competency, but destroys its own power structures constantly due to infighting and assasinations.",
"The Order of Giants values physical might, not just to crush their foes, but as the backbone of the great constructions in the Realms, their strength making them invaluable to Builders. Their size also makes them vulnerable to faster and smaller opponents and their leaders often win their position through combat prowess, which has led to a culture of poor strategic decisions in preference of displaying their full strength.",

"The Order of Perfection loves to both appreciate and create beautiful things. They disregard confrontation in favor of creation, appreciation, and protection of art and and refinement of culture. Although often dismissed as just artists and bards, those with intelligence know that the most dangerous creations originate from the Order of Perfection, and hope to never see those creations come to light.",
"The order of Reflection thrives off of time spent with their own thoughts, believing that interaction with an everchanging Realm dulls their ability to see the ethereal. They’re most often found searching for insights into the past and the future by isolating themselves in the darkness. There are rumors of disturbing rituals to aid in conjuring the visions they seek, and their trade in the less savoury markets banned in some Realms does nothing to dispel these rumors.",
"The Order of Detection are attuned to empathy. Some use it for good, some use it for manipulation. They can communicate wordlessly. Their leadership hierarchy is through persuasion not physical power, and are masters of propoganda. Their rumors can be enough to change the tides of fate though, as an army location is misreported or a merchant caravan route leaked.",
"The Order of Skill thrives off of constant self-improvement and self-reliance but still prefer to be part of a team. They are energetic and can accomplish any task they set their mind to. They play by the rules and compete based on their own merit. Their need to demonstrate their proficiency can perversely lead to the very opposite, when they show their hand too early in battle or political games.",
"The Order of Brilliance believes that true perfection lies in the school of thought. They are renowned for their academies, in which they provide basic education in order to find the most promising minds. In the lifelong pursuit of knowledge they catalog and store the history of the realms and conduct extensive research into mana usage.",

"The Order of Protection values stability between the Realms, they wish to build economies to help feed and clothe the destitute. They will often create neutral zones such as Inns whereby adventurers can rest at ease. Their desire to do good can often be their downfall, as not all pay kindness for kindness, especially those of the Dark.",
"The Order of Power are one of the oldest orders and fixtures of the history of the realms. They compete by working harder and smarter than everyone else, are natural leaders, and have endless self-confidence. Their confidence can also be their greatest weakness.",
"The Order of Titans are said to have come from the Giants and share many similarities. The people say that the Giants are like earth, and the Titans the metal they find within it. They are strongly attuned to a sense of justice in the world, however their justice can vary greatly. For Titans, going against the Lord or Lady of a realm is an unforgivable sin, they play by the rules to a fault and can be caught up in their own rules by a skilled or less honourable enemy.",
"The Twins are another one of the oldest orders. Amongst themselves, they tend to morph to the styles and sensibilities of the most dominant member of their order. They move in-sync with one-another and live communally. Amongst other orders, they have an uncanny ability to mimic the mannerisms and patterns of those they choose. They can change personalities as one would change outfits.",
"The order of Vitriol loves debate and offers their opinions with complete disregard to the feelings of others. From an early age they face ruthless criticism from their teachers, parents, and leaders. They hold both themselves and others to impossible standards.",

"The Order of Rage was said to be birthed from the Order of Anger, as not all could display their anger without losing their life. Instead, the Order of Rage values an implacable front to hide a deep well of anger. When they reach positions of power, they tend to enact schemes of revenge on those who hurt them, and in doing so often dig a grave for two.",

"The Order of Protection values stability between the Realms, they wish to build economies to help feed and clothe the destitute. They will often create neutral zones such as Inns whereby adventurers can rest at ease. Their desire to do good can often be their downfall, as not all pay kindness for kindness, especially those of the Dark.",
"The Order of Anger loves the intensity of high strung situations, their emotions welling deep inside to provide fuel for the challenge. They are always seeking conflict and particularly so with the Order of Protection, who despises their constant troublemaking. Their need for confrontation can often be their downfall, as there is always a bigger fish.",
"The Order of Enlightenment seeks harmony and peace above all else, instead using their intelligence to help guide the world and those around them. The path to enlightenment is unique to every individual, and this Order wishes to turn swords into plows wherever they go. As skilled diplomats many seek them out for negotiations, their wisdom and countenance more valuble than gold. Although strangers to violence in general, their individual defensive measures can be extreme.",
];
28 changes: 3 additions & 25 deletions client/src/dojo/contractComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -381,20 +381,6 @@ export function defineContractComponents(world: World) {
},
);
})(),
EntityMetadata: (() => {
return defineComponent(
world,
{ entity_id: RecsType.Number, entity_type: RecsType.Number },
{
metadata: {
namespace: "eternum",
name: "EntityMetadata",
types: ["u32", "u32"],
customTypes: [],
},
},
);
})(),
EntityName: (() => {
return defineComponent(
world,
Expand Down Expand Up @@ -948,21 +934,15 @@ export function defineContractComponents(world: World) {
{
entity_id: RecsType.Number,
realm_id: RecsType.Number,
resource_types_packed: RecsType.BigInt,
resource_types_count: RecsType.Number,
cities: RecsType.Number,
harbors: RecsType.Number,
rivers: RecsType.Number,
regions: RecsType.Number,
wonder: RecsType.Number,
produced_resources: RecsType.BigInt,
order: RecsType.Number,
level: RecsType.Number,
},
{
metadata: {
namespace: "eternum",
name: "Realm",
types: ["u32", "u32", "u128", "u8", "u8", "u8", "u8", "u8", "u8", "u8", "u8"],
types: ["u32", "u32", "u128", "u8", "u8"],
customTypes: [],
},
},
Expand Down Expand Up @@ -1710,8 +1690,7 @@ const eventsComponents = (world: World) => {
owner_address: RecsType.BigInt,
owner_name: RecsType.BigInt,
realm_name: RecsType.BigInt,
resource_types_packed: RecsType.BigInt,
resource_types_count: RecsType.Number,
produced_resources: RecsType.BigInt,
cities: RecsType.Number,
harbors: RecsType.Number,
rivers: RecsType.Number,
Expand Down Expand Up @@ -1740,7 +1719,6 @@ const eventsComponents = (world: World) => {
"u8",
"u8",
"u8",
"u8",
"u32",
"u32",
"u64",
Expand Down
10 changes: 2 additions & 8 deletions client/src/dojo/modelManager/__tests__/__BattleManagerMock__.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,15 +116,9 @@ export const generateMockArmyInfo = (
realm: {
entity_id: ARMY_ENTITY_ID,
realm_id: 1,
resource_types_packed: 1n,
resource_types_count: 1,
cities: 1,
harbors: 1,
rivers: 1,
regions: 1,
wonder: 1,
order: 1,
produced_resources: 1n,
level: 1,
order: 1,
},
homePosition: { entity_id: ARMY_ENTITY_ID, x: 0, y: 0 },
};
Expand Down
51 changes: 5 additions & 46 deletions client/src/hooks/helpers/useRealm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@ type RealmInfo = {
realmId: ID;
entityId: ID;
name: string;
cities: number;
rivers: number;
wonder: number;
harbors: number;
regions: number;
resourceTypesCount: number;
resourceTypesPacked: bigint;
order: number;
position: ComponentValue<ClientComponents["Position"]["schema"]>;
Expand All @@ -42,7 +36,7 @@ export function useRealm() {

const getQuestResources = () => {
const realm = getComponentValue(Realm, getEntityIdFromKeys([BigInt(structureEntityId)]));
const resourcesProduced = realm ? unpackResources(realm.resource_types_packed, realm.resource_types_count) : [];
const resourcesProduced = realm ? unpackResources(realm.produced_resources) : [];
return getStartingResources(resourcesProduced);
};

Expand Down Expand Up @@ -191,19 +185,7 @@ export function useGetRealm(realmEntityId: ID | undefined) {
const population = getComponentValue(Population, entityId);

if (realm && owner && position) {
const {
realm_id,
entity_id,
cities,
rivers,
wonder,
harbors,
regions,
resource_types_count,
resource_types_packed,
order,
level,
} = realm;
const { realm_id, entity_id, produced_resources, order, level } = realm;

const name = getRealmNameById(realm_id);

Expand All @@ -213,14 +195,8 @@ export function useGetRealm(realmEntityId: ID | undefined) {
realmId: realm_id,
entityId: entity_id,
name,
cities,
rivers,
wonder,
harbors,
regions,
level,
resourceTypesCount: resource_types_count,
resourceTypesPacked: resource_types_packed,
resourceTypesPacked: produced_resources,
order,
position,
...population,
Expand Down Expand Up @@ -255,18 +231,7 @@ export function getRealms(): RealmInfo[] {

if (!realm || !owner || !position) return;

const {
realm_id,
entity_id,
cities,
rivers,
wonder,
harbors,
regions,
resource_types_count,
resource_types_packed,
order,
} = realm;
const { realm_id, entity_id, produced_resources, order } = realm;

const name = getRealmNameById(realm_id);

Expand All @@ -279,13 +244,7 @@ export function getRealms(): RealmInfo[] {
realmId: realm_id,
entityId: entity_id,
name,
cities,
rivers,
wonder,
harbors,
regions,
resourceTypesCount: resource_types_count,
resourceTypesPacked: resource_types_packed,
resourceTypesPacked: produced_resources,
order,
position,
...population,
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/helpers/useStructures.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export function useStructuresFromPosition({ position }: { position: Position })
if (!realmData) return undefined;
const name = realmData.name;
const owner = getComponentValue(Owner, entityId);
const resources = unpackResources(BigInt(realm.resource_types_packed), realm.resource_types_count);
const resources = unpackResources(BigInt(realm.produced_resources));

const distanceFromPosition = calculateDistance(position, realmPosition) ?? 0;

Expand Down
20 changes: 2 additions & 18 deletions client/src/ui/components/cityview/realm/SettleRealmComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { useState } from "react";
import Button from "../../../elements/Button";

import { MAX_REALMS } from "@/ui/constants";
import { toValidAscii } from "@/ui/utils/utils";
import { getOrderName, orders } from "@bibliothecadao/eternum";
import clsx from "clsx";
import { shortString } from "starknet";
import { order_statments } from "../../../../data/orders";
import { useDojo } from "../../../../hooks/context/DojoContext";
import { useRealm } from "../../../../hooks/helpers/useRealm";
Expand Down Expand Up @@ -42,26 +40,12 @@ const SettleRealmComponent = () => {
// take next realm id
let realm = getRealm(new_realm_id);
if (!realm) return;

const realmNameInAscii = toValidAscii(realm.name);

calldata.push({
realm_name: shortString.encodeShortString(realmNameInAscii),
realm_id: Number(realm.realmId),
order: realm.order,
wonder: realm.wonder,
regions: realm.regions,
resource_types_count: realm.resourceTypesCount,
resource_types_packed: realm.resourceTypesPacked,
rivers: realm.rivers,
harbors: realm.harbors,
cities: realm.cities,
});
calldata.push(Number(realm.realmId));
}

await create_multiple_realms({
signer: account,
realms: [calldata[0]],
realm_ids: [calldata[0]],
});
setIsLoading(false);
playSign();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const SelectPreviewBuildingMenu = ({ className, entityId }: { className?:

const realmResourceIds = useMemo(() => {
if (realm) {
return unpackResources(BigInt(realm.resourceTypesPacked), realm.resourceTypesCount);
return unpackResources(BigInt(realm.resourceTypesPacked));
} else {
return [];
}
Expand Down
Loading

0 comments on commit f6db602

Please sign in to comment.