Skip to content

Commit

Permalink
- implement death messages to twitter
Browse files Browse the repository at this point in the history
- shorten killed battle messages to fit in tweets
  • Loading branch information
starknetdev committed Sep 28, 2023
1 parent ef24bc5 commit 97f0c64
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 27 deletions.
10 changes: 6 additions & 4 deletions ui/src/app/components/actions/DiscoveryDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
<span className="flex flex-row items-center justify-between">
<p>
YIKES! Ambushed by a {beastName} for {discoveryData.damageTaken}{" "}
damage to {discoveryData.damageLocation}{" "}
damage to {discoveryData.damageLocation} !
</p>
<GiBruteIcon />
</span>
Expand All @@ -45,7 +45,7 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
<p>
YIKES! Killed by a {beastName} from an ambush of{" "}
{discoveryData.damageTaken} damage to{" "}
{discoveryData.damageLocation}
{discoveryData.damageLocation}!
</p>
<SkullCrossedBonesIcon />
</span>
Expand Down Expand Up @@ -83,7 +83,8 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
{discoveryData?.obstacle?.endsWith("s")
? `a ${discoveryData?.obstacle}`
: discoveryData?.obstacle}{" "}
with {discoveryData?.damageTaken} damage!
with {discoveryData?.damageTaken} damage to{" "}
{discoveryData.damageLocation}!
</p>
<SkullCrossedBonesIcon />
</span>
Expand All @@ -96,7 +97,8 @@ export const DiscoveryDisplay = ({ discoveryData }: DiscoveryProps) => {
{discoveryData?.obstacle?.endsWith("s")
? discoveryData?.obstacle
: `A ${discoveryData?.obstacle}`}{" "}
inflicted {discoveryData?.damageTaken} damage!
inflicted {discoveryData?.damageTaken} damage to{" "}
{discoveryData.damageLocation}!
</p>
<SpikedWallIcon />
</span>
Expand Down
11 changes: 8 additions & 3 deletions ui/src/app/components/adventurer/DeathDialog.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useEffect, useState } from "react";
import React, { useEffect, useState, useRef } from "react";
import TwitterShareButton from "../buttons/TwitterShareButtons";
import useAdventurerStore from "../../hooks/useAdventurerStore";
import useLoadingStore from "../../hooks/useLoadingStore";
Expand All @@ -16,6 +16,7 @@ import { getDeathMessageByRank } from "../../lib/utils";
import Image from "next/image";

