public BoardCard(CardEntity e, bool active = true)
		{
			var card = Database.GetCardFromId(e.CardId);
			var cardName = card != null ? card.Name : "";
			var name = string.IsNullOrEmpty(e.Entity.Name) ? cardName : e.Entity.Name;

			_stdAttack = e.Entity.GetTag(ATK);
			_health = e.Entity.GetTag(HEALTH);
			_armor = e.Entity.GetTag(ARMOR);
			_durability = e.Entity.GetTag(DURABILITY);
			_damageTaken = e.Entity.GetTag(DAMAGE);
			Exhausted = e.Entity.GetTag(EXHAUSTED) == 1;
			_cantAttack = e.Entity.GetTag(CANT_ATTACK) == 1;
			_frozen = e.Entity.GetTag(FROZEN) == 1;
			Charge = e.Entity.GetTag(CHARGE) == 1;
			Windfury = e.Entity.GetTag(WINDFURY) == 1;
			AttacksThisTurn = e.Entity.GetTag(NUM_ATTACKS_THIS_TURN);

			Name = name;
			CardId = e.CardId;
			Taunt = e.Entity.GetTag(TAUNT) == 1;
			Zone = Enum.Parse(typeof(TAG_ZONE), e.Entity.GetTag(ZONE).ToString()).ToString();
			CardType = Enum.Parse(typeof(TAG_CARDTYPE), e.Entity.GetTag(CARDTYPE).ToString()).ToString();

			Health = CalculateHealth(e.Entity.IsWeapon);
			Attack = CalculateAttack(active, e.Entity.IsWeapon);
			Include = IsAbleToAttack(active, e.Entity.IsWeapon);
		}
		public BoardCard(CardEntity e, bool active = true)
		{
			var card = Database.GetCardFromId(e.CardId);
			var cardName = card != null ? card.Name : "";
			var name = string.IsNullOrEmpty(e.Entity.Name) ? cardName : e.Entity.Name;

			_activeTurn = active;
			_stdAttack = e.Entity.GetTag(GAME_TAG.ATK);
			_health = e.Entity.GetTag(GAME_TAG.HEALTH);
			_armor = e.Entity.GetTag(GAME_TAG.ARMOR);
			_durability = e.Entity.GetTag(GAME_TAG.DURABILITY);
			_damageTaken = e.Entity.GetTag(GAME_TAG.DAMAGE);
			_exhausted = e.Entity.GetTag(GAME_TAG.EXHAUSTED) == 1 ? true : false;
			_cantAttack = e.Entity.GetTag(GAME_TAG.CANT_ATTACK) == 1 ? true : false;
			_frozen = e.Entity.GetTag(GAME_TAG.FROZEN) == 1 ? true : false;
			_charge = e.Entity.GetTag(GAME_TAG.CHARGE) == 1 ? true : false;
			_windfury = e.Entity.GetTag(GAME_TAG.WINDFURY) == 1 ? true : false;
			_attacksThisTurn = e.Entity.GetTag(GAME_TAG.NUM_ATTACKS_THIS_TURN);
			_justPlayed = e.Entity.GetTag(GAME_TAG.JUST_PLAYED) == 1 ? true : false;

			Name = name;
			CardId = e.CardId;
			Taunt = e.Entity.GetTag(GAME_TAG.TAUNT) == 1 ? true : false;
			Zone = Enum.Parse(typeof(TAG_ZONE), e.Entity.GetTag(GAME_TAG.ZONE).ToString()).ToString();
			CardType = Enum.Parse(typeof(TAG_CARDTYPE), e.Entity.GetTag(GAME_TAG.CARDTYPE).ToString()).ToString();

			Health = CalculateHealth(e.Entity.IsWeapon);
			Attack = CalculateAttack(_activeTurn, e.Entity.IsWeapon);
			Include = IsAbleToAttack(_activeTurn, e.Entity.IsWeapon);
		}
		public BoardHero(CardEntity hero, CardEntity weapon, bool activeTurn)
		{
			_hero = new BoardCard(hero, activeTurn);
			// hero gains windfury with weapon, doubling attack get base attack
			_baseAttack = hero.Entity.GetTag(GAME_TAG.ATK);
			if(weapon != null)
				_weapon = new BoardCard(weapon, activeTurn);
			Include = activeTurn && _hero.Include;
			Attack = AttackWithWeapon();
		}
