Skip to content

Commit

Permalink
Season 0.3 Updates 🗾
Browse files Browse the repository at this point in the history
  • Loading branch information
Kooshaba committed Mar 19, 2024
1 parent 018fe4c commit b6283cd
Show file tree
Hide file tree
Showing 70 changed files with 2,349 additions and 849 deletions.
2 changes: 1 addition & 1 deletion maps/community/Rumble.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions packages/analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
"type": "module",
"description": "point this node process at a sky strife world to generate CSVs containing historic gameplay analytics.can be run after all matches are compeleted.",
"dependencies": {
"@latticexyz/block-logs-stream": "2.0.0-main-5ab67e33",
"@latticexyz/common": "2.0.0-main-5ab67e33",
"@latticexyz/phaserx": "2.0.0-main-5ab67e33",
"@latticexyz/react": "2.0.0-main-5ab67e33",
"@latticexyz/recs": "2.0.0-main-5ab67e33",
"@latticexyz/schema-type": "2.0.0-main-5ab67e33",
"@latticexyz/store": "2.0.0-main-5ab67e33",
"@latticexyz/store-sync": "2.0.0-main-5ab67e33",
"@latticexyz/utils": "2.0.0-main-5ab67e33",
"@latticexyz/world": "2.0.0-main-5ab67e33",
"@latticexyz/block-logs-stream": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/common": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/phaserx": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/react": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/recs": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/schema-type": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/store": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/store-sync": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/utils": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/world": "2.0.0-march-19-skystrife-playtest-f486281e",
"@protobuf-ts/grpcweb-transport": "^2.9.1",
"@protobuf-ts/plugin": "^2.9.1",
"@protobuf-ts/runtime-rpc": "^2.9.1",
Expand Down
22 changes: 11 additions & 11 deletions packages/art/tiled/maps/community/Rumble.tmx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<editorsettings>
<export format="MUD Templates"/>
</editorsettings>
<tileset firstgid="1" source="../../tilesets/map-maker-tileset.tsx"/>
<tileset firstgid="1" source="../../../tilesets/map-maker-tileset.tsx"/>
<group id="17" name="Tiles" offsetx="2.84217e-14" offsety="0">
<properties>
<property name="entityLayer" type="bool" value="true"/>
Expand All @@ -13,18 +13,18 @@
<property name="prototypeLayer" type="bool" value="true"/>
</properties>
<data encoding="csv">
1073741825,1073741825,1073741826,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225474,3221225473,3221225473,
1073741825,1073741826,1073741851,1073741851,1073741851,1073741825,3221225473,3221225499,3221225499,3221225499,3221225474,3221225473,
1073741826,1073741851,1073741825,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225473,3221225499,3221225474,
1073741825,1073741851,1073741825,1073741826,1073741825,1073741825,3221225473,3221225473,3221225474,3221225473,3221225499,3221225473,
1073741825,1073741851,1073741825,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225473,3221225499,3221225473,
1073741825,1073741825,2,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,2,3221225473,3221225473,
1073741825,2,3,3,3,1073741825,3221225473,3,3,3,2,3221225473,
2,3,1073741825,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225473,3,2,
1073741825,3,1073741825,2,1073741825,1073741825,3221225473,3221225473,2,3221225473,3,3221225473,
1073741825,3,1073741825,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225473,3,3221225473,
1073741825,1073741825,1073741825,1073741825,1073741825,1073741825,3221225473,3221225473,3221225473,3221225473,3221225473,3221225473,
1,1,1,1,1,1,2147483649,2147483649,2147483649,2147483649,2147483649,2147483649,
1,27,1,1,1,1,2147483649,2147483649,2147483649,2147483649,2147483675,2147483649,
1,27,1,2,1,1,2147483649,2147483649,2147483650,2147483649,2147483675,2147483649,
2,27,1,1,1,1,2147483649,2147483649,2147483649,2147483649,2147483675,2147483650,
1,2,27,27,27,1,2147483649,2147483675,2147483675,2147483675,2147483650,2147483649,
1,1,2,1,1,1,2147483649,2147483649,2147483649,2147483650,2147483649,2147483649
1,3,1,1,1,1,2147483649,2147483649,2147483649,2147483649,3,2147483649,
1,3,1,2,1,1,2147483649,2147483649,2,2147483649,3,2147483649,
2,3,1,1,1,1,2147483649,2147483649,2147483649,2147483649,3,2,
1,2,3,3,3,1,2147483649,3,3,3,2,2147483649,
1,1,2,1,1,1,2147483649,2147483649,2147483649,2,2147483649,2147483649
</data>
</layer>
</group>
Expand Down
26 changes: 13 additions & 13 deletions packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,19 @@
"@canvas-js/hooks": "0.8.26",
"@canvas-js/interfaces": "0.8.26",
"@ethersproject/providers": "^5.7.2",
"@latticexyz/block-logs-stream": "2.0.0-main-5ab67e33",
"@latticexyz/common": "2.0.0-main-5ab67e33",
"@latticexyz/dev-tools": "2.0.0-main-5ab67e33",
"@latticexyz/faucet": "2.0.0-main-5ab67e33",
"@latticexyz/protocol-parser": "2.0.0-main-5ab67e33",
"@latticexyz/react": "2.0.0-main-5ab67e33",
"@latticexyz/recs": "2.0.0-main-5ab67e33",
"@latticexyz/schema-type": "2.0.0-main-5ab67e33",
"@latticexyz/services": "2.0.0-main-5ab67e33",
"@latticexyz/store": "2.0.0-main-5ab67e33",
"@latticexyz/store-sync": "2.0.0-main-5ab67e33",
"@latticexyz/utils": "2.0.0-main-5ab67e33",
"@latticexyz/world": "2.0.0-main-5ab67e33",
"@latticexyz/block-logs-stream": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/common": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/dev-tools": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/faucet": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/protocol-parser": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/react": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/recs": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/schema-type": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/services": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/store": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/store-sync": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/utils": "2.0.0-march-19-skystrife-playtest-f486281e",
"@latticexyz/world": "2.0.0-march-19-skystrife-playtest-f486281e",
"@libp2p/multistream-select": "4.0.9",
"@protobuf-ts/grpcweb-transport": "^2.9.1",
"@protobuf-ts/plugin": "^2.9.1",
Expand Down
60 changes: 52 additions & 8 deletions packages/client/src/app/Amalgema.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from "react";
import { useEffect, useState } from "react";
import { useStore } from "../useStore";
import { useNetworkLayer } from "./useNetworkLayer";
import { AmalgemaUIRoot } from "./amalgema-ui/AmalgemaUIRoot";
Expand All @@ -8,7 +8,10 @@ import { RainbowKitProvider } from "@rainbow-me/rainbowkit";
import { publicProvider } from "wagmi/providers/public";
import { Link } from "./ui/Theme/SkyStrife/Typography";
import { DISCORD_URL } from "./links";
import { SEASON_NAME } from "../constants";
import { SEASON_NAME, SEASON_START } from "../constants";
import { DateTime } from "luxon";
import { useCurrentTime } from "./amalgema-ui/hooks/useCurrentTime";
import { Button } from "./ui/Theme/SkyStrife/Button";

// Default config setup
const { publicClient } = configureChains([mainnet], [publicProvider()]);
Expand All @@ -17,9 +20,14 @@ const wagmiConfig = createConfig({
});

export const Amalgema = () => {
const LOCK_CLIENT = false;
const LOCK_CLIENT = true;

return LOCK_CLIENT ? <AmalgemaLockScreen /> : <AmalgemaMenu />;
const now = DateTime.now().toSeconds();
if (LOCK_CLIENT && now < SEASON_START) {
return <AmalgemaLockScreen />;
}

return <AmalgemaMenu />;
};

const AmalgemaMenu = () => {
Expand All @@ -46,6 +54,43 @@ const AmalgemaMenu = () => {
};

const AmalgemaLockScreen = () => {
const seasonStartTime = DateTime.fromSeconds(SEASON_START);
const [durationUntilSeasonStart, setDurationUntilSeasonStart] = useState(
seasonStartTime.diffNow(["days", "hours", "minutes", "seconds"])
);

const now = useCurrentTime();
useEffect(() => {
setDurationUntilSeasonStart(seasonStartTime.diff(now, ["days", "hours", "minutes", "seconds"]));
}, [now]);

const { days, hours, minutes, seconds } = durationUntilSeasonStart;

function pluralize(n: number, unit: string) {
return `${n} ${unit}${n === 1 ? "" : "s"}`;
}

const timeLeftMessage = `${pluralize(days, "day")}, ${pluralize(hours, "hour")}, ${pluralize(
minutes,
"minute"
)}, and ${pluralize(Math.floor(seconds), "second")}`;
const countdown = (
<span className="text-3xl text-ss-text-link">
{SEASON_NAME} starts in:
<br />
<span className="text-4xl font-bold text-black">{timeLeftMessage}</span>
</span>
);
const reloadButton = (
<>
<div className="text-3xl text-ss-text-link">{SEASON_NAME} starts now!</div>
<div className="h-6" />
<Button buttonType="primary" className="text-2xl p-4" onClick={() => window.location.reload()}>
Reload to Join
</Button>
</>
);

return (
<div className="h-screen w-screen flex flex-col justify-center items-center">
<div
Expand All @@ -58,11 +103,10 @@ const AmalgemaLockScreen = () => {
}}
className="fixed top-0 left-0 h-screen w-screen bg-cover"
/>
<div className="text-4xl font-bold">Season 0.2 has ended.</div>
<div className="h-3" />
<div className="h-2" />
<div className="text-xl text-ss-text-default text-center mt-3">
{/* <span className="font-bold">{SEASON_NAME} starts on February 6th, 2024</span> */}
Sky Strife will be back on Tuesday, March 19th.
{now.toSeconds() < SEASON_START ? countdown : reloadButton}
<div className="h-6" />
<div>
Follow along on{" "}
<Link style={{ fontSize: "18px" }} href={DISCORD_URL}>
Expand Down
127 changes: 102 additions & 25 deletions packages/client/src/app/amalgema-ui/LoadingScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,104 @@ type Props = {
usePrepTime?: boolean;
};

function createAnalyticsSender(networkLayer: NetworkLayer) {
const {
components: { SyncProgress },
utils: { sendAnalyticsEvent },
network: {
matchEntity,
networkConfig: { indexerUrl },
},
} = networkLayer;

function getNowSeconds() {
return Math.floor(DateTime.now().toSeconds());
}

sendAnalyticsEvent("loading-screen", {
startTime: getNowSeconds(),
matchEntity,
});
if (indexerUrl) {
sendAnalyticsEvent("loading-screen", {
startSnapshotFetch: getNowSeconds(),
matchEntity,
});
}

let sentEndEvent = false;
let sentEndSnapshotFetch = false;
let sentStartSnapshotHydrate = false;
let sentEndSnapshotHydrate = false;
let sentStartRpcHydrate = false;
let sentEndRpcHydrate = false;

SyncProgress.update$.subscribe(() => {
const loadingState = getComponentValue(SyncProgress, singletonEntity);
if (!loadingState) return;

if (!sentEndSnapshotFetch && loadingState.step === SyncStep.SNAPSHOT) {
sendAnalyticsEvent("loading-screen", {
endSnapshotFetch: getNowSeconds(),
matchEntity,
blockNumber: loadingState.lastBlockNumberProcessed,
});
sentEndSnapshotFetch = true;
}

if (
!sentStartSnapshotHydrate &&
loadingState.step === SyncStep.SNAPSHOT &&
loadingState.message.includes("Hydrating")
) {
sendAnalyticsEvent("loading-screen", {
startSnapshotHydrate: getNowSeconds(),
matchEntity,
});
sentStartSnapshotHydrate = true;
}

if (
!sentEndSnapshotHydrate &&
loadingState.step === SyncStep.SNAPSHOT &&
loadingState.message.includes("Hydrating") &&
loadingState.percentage === 100
) {
sendAnalyticsEvent("loading-screen", {
endSnapshotHydrate: getNowSeconds(),
matchEntity,
});
sentEndSnapshotHydrate = true;
}

if (!sentStartRpcHydrate && loadingState.step === SyncStep.RPC) {
sendAnalyticsEvent("loading-screen", {
startRpcHydrate: getNowSeconds(),
matchEntity,
blockNumber: loadingState.lastBlockNumberProcessed,
});
sentStartRpcHydrate = true;
}

if (sentStartRpcHydrate && !sentEndRpcHydrate && loadingState.step === SyncStep.LIVE) {
sendAnalyticsEvent("loading-screen", {
endRpcHydrate: getNowSeconds(),
matchEntity,
blockNumber: loadingState.lastBlockNumberProcessed,
});
sentEndRpcHydrate = true;
}

if (!sentEndEvent && loadingState.step === SyncStep.LIVE) {
sendAnalyticsEvent("loading-screen", {
endTime: getNowSeconds(),
matchEntity,
});
sentEndEvent = true;
}
});
}

export const LoadingScreen = ({ networkLayer, usePrepTime }: Props) => {
const [hide, setHide] = React.useState(false);

Expand All @@ -27,15 +125,11 @@ export const LoadingScreen = ({ networkLayer, usePrepTime }: Props) => {
const loadingState = useObservableValue(
useMemo(() => {
if (!networkLayer) return;

const {
components: { SyncProgress },
utils: { sendAnalyticsEvent },
} = networkLayer;

sendAnalyticsEvent("loading-screen", {
startTime: Math.floor(DateTime.now().toSeconds()),
});
createAnalyticsSender(networkLayer);

// use LoadingState.update$ as a trigger rather than a value
// and concat with an initial value to trigger the first look up
Expand All @@ -56,24 +150,6 @@ export const LoadingScreen = ({ networkLayer, usePrepTime }: Props) => {
}
);

const [sentEndEvent, setSentEndEvent] = React.useState(false);
useEffect(() => {
if (sentEndEvent) return;
if (!networkLayer) return;

// Send analytics event when the game is ready
if (loadingState.step === SyncStep.LIVE) {
const {
utils: { sendAnalyticsEvent },
} = networkLayer;

setSentEndEvent(true);
sendAnalyticsEvent("loading-screen", {
endTime: Math.floor(DateTime.now().toSeconds()),
});
}
}, [loadingState, networkLayer, sentEndEvent, usePrepTime]);

const [worldValid, setWorldValid] = useState(false);
useEffect(() => {
if (!networkLayer) return;
Expand Down Expand Up @@ -125,7 +201,8 @@ export const LoadingScreen = ({ networkLayer, usePrepTime }: Props) => {
const showPrepMessage = loadingState.step === SyncStep.LIVE && usePrepTime;

const loadingMessage = showPrepMessage ? "Preparing Game" : loadingState.message;
const loadingPercentage = showPrepMessage ? prepareGameProgress : loadingState.percentage;
const loadingPercentage = showPrepMessage ? prepareGameProgress : Math.round(loadingState.percentage);
const showPercentage = showPrepMessage || loadingPercentage > 0;

return (
<div
Expand Down Expand Up @@ -200,7 +277,7 @@ export const LoadingScreen = ({ networkLayer, usePrepTime }: Props) => {
<div className="w-4"></div>
<Body className="text-center text-3xl text-ss-text-default">
{loadingMessage}
<div className="text-ss-blue">({loadingPercentage}%)</div>
{showPercentage && <div className="text-ss-blue">({loadingPercentage}%)</div>}
</Body>
<div className="w-4"></div>
<img height="64px" width="64px" src="/public/assets/dragoon_attack.gif" />
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/app/amalgema-ui/MatchRewardsFooter.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Mana } from "../ui/Theme/SkyStrife/Mana";
import { Caption } from "../ui/Theme/SkyStrife/Typography";
import { Tooltip } from "react-tooltip";
import { useMatchRewards } from "./hooks/useMatchRewards";
import { Entity } from "@latticexyz/recs";
import { useComponentValue } from "@latticexyz/react";
import { useAmalgema } from "../../useAmalgema";
Expand Down Expand Up @@ -30,10 +29,11 @@ export function MatchRewardsFooter({ matchEntity }: { matchEntity: Entity }) {
network: {
components: { MatchSweepstake },
},
utils: { getMatchRewards },
} = useAmalgema();

const sweepstake = useComponentValue(MatchSweepstake, matchEntity);
const matchRewards = useMatchRewards(matchEntity);
const matchRewards = getMatchRewards(matchEntity);
const totalReward = matchRewards.totalRewards.reduce((acc, reward) => acc + reward.value, 0n);

return (
Expand Down
Loading

0 comments on commit b6283cd

Please sign in to comment.