public Game CloneWithController(BaseController controller) { Game clonedGame = new Game(); int numPlayers = m_players.Length; clonedGame.m_players = new Player[numPlayers]; clonedGame.Players = clonedGame.m_players.ToIndexable(); clonedGame.Random = new Random(Random); clonedGame.m_nextCardGuid = m_nextCardGuid; clonedGame.ZoneConfigs = ZoneConfigs; if (controller != null) { controller.Game = clonedGame; clonedGame.Controller = controller; } clonedGame.CurrentPhase = CurrentPhase; clonedGame.Round = Round; clonedGame.m_actingPlayer = m_actingPlayer; clonedGame.DidSacrifice = DidSacrifice; clonedGame.DidRedeem = DidRedeem; // Clone the data structure (Behaviors will only be default-constructed) for (int i = 0; i < numPlayers; ++i) { clonedGame.m_players[i] = m_players[i].Clone(clonedGame); } // Transfer behaviors to cloned ones for (int i = 0; i < numPlayers; ++i) { clonedGame.m_players[i].TransferCardsFrom(m_players[i]); } return clonedGame; }
internal Player Clone(Game game) { var clonedPlayer = new Player(Name, Index, game); clonedPlayer.Health = Health; clonedPlayer.Mana = Mana; clonedPlayer.m_zones = new Zones(Game.ZoneConfigs, clonedPlayer); clonedPlayer.m_handSet = clonedPlayer.m_zones.GetZone(SystemZone.Hand).CardInstances; clonedPlayer.m_sacrifices = clonedPlayer.m_zones.GetZone(SystemZone.Sacrifice).CardInstances; clonedPlayer.m_battlefieldCards = clonedPlayer.m_zones.GetZone(SystemZone.Battlefield).CardInstances; clonedPlayer.m_assists = clonedPlayer.m_zones.GetZone(SystemZone.Assist).CardInstances; clonedPlayer.m_library = clonedPlayer.m_zones.GetZone(SystemZone.Library).CardModels; clonedPlayer.m_graveyard = clonedPlayer.m_zones.GetZone(SystemZone.Graveyard).CardModels; clonedPlayer.m_activatedAssists = new List<CardInstance>(); clonedPlayer.CardsOnHand = clonedPlayer.m_handSet.ToIndexable(); clonedPlayer.CardsSacrificed = clonedPlayer.m_sacrifices.ToIndexable(); clonedPlayer.CardsOnBattlefield = clonedPlayer.m_battlefieldCards.ToIndexable(); clonedPlayer.Assists = clonedPlayer.m_assists.ToIndexable(); clonedPlayer.ActivatedAssits = clonedPlayer.m_activatedAssists.ToIndexable(); clonedPlayer.Library = new Pile(clonedPlayer.m_library); clonedPlayer.Graveyard = new Pile(clonedPlayer.m_graveyard); clonedPlayer.m_manaAddModifiers.Capacity = m_manaAddModifiers.Capacity; foreach (var mod in m_manaAddModifiers) { clonedPlayer.m_manaAddModifiers.Add(mod); } clonedPlayer.m_manaSubtractModifiers.Capacity = m_manaSubtractModifiers.Capacity; foreach (var mod in m_manaSubtractModifiers) { clonedPlayer.m_manaSubtractModifiers.Add(mod); } clonedPlayer.m_lifeAddModifiers.Capacity = m_lifeAddModifiers.Capacity; foreach (var mod in m_lifeAddModifiers) { clonedPlayer.m_lifeAddModifiers.Add(mod); } clonedPlayer.m_lifeSubtractModifiers.Capacity = m_lifeSubtractModifiers.Capacity; foreach (var mod in m_lifeSubtractModifiers) { clonedPlayer.m_lifeSubtractModifiers.Add(mod); } clonedPlayer.m_handSet.Capacity = m_handSet.Capacity; for (int i = 0; i < m_handSet.Count; ++i) { clonedPlayer.m_handSet.Add(m_handSet[i].Clone(clonedPlayer)); } clonedPlayer.m_sacrifices.Capacity = m_sacrifices.Capacity; for (int i = 0; i < m_sacrifices.Count; ++i) { clonedPlayer.m_sacrifices.Add(m_sacrifices[i].Clone(clonedPlayer)); } clonedPlayer.m_battlefieldCards.Capacity = m_battlefieldCards.Capacity; for (int i = 0; i < m_battlefieldCards.Count; ++i) { var clonedCard = m_battlefieldCards[i].Clone(clonedPlayer); clonedPlayer.m_battlefieldCards.Add(clonedCard); clonedPlayer.Game.SubscribeCardToCommands(clonedCard); } if (Hero != null) { throw new NotImplementedException("Hero clone not implemented"); } clonedPlayer.m_assists.Capacity = m_assists.Capacity; for (int i = 0; i < m_assists.Count; ++i) { clonedPlayer.m_assists.Add(m_assists[i].Clone(clonedPlayer)); } clonedPlayer.m_activatedAssists.Capacity = m_activatedAssists.Capacity; for (int i = 0; i < m_activatedAssists.Count; ++i) { clonedPlayer.m_activatedAssists.Add(clonedPlayer.m_assists[m_assists.IndexOf(m_activatedAssists[i])]); clonedPlayer.Game.SubscribeCardToCommands(clonedPlayer.m_activatedAssists[i]); } clonedPlayer.m_library.Capacity = m_library.Capacity; for (int i = 0; i < m_library.Count; ++i) { clonedPlayer.m_library.Add(m_library[i]); } clonedPlayer.m_graveyard.Capacity = m_graveyard.Capacity; for (int i = 0; i < m_graveyard.Count; ++i) { clonedPlayer.m_graveyard.Add(m_graveyard[i]); } return clonedPlayer; }
internal ResolveContext(Game game) { Game = game; }