export const DeathDialog = () => {
const messageRef = useRef<HTMLSpanElement>(null);
const [rank, setRank] = useState<number | null>(null);
const deathMessage = useLoadingStore((state) => state.deathMessage);
const setDeathMessage = useLoadingStore((state) => state.setDeathMessage);
Expand Down Expand Up @@ -74,7 +75,7 @@ export const DeathDialog = () => {
) : (
<h1 className="text-red-500 text-6xl">YOU DIED!</h1>
)}
<span className="text-lg sm:text-3xl text-red-500">
<span ref={messageRef} className="text-lg sm:text-3xl text-red-500">
{deathMessage}
</span>
<span className="flex flex-col gap-2 text-lg sm:text-4xl">
Expand All @@ -98,7 +99,11 @@ export const DeathDialog = () => {
</span>
</div>
<TwitterShareButton
text={`RIP ${adventurer?.name}, who died at ${rank} place on the #LootSurvivor leaderboard.\n\nThink you can beat ${adventurer?.xp} XP? Enter here and try to survive: ${appUrl}\n\n@lootrealms #Starknet #Play2Die #LootSurvivor`}
text={`RIP ${adventurer?.name}, who died at ${getOrdinalSuffix(
rank! ?? 0
)} place on #LootSurvivor.\n\nGravestone bears the inscription: ${
messageRef.current?.innerText
}🪦\n\nEnter here and try to survive: ${appUrl}\n\n@lootrealms #Starknet #Play2Die #LootSurvivor`}
/>
<Button
onClick={() => {
Expand Down
27 changes: 8 additions & 19 deletions ui/src/app/components/beast/BattleDisplay.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@ export const NotificationBattleDisplay = ({
<span className="flex flex-col gap-1">
<p>Failed to flee the {beastName || ""}.</p>
<p>
{beastName || ""} dealt {battleData[1]?.damageTaken} damage
{beastName || ""} dealt {battleData[1]?.damageTaken} damage to{" "}
{battleData[1].damageLocation}
{battleData[1]?.criticalHit && (
<>
, a <span className="text-terminal-yellow">critical hit</span>
Expand All @@ -279,10 +280,9 @@ export const NotificationBattleDisplay = ({
return (
<span className="flex flex-row items-center justify-between w-full">
<span className="flex flex-col gap-1">
<p>Failed to flee the {beastName || ""}.</p>
<p>
Killed by the {beastName || ""} from {battleData[1]?.damageTaken}{" "}
damage
damage to {battleData[1]?.damageLocation}
{battleData[1]?.criticalHit && (
<>
, a <span className="text-terminal-yellow">critical hit</span>
Expand Down Expand Up @@ -310,7 +310,7 @@ export const NotificationBattleDisplay = ({
</p>
<p>
{beastName || ""} counterattacked for {battleData[1]?.damageTaken}{" "}
damage
damage to {battleData[1]?.damageLocation}
{battleData[1]?.criticalHit && ", a critical hit"}!
</p>
</span>
Expand All @@ -321,24 +321,16 @@ export const NotificationBattleDisplay = ({
return (
<span className="flex flex-row items-center justify-between w-full">
<span className="flex flex-col gap-1">
<p>
With a last breath you strike the {beastName || ""} for{" "}
{battleData[0]?.damageDealt} damage
{battleData[0]?.criticalHit && (
<>
, a <span className="text-terminal-yellow">critical hit</span>
</>
)}
!
</p>
<p>
Killed by the {beastName || ""} taking {""}
{battleData[1]?.damageTaken} damage
{battleData[1]?.damageTaken} damage to{" "}
{battleData[1]?.damageLocation}
{battleData[0]?.criticalHit && (
<>
, a <span className="text-terminal-yellow">critical hit</span>
</>
)}
!
</p>
</span>
<SkullCrossedBonesIcon />
Expand All @@ -360,9 +352,6 @@ export const NotificationBattleDisplay = ({
</p>
<GiBattleGearIcon />
</span>
{/* <TwitterShareButton
text={`My adventurer just slew a level ${beastLevel} ${beastName} (Tier ${tier}) on #LootSurvivor.\n\n${adventurer?.name} is currently ${ordinalRank} place on the leaderboard.\n\nThink you can out-survive me?\n\nEnter here and try to survive: ${appUrl}\n\n@lootrealms #Starknet #Play2Die #LootSurvivor`}
/> */}
<TwitterShareButton
text={`${adventurer?.name} just slew a level ${beastLevel} ${beastName} (Tier ${tier}) on #LootSurvivor.\n\nThink you can out-survive me?\n\nEnter here and try to survive: ${appUrl}\n\n@lootrealms #Starknet #Play2Die #LootSurvivor`}
/>
Expand All @@ -371,7 +360,7 @@ export const NotificationBattleDisplay = ({
} else if (IdleDeathPenalty) {
return (
<span className="flex flex-row items-center justify-between w-full">
<p>You were killed from the idle death penalty!</p>
<p>Killed from the idle death penalty!</p>
<SkullCrossedBonesIcon />
</span>
);
Expand Down
2 changes: 1 addition & 1 deletion ui/src/app/hooks/useUIStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const useUIStore = create<State>((set) => ({
setScreen: (value) => set({ screen: value }),
profile: 0,
setProfile: (value) => set({ profile: value }),
deathDialog: true,
deathDialog: false,
showDeathDialog: (value) => set({ deathDialog: value }),
tutorialDialog: false,
showTutorialDialog: (value) => set({ tutorialDialog: value }),
Expand Down

0 comments on commit 97f0c64

Please sign in to comment.