public TriggerData(ConvergePlayer player, ConvergeObject subject, ConvergeObject target, int amount) { this.player = player; this.subject = subject; this.target = target; this.amount = amount; }
public void Add(ConvergeObject newObj) { ConvergeZone oldZone = newObj.zone; if (oldZone != null) { oldZone.Remove(newObj); } newObj.slot = contents.Count; newObj.zone = this; contents.Add(newObj); newlyAdded.Add(newObj); RenumberAll(); if (!inPlay && oldZone != null && oldZone.inPlay) { newObj.OnLeavingPlay(); } else if (inPlay && (oldZone == null || !oldZone.inPlay)) { newObj.OnEnteringPlay(); } }
public void Update(InputState inputState) { frame = new Rectangle(parent.gfxFrame.Left + (int)offset.X - 16, parent.gfxFrame.Top + (int)offset.Y - 16, 32, 32); isMouseOver = (inputState.hoveringElement == this); if (isMouseOver && inputState.mouseLeft.justPressed && ability.controller.isActivePlayer && ability.CanActivate(Game1.activePlayer)) { isMousePressing = true; } if (isMousePressing && ability.hasTarget) { beamVisible = true; Vector2 offset = inputState.MousePos - frame.Center.ToVector2(); beamRotation = offset.ToAngle(); beamRect = new Rectangle(frame.Center.X, frame.Center.Y, (int)offset.Length(), 16); beamArrowRect = new Rectangle((int)inputState.MousePos.X, (int)inputState.MousePos.Y, 16, 16); if (inputState.hoveringElement != null && inputState.hoveringElement is ConvergeUIObject) { ConvergeObject targetedObject = ((ConvergeUIObject)inputState.hoveringElement).represented; beamBad = !ability.CanTarget(targetedObject, Game1.activePlayer); } else { beamBad = false; } } else { beamVisible = false; } if (isMousePressing && !inputState.mouseLeft.isDown) { isMousePressing = false; if (ability.hasTarget) { if (inputState.hoveringElement != null) { // used on target if (inputState.hoveringElement is ConvergeUIObject) { ability.ActivateOn(((ConvergeUIObject)inputState.hoveringElement).represented, Game1.activePlayer); } } } else { ability.Activate(Game1.activePlayer); } } }
public void BeginMyTurn() { if (zone.zoneId == ConvergeZoneId.Attack && !dying) { if (attackingWithAbility != null) { MoveZone(controller.defense); attackingWithAbility.DoAttackEffect(attackVictim, controller); attackingWithAbility = null; attackVictim = null; } else if (!tapped) { DealDamage(controller.opponent.homeBase, effectivePower, true); if (keywords.HasFlag(ConvergeKeyword.DoubleStrike)) { DealDamage(controller.opponent.homeBase, effectivePower, true); } } } if (keywords.HasFlag(ConvergeKeyword.Vigilance)) { WithdrawAttack(); tapped = false; } tapped = false; damage = 0; powerUsed = 0; }
public void Remove(ConvergeObject oldObj) { contents.Remove(oldObj); oldObj.zone = null; oldObj.slot = 0; RenumberAll(); }
public ConvergePlayer(JSONTable template, ContentManager Content) { this.home = new ConvergeZone(template.getJSON("home"), this, ConvergeZoneId.Home); this.resourceZone = new ConvergeZone(template.getJSON("resources"), this, ConvergeZoneId.Resources); this.attack = new ConvergeZone(template.getJSON("attack"), this, ConvergeZoneId.Attack); this.defense = new ConvergeZone(template.getJSON("defense"), this, ConvergeZoneId.Defense); this.hand = new ConvergeZone(template.getJSON("hand"), this, ConvergeZoneId.Hand); this.homeBase = new ConvergeObject(new ConvergeCardSpec(template.getJSON("homebase"), Content), home); this.discardPile = new ConvergeZone(template.getJSON("discardPile"), this, ConvergeZoneId.DiscardPile); this.laboratory = new ConvergeZone(template.getJSON("laboratory"), this, ConvergeZoneId.Laboratory); zones = new Dictionary <ConvergeZoneId, ConvergeZone>() { { ConvergeZoneId.Home, home }, { ConvergeZoneId.Resources, resourceZone }, { ConvergeZoneId.Attack, attack }, { ConvergeZoneId.Defense, defense }, { ConvergeZoneId.Hand, hand }, { ConvergeZoneId.DiscardPile, discardPile }, { ConvergeZoneId.Laboratory, laboratory }, }; this.life = template.getInt("startingLife"); this.faceLeft = template.getBool("faceLeft", false); }
public ConvergeUIObject(ConvergeObject represented) { this.represented = represented; represented.ui = this; this.gfxFrame = new Rectangle(represented.nominalPosition.ToPoint(), new Point(50, 60)); UpdateAbilityUIs(); }
public void EnterAttackWithAbility(ConvergeActivatedAbility ability, ConvergeObject target) { if (zone.zoneId == ConvergeZoneId.Defense) { MoveZone(controller.attack); attackingWithAbility = ability; attackVictim = target; } }
public void Shuffle() { for (int Idx = contents.Count - 1; Idx > 0; --Idx) { int insertPoint = Game1.rand.Next(Idx + 1); ConvergeObject temp = contents[Idx]; contents[Idx] = contents[insertPoint]; contents[insertPoint] = temp; } }
public void WithdrawAttack() { if (zone.zoneId == ConvergeZoneId.Attack && cardType.HasFlag(ConvergeCardType.Unit)) { MoveZone(controller.defense); tapped = true; attackingWithAbility = null; attackVictim = null; } }
public bool CanTarget(ConvergeObject target, ConvergePlayer you) { if (original.actionTarget == null) { return(false); } ConvergeEffectContext context = new ConvergeEffectContext(this, you); return(original.actionTarget.Test(target, context)); }
public override bool Test(ConvergeObject subject, ConvergeEffectContext context) { foreach (ConvergeSelector select in cases) { if (!select.Test(subject, context)) { return(false); } } return(true); }
public override void Run(ConvergeEffectContext context) { foreach (ConvergeObject player in players.GetList(context)) { ConvergeZone spawnZone = player.controller.GetZone(zoneId); ConvergeObject newSpawned = new ConvergeObject(cardSpec, spawnZone); if (spawnZone.inPlay && newSpawned.cardType.HasFlag(ConvergeCardType.Unit)) { newSpawned.tapped = true; } } }
public void DoAttackEffect(ConvergeObject target, ConvergePlayer you) { if (!CanTarget(target, you)) { return; } ConvergeEffectContext context = new ConvergeEffectContext(source, you, this); context.target = target; attackEffect.Run(context); }
public void DrawCards(int n) { if (laboratory.contents.Count < n) { n = laboratory.contents.Count; } for (int Idx = 0; Idx < n; ++Idx) { ConvergeObject drawn = laboratory.contents[Idx]; drawn.MoveZone(hand); } }
public override bool Test(ConvergeObject subject, ConvergeEffectContext context) { context.subject = subject; foreach (ConvergeObject potentialController in controller.GetList(context)) { if (potentialController.controller == subject.controller) { return(true); } } return(false); }
public override bool Test(ConvergeObject subject, ConvergeEffectContext context) { if ((subject.zone.zoneId & ConvergeZoneId.Play) == 0) { return(false); } foreach (ConvergeSelector select in filters) { if (!select.Test(subject, context)) { return(false); } } return(true); }
public override bool Test(ConvergeObject subject, ConvergeEffectContext context) { // TO DO: at some point we're going to be sad this isn't checking the zone correctly if (subject.zone.zoneId != zoneId)// || !whose.Test(subject.zone.owner.homeBase, context)) { return(false); } foreach (ConvergeSelector select in filters) { if (!select.Test(subject, context)) { return(false); } } return(true); }
public void UseOn(ConvergeObject target) { if (this.cardType.HasFlag(ConvergeCardType.Unit) && target.cardType.HasFlag(ConvergeCardType.Unit) && this.controller != target.controller ) { // see if we can fight this creature if (target.zone.zoneId != ConvergeZoneId.Attack) { return; } if (this.tapped || this.keywords.HasFlag(ConvergeKeyword.CantBlock)) { return; } if (this.zone.zoneId != ConvergeZoneId.Defense && this.zone.zoneId != ConvergeZoneId.Attack && !this.keywords.HasFlag(ConvergeKeyword.Vigilance)) { return; } if (target.keywords.HasFlag(ConvergeKeyword.Flying) && !this.keywords.HasFlag(ConvergeKeyword.Flying) && !this.keywords.HasFlag(ConvergeKeyword.Reach)) { return; } tapped = true; if (!target.keywords.HasFlag(ConvergeKeyword.Trample)) { target.tapped = true; } Fight(target, true); } else if (original.actionTarget != null && zone.zoneId == ConvergeZoneId.Hand) { // playing an action/augment from my hand PlayOn(target, Game1.activePlayer); } }
public void DealDamage(ConvergeObject victim, int amount, bool isCombatDamage) { if (amount <= 0) { return; } if (TriggerSystem.HasTriggers(ConvergeTriggerType.DealDamage)) { TriggerSystem.CheckTriggers(ConvergeTriggerType.DealDamage, new TriggerData(controller, this, victim, amount)); } victim.TakeDamage(this, amount); if (keywords.HasFlag(ConvergeKeyword.Lifelink)) { controller.GainLife(amount); } }
public void ActivateOn(ConvergeObject target, ConvergePlayer you) { if (!hasTarget) { return; } if (!CanTarget(target, you)) { return; } if (you.TryPayCost(manacost) && source.TryPayAltCost(altCost)) { timesUsed++; ConvergeEffectContext context = new ConvergeEffectContext(source, you, this); context.target = target; effect.Run(context); } }
void TakeDamage(ConvergeObject source, int amount) { if (amount <= 0) { return; } if (cardType.HasFlag(ConvergeCardType.Home)) { controller.TakeDamage(amount); } else { damage += amount; if (source.keywords.HasFlag(ConvergeKeyword.Deathtouch)) { destroyed = true; } } }
public void PlayOn(ConvergeObject target, ConvergePlayer you) { if (zone.zoneId == ConvergeZoneId.Hand && (cardType.HasFlag(ConvergeCardType.Action) || cardType.HasFlag(ConvergeCardType.Augment)) && CanTarget(target, you) ) { if (you.TryPayCost(cost)) { if (TriggerSystem.HasTriggers(ConvergeTriggerType.PlayCard)) { TriggerSystem.CheckTriggers(ConvergeTriggerType.PlayCard, new TriggerData(you, this, target, 0)); } ConvergeEffectContext context = new ConvergeEffectContext(this, you); context.target = target; original.actionEffect.Run(context); MoveZone(owner.discardPile); } } }
public override bool Test(ConvergeObject subject, ConvergeEffectContext context) { context.subject = subject; int aValue = a.GetValue(context); int bValue = b.GetValue(context); switch (comparison) { case ConvergeComparison.equal: return(aValue == bValue); case ConvergeComparison.notEqual: return(aValue != bValue); case ConvergeComparison.greater: return(aValue > bValue); case ConvergeComparison.less: return(aValue < bValue); case ConvergeComparison.greaterOrEqual: return(aValue >= bValue); case ConvergeComparison.lessOrEqual: return(aValue <= bValue); default: throw new NotImplementedException(); } }
void UpdateZoneChanges() { bool didAnything = zoneChanges.Count > 0; for (int Idx = 0; Idx < zoneChanges.Count; ++Idx) { KeyValuePair <ConvergeObject, ConvergeZone> kv = zoneChanges[Idx]; ConvergeObject obj = kv.Key; ConvergeZone newZone = kv.Value; ConvergeZone oldZone = obj.zone; if (newZone.zoneId == ConvergeZoneId.DiscardPile && TriggerSystem.HasTriggers(ConvergeTriggerType.Discarded)) { TriggerSystem.CheckTriggers(ConvergeTriggerType.Discarded, new TriggerData(newZone.owner, null, obj, 0)); } newZone.Add(obj); if (newZone.inPlay && (oldZone == null || !oldZone.inPlay) && TriggerSystem.HasTriggers(ConvergeTriggerType.EnterPlay)) { TriggerSystem.CheckTriggers(ConvergeTriggerType.EnterPlay, new TriggerData(newZone.owner, obj, null, 0)); } if (obj.ui == null && !newZone.isHidden && obj.zone == newZone) { obj.ui = new ConvergeUIObject(obj); ui.Add(obj.ui); } else if (obj.ui != null && newZone.isHidden && obj.zone == newZone) { ui.Remove(obj.ui); obj.ui = null; } } zoneChanges.Clear(); }
public ConvergeEffect_Upgrade(int power, int toughness, ConvergeKeyword keywords, ConvergeObject source, Texture2D new_art, ConvergeDuration duration) : base(source, duration) { this.power = power; this.toughness = toughness; this.keywords = keywords; this.new_art = new_art; }
public bool CanTarget(ConvergeObject target, ConvergePlayer you) { ConvergeEffectContext context = new ConvergeEffectContext(source, you, this); return(spec.target.Test(target, context)); }
public ConvergeActivatedAbility(ConvergeActivatedAbilitySpec spec, ConvergeObject source) { this.spec = spec; this.source = source; }
public void Fight(ConvergeObject target, bool isCombatDamage) { if (dying || target.dying) { return; } int selfPowerUsed = GetPowerToUse(target.effectiveToughness); powerUsed += selfPowerUsed; int targetPowerUsed = target.GetPowerToUse(effectiveToughness); target.powerUsed += targetPowerUsed; int incomingFirstDamage; int incomingNormalDamage; int dealtFirstDamage; int dealtNormalDamage; if (target.keywords.HasFlag(ConvergeKeyword.DoubleStrike)) { incomingFirstDamage = targetPowerUsed; incomingNormalDamage = targetPowerUsed; } else if (target.keywords.HasFlag(ConvergeKeyword.FirstStrike)) { incomingFirstDamage = targetPowerUsed; incomingNormalDamage = 0; } else { incomingFirstDamage = 0; incomingNormalDamage = targetPowerUsed; } if (keywords.HasFlag(ConvergeKeyword.DoubleStrike)) { dealtFirstDamage = selfPowerUsed; dealtNormalDamage = selfPowerUsed; } else if (keywords.HasFlag(ConvergeKeyword.FirstStrike)) { dealtFirstDamage = selfPowerUsed; dealtNormalDamage = 0; } else { dealtFirstDamage = 0; dealtNormalDamage = selfPowerUsed; } DealDamage(target, dealtFirstDamage, isCombatDamage); target.DealDamage(this, incomingFirstDamage, isCombatDamage); if (dying || target.dying) { return; } DealDamage(target, dealtNormalDamage, isCombatDamage); target.DealDamage(this, incomingNormalDamage, isCombatDamage); }
public ConvergeEffect_GainTriggered(ConvergeTriggeredAbilitySpec abilitySpec, ConvergeObject subject, ConvergeObject source, ConvergeDuration duration) : base(source, duration) { this.ability = new ConvergeTriggeredAbility(abilitySpec, subject); }