protected override void LoadContent() { base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); FullEntity.Initialize(Game.Content); FullEntity.CreateThePixel(GraphicsDevice); }
public void Constructor() { var entity = new EntityData(1, "NAME", "CARD_ID", Zone.DECK); var block = new MockBlockData(); var mod = new FullEntity(entity, block); Assert.AreEqual(entity, mod.Data); Assert.AreEqual(block, mod.ParentBlock); }
public void GameStateChange_Entity_PredictedCardId() { FullEntity entity = null; var parser = new PowerParser(new MockGameInfo()); parser.GameStateChange += args => entity = args as FullEntity; parser.Parse(new Line("Power", "D 00:31:50.9114028 PowerTaskList.DebugPrintPower() - BLOCK_START BlockType=POWER Entity=[entityName=King Togwaggle id=60 zone=PLAY zonePos=2 cardId=LOOT_541 player=2] EffectCardId= EffectIndex=0 Target=0 SubOption=-1")); parser.Parse(new Line("Power", "D 00:32:08.3649436 PowerTaskList.DebugPrintPower() - FULL_ENTITY - Updating [entityName=UNKNOWN ENTITY [cardType=INVALID] id=61 zone=HAND zonePos=0 cardId= player=1] CardID=")); Assert.IsNotNull(entity); Assert.AreEqual(CardIds.NonCollectible.Neutral.KingTogwaggle_KingsRansomToken, entity.Data.CardId); }
public void Apply_Entity_JoustReveal() { var data = new EntityData(1, "NAME", "CARD_ID", Zone.SETASIDE); var mod = new FullEntity(data, new MockBlockData { Type = BlockType.JOUST }); mod.Apply(_game); var entity = _game.Entities[data.Id]; Assert.IsTrue(entity.Info.JoustReveal); }
public void Apply_GameEntity() { var entity = new GameEntityData(1); var mod = new FullEntity(entity, new MockBlockData()); mod.Apply(_game); Assert.AreEqual(1, _game.Entities.Count); Assert.IsNotNull(_game.GameEntity); Assert.IsNotNull(_game.Entities[entity.Id]); Assert.AreEqual(entity.Id, _game.GameEntity.Id); Assert.AreEqual(entity.Id, _game.Entities[entity.Id].Id); }
protected override void LoadContent() { base.LoadContent(); spriteBatch = new SpriteBatch(GraphicsDevice); FullEntity.Initialize(Game.Content); FullEntity.CreateThePixel(GraphicsDevice); Ships = new(); Player = Ships.Player; Player.OnResize(GraphicsDevice); GraphicsDevice.DeviceReset += Player.OnResize; Bullets = new(); }
public void Apply_Entity_MulliganDone() { var game = new MockGameState { IsMulliganDone = true, SetupComplete = true }; var data = new EntityData(1, "NAME", "CARD_ID", Zone.SETASIDE); var mod = new FullEntity(data, new MockBlockData()); mod.Apply(game); var entity = game.Entities[data.Id]; Assert.IsTrue(entity.IsCreated); }
public void GameStateChange_Entity() { FullEntity entity = null; var parser = new PowerParser(new MockGameInfo()); parser.GameStateChange += args => entity = args as FullEntity; parser.Parse(new Line("Power", "D 00:29:52.7090966 PowerTaskList.DebugPrintPower() - FULL_ENTITY - Updating [entityName=UNKNOWN ENTITY [cardType=INVALID] id=4 zone=DECK zonePos=0 cardId= player=1] CardID=")); Assert.IsNotNull(entity); Assert.IsNotNull(entity.Data); Assert.AreEqual(4, entity.Data.Id); Assert.AreEqual(string.Empty, entity.Data.CardId); Assert.AreEqual(Zone.DECK, entity.Data.Zone); }
public void GameStateChange_GameEntity() { FullEntity entity = null; var parser = new PowerParser(new MockGameInfo()); parser.GameStateChange += args => entity = args as FullEntity; parser.Parse(new Line("Power", "D 00:29:52.6063231 PowerTaskList.DebugPrintPower() - GameEntity EntityID=1")); Assert.IsNotNull(entity); var data = entity.Data as GameEntityData; Assert.IsNotNull(data); Assert.AreEqual(1, data.Id); }
public void GameStateChange_PlayerEntity() { FullEntity entity = null; var parser = new PowerParser(new MockGameInfo()); parser.GameStateChange += args => entity = args as FullEntity; parser.Parse(new Line("Power", "D 00:29:52.6665096 PowerTaskList.DebugPrintPower() - Player EntityID=3 PlayerID=2 GameAccountId=[hi=144115198130930503 lo=15856412]")); Assert.IsNotNull(entity); var data = entity.Data as PlayerEntityData; Assert.IsNotNull(data); Assert.AreEqual(2, data.PlayerId); Assert.AreEqual(3, data.Id); }
public void Apply_Entity() { var data = new EntityData(1, "NAME", "CARD_ID", Zone.SETASIDE); var mod = new FullEntity(data, new MockBlockData()); mod.Apply(_game); var entity = _game.Entities[data.Id]; Assert.IsNotNull(entity); Assert.AreEqual(data.Id, entity.Id); Assert.AreEqual(data.CardId, entity.CardId); Assert.IsTrue(entity.IsCreated); Assert.AreEqual((int)data.Zone, entity.GetTag(GameTag.ZONE)); Assert.IsFalse(entity.Info.JoustReveal); Assert.AreEqual(data.Zone, entity.Info.OriginalZone); }
public void Apply_PlayerEntity() { var p1 = new PlayerEntityData(2, 1); var p2 = new PlayerEntityData(3, 2); var mod1 = new FullEntity(p1, new MockBlockData()); var mod2 = new FullEntity(p2, new MockBlockData()); mod1.Apply(_game); mod2.Apply(_game); Assert.AreEqual(2, _game.Entities.Count); Assert.IsNotNull(_game.Entities[p1.Id] as PlayerEntity); Assert.IsNotNull(_game.PlayerEntities[p1.PlayerId]); Assert.AreEqual(p1.PlayerId, _game.PlayerEntities[p1.PlayerId].PlayerId); Assert.IsNotNull(_game.Entities[p2.Id] as PlayerEntity); Assert.IsNotNull(_game.PlayerEntities[p2.PlayerId]); Assert.AreEqual(p2.PlayerId, _game.PlayerEntities[p2.PlayerId].PlayerId); }
public void HandleCollision(FullEntity other) => throw new NotImplementedException();
public static void Handle(string timestamp, string data, ParserState state) { var trimmed = data.Trim(); var indentLevel = data.Length - trimmed.Length; data = trimmed; if (state.Node != null && indentLevel <= state.Node.IndentLevel) { var action = state.Node.Object as Action; if (action == null || action.Entity != 1 || !data.ToLower().Contains("mulligan")) { state.Node = state.Node.Parent ?? state.Node; } } if (data == "CREATE_GAME") { state.CurrentGame = new Game { Data = new List <GameData>(), TimeStamp = timestamp }; state.Replay.Games.Add(state.CurrentGame); state.Node = new Node(typeof(Game), state.CurrentGame, 0, null); return; } var match = Regexes.ActionCreategameRegex.Match(data); if (match.Success) { var id = match.Groups[1].Value; Debug.Assert(id == "1"); var gEntity = new GameEntity { Id = int.Parse(id), Tags = new List <Tag>() }; state.CurrentGame.Data.Add(gEntity); state.Node = new Node(typeof(GameEntity), gEntity, indentLevel, state.Node); return; } match = Regexes.ActionCreategamePlayerRegex.Match(data); if (match.Success) { var id = match.Groups[1].Value; var playerId = match.Groups[2].Value; var accountHi = match.Groups[3].Value; var accountLo = match.Groups[4].Value; var pEntity = new PlayerEntity { Id = int.Parse(id), AccountHi = accountHi, AccountLo = accountLo, PlayerId = int.Parse(playerId), Tags = new List <Tag>() }; state.CurrentGame.Data.Add(pEntity); state.Node = new Node(typeof(PlayerEntity), pEntity, indentLevel, state.Node); return; } match = Regexes.ActionStartRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var rawType = match.Groups[2].Value; var index = match.Groups[3].Value; var rawTarget = match.Groups[4].Value; var entity = Helper.ParseEntity(rawEntity, state); var target = Helper.ParseEntity(rawTarget, state); var type = Helper.ParseEnum <PowSubType>(rawType); var action = new Action { Data = new List <GameData>(), Entity = entity, Index = int.Parse(index), Target = target, TimeStamp = timestamp, Type = type }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(action); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(action); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(Action), action, indentLevel, state.Node); return; } match = Regexes.ActionMetadataRegex.Match(data); if (match.Success) { var rawMeta = match.Groups[1].Value; var rawData = match.Groups[2].Value; var info = match.Groups[3].Value; var parsedData = Helper.ParseEntity(rawData, state); var meta = Helper.ParseEnum <MetaDataType>(rawMeta); var metaData = new MetaData { Data = parsedData, Info = int.Parse(info), Meta = meta, MetaInfo = new List <Info>() }; if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(metaData); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(MetaData), metaData, indentLevel, state.Node); return; } match = Regexes.ActionMetaDataInfoRegex.Match(data); if (match.Success) { var index = match.Groups[1].Value; var rawEntity = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var metaInfo = new Info { Id = entity, Index = int.Parse(index) }; if (state.Node.Type == typeof(MetaData)) { ((MetaData)state.Node.Object).MetaInfo.Add(metaInfo); } else { throw new Exception("Invalid node " + state.Node.Type); } } match = Regexes.ActionShowEntityRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new ShowEntity { CardId = cardId, Entity = entity, Tags = new List <Tag>() }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(showEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(showEntity); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(ShowEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionHideEntityRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var entity = Helper.ParseEntity(rawEntity, state); var zone = Helper.ParseTag(tagName, value); var hideEntity = new HideEntity { Entity = entity, Zone = zone.Value, TimeStamp = timestamp }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(hideEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(hideEntity); } else { throw new Exception("Invalid node: " + state.Node.Type); } return; } match = Regexes.ActionFullEntityUpdatingRegex.Match(data); if (!match.Success) { match = Regexes.ActionFullEntityCreatingRegex.Match(data); } if (match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new FullEntity { CardId = cardId, Id = entity, Tags = new List <Tag>() }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(showEntity); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(showEntity); } else { throw new Exception("Invalid node " + state.Node.Type); } state.Node = new Node(typeof(FullEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionTagChangeRegex.Match(data); if (match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var tag = Helper.ParseTag(tagName, value); if (tag.Name == (int)GameTag.CURRENT_PLAYER) { UpdateCurrentPlayer(state, rawEntity, tag); } var entity = Helper.ParseEntity(rawEntity, state); if (tag.Name == (int)GameTag.ENTITY_ID) { entity = UpdatePlayerEntity(state, rawEntity, tag, entity); } var tagChange = new TagChange { Entity = entity, Name = tag.Name, Value = tag.Value }; if (state.Node.Type == typeof(Game)) { ((Game)state.Node.Object).Data.Add(tagChange); } else if (state.Node.Type == typeof(Action)) { ((Action)state.Node.Object).Data.Add(tagChange); } else { throw new Exception("Invalid node " + state.Node.Type); } return; } match = Regexes.ActionTagRegex.Match(data); if (match.Success) { var tagName = match.Groups[1].Value; var value = match.Groups[2].Value; var tag = Helper.ParseTag(tagName, value); if (tag.Name == (int)GameTag.CURRENT_PLAYER) { state.FirstPlayerId = ((PlayerEntity)state.Node.Object).Id; } if (state.Node.Type == typeof(GameEntity)) { ((GameEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(PlayerEntity)) { ((PlayerEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(FullEntity)) { ((FullEntity)state.Node.Object).Tags.Add(tag); } else if (state.Node.Type == typeof(ShowEntity)) { ((ShowEntity)state.Node.Object).Tags.Add(tag); } else { throw new Exception("Invalid node " + state.Node.Type + " -- " + data); } } }
public static void Handle(string timestamp, string data, ParserState state) { var trimmed = data.Trim(); var indentLevel = data.Length - trimmed.Length; data = trimmed; if(state.Node != null && indentLevel <= state.Node.IndentLevel) state.Node = state.Node.Parent ?? state.Node; if(data == "CREATE_GAME") { state.CurrentGame = new Game {Data = new List<GameData>()}; state.Replay.Games.Add(state.CurrentGame); state.Node = new Node(typeof(Game), state.CurrentGame, 0, null); return; } var match = Regexes.ActionCreategameRegex.Match(data); if(match.Success) { var id = match.Groups[1].Value; Debug.Assert(id == "1"); var gEntity = new GameEntity {Id = int.Parse(id), Tags = new List<Tag>()}; state.CurrentGame.Data.Add(gEntity); state.Node = new Node(typeof(GameEntity), gEntity, indentLevel, state.Node); return; } match = Regexes.ActionCreategamePlayerRegex.Match(data); if(match.Success) { var id = match.Groups[1].Value; var playerId = match.Groups[2].Value; var accountHi = match.Groups[3].Value; var accountLo = match.Groups[4].Value; var pEntity = new PlayerEntity { Id = int.Parse(id), AccountHi = accountHi, AccountLo = accountLo, PlayerId = int.Parse(playerId), Tags = new List<Tag>() }; state.CurrentGame.Data.Add(pEntity); state.Node = new Node(typeof(PlayerEntity), pEntity, indentLevel, state.Node); return; } match = Regexes.ActionStartRegex.Match(data); if(match.Success) { var rawEntity = match.Groups[1].Value; var rawType = match.Groups[2].Value; var index = match.Groups[3].Value; var rawTarget = match.Groups[4].Value; var entity = Helper.ParseEntity(rawEntity, state); var target = Helper.ParseEntity(rawTarget, state); var type = Helper.ParseEnum<POWER_SUBTYPE>(rawType); var action = new Action { Data = new List<GameData>(), Entity = entity, Index = int.Parse(index), Target = target, //TimeStamp = timestamp, Type = type }; if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(action); else if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(action); else throw new Exception("Invalid node " + state.Node.Type); state.Node = new Node(typeof(Action), action, indentLevel, state.Node); return; } match = Regexes.ActionMetadataRegex.Match(data); if(match.Success) { var rawMeta = match.Groups[1].Value; var rawData = match.Groups[2].Value; var info = match.Groups[3].Value; var parsedData = Helper.ParseEntity(rawData, state); var meta = Helper.ParseEnum<METADATA_TYPE>(rawMeta); var metaData = new MetaData {Data = parsedData, Info = int.Parse(info), Meta = meta, MetaInfo = new List<Info>()}; if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(metaData); else throw new Exception("Invalid node " + state.Node.Type); state.Node = new Node(typeof(MetaData), metaData, indentLevel, state.Node); return; } match = Regexes.ActionMetaDataInfoRegex.Match(data); if(match.Success) { var index = match.Groups[1].Value; var rawEntity = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var metaInfo = new Info {Id = entity, Index = int.Parse(index)}; if(state.Node.Type == typeof(MetaData)) ((MetaData)state.Node.Object).MetaInfo.Add(metaInfo); else throw new Exception("Invalid node " + state.Node.Type); } match = Regexes.ActionShowEntityRegex.Match(data); if(match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new ShowEntity {CardId = cardId, Entity = entity, Tags = new List<Tag>()}; if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(showEntity); else if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(showEntity); else throw new Exception("Invalid node " + state.Node.Type); state.Node = new Node(typeof(ShowEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionHideEntityRegex.Match(data); if(match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var entity = Helper.ParseEntity(rawEntity, state); var tag = Helper.ParseTag(tagName, value); var hideEntity = new HideEntity {Entity = entity, TagName = tag.Name, TagValue = tag.Value}; if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(hideEntity); else if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(hideEntity); else throw new Exception("Invalid node: " + state.Node.Type); return; } match = Regexes.ActionFullentityRegex1.Match(data); if(!match.Success) match = Regexes.ActionFullentityRegex2.Match(data); if(match.Success) { var rawEntity = match.Groups[1].Value; var cardId = match.Groups[2].Value; var entity = Helper.ParseEntity(rawEntity, state); var showEntity = new FullEntity {CardId = cardId, Id = entity, Tags = new List<Tag>()}; if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(showEntity); else if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(showEntity); else throw new Exception("Invalid node " + state.Node.Type); state.Node = new Node(typeof(FullEntity), showEntity, indentLevel, state.Node); return; } match = Regexes.ActionTagChangeRegex.Match(data); if(match.Success) { var rawEntity = match.Groups[1].Value; var tagName = match.Groups[2].Value; var value = match.Groups[3].Value; var tag = Helper.ParseTag(tagName, value); if(tag.Name == (int)GAME_TAG.CURRENT_PLAYER) UpdateCurrentPlayer(state, rawEntity, tag); var entity = Helper.ParseEntity(rawEntity, state); if(tag.Name == (int)GAME_TAG.ENTITY_ID) entity = UpdatePlayerEntity(state, rawEntity, tag, entity); var tagChange = new TagChange {Entity = entity, Name = tag.Name, Value = tag.Value}; if(state.Node.Type == typeof(Game)) ((Game)state.Node.Object).Data.Add(tagChange); else if(state.Node.Type == typeof(Action)) ((Action)state.Node.Object).Data.Add(tagChange); else throw new Exception("Invalid node " + state.Node.Type); return; } match = Regexes.ActionTagRegex.Match(data); if(match.Success) { var tagName = match.Groups[1].Value; var value = match.Groups[2].Value; var tag = Helper.ParseTag(tagName, value); if(tag.Name == (int)GAME_TAG.CURRENT_PLAYER) state.FirstPlayerId = ((PlayerEntity)state.Node.Object).Id; if(state.Node.Type == typeof(GameEntity)) ((GameEntity)state.Node.Object).Tags.Add(tag); else if(state.Node.Type == typeof(PlayerEntity)) ((PlayerEntity)state.Node.Object).Tags.Add(tag); else if(state.Node.Type == typeof(FullEntity)) ((FullEntity)state.Node.Object).Tags.Add(tag); else if(state.Node.Type == typeof(ShowEntity)) ((ShowEntity)state.Node.Object).Tags.Add(tag); else throw new Exception("Invalid node " + state.Node.Type + " -- " + data); } }