public bool Parse(State.Game game, State.ReadOnlyEntity entity) { bool ret = true; ret = this.ParseOneStatus(entity, State.GameTag.CHARGE, out this.charge) && ret; ret = this.ParseOneStatus(entity, State.GameTag.TAUNT, out this.taunt) && ret; ret = this.ParseOneStatus(entity, State.GameTag.DIVINE_SHIELD, out this.divine_shield) && ret; ret = this.ParseOneStatus(entity, State.GameTag.STEALTH, out this.stealth) && ret; ret = this.ParseOneStatus(entity, State.GameTag.FORGETFUL, out this.forgetful) && ret; ret = this.ParseOneStatus(entity, State.GameTag.FREEZE, out this.freeze) && ret; ret = this.ParseOneStatus(entity, State.GameTag.FROZEN, out this.frozen) && ret; ret = this.ParseOneStatus(entity, State.GameTag.POISONOUS, out this.poisonous) && ret; ret = this.ParseOneStatus(entity, State.GameTag.WINDFURY, out this.windfury) && ret; return(ret); }
public bool Parse(State.Game game, State.ReadOnlyEntity entity) { bool ret = true; this.entity_id = entity.Id; this.card_id = entity.CardId; if (entity.HasTag(State.GameTag.CLASS) == false) { this.@class = ""; } else { this.@class = ((State.TAG_CLASS)entity.GetTag(State.GameTag.CLASS)).ToString(); } return(ret); }
public bool Parse(State.Game game, State.ReadOnlyEntity player) { bool ret = true; int controller = player.GetTagOrDefault(State.GameTag.CONTROLLER, -1); if (controller < 0) { return(false); } SortedDictionary <int, int> sorted_cards = new SortedDictionary <int, int>(); foreach (var entity in game.Entities.Items) { if (entity.Value.GetTagOrDefault(State.GameTag.CONTROLLER, controller - 1) != controller) { continue; } if (!entity.Value.HasTag(State.GameTag.ZONE)) { continue; } if (entity.Value.GetTag(State.GameTag.ZONE) != (int)State.TAG_ZONE.HAND) { continue; } var zone_pos = entity.Value.GetTagOrDefault(State.GameTag.ZONE_POSITION, -1); if (zone_pos < 0) { ret = false; } sorted_cards.Add(zone_pos, entity.Value.Id); } foreach (var sorted_card in sorted_cards) { this.entities.Add(sorted_card.Value); } return(ret); }
public bool Parse(State.Game game, State.ReadOnlyEntity entity) { this.entity_id = entity.Id; this.card_id = entity.CardId; this.max_hp = entity.GetTagOrDefault(State.GameTag.HEALTH, -1); this.damage = entity.GetTagOrDefault(State.GameTag.DAMAGE, 0); this.attack = entity.GetTagOrDefault(State.GameTag.ATK, 0); this.attacks_this_turn = entity.GetTagOrDefault(State.GameTag.NUM_ATTACKS_THIS_TURN, 0); this.exhausted = (entity.GetTagOrDefault(State.GameTag.EXHAUSTED, 0) != 0); this.silenced = (entity.GetTagOrDefault(State.GameTag.SILENCED, 0) != 0); this.spellpower = entity.GetTagOrDefault(State.GameTag.SPELLPOWER, 0); this.summoned_this_turn = entity.GetTagOrDefault(State.GameTag.JUST_PLAYED, 0) != 0; this.status.Parse(game, entity); this.enchantments.Parse(game, entity); return(true); }
public bool Parse(State.Game game, State.ReadOnlyEntity entity) { bool ret = true; entity_id = entity.Id; ret = this.crystal.Parse(game, entity) && ret; this.fatigue = entity.GetTagOrDefault(State.GameTag.FATIGUE, 0); this.first_player = (entity.GetTagOrDefault(State.GameTag.FIRST_PLAYER, 0) != 0); ret = this.enchantments.Parse(game, entity) && ret; if (entity.HasTag(State.GameTag.HERO_ENTITY) == false) { ret = false; } else { int hero_entity_id = entity.GetTag(State.GameTag.HERO_ENTITY); if (game.Entities.Items.ContainsKey(hero_entity_id) == false) { ret = false; } else { ret = this.hero.Parse(game, game.Entities.Items[hero_entity_id]) && ret; } } ret = this.weapon.Parse(game, entity) && ret; ret = this.secrets.Parse(game, entity) && ret; ret = this.minions.Parse(game, entity) && ret; ret = this.hand.Parse(game, entity) && ret; ret = this.deck.Parse(game, entity) && ret; return(ret); }
public bool Parse(State.Game game, State.ReadOnlyEntity entity) { this.id = entity.Id; this.card_id = entity.CardId; this.controller = entity.GetTagOrDefault(State.GameTag.CONTROLLER, -1); this.generate_under_blocks = new EntityGenerationInfo(); foreach (var obj in entity.generate_under_blocks_) { this.generate_under_blocks.Add(obj); } tags = new Dictionary <string, int>(); foreach (var kv in entity.Tags) { tags[kv.Key.ToString()] = kv.Value; } return(true); }
public void NotifyEntityTagChanged(int id, State.ReadOnlyEntity prev, LogWatcher.Logger logger) { State.ReadOnlyEntity current = entities_.Items[id]; int current_controller = current.GetTagOrDefault(GameTag.CONTROLLER, -1); TAG_ZONE current_zone = (TAG_ZONE)current.GetTagOrDefault(GameTag.ZONE, (int)TAG_ZONE.INVALID); if (current_controller < 0) { return; } if (current_zone == TAG_ZONE.INVALID) { return; } if (prev != null) { if (prev.Id != id) { logger.Info("entity id should not be changed."); return; } int prev_controller = prev.GetTagOrDefault(GameTag.CONTROLLER, -1); TAG_ZONE prev_zone = (TAG_ZONE)prev.GetTagOrDefault(GameTag.ZONE, (int)TAG_ZONE.INVALID); if (prev_controller >= 0 && prev_zone != TAG_ZONE.INVALID) { if (prev_controller == current_controller && prev_zone == current_zone) { return; } EntityZoneChanged(id, prev_zone, prev_controller, current_zone, current_controller, logger); } } EntityAdded(id, current_zone, current_controller, logger); }
public bool Parse(State.Game game, State.ReadOnlyEntity player) { bool ret = true; int controller = player.GetTagOrDefault(State.GameTag.CONTROLLER, -1); if (controller < 0) { return(false); } this.total_cards = 0; foreach (var entity in game.Entities.Items) { if (entity.Value.GetTagOrDefault(State.GameTag.CONTROLLER, controller - 1) != controller) { continue; } if (!entity.Value.HasTag(State.GameTag.ZONE)) { continue; } if (entity.Value.GetTag(State.GameTag.ZONE) != (int)State.TAG_ZONE.DECK) { continue; } this.total_cards++; this.entities.Add(entity.Value.Id); if (entity.Value.CardId != "") { this.known_cards.Add(entity.Value.CardId); } } foreach (var joust_entity_id in game.joust_information.entities) { var joust_card = game.Entities.Items[joust_entity_id]; if (joust_card.GetTagOrDefault(State.GameTag.CONTROLLER, controller - 1) != controller) { continue; } this.joust_cards.Add(joust_card.CardId); } List <string> raw_played_cards; if (player.Id == game.PlayerEntityId) { raw_played_cards = game.player_played_hand_cards; } else if (player.Id == game.OpponentEntityId) { raw_played_cards = game.opponent_played_hand_cards; } else { raw_played_cards = new List <string>(); } foreach (var played_card in raw_played_cards) { this.played_cards.Add(played_card); } return(ret); }
private bool ParseOneStatus(State.ReadOnlyEntity entity, State.GameTag tag, out int value) { value = entity.GetTagOrDefault(tag, 0); return(true); }