lighteningcards 2.0.8 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -43387,7 +43387,7 @@ const useLightening = () => {
43387
43387
  // Calculate layout: arrange cards horizontally, centered
43388
43388
  const numCards = this.cards.length;
43389
43389
  const spacing = 77.6 * 0.5 + 20; // space between cards, adjust as needed
43390
- const spriteScale = window.innerWidth < 768 ? 0.17 : 0.3;
43390
+ const spriteScale = window.innerWidth < 768 ? 0.25 : 0.3;
43391
43391
  this.appRef.current.renderer.height / 2;
43392
43392
 
43393
43393
  // We'll keep track of all sprite promises to add them after all loaded
@@ -43437,7 +43437,11 @@ const useLightening = () => {
43437
43437
  fontSize: 75,
43438
43438
  fontWeight: "bold",
43439
43439
  fill: 0xffd700,
43440
- align: "center"
43440
+ align: "center",
43441
+ stroke: {
43442
+ color: 0x000000,
43443
+ width: 5
43444
+ }
43441
43445
  }
43442
43446
  });
43443
43447
  multiplier_txt.anchor.set(0.5);
@@ -43472,9 +43476,16 @@ const useLightening = () => {
43472
43476
  });
43473
43477
 
43474
43478
  // After all sprites are loaded, add them to the container and stage
