40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using System.Linq;
|
|
using System.Collections.Generic;
|
|
using RobotAndDonkey.Game.Cards;
|
|
using RobotAndDonkey.Game.GameState;
|
|
using RobotAndDonkey.Game.Modifiers;
|
|
|
|
namespace RobotAndDonkey.Game.Utils;
|
|
|
|
public static class CardExtensions
|
|
{
|
|
public static int NextIndexConsideringCorruption(int cardIndex, CoreLoop coreLoop)
|
|
{
|
|
var tape = coreLoop.GetTapeCards();
|
|
if (cardIndex < 0 || cardIndex >= tape.Count)
|
|
return -1;
|
|
|
|
var card = tape[cardIndex];
|
|
var isCorrupted = card.Modifiers.Any(m => m is CorruptModifierBase && m.DebuffSources.Count == 0);
|
|
cardIndex = isCorrupted ? cardIndex - 1 : cardIndex + 1;
|
|
if (cardIndex < 0 || cardIndex >= tape.Count)
|
|
return -1;
|
|
|
|
return cardIndex;
|
|
}
|
|
|
|
public static List<Card> SortForHand(IEnumerable<Card> cards)
|
|
{
|
|
return cards.Order(Comparer<Card>.Create((a, b) =>
|
|
{
|
|
var cmp = a.Rarity.CompareTo(b.Rarity);
|
|
if (cmp == 0)
|
|
cmp = a.Id.CompareTo(b.Id);
|
|
if (cmp == 0)
|
|
cmp = a.Modifiers.Count.CompareTo(b.Modifiers.Count);
|
|
if (cmp == 0)
|
|
cmp = a.CardId.CompareTo(b.CardId);
|
|
return cmp;
|
|
})).ToList();
|
|
}
|
|
} |