Files
GameJamDungeon/Zennysoft.Game.Ma/src/player/PlayerEffectService.cs
2026-02-17 15:46:16 -08:00

41 lines
954 B
C#

using Godot;
using Zennysoft.Game.Ma;
using Zennysoft.Ma.Adapter;
using Zennysoft.Ma.Adapter.Entity;
internal class PlayerEffectService
{
private IPlayer _player;
public PlayerEffectService(IPlayer player)
{
_player = player;
}
public void TakeSelfDamage(int damage)
{
_player.TakeDamage(new AttackData(5, ElementType.None, true, true));
}
public void Instakill(IEnemy enemy)
{
if (enemy is BossTypeA || enemy is DemonWall)
return;
var rng = new RandomNumberGenerator();
rng.Randomize();
var rand = rng.RandiRange(1, 100);
if (rand <= _player.TotalLuck)
{
enemy.HealthComponent.SetCurrentHealth(0);
enemy.Die();
}
}
public void Degrade()
{
var weapon = _player.EquipmentComponent.EquippedWeapon.Value as Weapon;
var newAttack = Mathf.Max(weapon.BonusAttack - 1, 0);
weapon.SetAttack(newAttack);
_player.EquipmentComponent.UpdateEquipment(weapon);
}
}