Example #4
0
        public void CreateInHand(Entity entity, int turn)
        {
            var ce = new CardEntity(entity)
            {
                Turn = turn, CardMark = CardMark.Created, Created = true
            };

            if (entity != null &&
                (entity.CardId == HearthDb.CardIds.NonCollectible.Neutral.TheCoin ||
                 entity.CardId == HearthDb.CardIds.NonCollectible.Neutral.GallywixsCoinToken))
            {
                ce.CardMark = CardMark.Coin;
            }
            Hand.Add(ce);
            if (IsLocalPlayer)
            {
                CreatedInHandCardIds.Add(entity.CardId);
            }
            Log("CreateInHand", ce);
        }
		public void CreateInHand(Entity entity, int turn)
		{
			var ce = new CardEntity(entity) {Turn = turn, CardMark = CardMark.Created, Created = true};
            Hand.Add(ce);
			if(IsLocalPlayer)
				CreatedInHandCardIds.Add(entity.CardId);
			Log("CreateInHand", ce);
		}
		private void UpdateRevealedEntity(CardEntity entity, int turn, bool? discarded = null, CardMark? cardMark = null)
		{
			var revealed = RevealedCards.FirstOrDefault(ce => ce.Entity == entity.Entity || (ce.CardId == entity.CardId && ce.Entity == null && ce.Turn <= entity.PrevTurn));
			if(revealed != null)
			{
				revealed.Update(entity.Entity);
			}
			else
			{
				revealed = new CardEntity(entity.Entity) {Turn = turn, Created = entity.Created, Discarded = entity.Discarded};
                RevealedCards.Add(revealed);
			}
			if(discarded.HasValue)
				revealed.Discarded = discarded.Value;
			if(cardMark.HasValue)
				revealed.CardMark = cardMark.Value;
		}
		private void Log(string action, CardEntity ce)
		{
			var player = IsLocalPlayer ? "Player " : "Opponent ";
			Logger.WriteLine(ce.ToString(), player + action);
		}
		private int ZonePosComparison(CardEntity ce1, CardEntity ce2)
		{
			var v1 = (ce1.Entity != null ? ce1.Entity.GetTag(GAME_TAG.ZONE_POSITION) : 10);
			var v2 = (ce2.Entity != null ? ce2.Entity.GetTag(GAME_TAG.ZONE_POSITION) : 10);
			return v1.CompareTo(v2);
		}
		private CardEntity MoveCardEntity(Entity entity, List<CardEntity> @from, List<CardEntity> to, int turn)
		{
			var cardEntity = GetEntityFromCollection(from, entity);
			if(cardEntity != null)
			{
				from.Remove(cardEntity);
			}
			else
			{
				cardEntity = @from.FirstOrDefault(ce => string.IsNullOrEmpty(ce.CardId) && ce.Entity == null);
				if(cardEntity != null)
				{
					from.Remove(cardEntity);
					cardEntity.Update(entity);
				}
				else
				{
					cardEntity = new CardEntity(entity) { Turn = turn };
				}
			}
			to.Add(cardEntity);
			to.Sort(ZonePosComparison);
			cardEntity.Turn = turn;
			return cardEntity;
		}
		public void CreateInHand(Entity entity, int turn)
		{
			var ce = new CardEntity(entity) {Turn = turn, CardMark = CardMark.Created, Created = true};
			if(entity != null
			   && (entity.CardId == HearthDb.CardIds.NonCollectible.Neutral.TheCoin
			       || entity.CardId == HearthDb.CardIds.NonCollectible.Neutral.GallywixsCoinToken))
				ce.CardMark = CardMark.Coin;
			Hand.Add(ce);
			if(IsLocalPlayer)
				CreatedInHandCardIds.Add(entity.CardId);
			Log("CreateInHand", ce);
		}
		public void JoustReveal(Entity entity, int turn)
		{
			if(Deck.Where(ce => ce.InDeck).All(ce => ce.CardId != entity.CardId))
			{
				RevealDeckCard(entity.CardId, turn);
				var ce = new CardEntity(entity.CardId, null) {Turn = turn};
                RevealedCards.Add(ce);
				Log("JoustReveal", ce);
			}
		}
		private void Log(string action, CardEntity ce) => Log(ce.ToString(), action);
		private void UpdateRevealedEntity(CardEntity entity, int turn, bool? discarded = null, CardMark? cardMark = null)
		{
			var revealed =
				RevealedCards.FirstOrDefault(
				                             ce =>
				                             ce.Entity == entity.Entity
				                             || (ce.CardId == entity.CardId && ce.Entity == null && ce.Turn <= entity.PrevTurn));
			if(revealed != null)
				revealed.Update(entity.Entity);
			else
			{
				revealed = new CardEntity(entity.Entity) {Turn = turn, Created = entity.Created, Discarded = entity.Discarded};
				var cardType = entity.Entity.GetTag(GAME_TAG.CARDTYPE);
				if(cardType != (int)TAG_CARDTYPE.HERO && cardType != (int)TAG_CARDTYPE.ENCHANTMENT && cardType != (int)TAG_CARDTYPE.HERO_POWER
				   && cardType != (int)TAG_CARDTYPE.PLAYER)
					RevealedCards.Add(revealed);
			}
			if(discarded.HasValue)
				revealed.Discarded = discarded.Value;
			if(cardMark.HasValue)
				revealed.CardMark = cardMark.Value;
		}
		private int ZonePosComparison(CardEntity ce1, CardEntity ce2)
		{
			var v1 = ce1.Entity?.GetTag(GAME_TAG.ZONE_POSITION) ?? 10;
			var v2 = ce2.Entity?.GetTag(GAME_TAG.ZONE_POSITION) ?? 10;
			return v1.CompareTo(v2);
		}