43475
- Promise.all(spritePromises).then(sprites => {
43479
+ Promise.all(spritePromises).then(async sprites => {
43480
+ const bg_tex = await Assets.load("/card_bg.svg");
43481
+ const bg_sprite = new Sprite(bg_tex);
43482
+ bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
43483
+ bg_sprite.anchor.set(0.5);
43484
+ bg_sprite.x = 0;
43485
+ bg_sprite.y = 0;
43486
+ cardsContainer.addChild(bg_sprite);
43487
+ cardsContainer.label = "card_container";
43476
43488
  sprites.forEach(sprite => cardsContainer.addChild(sprite));
43477
- // Center the container in the canvas
43478
43489
  cardsContainer.x = this.appRef.current.renderer.width / 2;
43479
43490
  cardsContainer.y = this.appRef.current.renderer.height / 2;
43480
43491
  this.appRef.current.stage.addChild(cardsContainer);
@@ -43549,11 +43560,139 @@ const useMiddleThunder = () => {
43549
43560
  };
43550
43561
  };
43551
43562
 
43563
+ const useLighteningStart = () => {
43564
+ class LighteningStart {
43565
+ constructor(cards, spritePath, appRef) {
43566
+ this.cards = cards;
43567
+ this.spritePath = spritePath;
43568
+ this.appRef = appRef;
43569
+ this.initiateAnimation();
43570
+ }
43571
+ async initiateAnimation() {
43572
+ // Create a container to hold all animatedSprites
43573
+ const cardsContainer = new Container();
43574
+
43575
+ // Calculate layout: arrange cards horizontally, centered
43576
+ const numCards = this.cards.length;
43577
+ const spacing = 77.6 * 0.5 + 20; // space between cards, adjust as needed
43578
+ const spriteScale = window.innerWidth < 768 ? 0.25 : 0.3;
43579
+ this.appRef.current.renderer.height / 2;
43580
+
43581
+ // We'll keep track of all sprite promises to add them after all loaded
43582
+ const spritePromises = this.cards.map(async (card, i) => {
43583
+ var _baseTexture$resource, _baseTexture$resource2, _card$multiplier, _card$suit;
43584
+ const baseTexture = await Assets.load(this.spritePath);
43585
+
43586
+ // Prepare frames for animation
43587
+ const frames = [];
43588
+ const texWidth = ((_baseTexture$resource = baseTexture.resource) === null || _baseTexture$resource === void 0 ? void 0 : _baseTexture$resource.width) || baseTexture.width;
43589
+ const texHeight = ((_baseTexture$resource2 = baseTexture.resource) === null || _baseTexture$resource2 === void 0 ? void 0 : _baseTexture$resource2.height) || baseTexture.height;
43590
+ const columns = 10;
43591
+ const rows = 3;
43592
+ const frameWidth = texWidth / columns;
43593
+ const frameHeight = texHeight / rows;
43594
+ for (let row = 0; row < rows; row++) {
43595
+ for (let col = 0; col < columns; col++) {
43596
+ const x = col * frameWidth;
43597
+ const y = row * frameHeight;
43598
+ const frameRect = new Rectangle(x, y, frameWidth, frameHeight);
43599
+ frames.push(new Texture({
43600
+ source: baseTexture.source,
43601
+ frame: frameRect
43602
+ }));
43603
+ }
43604
+ }
43605
+
43606
+ // Create and configure the AnimatedSprite
43607
+ const animatedSprite = new AnimatedSprite(frames);
43608
+ animatedSprite.animationSpeed = 0.25;
43609
+ animatedSprite.label = "starting_animation";
43610
+ animatedSprite.loop = true;
43611
+ animatedSprite.scale.set(spriteScale);
43612
+ animatedSprite.anchor.set(0.5);
43613
+ animatedSprite.allowChildren = true;
43614
+
43615
+ // Position horizontally, centered
43616
+ const totalWidth = (numCards - 1) * spacing;
43617
+ animatedSprite.x = -totalWidth / 2 + i * spacing;
43618
+ animatedSprite.y = 0; // Centered in container
43619
+
43620
+ animatedSprite.play();
43621
+
43622
+ // Add multiplier text
43623
+ const multiplier_txt = new Text({
43624
+ text: `${(_card$multiplier = card.multiplier) !== null && _card$multiplier !== void 0 ? _card$multiplier : card.multplier}X`,
43625
+ style: {
43626
+ fontSize: 75,
43627
+ fontWeight: "bold",
43628
+ fill: 0xffd700,
43629
+ align: "center",
43630
+ stroke: {
43631
+ color: 0x000000,
43632
+ width: 5
43633
+ }
43634
+ }
43635
+ });
43636
+ multiplier_txt.anchor.set(0.5);
43637
+ multiplier_txt.position.set(0, -50);
43638
+ animatedSprite.addChild(multiplier_txt);
43639
+
43640
+ // Suit icon
43641
+ let suit_url = "";
43642
+ switch ((_card$suit = card.suit) === null || _card$suit === void 0 ? void 0 : _card$suit.toLowerCase()) {
43643
+ case "hearts":
43644
+ suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f0/SuitHearts.svg/60px-SuitHearts.svg.png";
43645
+ break;
43646
+ case "clubs":
43647
+ suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/8/8a/SuitClubs.svg/60px-SuitClubs.svg.png";
43648
+ break;
43649
+ case "diamonds":
43650
+ suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/d/db/SuitDiamonds.svg/60px-SuitDiamonds.svg.png";
43651
+ break;
43652
+ default:
43653
+ suit_url = "https://upload.wikimedia.org/wikipedia/commons/thumb/5/5b/SuitSpades.svg/60px-SuitSpades.svg.png";
43654
+ break;
43655
+ }
43656
+
43657
+ // Load and add suit sprite
43658
+ const card_suit_tex = await Assets.load(suit_url);
43659
+ const card_suit_sprite = new Sprite(card_suit_tex);
43660
+ card_suit_sprite.anchor.set(0.5);
43661
+ card_suit_sprite.scale.set(1.2);
43662
+ card_suit_sprite.position.set(0, 35);
43663
+ animatedSprite.addChild(card_suit_sprite);
43664
+ return animatedSprite;
43665
+ });
43666
+
43667
+ // After all sprites are loaded, add them to the container and stage
43668
+ Promise.all(spritePromises).then(async sprites => {
43669
+ const bg_tex = await Assets.load("/card_bg.svg");
43670
+ const bg_sprite = new Sprite(bg_tex);
43671
+ bg_sprite.scale.set(window.innerWidth < 768 ? 0.65 : 0.75);
43672
+ bg_sprite.anchor.set(0.5);
43673
+ bg_sprite.x = 0;
43674
+ bg_sprite.y = 0;
43675
+ cardsContainer.addChild(bg_sprite);
43676
+ cardsContainer.label = "card_container";
43677
+ sprites.forEach(sprite => cardsContainer.addChild(sprite));
43678
+ // Center the container in the canvas
43679
+ cardsContainer.x = this.appRef.current.renderer.width / 2;
43680
+ cardsContainer.y = this.appRef.current.renderer.height / 2;
43681
+ this.appRef.current.stage.addChild(cardsContainer);
43682
+ });
43683
+ }
43684
+ }
43685
+ return {
43686
+ LighteningStart
43687
+ };
43688
+ };
43689
+
43552
43690
  // CSS is provided separately via the style field in package.json
43553
43691
 
43554
43692
  const thunder_left = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/lightnings.f9848fb7.webp";
43555
43693
  const thunder_middle = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/feeborderb.0e2c6bbe.webp";
43556
43694
  const thunder_right = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/lightnings.aeaa062e.webp";
43695
+ const border_start = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/borderstar.65180209.webp";
43557
43696
  const border_loop = "https://babylonbetst.evo-games.com/frontend/evo/mini/images/borderloop.c55570cc.webp";
43558
43697
  const LighteningCard = ({
43559
43698
  roundStatus,
@@ -43573,6 +43712,9 @@ const LighteningCard = ({
43573
43712
  const {
43574
43713
  Lightening
43575
43714
  } = useLightening();
43715
+ const {
43716
+ LighteningStart
43717
+ } = useLighteningStart();
43576
43718
  const initiatePixiApplication = async () => {
43577
43719
  appRef.current = new Application();
43578
43720
  await appRef.current.init({
@@ -43586,10 +43728,9 @@ const LighteningCard = ({
43586
43728
  globalThis.__PIXI_APP__ = appRef.current;
43587
43729
  ["NO_MORE_BETS", "LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new LeftThunder(thunder_left, appRef);
43588
43730
  ["NO_MORE_BETS", "LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new RightThunder(thunder_right, appRef);
43589
- ["NO_MORE_BETS", "LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new MiddleThunder(thunder_middle, appRef);
43590
- // roundStatus === "LIGHTNING" &&
43591
- // new LighteningStart(cards, border_start, appRef);
43592
- ["LIGHTNING", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new Lightening(cards, border_loop, appRef);
43731
+ ["NO_MORE_BETS", "NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new MiddleThunder(thunder_middle, appRef);
43732
+ ["LIGHTNING"].includes(roundStatus) && new LighteningStart(cards, border_start, appRef);
43733
+ ["NEW_CARD", "ROUND_END", "BETTING_STARTED"].includes(roundStatus) && new Lightening(cards, border_loop, appRef);
43593
43734
  };
43594
43735
  React.useEffect(() => {
43595
43736
  if (!containerRef.current) return;