void HandleMoveFromTo(OwnedZone srcZone, OwnedZone destZone, ICollection <IZoneAndInstanceIdChange> moves) { try { var cards = cardsInZones[srcZone].TakeCards(moves .Select(m => new CardIds(m.OldInstanceId, m.GrpId)) .ToArray()); var tempArray = moves.Join(cards, m => m.OldInstanceId, c => c.InstId, (change, card) => card .UpdateInstanceId(change.NewInstanceId) .MoveToZone(change.DestZone, change.SrcZone)) .ToArray(); // Force evaluation if (tempArray.Length != moves.Count) { Log.Warning("(InGameTrackerState2.HandleMoveFromTo) invalid move(s) detected. All moves: {moves}{nl}State: {this}", moves, Environment.NewLine, this); } cardsInZones[destZone].AddCards(cards); oppCardTracker.ProcessIdChanges(moves); } catch (Exception e) { Log.Warning(e, "(HandleMoveTo) exception swallowed"); } }
public static PlayerEnum GetPlayerEnum(this OwnedZone zone) { switch (zone) { case MyLibrary: case MyGraveyard: case MyHand: case MyCommand: case MySideboard: case MyRevealed: case MyPhasedOut: return(PlayerEnum.Me); case OppHand: case OppLibrary: case OppGraveyard: case OppCommand: case OppSideboard: case OppRevealed: case OppPhasedOut: return(PlayerEnum.Opponent); case Unknown: case Battlefield: case Exile: case Stack: case Limbo: case Pending: return(PlayerEnum.Unknown); default: throw new ArgumentOutOfRangeException(nameof(zone), zone, null); } }
public GameCardInZone MovedTo(int newInstId, OwnedZone destZone, int?grpId = null) { if (grpId != null && grpId != GrpId) { Log.Warning($"changing grpId from {GrpId} to {grpId}"); } return(new GameCardInZone(newInstId, OwnerSeatId, destZone, grpId ?? GrpId, GameObjectType, Visibility, Card)); }
public ZoneTransferInfo2(int newInstanceId, OwnedZone srcZone, OwnedZone destZone, string category = "") { IsValid = true; NewInstanceId = newInstanceId; SrcZone = srcZone; DestZone = destZone; Category = category; }
internal void RegisterZone(OwnedZone zone, Func <IEnumerable <int> > getInstanceIds) { if (instanceIdsByZone.ContainsKey(zone)) { var ex = new ArgumentException($"zone {zone} already coupled!", nameof(zone)); Log.Error(ex, $"tried to add zone {zone} that was already coupled!"); return; } instanceIdsByZone.Add(zone, getInstanceIds); }
public static bool IsSharedZone(this OwnedZone zone) { switch (zone) { case Battlefield: case Exile: case Stack: case Limbo: case Pending: return(true); default: return(false); } }
public GameCardInZone( int instanceId, int ownerSeatId, OwnedZone zone, int grpId, GameObjectType gameObjectType, Visibility visibility, Card card) : base(instanceId, grpId) { OwnerSeatId = ownerSeatId; Zone = zone; GameObjectType = gameObjectType; Visibility = visibility; Card = card; }
public StateCard2 MoveToZone(OwnedZone newZone, OwnedZone fromZone = OwnedZone.Unknown) { if (fromZone != OwnedZone.Unknown && fromZone != CurrentZone) { Log.Warning("Card {InstId}({GrpId}) expected to move from {fromZone} to {newZone} but was in zone {CurrentZone}", InstId, GrpId, fromZone, newZone, CurrentZone); Debugger.Break(); } zoneHistory.Push(newZone); return(this); }
public static bool IsOneOfMyZones(this OwnedZone zone) { switch (zone) { case MyLibrary: case MyGraveyard: case MyHand: case MyCommand: case MySideboard: case MyRevealed: case MyPhasedOut: return(true); default: return(false); } }
public static bool IsOpponentZone(this OwnedZone zone) { switch (zone) { case OppLibrary: case OppGraveyard: case OppHand: case OppCommand: case OppSideboard: case OppRevealed: case OppPhasedOut: return(true); default: return(false); } }
private static IZoneTracker GetZoneTracker(OwnedZone zone, OpponentCardTracker oppCardTracker) { switch (zone) { case OwnedZone.MyLibrary: return(new LibraryTracker(zone)); case OwnedZone.MySideboard: case OwnedZone.OppSideboard: return(new SideboardTracker(zone)); case OwnedZone.Unknown: case OwnedZone.Battlefield: case OwnedZone.Exile: case OwnedZone.Stack: case OwnedZone.Limbo: case OwnedZone.OppGraveyard: case OwnedZone.OppCommand: case OwnedZone.MyGraveyard: case OwnedZone.MyHand: case OwnedZone.MyCommand: case OwnedZone.Pending: case OwnedZone.MyRevealed: case OwnedZone.MyPhasedOut: return(new SimpleZoneTracker(zone)); case OwnedZone.OppLibrary: case OwnedZone.OppHand: case OwnedZone.OppPhasedOut: return(new OpponentZoneTracker(zone, oppCardTracker)); case OwnedZone.OppRevealed: return(new OppRevealedTracker(zone, oppCardTracker)); default: throw new ArgumentOutOfRangeException(nameof(zone), zone, null); } }
public SideboardTracker(OwnedZone forZone) : base(forZone) { }
public static bool IsOneOfMyZones(this OwnedZone zone) { return(GetPlayerEnum(zone) == PlayerEnum.Me); }
public static bool IsOpponentZone(this OwnedZone zone) { return(GetPlayerEnum(zone) == PlayerEnum.Opponent); }
public LibraryTracker(OwnedZone forZone) : base(forZone) { }
public StateCard2(int grpId, OwnedZone zone) { GrpId = grpId; IsOpponentsCard = zone.IsOpponentZone(); zoneHistory.Push(zone); }
public SimpleZoneTracker(OwnedZone forZone) : base(forZone) { }
public static bool ShouldTrackOpponentCards(this OwnedZone zone) { return(zone != Unknown && zone != Limbo); }
protected ZoneTrackerBase(OwnedZone forZone) { ForZone = forZone; }
public OpponentZoneTracker(OwnedZone forZone, OpponentCardTracker cardTracker) : base(forZone) { this.cardTracker = cardTracker; cardTracker.RegisterZone(forZone, () => cards.Select(c => c.InstId)); }
public OppRevealedTracker(OwnedZone forZone, OpponentCardTracker cardTracker) : base(forZone, cardTracker) { }