Files
2026-09-04 11:31:52 +02:00

218 lines
6.0 KiB
C#

namespace Faraon.Client.Services;
using Microsoft.JSInterop;
using Faraon.Core.Models;
public class FxService
{
private readonly IJSRuntime _js;
public FxService(IJSRuntime js)
{
_js = js;
}
public async ValueTask InitParticlesAsync(string canvasId = "particle-canvas")
{
try { await _js.InvokeVoidAsync("FaraonFx.initParticles", canvasId); } catch { }
}
public async ValueTask PlayCardSnapAsync()
{
try { await _js.InvokeVoidAsync("FaraonFx.playCardSnap"); } catch { }
}
public async ValueTask PlayCardDrawAsync()
{
try { await _js.InvokeVoidAsync("FaraonFx.playCardDraw"); } catch { }
}
public async ValueTask PlaySevenStackAsync(int level)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.playSevenStack", level);
await _js.InvokeVoidAsync("FaraonFx.triggerFireParticles", null, null, 25 * level);
}
catch { }
}
public async ValueTask PlayAceFreezeAsync()
{
try
{
await _js.InvokeVoidAsync("FaraonFx.playAceFreeze");
await _js.InvokeVoidAsync("FaraonFx.triggerIceParticles", null, null, 35);
}
catch { }
}
public async ValueTask TriggerIceShatterAsync(string position)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.triggerIceShatter", position);
}
catch { }
}
public async ValueTask PlayHornikChimeAsync()
{
try { await _js.InvokeVoidAsync("FaraonFx.playHornikChime"); } catch { }
}
public async ValueTask PlayLeafShieldAsync(string? position = null)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.playLeafShield");
await _js.InvokeVoidAsync("FaraonFx.triggerLeafParticles", null, null, 40);
}
catch { }
}
public async ValueTask PlayBurnExplosionAsync()
{
try
{
await _js.InvokeVoidAsync("FaraonFx.playBurnExplosion");
await _js.InvokeVoidAsync("FaraonFx.triggerBurnExplosion", null, null);
}
catch { }
}
public async ValueTask PlayVictoryAsync()
{
try
{
await _js.InvokeVoidAsync("FaraonFx.playVictory");
await _js.InvokeVoidAsync("FaraonFx.triggerConfetti");
}
catch { }
}
public async ValueTask PlayHeartbeatAsync()
{
try { await _js.InvokeVoidAsync("FaraonFx.playHeartbeat"); } catch { }
}
public async ValueTask TriggerScreenShakeAsync(int intensity = 5)
{
try { await _js.InvokeVoidAsync("FaraonFx.triggerScreenShake", intensity); } catch { }
}
public async ValueTask AnimateCardPlayAsync(string sourcePosition, Card card, string deck = "original")
{
try
{
var cardInfo = new
{
deck = deck,
suit = card.Suit.ToString(),
rank = card.Rank.ToString(),
shortName = card.ShortName,
suitSymbol = card.SuitSymbol,
suitColor = card.SuitColor,
rankName = card.RankName,
suitName = card.SuitName,
isHornik = card.IsHornik,
isRedSeven = card.IsRedSeven
};
await _js.InvokeVoidAsync("FaraonFx.animateCardPlay", sourcePosition, cardInfo);
}
catch { }
}
public async ValueTask AnimateCardDrawAsync(string targetPosition, string deck = "original")
{
try
{
await _js.InvokeVoidAsync("FaraonFx.animateCardDraw", targetPosition, deck);
}
catch { }
}
public async ValueTask AnimateTurnTransitionAsync(string fromPosition, string toPosition)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.animateTurnTransition", fromPosition, toPosition);
}
catch { }
}
public async ValueTask SetSpeedLevelAsync(int level)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.setSpeedLevel", level);
}
catch { }
}
public async ValueTask PlaySelectStepAsync(int step)
{
try { await _js.InvokeVoidAsync("FaraonFx.playSelectStep", step); } catch { }
}
public async ValueTask TriggerComboSlamAsync(int count, string title, string sub = "")
{
try
{
string type = count >= 4 ? "quad" : (count == 3 ? "triple" : "double");
await _js.InvokeVoidAsync("FaraonFx.triggerDopamineBanner", title, sub, type);
}
catch { }
}
public async ValueTask TriggerFreezeEffectAsync()
{
try
{
await _js.InvokeVoidAsync("FaraonFx.triggerDopamineBanner", "❄️ ZMRAZENÝ!", "Stojíš jedno kolo", "freeze");
}
catch { }
}
public async ValueTask TriggerReviveEffectAsync(string playerName)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.triggerDopamineBanner", "⚡ VSTÁVAJ Z MŔTVYCH!", $"{playerName} je späť v hre!", "revive");
}
catch { }
}
public async ValueTask TriggerJackpotWinAsync(string winnerName)
{
try
{
await _js.InvokeVoidAsync("FaraonFx.triggerDopamineBanner", "🏆 FARAÓN!", $"{winnerName} vyhráva hru!", "jackpot");
}
catch { }
}
public async ValueTask TriggerDopamineBannerAsync(string title, string subtitle, string type)
{
try { await _js.InvokeVoidAsync("FaraonFx.triggerDopamineBanner", title, subtitle, type); } catch { }
}
public async ValueTask PlayCardWhooshAsync()
{
try { await _js.InvokeVoidAsync("FaraonFx.playCardWhoosh"); } catch { }
}
public async ValueTask PlayBotSfxAsync(string? personalityId, string? emotion = null)
{
try { await _js.InvokeVoidAsync("FaraonFx.playBotPersonalitySfx", personalityId, emotion); } catch { }
}
public async ValueTask<bool> ToggleMuteAsync()
{
try { return await _js.InvokeAsync<bool>("FaraonFx.toggleMute"); } catch { return false; }
}
}