init
This commit is contained in:
34
Assets/TcgEngine/Scripts/Conditions/ConditionCardData.cs
Normal file
34
Assets/TcgEngine/Scripts/Conditions/ConditionCardData.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that checks the card data matches
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardData", order = 10)]
|
||||
public class ConditionCardData : ConditionData
|
||||
{
|
||||
[Header("Card is")]
|
||||
public CardData card_type;
|
||||
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(target.card_id == card_type.id, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return false; //Not a card
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return false; //Not a card
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dafbad6af09c6ed49bfbe03e2d2bf8f1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/TcgEngine/Scripts/Conditions/ConditionCardPile.cs
Normal file
71
Assets/TcgEngine/Scripts/Conditions/ConditionCardPile.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that checks in which pile a card is (deck/discard/hand/board/secrets)
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardPile", order = 10)]
|
||||
public class ConditionCardPile : ConditionData
|
||||
{
|
||||
[Header("Card is in pile")]
|
||||
public PileType type;
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
if (target == null)
|
||||
return false;
|
||||
|
||||
if (type == PileType.Hand)
|
||||
{
|
||||
return CompareBool(data.IsInHand(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Board)
|
||||
{
|
||||
return CompareBool(data.IsOnBoard(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Equipped)
|
||||
{
|
||||
return CompareBool(data.IsEquipped(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Deck)
|
||||
{
|
||||
return CompareBool(data.IsInDeck(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Discard)
|
||||
{
|
||||
return CompareBool(data.IsInDiscard(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Secret)
|
||||
{
|
||||
return CompareBool(data.IsInSecret(target), oper);
|
||||
}
|
||||
|
||||
if (type == PileType.Temp)
|
||||
{
|
||||
return CompareBool(data.IsInTemp(target), oper);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return false; //Player cannot be in a pile
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return type == PileType.Board && target != Slot.None; //Slot is always on board
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c274f103d1df9814494533f6e0f3aedc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
52
Assets/TcgEngine/Scripts/Conditions/ConditionCardType.cs
Normal file
52
Assets/TcgEngine/Scripts/Conditions/ConditionCardType.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that checks the type, team and traits of a card
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardType", order = 10)]
|
||||
public class ConditionCardType : ConditionData
|
||||
{
|
||||
[Header("Card is of type")]
|
||||
public CardType has_type;
|
||||
public TeamData has_team;
|
||||
public TraitData has_trait;
|
||||
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(IsTrait(target), oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return false; //Not a card
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return false; //Not a card
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, CardData target)
|
||||
{
|
||||
bool is_type = target.type == has_type || has_type == CardType.None;
|
||||
bool is_team = target.team == has_team || has_team == null;
|
||||
bool is_trait = target.HasTrait(has_trait) || has_trait == null;
|
||||
return (is_type && is_team && is_trait);
|
||||
}
|
||||
|
||||
private bool IsTrait(Card card)
|
||||
{
|
||||
bool is_type = card.CardData.type == has_type || has_type == CardType.None;
|
||||
bool is_team = card.CardData.team == has_team || has_team == null;
|
||||
bool is_trait = card.HasTrait(has_trait) || has_trait == null;
|
||||
return (is_type && is_team && is_trait);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d028860b966ab8f44908a62e25280a39
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
95
Assets/TcgEngine/Scripts/Conditions/ConditionCount.cs
Normal file
95
Assets/TcgEngine/Scripts/Conditions/ConditionCount.cs
Normal file
@@ -0,0 +1,95 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
public enum ConditionPlayerType
|
||||
{
|
||||
Self = 0,
|
||||
Opponent = 1,
|
||||
Both = 2,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Trigger condition that count the amount of cards in pile of your choise (deck/discard/hand/board...)
|
||||
/// Can also only count cards of a specific type/team/trait
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/Count", order = 10)]
|
||||
public class ConditionCount : ConditionData
|
||||
{
|
||||
[Header("Count cards of type")]
|
||||
public ConditionPlayerType target;
|
||||
public PileType pile;
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
[Header("Traits")]
|
||||
public CardType has_type;
|
||||
public TeamData has_team;
|
||||
public TraitData has_trait;
|
||||
|
||||
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||
{
|
||||
int count = 0;
|
||||
if (target == ConditionPlayerType.Self || target == ConditionPlayerType.Both)
|
||||
{
|
||||
Player player = data.GetPlayer(caster.player_id);
|
||||
count += CountPile(player, pile);
|
||||
}
|
||||
if (target == ConditionPlayerType.Opponent || target == ConditionPlayerType.Both)
|
||||
{
|
||||
Player player = data.GetOpponentPlayer(caster.player_id);
|
||||
count += CountPile(player, pile);
|
||||
}
|
||||
return CompareInt(count, oper, value);
|
||||
}
|
||||
|
||||
private int CountPile(Player player, PileType pile)
|
||||
{
|
||||
List<Card> card_pile = null;
|
||||
|
||||
if (pile == PileType.Hand)
|
||||
card_pile = player.cards_hand;
|
||||
|
||||
if (pile == PileType.Board)
|
||||
card_pile = player.cards_board;
|
||||
|
||||
if (pile == PileType.Equipped)
|
||||
card_pile = player.cards_equip;
|
||||
|
||||
if (pile == PileType.Deck)
|
||||
card_pile = player.cards_deck;
|
||||
|
||||
if (pile == PileType.Discard)
|
||||
card_pile = player.cards_discard;
|
||||
|
||||
if (pile == PileType.Secret)
|
||||
card_pile = player.cards_secret;
|
||||
|
||||
if (pile == PileType.Temp)
|
||||
card_pile = player.cards_temp;
|
||||
|
||||
if (card_pile != null)
|
||||
{
|
||||
int count = 0;
|
||||
foreach (Card card in card_pile)
|
||||
{
|
||||
if (IsTrait(card))
|
||||
count++;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
private bool IsTrait(Card card)
|
||||
{
|
||||
bool is_type = card.CardData.type == has_type || has_type == CardType.None;
|
||||
bool is_team = card.CardData.team == has_team || has_team == null;
|
||||
bool is_trait = card.HasTrait(has_trait) || has_trait == null;
|
||||
return (is_type && is_team && is_trait);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionCount.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionCount.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9642af46d64291e468622adccd555b22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/TcgEngine/Scripts/Conditions/ConditionDamaged.cs
Normal file
32
Assets/TcgEngine/Scripts/Conditions/ConditionDamaged.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Check if a card/player is damaged
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/Damaged", order = 10)]
|
||||
public class ConditionDamaged : ConditionData
|
||||
{
|
||||
[Header("Card is damaged")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(target.damage > 0, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareBool(target.hp < target.hp_max, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionDamaged.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionDamaged.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 39b7e85a87131bc4494769ae3ed91e20
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
27
Assets/TcgEngine/Scripts/Conditions/ConditionDeckbuilding.cs
Normal file
27
Assets/TcgEngine/Scripts/Conditions/ConditionDeckbuilding.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that check if the CardData is a valid deckbuilding card (not a summon token)
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardDeckbuilding", order = 10)]
|
||||
public class ConditionDeckbuilding : ConditionData
|
||||
{
|
||||
[Header("Card is Deckbuilding")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(target.CardData.deckbuilding, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, CardData target)
|
||||
{
|
||||
return CompareBool(target.deckbuilding, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47697886145249247bdbaa7a3452ef34
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/TcgEngine/Scripts/Conditions/ConditionEquipped.cs
Normal file
32
Assets/TcgEngine/Scripts/Conditions/ConditionEquipped.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that check if the card is equipped with an equipment card
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardEquipped", order = 10)]
|
||||
public class ConditionEquipped : ConditionData
|
||||
{
|
||||
[Header("Target is equipped")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(target.equipped_uid != null, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 303a0dbac5969f440a9cf0d8e8c7a577
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/TcgEngine/Scripts/Conditions/ConditionExhaust.cs
Normal file
32
Assets/TcgEngine/Scripts/Conditions/ConditionExhaust.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that check if the card is exhausted or not
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardExhausted", order = 10)]
|
||||
public class ConditionExhaust : ConditionData
|
||||
{
|
||||
[Header("Target is exhausted")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(target.exhausted, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareBool(false, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return CompareBool(false, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionExhaust.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionExhaust.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d05746ad826de244783b23ff99b0cbe5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
20
Assets/TcgEngine/Scripts/Conditions/ConditionOnce.cs
Normal file
20
Assets/TcgEngine/Scripts/Conditions/ConditionOnce.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Add this to an ability to prevent it from being cast more than once per turn
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/OncePerTurn", order = 10)]
|
||||
public class ConditionOnce : ConditionData
|
||||
{
|
||||
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||
{
|
||||
return !data.ability_played.Contains(ability.id);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionOnce.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionOnce.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f3b28cf451548d840bae6f9839af5596
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
35
Assets/TcgEngine/Scripts/Conditions/ConditionOwner.cs
Normal file
35
Assets/TcgEngine/Scripts/Conditions/ConditionOwner.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that check the owner of the target match the owner of the caster
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardOwner", order = 10)]
|
||||
public class ConditionOwner : ConditionData
|
||||
{
|
||||
[Header("Target owner is caster owner")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
bool same_owner = caster.player_id == target.player_id;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
bool same_owner = caster.player_id == target.player_id;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
bool same_owner = Slot.GetP(caster.player_id) == target.p;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionOwner.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionOwner.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 004c422eee4e9ee41a7603d981a2fff7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
51
Assets/TcgEngine/Scripts/Conditions/ConditionOwnerAI.cs
Normal file
51
Assets/TcgEngine/Scripts/Conditions/ConditionOwnerAI.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that is checked only by the AI.
|
||||
/// Prevents the AI from targeting itself with bad spells even though you want to give real players the flexibility to do it
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardOwnerAI", order = 10)]
|
||||
public class ConditionOwnerAI : ConditionData
|
||||
{
|
||||
[Header("AI Only: Target owner is caster owner")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
if (!IsAIPlayer(data, caster))
|
||||
return true; //Condition always true for human players
|
||||
|
||||
bool same_owner = caster.player_id == target.player_id;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
if (!IsAIPlayer(data, caster))
|
||||
return true; //Condition always true for human players
|
||||
|
||||
bool same_owner = caster.player_id == target.player_id;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
if (!IsAIPlayer(data, caster))
|
||||
return true; //Condition always true for human players
|
||||
|
||||
bool same_owner = Slot.GetP(caster.player_id) == target.p;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
private bool IsAIPlayer(Game data, Card caster)
|
||||
{
|
||||
Player player = data.GetPlayer(caster.player_id);
|
||||
return player.is_ai;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionOwnerAI.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionOwnerAI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b5f2a0ee74f5ccd428221969a56ee854
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
40
Assets/TcgEngine/Scripts/Conditions/ConditionPlayerStat.cs
Normal file
40
Assets/TcgEngine/Scripts/Conditions/ConditionPlayerStat.cs
Normal file
@@ -0,0 +1,40 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares basic player stats such as attack/hp/mana
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/PlayerStat", order = 10)]
|
||||
public class ConditionPlayerStat : ConditionData
|
||||
{
|
||||
[Header("Card stat is")]
|
||||
public ConditionStatType type;
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
Player ptarget = data.GetPlayer(target.player_id);
|
||||
return IsTargetConditionMet(data, ability, caster, ptarget);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
if (type == ConditionStatType.HP)
|
||||
{
|
||||
return CompareInt(target.hp, oper, value);
|
||||
}
|
||||
|
||||
if (type == ConditionStatType.Mana)
|
||||
{
|
||||
return CompareInt(target.mana, oper, value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2829dec3f20bf1749be842a462dc7209
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/TcgEngine/Scripts/Conditions/ConditionRolled.cs
Normal file
38
Assets/TcgEngine/Scripts/Conditions/ConditionRolled.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if its your turn
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/RolledValue", order = 10)]
|
||||
public class ConditionRolled : ConditionData
|
||||
{
|
||||
[Header("Value Rolled is")]
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||
{
|
||||
return CompareInt(data.rolled_value, oper, value);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareInt(data.rolled_value, oper, value);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareInt(data.rolled_value, oper, value);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return CompareInt(data.rolled_value, oper, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionRolled.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionRolled.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d038beb97da312344a27296b92629b7e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,23 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Check selected value for card cost
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SelectedValue", order = 10)]
|
||||
public class ConditionSelectedValue : ConditionData
|
||||
{
|
||||
[Header("Selected Value is")]
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||
{
|
||||
return CompareInt(data.selected_value, oper, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b36c860069675084cbf42329be6ed7bf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/TcgEngine/Scripts/Conditions/ConditionSelf.cs
Normal file
33
Assets/TcgEngine/Scripts/Conditions/ConditionSelf.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that check if the target is the same as the caster
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardSelf", order = 10)]
|
||||
public class ConditionSelf : ConditionData
|
||||
{
|
||||
[Header("Target is caster")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(caster == target, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
bool same_owner = caster.player_id == target.player_id;
|
||||
return CompareBool(same_owner, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return CompareBool(caster.slot == target, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionSelf.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionSelf.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0b48d9d9834b3f54689381231f73f1d2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
32
Assets/TcgEngine/Scripts/Conditions/ConditionSlotDist.cs
Normal file
32
Assets/TcgEngine/Scripts/Conditions/ConditionSlotDist.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// SlotDist is the travel distance from the caster to the target
|
||||
/// Unlike SlotRange which is just checking each X,Y,P separately
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SlotDist", order = 11)]
|
||||
public class ConditionSlotDist : ConditionData
|
||||
{
|
||||
[Header("Slot Distance")]
|
||||
public int distance = 1;
|
||||
public bool diagonals;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return IsTargetConditionMet(data, ability, caster, target.slot);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
Slot cslot = caster.slot;
|
||||
if (diagonals)
|
||||
return cslot.IsInDistance(target, distance);
|
||||
return cslot.IsInDistanceStraight(target, distance);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 23876ed3b55361b4e8abbc86b94a342d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/TcgEngine/Scripts/Conditions/ConditionSlotEmpty.cs
Normal file
33
Assets/TcgEngine/Scripts/Conditions/ConditionSlotEmpty.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if a slot contains a card or not
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SlotEmpty", order = 11)]
|
||||
public class ConditionSlotEmpty : ConditionData
|
||||
{
|
||||
[Header("Slot Is Empty")]
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(false, oper); //Target is not empty slot
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareBool(false, oper); //Target is not empty slot
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
Card slot_card = data.GetSlotCard(target);
|
||||
return CompareBool(slot_card == null, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d3dd4e502c8dfa34fbb025ff1a8aaeb0
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/TcgEngine/Scripts/Conditions/ConditionSlotRange.cs
Normal file
34
Assets/TcgEngine/Scripts/Conditions/ConditionSlotRange.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// SlotRange check each axis variable individualy for range between the caster and target
|
||||
/// If you want to check the travel distance instead (all at once) use SlotDist
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SlotRange", order = 11)]
|
||||
public class ConditionSlotRange : ConditionData
|
||||
{
|
||||
[Header("Slot Range")]
|
||||
public int range_x = 1;
|
||||
public int range_y = 1;
|
||||
public int range_p = 0;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return IsTargetConditionMet(data, ability, caster, target.slot);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
Slot cslot = caster.slot;
|
||||
int dist_x = Mathf.Abs(cslot.x - target.x);
|
||||
int dist_y = Mathf.Abs(cslot.y - target.y);
|
||||
int dist_p = Mathf.Abs(cslot.p - target.p);
|
||||
return dist_x <= range_x && dist_y <= range_y && dist_p <= range_p;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8debe5efbe667de4fbf47dc9212bd159
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
33
Assets/TcgEngine/Scripts/Conditions/ConditionSlotValue.cs
Normal file
33
Assets/TcgEngine/Scripts/Conditions/ConditionSlotValue.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// SlotValue compare each slot x and y to a specific value, like slot.x >=3 and slot.y < 5
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/SlotValue", order = 11)]
|
||||
public class ConditionSlotValue : ConditionData
|
||||
{
|
||||
[Header("Slot Value")]
|
||||
public ConditionOperatorInt oper_x;
|
||||
public int value_x = 0;
|
||||
|
||||
public ConditionOperatorInt oper_y;
|
||||
public int value_y = 0;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return IsTargetConditionMet(data, ability, caster, target.slot);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
bool valid_x = CompareInt(target.x, oper_x, value_x);
|
||||
bool valid_y = CompareInt(target.y, oper_y, value_y);
|
||||
return valid_x && valid_y;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 274374999bbffee429c9dfa75d2592db
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
62
Assets/TcgEngine/Scripts/Conditions/ConditionStat.cs
Normal file
62
Assets/TcgEngine/Scripts/Conditions/ConditionStat.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
public enum ConditionStatType
|
||||
{
|
||||
None = 0,
|
||||
Attack = 10,
|
||||
HP = 20,
|
||||
Mana = 30,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Compares basic card or player stats such as attack/hp/mana
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/Stat", order = 10)]
|
||||
public class ConditionStat : ConditionData
|
||||
{
|
||||
[Header("Card stat is")]
|
||||
public ConditionStatType type;
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
if (type == ConditionStatType.Attack)
|
||||
{
|
||||
return CompareInt(target.GetAttack(), oper, value);
|
||||
}
|
||||
|
||||
if (type == ConditionStatType.HP)
|
||||
{
|
||||
return CompareInt(target.GetHP(), oper, value);
|
||||
}
|
||||
|
||||
if (type == ConditionStatType.Mana)
|
||||
{
|
||||
return CompareInt(target.GetMana(), oper, value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
if (type == ConditionStatType.HP)
|
||||
{
|
||||
return CompareInt(target.hp, oper, value);
|
||||
}
|
||||
|
||||
if (type == ConditionStatType.Mana)
|
||||
{
|
||||
return CompareInt(target.mana, oper, value);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionStat.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionStat.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56b5ff935f8b7194ea353bb38598d96e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
37
Assets/TcgEngine/Scripts/Conditions/ConditionStatus.cs
Normal file
37
Assets/TcgEngine/Scripts/Conditions/ConditionStatus.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Checks if a player or card has a status effect
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/CardStatus", order = 10)]
|
||||
public class ConditionStatus : ConditionData
|
||||
{
|
||||
[Header("Card has status")]
|
||||
public StatusType has_status;
|
||||
public int value = 0;
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
bool hstatus = target.HasStatus(has_status) && target.GetStatusValue(has_status) >= value;
|
||||
return CompareBool(hstatus, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
bool hstatus = target.HasStatus(has_status) && target.GetStatusValue(has_status) >= value;
|
||||
return CompareBool(hstatus, oper);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
Card card = data.GetSlotCard(target);
|
||||
if (card != null)
|
||||
return IsTargetConditionMet(data, ability, caster, card);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionStatus.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionStatus.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7a3c78f482b96ed47896e9c6ad583d1e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
42
Assets/TcgEngine/Scripts/Conditions/ConditionTarget.cs
Normal file
42
Assets/TcgEngine/Scripts/Conditions/ConditionTarget.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using TcgEngine.AI;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Condition that compares the target category of an ability to the actual target (card, player or slot)
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/Player", order = 10)]
|
||||
public class ConditionTarget : ConditionData
|
||||
{
|
||||
[Header("Target is of type")]
|
||||
public ConditionTargetType type;
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareBool(type == ConditionTargetType.Card, oper); //Is Card
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareBool(type == ConditionTargetType.Player, oper); //Is Player
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Slot target)
|
||||
{
|
||||
return CompareBool(type == ConditionTargetType.Slot, oper); //Is Player
|
||||
}
|
||||
}
|
||||
|
||||
public enum ConditionTargetType
|
||||
{
|
||||
None = 0,
|
||||
Card = 10,
|
||||
Player = 20,
|
||||
Slot = 30,
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionTarget.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionTarget.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 06df69f70efef364b8eab89605ed0d70
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
29
Assets/TcgEngine/Scripts/Conditions/ConditionTrait.cs
Normal file
29
Assets/TcgEngine/Scripts/Conditions/ConditionTrait.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Compares cards or players custom stats
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/StatCustom", order = 10)]
|
||||
public class ConditionTrait : ConditionData
|
||||
{
|
||||
[Header("Card stat is")]
|
||||
public TraitData trait;
|
||||
public ConditionOperatorInt oper;
|
||||
public int value;
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Card target)
|
||||
{
|
||||
return CompareInt(target.GetTraitValue(trait.id), oper, value);
|
||||
}
|
||||
|
||||
public override bool IsTargetConditionMet(Game data, AbilityData ability, Card caster, Player target)
|
||||
{
|
||||
return CompareInt(target.GetTraitValue(trait.id), oper, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionTrait.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionTrait.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bc5ee312d5d0efd448bf6e1a851af5ce
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/TcgEngine/Scripts/Conditions/ConditionTurn.cs
Normal file
22
Assets/TcgEngine/Scripts/Conditions/ConditionTurn.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Checks if its your turn
|
||||
/// </summary>
|
||||
|
||||
[CreateAssetMenu(fileName = "condition", menuName = "TcgEngine/Condition/Turn", order = 10)]
|
||||
public class ConditionTurn : ConditionData
|
||||
{
|
||||
public ConditionOperatorBool oper;
|
||||
|
||||
public override bool IsTriggerConditionMet(Game data, AbilityData ability, Card caster)
|
||||
{
|
||||
bool yourturn = caster.player_id == data.current_player;
|
||||
return CompareBool(yourturn, oper);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/ConditionTurn.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/ConditionTurn.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dbbc55df9ef91354d88c2afe3b5105b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
38
Assets/TcgEngine/Scripts/Conditions/FilterFirst.cs
Normal file
38
Assets/TcgEngine/Scripts/Conditions/FilterFirst.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Pick X first cards from the source array
|
||||
|
||||
[CreateAssetMenu(fileName = "filter", menuName = "TcgEngine/Filter/First", order = 10)]
|
||||
public class FilterFirst : FilterData
|
||||
{
|
||||
public int amount = 1; //Number of first targets selected
|
||||
|
||||
public override List<Card> FilterTargets(Game data, AbilityData ability, Card caster, List<Card> source, List<Card> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
for (int i = 0; i < max; i++)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public override List<Player> FilterTargets(Game data, AbilityData ability, Card caster, List<Player> source, List<Player> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
for (int i = 0; i < max; i++)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public override List<Slot> FilterTargets(Game data, AbilityData ability, Card caster, List<Slot> source, List<Slot> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
for (int i = 0; i < max; i++)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/FilterFirst.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/FilterFirst.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 344a45cba28a5db439b6bf1f57127475
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/TcgEngine/Scripts/Conditions/FilterHighestStat.cs
Normal file
53
Assets/TcgEngine/Scripts/Conditions/FilterHighestStat.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Pick all targets with the highest stat
|
||||
|
||||
[CreateAssetMenu(fileName = "filter", menuName = "TcgEngine/Filter/HighestStat", order = 10)]
|
||||
public class FilterHighestStat : FilterData
|
||||
{
|
||||
public ConditionStatType stat;
|
||||
|
||||
public override List<Card> FilterTargets(Game data, AbilityData ability, Card caster, List<Card> source, List<Card> dest)
|
||||
{
|
||||
//Find highest
|
||||
int highest = -999;
|
||||
foreach (Card card in source)
|
||||
{
|
||||
int stat = GetStat(card);
|
||||
if (stat > highest)
|
||||
highest = stat;
|
||||
}
|
||||
|
||||
//Add all highest
|
||||
foreach (Card card in source)
|
||||
{
|
||||
int stat = GetStat(card);
|
||||
if (stat == highest)
|
||||
dest.Add(card);
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
private int GetStat(Card card)
|
||||
{
|
||||
if (stat == ConditionStatType.Attack)
|
||||
{
|
||||
return card.GetAttack();
|
||||
}
|
||||
if (stat == ConditionStatType.HP)
|
||||
{
|
||||
return card.GetHP();
|
||||
}
|
||||
if (stat == ConditionStatType.Mana)
|
||||
{
|
||||
return card.GetMana();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 26d6c56df3cf5e64d857568f0f8cc444
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
41
Assets/TcgEngine/Scripts/Conditions/FilterLast.cs
Normal file
41
Assets/TcgEngine/Scripts/Conditions/FilterLast.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Pick X first cards from the source array
|
||||
|
||||
[CreateAssetMenu(fileName = "filter", menuName = "TcgEngine/Filter/Last", order = 10)]
|
||||
public class FilterLast : FilterData
|
||||
{
|
||||
public int amount = 1; //Number of first targets selected
|
||||
|
||||
public override List<Card> FilterTargets(Game data, AbilityData ability, Card caster, List<Card> source, List<Card> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
int min = source.Count - max;
|
||||
for (int i = source.Count-1; i >= min; i--)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public override List<Player> FilterTargets(Game data, AbilityData ability, Card caster, List<Player> source, List<Player> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
int min = source.Count - max;
|
||||
for (int i = source.Count - 1; i >= min; i--)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
|
||||
public override List<Slot> FilterTargets(Game data, AbilityData ability, Card caster, List<Slot> source, List<Slot> dest)
|
||||
{
|
||||
int max = Mathf.Min(source.Count, amount);
|
||||
int min = source.Count - max;
|
||||
for (int i = source.Count - 1; i >= min; i--)
|
||||
dest.Add(source[i]);
|
||||
return dest;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/FilterLast.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/FilterLast.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 08d4e8ec101e29f47a83f7531bc32e74
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
53
Assets/TcgEngine/Scripts/Conditions/FilterLowestStat.cs
Normal file
53
Assets/TcgEngine/Scripts/Conditions/FilterLowestStat.cs
Normal file
@@ -0,0 +1,53 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Pick all targets with the lowest stat
|
||||
|
||||
[CreateAssetMenu(fileName = "filter", menuName = "TcgEngine/Filter/LowestStat", order = 10)]
|
||||
public class FilterLowestStat : FilterData
|
||||
{
|
||||
public ConditionStatType stat;
|
||||
|
||||
public override List<Card> FilterTargets(Game data, AbilityData ability, Card caster, List<Card> source, List<Card> dest)
|
||||
{
|
||||
//Find lowest
|
||||
int lowest = 99999;
|
||||
foreach (Card card in source)
|
||||
{
|
||||
int stat = GetStat(card);
|
||||
if (stat < lowest)
|
||||
lowest = stat;
|
||||
}
|
||||
|
||||
//Add all lowest
|
||||
foreach (Card card in source)
|
||||
{
|
||||
int stat = GetStat(card);
|
||||
if (stat == lowest)
|
||||
dest.Add(card);
|
||||
}
|
||||
|
||||
return dest;
|
||||
}
|
||||
|
||||
private int GetStat(Card card)
|
||||
{
|
||||
if (stat == ConditionStatType.Attack)
|
||||
{
|
||||
return card.GetAttack();
|
||||
}
|
||||
if (stat == ConditionStatType.HP)
|
||||
{
|
||||
return card.GetHP();
|
||||
}
|
||||
if (stat == ConditionStatType.Mana)
|
||||
{
|
||||
return card.GetMana();
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/FilterLowestStat.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/FilterLowestStat.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bda5e3e8df054240a5ff29e526a22a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
34
Assets/TcgEngine/Scripts/Conditions/FilterRandom.cs
Normal file
34
Assets/TcgEngine/Scripts/Conditions/FilterRandom.cs
Normal file
@@ -0,0 +1,34 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace TcgEngine
|
||||
{
|
||||
//Pick X number of targets at random from the source array
|
||||
|
||||
[CreateAssetMenu(fileName = "filter", menuName = "TcgEngine/Filter/Random", order = 10)]
|
||||
public class FilterRandom : FilterData
|
||||
{
|
||||
public int amount = 1; //Number of random targets selected
|
||||
|
||||
public override List<Card> FilterTargets(Game data, AbilityData ability, Card caster, List<Card> source, List<Card> dest)
|
||||
{
|
||||
return GameTool.PickXRandom(source, dest, amount);
|
||||
}
|
||||
|
||||
public override List<Player> FilterTargets(Game data, AbilityData ability, Card caster, List<Player> source, List<Player> dest)
|
||||
{
|
||||
return GameTool.PickXRandom(source, dest, amount);
|
||||
}
|
||||
|
||||
public override List<Slot> FilterTargets(Game data, AbilityData ability, Card caster, List<Slot> source, List<Slot> dest)
|
||||
{
|
||||
return GameTool.PickXRandom(source, dest, amount);
|
||||
}
|
||||
|
||||
public override List<CardData> FilterTargets(Game data, AbilityData ability, Card caster, List<CardData> source, List<CardData> dest)
|
||||
{
|
||||
return GameTool.PickXRandom(source, dest, amount);
|
||||
}
|
||||
}
|
||||
}
|
||||
11
Assets/TcgEngine/Scripts/Conditions/FilterRandom.cs.meta
Normal file
11
Assets/TcgEngine/Scripts/Conditions/FilterRandom.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5f59c8a06280cb40b425b437dec3c57
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user