public unsafe virtual void attack(ICase target) { if (!haveAttacked) { WrapperBattleAlgo algo = new WrapperBattleAlgo(); Dictionary<int, IUnit> EnemyDefPoints = new Dictionary<int, IUnit>(); foreach (IUnit unit in target.Units) EnemyDefPoints.Add((int)((double)unit.DefensePoints / ((double)unit.HP / (double)unit.MaxHP)), unit); IUnit targetUnit = EnemyDefPoints[(EnemyDefPoints.Max()).Key]; int* results = algo.computeBattle(AttackPoints, EnemyDefPoints.Max().Key, HP, targetUnit.HP); if (results[0] != 0) HP = results[0]; else Case.removeUnit(this); if (results[1] != 0) targetUnit.HP = results[1]; else { target.removeUnit(targetUnit); if (MovePoints == 0) MovePoints++; move(target); } haveAttacked = true; } }