|
| 1 | +using MegaCrit.Sts2.Core.Entities.Cards; |
| 2 | + |
| 3 | +namespace STS2RitsuLib.Combat.SecondaryResources |
| 4 | +{ |
| 5 | + /// <summary> |
| 6 | + /// Color state for a secondary-resource card cost. |
| 7 | + /// 次级资源卡牌费用的颜色状态。 |
| 8 | + /// </summary> |
| 9 | + public enum SecondaryResourceCardCostColor |
| 10 | + { |
| 11 | + /// <summary> |
| 12 | + /// Use the default cost color. |
| 13 | + /// 使用默认费用颜色。 |
| 14 | + /// </summary> |
| 15 | + Unmodified, |
| 16 | + |
| 17 | + /// <summary> |
| 18 | + /// Cost is higher than the current base cost. |
| 19 | + /// 费用高于当前基础费用。 |
| 20 | + /// </summary> |
| 21 | + Increased, |
| 22 | + |
| 23 | + /// <summary> |
| 24 | + /// Cost is lower than the current base cost, or upgrade preview lowered the base cost. |
| 25 | + /// 费用低于当前基础费用,或升级预览降低了基础费用。 |
| 26 | + /// </summary> |
| 27 | + Decreased, |
| 28 | + |
| 29 | + /// <summary> |
| 30 | + /// A required cost cannot be paid. |
| 31 | + /// 必需费用无法支付。 |
| 32 | + /// </summary> |
| 33 | + InsufficientResources, |
| 34 | + |
| 35 | + /// <summary> |
| 36 | + /// An optional spend is unavailable but does not block card play. |
| 37 | + /// 可选支付不可用,但不阻止卡牌打出。 |
| 38 | + /// </summary> |
| 39 | + OptionalUnavailable, |
| 40 | + } |
| 41 | + |
| 42 | + /// <summary> |
| 43 | + /// Mirrors the game's card cost color rules for secondary-resource card UI. |
| 44 | + /// 为次级资源卡牌 UI 对齐游戏原版费用颜色规则。 |
| 45 | + /// </summary> |
| 46 | + public static class SecondaryResourceCardCostHelper |
| 47 | + { |
| 48 | + /// <summary> |
| 49 | + /// Gets the color state for a resolved secondary-resource payment line. |
| 50 | + /// 获取已解析次级资源支付行的颜色状态。 |
| 51 | + /// </summary> |
| 52 | + public static SecondaryResourceCardCostColor GetCostColor( |
| 53 | + SecondaryResourcePaymentLine line, |
| 54 | + PileType pileType, |
| 55 | + CardPreviewMode previewMode, |
| 56 | + bool pretendCardCanBePlayed = false, |
| 57 | + bool includeOptionalUnavailable = true) |
| 58 | + { |
| 59 | + ArgumentNullException.ThrowIfNull(line); |
| 60 | + |
| 61 | + if (line.CostsX) |
| 62 | + return SecondaryResourceCardCostColor.Unmodified; |
| 63 | + |
| 64 | + if (previewMode == CardPreviewMode.Upgrade && line.BaseCost < line.CanonicalCost) |
| 65 | + return SecondaryResourceCardCostColor.Decreased; |
| 66 | + |
| 67 | + if (pileType != PileType.Hand) |
| 68 | + return SecondaryResourceCardCostColor.Unmodified; |
| 69 | + |
| 70 | + if (line is { CanPlay: false, BlocksPlay: true }) |
| 71 | + return pretendCardCanBePlayed |
| 72 | + ? SecondaryResourceCardCostColor.Unmodified |
| 73 | + : SecondaryResourceCardCostColor.InsufficientResources; |
| 74 | + |
| 75 | + if (includeOptionalUnavailable && line is { IsOptional: true, Activated: false }) |
| 76 | + return SecondaryResourceCardCostColor.OptionalUnavailable; |
| 77 | + |
| 78 | + if (line.Cost > line.BaseCost) |
| 79 | + return SecondaryResourceCardCostColor.Increased; |
| 80 | + |
| 81 | + // ReSharper disable once ConvertIfStatementToReturnStatement |
| 82 | + if (line.Cost < line.BaseCost) |
| 83 | + return SecondaryResourceCardCostColor.Decreased; |
| 84 | + |
| 85 | + return SecondaryResourceCardCostColor.Unmodified; |
| 86 | + } |
| 87 | + } |
| 88 | +} |
0 commit comments