/// <summary> /// Check completeness of last action on stack. /// </summary> public void CheckLastActionOnStack() { if (this.Count == 0) { return; } MagicAction ma = this.Peek() as MagicAction; if (ma == null) { return; } if (ma.CardSource != null) { if (ma.CardSource.Controler != engine.pp) { return; } } //Magic.CurrentGameWin.CursorVisible = true; if (!ma.IsComplete) { if (ma.remainingCost == CostTypes.Tap) { ma.remainingCost = null; ma.CardSource.Tap(); } else if ((engine.pp.AvailableManaOnTable + engine.pp.ManaPool) < ma.RemainingCost?.ManaCost) { Magic.AddLog("Not enough mana available"); CancelLastActionOnStack(); return; } else if (engine.pp.ManaPool != null && ma.RemainingCost?.ManaCost != null) { string lastRemCost = ma.RemainingCost.ToString(); ma.PayCost(ref engine.pp.ManaPool); bool skipUpdateUI = false; if (ma.RemainingCost != null) { if (string.Equals(ma.RemainingCost.ToString(), lastRemCost, StringComparison.Ordinal)) { skipUpdateUI = true; } } if (!skipUpdateUI) { engine.pp.NotifyValueChange("ManaPoolElements", engine.pp.ManaPoolElements); notifyStackElementChange(); } } // if (ma.IsComplete && ma.GoesOnStack) // GivePriorityToNextPlayer (); } if (ma.IsComplete) { if (ma.GoesOnStack) { //should show spell to player... //UpdateStackLayouting(); engine.GivePriorityToNextPlayer(); } else { PopMSE(); ma.Resolve(); } return; } engine.pp.UpdateUi(); // AbilityActivation aa = ma as AbilityActivation; // //mana doest go on stack // if (aa != null){ // if (aa.Source.AbilityType == AbilityEnum.Mana) { // MagicEvent (new AbilityEventArg (aa.Source, aa.CardSource)); // MagicStack.Pop; // return; // } // } }