Skip to content

Commit

Permalink
Merge pull request #2426 from BibliothecaDAO/next
Browse files Browse the repository at this point in the history
Contract battle fixes + hardcoded timer (to revert)
  • Loading branch information
RedBeardEth authored Dec 11, 2024
2 parents 7939b2e + a751db8 commit 2dc0824
Show file tree
Hide file tree
Showing 13 changed files with 325 additions and 361 deletions.
2 changes: 1 addition & 1 deletion client/dojoConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ const {
VITE_PUBLIC_ACCOUNT_CLASS_HASH,
VITE_PUBLIC_DEV,
VITE_PUBLIC_FEE_TOKEN_ADDRESS,
VITE_PUBLIC_CHAIN
VITE_PUBLIC_CHAIN,
} = env;

let manifest = VITE_PUBLIC_DEV === true ? devManifest : productionManifest;
Expand Down
574 changes: 287 additions & 287 deletions client/src/hooks/context/mainnet-policies.tsx

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions client/src/hooks/useSeasonStart.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { configManager } from "@/dojo/setup";
//import { configManager } from "@/dojo/setup";
import { useMemo, useState } from "react";

export const useSeasonStart = () => {
const seasonStart = useMemo(() => BigInt(configManager.getSeasonConfig().startAt || 0), []);
const seasonStart = BigInt(new Date("2024-12-11T15:35:00Z").getTime() / 1000);/*useMemo(() => BigInt(configManager.getSeasonConfig().startAt || 0), []);*/
const nextBlockTimestamp = useMemo(() => BigInt(Math.floor(Date.now() / 1000)), []);

const [countdown, setCountdown] = useState<bigint>(0n);
Expand Down
8 changes: 8 additions & 0 deletions contracts/src/models/combat.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,14 @@ impl TroopsImpl of TroopsTrait {
return resource_precision_u64;
}

fn assert_minimum_for_battle(self: Troops) {
let total = self.knight_count + self.paladin_count + self.crossbowman_count;
assert!(
total >= (100 * RESOURCE_PRECISION).try_into().unwrap(),
"you need to have at least have 100 troops for battle"
);
}

fn assert_normalized(self: Troops) {
assert!(
self.knight_count % Self::normalization_factor() == 0,
Expand Down
2 changes: 2 additions & 0 deletions contracts/src/systems/combat/contracts/battle_systems.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,7 @@ mod battle_systems {

let mut attacking_army: Army = world.read_model(attacking_army_id);
attacking_army.assert_not_in_battle();
attacking_army.troops.assert_minimum_for_battle();

let attacking_army_entity_owner: EntityOwner = world.read_model(attacking_army_id);
attacking_army_entity_owner.assert_caller_owner(world);
Expand Down Expand Up @@ -877,6 +878,7 @@ mod battle_pillage_systems {
// ensure attacking army is not in a battle
let mut attacking_army: Army = world.read_model(army_id);
attacking_army.assert_not_in_battle();
attacking_army.troops.assert_minimum_for_battle();

// ensure army is at structure position
let army_position: Position = world.read_model(army_id);
Expand Down
45 changes: 0 additions & 45 deletions contracts/src/systems/config/contracts.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -608,52 +608,7 @@ mod config_systems {
assert_caller_is_admin(world);

let mut resource_production_config: ProductionConfig = world.read_model(resource_type);
assert!(
resource_production_config.amount.is_zero(),
"Production config already set for {} resource",
resource_type
);

resource_production_config.amount = amount;

loop {
match cost.pop_front() {
Option::Some((
input_resource_type, input_resource_amount
)) => {
// update output resource's production input/material
world
.write_model(
@ProductionInput {
output_resource_type: resource_type,
index: resource_production_config.input_count.try_into().unwrap(),
input_resource_type: *input_resource_type,
input_resource_amount: *input_resource_amount
}
);

resource_production_config.input_count += 1;

// update input resource's production output
let mut input_resource_production_config: ProductionConfig = world
.read_model(*input_resource_type);

world
.write_model(
@ProductionOutput {
input_resource_type: *input_resource_type,
index: input_resource_production_config.output_count.try_into().unwrap(),
output_resource_type: resource_type,
}
);

input_resource_production_config.output_count += 1;
world.write_model(@input_resource_production_config);
},
Option::None => { break; }
}
};

world.write_model(@resource_production_config);
}
}
Expand Down
1 change: 1 addition & 0 deletions docs/pages/mechanics/military/units.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ import { STAMINA_REFILL_PER_TICK } from "@bibliothecadao/eternum";

⚔️ **Attacking Army**

- Armies must have 100 troops in order to attack and pillage
- Three attacking armies can be created to start but increases as realm upgrades
- Explores map, can initiate battle and can join a side in an existing battle
- Can only transfer military to armies on the same hex
Expand Down
29 changes: 11 additions & 18 deletions docs/pages/overview/bridging.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,20 @@ import { Callout } from "vocs/components";
# Bridge Closure

<Callout type="danger">
# Critical End-Game Information
The Game Bridge **permanently** closes **48 hours** after after victory has been claimed.

[Read the full End Season Disclaimer](/overview/disclaimer) to understand all risks and limitations.
# Critical End-Game Information The Game Bridge **permanently** closes **48 hours** after after victory has been
claimed. [Read the full End Season Disclaimer](/overview/disclaimer) to understand all risks and limitations.
</Callout>

## Bridging in Eternum

Eternum is a fully onchain game with immutable smart contracts, meaning the game rules cannot be altered. Bridging tokens in and out of the game is a core mechanic, but you must carefully manage this process.
Eternum is a fully onchain game with immutable smart contracts, meaning the game rules cannot be altered. Bridging
tokens in and out of the game is a core mechanic, but you must carefully manage this process.

<Callout type="warning">
### End Game Bridge Closure
- The game bridge closes **permanently** 48 hours after "End Season" is triggered
- Only resources in your Realm's direct balance can be bridged out
- Resources in the following locations are NOT part of your bridgeable balance:
- AMM Liquidity Pool positions
- Open market orders
- Resources in transit
- Any resources not bridged out by the deadline are **permanently locked** in the contract
### End Game Bridge Closure - The game bridge closes **permanently** 48 hours after "End Season" is triggered - Only
resources in your Realm's direct balance can be bridged out - Resources in the following locations are NOT part of
your bridgeable balance: - AMM Liquidity Pool positions - Open market orders - Resources in transit - Any resources
not bridged out by the deadline are **permanently locked** in the contract
</Callout>

## Bridging in
Expand Down Expand Up @@ -70,9 +65,7 @@ To preserve your assets, you **must**:
> 4. Bridge out **$LORDS** and **Resources** from your Realm's balance within the 48-hour window
<Callout type="error">
### ⚠️ Permanent Loss Warning ⚠️
- The 48-hour countdown is **final** and **cannot be extended**
- Developers **cannot** recover any assets after the bridge closes
- Any resources not in your Realm's direct balance **cannot** be bridged out
- Plan ahead to ensure all your assets are in your Realm's balance before the season ends
### ⚠️ Permanent Loss Warning ⚠️ - The 48-hour countdown is **final** and **cannot be extended** - Developers
**cannot** recover any assets after the bridge closes - Any resources not in your Realm's direct balance **cannot** be
bridged out - Plan ahead to ensure all your assets are in your Realm's balance before the season ends
</Callout>
11 changes: 7 additions & 4 deletions docs/pages/overview/disclaimer.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,20 @@ A season of Eternum concludes when a single player achieves the required
**{formatNumberWithSpaces(HYPERSTRUCTURE_POINTS_FOR_WIN)}** Victory Points and clicks the "End Season" button. At this
point:



### ⚠️ SEASON END CRITICAL INFORMATION

When the season ends, **ALL in-game actions are DISABLED.**

#### ⛔️ Disabled Actions

- You **cannot** retrieve LP positions from the AMM
- You **cannot** cancel market orders to retrieve locked resources
- You **cannot** conclude ongoing battles

1. **48-Hour Withdrawal Window (starts immediately when "End Season" is clicked)**
- Starting from the exact moment the season ends, you have **48 hours** to bridge out **ALL $LORDS** tokens and resources from your Realms' balance

- Starting from the exact moment the season ends, you have **48 hours** to bridge out **ALL $LORDS** tokens and
resources from your Realms' balance
- **IMPORTANT:** Your Realm's balance withdrawal:
- Can be BLOCKED if your Realm is in an active battle
- Does NOT include resources that are:
Expand All @@ -47,6 +48,7 @@ When the season ends, **ALL in-game actions are DISABLED.**
- These locked/in-transit resources CANNOT be recovered after the season ends

2. **After 48 Hours**

- Any remaining **$LORDS** tokens and **Resources** will be **permanently locked**
- These assets **CANNOT** be recovered under any circumstances

Expand All @@ -56,7 +58,8 @@ When the season ends, **ALL in-game actions are DISABLED.**
- While registration has a deadline, prize claiming does not

<Callout type="warning">
**PRO TIP:** Don't wait for the season to end! You can and should start bridging out tokens during active gameplay to minimize risk.
**PRO TIP:** Don't wait for the season to end! You can and should start bridging out tokens during active gameplay to
minimize risk.
</Callout>

Please refer to the documentation for detailed instructions on the bridging process during active gameplay.
Expand Down
2 changes: 1 addition & 1 deletion landing/src/components/modules/season-start-timer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const SeasonStartTimer = () => {

return (
<div className="text-3xl text-primary font-semibold">
{String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
{"<"} {String(hours).padStart(2, "0")}:{String(minutes).padStart(2, "0")}:{String(seconds).padStart(2, "0")}
</div>
);
};
1 change: 1 addition & 0 deletions landing/src/components/ui/elements/CountdownTimer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export function CountdownTimer() {

<TypeH1 className="tracking-wider">Eternum is Launching in</TypeH1>
<div className="flex gap-4 text-center mt-4 mx-auto">
<span className="text-4xl font-bold">{"<"}</span>
<TimeUnit value={days} label="Days" />
<TimeUnit value={hours} label="Hours" />
<TimeUnit value={minutes} label="Minutes" />
Expand Down
2 changes: 1 addition & 1 deletion landing/src/dojo/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export async function setup({ ...config }: DojoConfig) {
"OwnedResourcesTracker",
"Weight",
"Resource",
"SpeedConfig"
"SpeedConfig",
]) as any;

const filteredEvents = getFilteredEvents([
Expand Down
5 changes: 3 additions & 2 deletions landing/src/hooks/use-season-start.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { configManager } from "@/dojo/setup";
import { useEffect, useState } from "react";

export const useSeasonStart = () => {
const seasonStart = BigInt(configManager.getSeasonConfig().startAt || 0);
const seasonStart = BigInt(new Date("2024-12-11T15:35:00Z").getTime() / 1000);

/*BigInt(configManager.getSeasonConfig().startAt || 0);*/
const nextBlockTimestamp = BigInt(Math.floor(Date.now() / 1000));

const [countdown, setCountdown] = useState<bigint>(0n);
Expand Down

0 comments on commit 2dc0824

Please sign in to comment.