Example #15
0
        private void Log(string action, CardEntity ce)
        {
            var player = IsLocalPlayer ? "Player " : "Opponent ";

            Logger.WriteLine(ce.ToString(), player + action);
        }
 private void Log(CardEntity ce, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "")
 => Log(ce.ToString(), memberName, sourceFilePath);
		public void CreateInDeck(Entity entity, int turn)
		{
			CardEntity ce;
			if(IsLocalPlayer)
			{
				ce = new CardEntity(entity) { Turn = turn };
				Deck.Add(ce);
				RevealedCards.Add(new CardEntity(entity) {Turn = turn});
			}
			else
			{
				Deck.Add(new CardEntity(null));
				RevealDeckCard(entity.CardId, turn);
				ce = new CardEntity(entity.CardId, null) { Turn = turn };
				RevealedCards.Add(ce);
			}
			Log("CreateInDeck", ce);
		}
		private void Log(CardEntity ce, [CallerMemberName] string memberName = "", [CallerFilePath] string sourceFilePath = "") 
			=> Log(ce.ToString(), memberName, sourceFilePath);
		public void CreateInPlay(Entity entity, int turn)
		{
			var ce = new CardEntity(entity) {Turn = turn, Created = true};
            Board.Add(ce);
			Log("CreateInPlay", ce);
		}
		public void CreateInDeck(Entity entity, int turn)
		{
			CardEntity ce;
			var created = turn > 1;
			if(IsLocalPlayer)
			{
				ce = new CardEntity(entity) {Turn = turn, Created = created};
				Deck.Add(ce);
				RevealedCards.Add(new CardEntity(entity) {Turn = turn, Created = created});
			}
			else
			{
				Deck.Add(new CardEntity(null));
				RevealDeckCard(entity.CardId, turn, created);
				ce = new CardEntity(entity.CardId, null) {Turn = turn, Created = created};
				RevealedCards.Add(ce);
			}
			Log(ce);
		}
		private void AddMinionDebugOverlay(CardEntity entity, Ellipse entityEllipse)
		{
			entityEllipse.Stroke = new SolidColorBrush(Colors.Red);
			entityEllipse.StrokeThickness = 1;
			var lbl = new Label {Content = entity.Entity.Card.Name, Foreground = Brushes.White};
			_debugBoardObjects.Add(lbl);
			CanvasInfo.Children.Add(lbl);
			var pos = entityEllipse.TransformToAncestor(CanvasInfo).Transform(new System.Windows.Point(0, 0));
			Canvas.SetTop(lbl, pos.Y + 10);
			Canvas.SetLeft(lbl, pos.X + 10);
		}
Example #22
0
 private void Log(string action, CardEntity ce)
 {
     Log(ce.ToString(), action);
 }